Authored by 毕凯

加价购增加信息读取

@@ -5,25 +5,48 @@ @@ -5,25 +5,48 @@
5 */ 5 */
6 6
7 var $ = require('jquery'), 7 var $ = require('jquery'),
8 - lazyLoad = require('yoho.lazyload'); 8 + lazyLoad = require('yoho.lazyload'),
  9 + Handlebars = require('yoho.handlebars'),
  10 + tip = require('../plugin/tip'),
  11 + chosePanel = require('./chose-panel');
9 12
10 -//var chosePanel = require('./chose-panel'); 13 +var panelTmpl,
  14 + $page = $('.gift-advance-page'),
  15 + $chosePanel = $('#chose-panel');
11 16
12 lazyLoad($('.lazy')); 17 lazyLoad($('.lazy'));
13 18
14 -//$('.gift-advance-page').on('touchstart', '.chose', function() {  
15 -// var id = $(this).closest('.gift-advance-good').data('id');  
16 -//  
17 -// $.ajax({  
18 -// type: 'GET',  
19 -// url: '/shoppingCart/goodinfo',  
20 -// data: {  
21 -// id: id  
22 -// },  
23 -// success: function(data) {  
24 -// if (data.code === 200) {  
25 -// chosePanel.show(data.data);  
26 -// }  
27 -// }  
28 -// });  
29 -//});  
  19 +$.get('/cart/index/giftinfoTpl', function(html) {
  20 + if (!html) {
  21 + tip.show('网络错误');
  22 + return;
  23 + }
  24 + panelTmpl = Handlebars.compile(html);
  25 +}).fail(function() {
  26 + tip.show('网络错误');
  27 +});
  28 +
  29 +function getProductInfo(skn, promotionId) {
  30 + $.get('/cart/index/giftinfo', {
  31 + skn: skn,
  32 + promotionId: promotionId
  33 + }).then(function(res) {
  34 + if (!res) {
  35 + tip.show('网络错误');
  36 + return;
  37 + }
  38 + console.log(res);
  39 + $chosePanel.html(panelTmpl(res));
  40 + chosePanel.show();
  41 + }).fail(function() {
  42 + tip.show('网络错误');
  43 + });
  44 +}
  45 +
  46 +$page.on('touchend', '.chose', function() {
  47 + var $this = $(this),
  48 + id = $this.closest('.gift-advance-good').data('id'),
  49 + promotionId = $this.closest('.advance-block').data('promotion-id');
  50 +
  51 + getProductInfo(id, promotionId);
  52 +});
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 <div class="gift-advance-page yoho-page"> 2 <div class="gift-advance-page yoho-page">
3 {{#if advanceBuyPage}} 3 {{#if advanceBuyPage}}
4 {{# advanceBuy}} 4 {{# advanceBuy}}
5 - <div class="advance-block"> 5 + <div class="advance-block" data-promotion-id="{{promotionId}}">
6 <p class="title">{{title}}</p> 6 <p class="title">{{title}}</p>
7 {{#goods}} 7 {{#goods}}
8 {{> cart/gift-advance-good}} 8 {{> cart/gift-advance-good}}
@@ -15,6 +15,6 @@ @@ -15,6 +15,6 @@
15 {{/ gift}} 15 {{/ gift}}
16 {{/if}} 16 {{/if}}
17 17
18 - 18 +<div id="chose-panel"></div>
19 </div> 19 </div>
20 {{> layout/footer}} 20 {{> layout/footer}}
@@ -6,19 +6,6 @@ @@ -6,19 +6,6 @@
6 <div class="deps"> 6 <div class="deps">
7 <p class="name row">{{name}}</p> 7 <p class="name row">{{name}}</p>
8 <p class="row"> 8 <p class="row">
9 - {{#if color}}  
10 - <span class="color">  
11 - 颜色:{{color}}  
12 - </span>  
13 - {{/if}}  
14 -  
15 - {{#if size}}  
16 - <span class="size">  
17 - 尺码:{{size}}  
18 - </span>  
19 - {{/if}}  
20 - </p>  
21 - <p class="row">  
22 <span class="price"> 9 <span class="price">
23 ¥{{price}} 10 ¥{{price}}
24 </span> 11 </span>