Authored by 郭成尧

check-handle

@@ -74,11 +74,13 @@ exports.cartPay = (params) => { @@ -74,11 +74,13 @@ exports.cartPay = (params) => {
74 return Promise.all([ 74 return Promise.all([
75 cartPayAPI, // 0. 订单数据 75 cartPayAPI, // 0. 订单数据
76 orderComputeAPI, 76 orderComputeAPI,
77 - shoppingAPI.getValidCouponCount(params.uid) // 2. 有效优惠券 77 + shoppingAPI.getValidCouponCount(params.uid), // 2 有效优惠券
  78 + shoppingAPI.countUsableGiftCard(params.uid) // 3 可用礼品卡数量
78 ]).then(res => { 79 ]).then(res => {
79 let pay = res[0]; 80 let pay = res[0];
80 let orderCompute = _.get(res[1], 'data', {}); 81 let orderCompute = _.get(res[1], 'data', {});
81 let validCouponCount = _.get(res[2], 'data.count', 0); 82 let validCouponCount = _.get(res[2], 'data.count', 0);
  83 + let validGiftCardCount = _.get(res[3], 'data.count', 0);
82 84
83 let goodsList = _.get(pay, 'data.goods_list', []); 85 let goodsList = _.get(pay, 'data.goods_list', []);
84 86
@@ -97,9 +99,13 @@ exports.cartPay = (params) => { @@ -97,9 +99,13 @@ exports.cartPay = (params) => {
97 result = Object.assign( 99 result = Object.assign(
98 result, 100 result,
99 paymentProcess.tranformPayment(pay.data, params.orderInfo, params.cartType, skuList, orderCompute), 101 paymentProcess.tranformPayment(pay.data, params.orderInfo, params.cartType, skuList, orderCompute),
100 -  
101 { 102 {
102 - coupon: paymentProcess.coupon(validCouponCount, params.orderInfo, orderCompute) 103 + coupon: paymentProcess.coupon(validCouponCount, params.orderInfo, orderCompute),
  104 + giftCards: paymentProcess.handleGiftCards({
  105 + validGiftCardCount: validGiftCardCount,
  106 + orderInfo: params.orderInfo,
  107 + orderCompute: orderCompute
  108 + })
103 } 109 }
104 ); 110 );
105 111
@@ -132,12 +132,12 @@ @@ -132,12 +132,12 @@
132 <li class="gift-card"> 132 <li class="gift-card">
133 <a href="{{choseGiftCard}}"> 133 <a href="{{choseGiftCard}}">
134 <span class="title">礼品卡</span> 134 <span class="title">礼品卡</span>
135 - {{# giftCard}} 135 + {{# giftCards}}
136 <span class="count">{{#if selectedAmount}}已选{{selectedAmount}}{{^}}{{count}}张可用{{/if}}</span> 136 <span class="count">{{#if selectedAmount}}已选{{selectedAmount}}{{^}}{{count}}张可用{{/if}}</span>
137 <span class="coupon-info pull-right{{#isEqualOr info '无可用'}} no-can-use{{/isEqualOr}}"> 137 <span class="coupon-info pull-right{{#isEqualOr info '无可用'}} no-can-use{{/isEqualOr}}">
138 {{info}}<i class="iconfont">&#xe614;</i> 138 {{info}}<i class="iconfont">&#xe614;</i>
139 </span> 139 </span>
140 - {{/giftCard}} 140 + {{/giftCards}}
141 </a> 141 </a>
142 </li> 142 </li>
143 {{/if}} 143 {{/if}}
@@ -27,8 +27,8 @@ @@ -27,8 +27,8 @@
27 </div> 27 </div>
28 </div> 28 </div>
29 <div class="checkbox pull-right"> 29 <div class="checkbox pull-right">
30 - <i class="iconfont">&#xe647;</i>  
31 - <i class="iconfont hide">&#xe617;</i> 30 + <i class="iconfont no-checked-icon">&#xe647;</i>
  31 + <i class="iconfont checked-icon">&#xe617;</i>
32 </div> 32 </div>
33 </div> 33 </div>
34 </div> 34 </div>
@@ -9,9 +9,11 @@ class SelectGiftCard extends Page { @@ -9,9 +9,11 @@ class SelectGiftCard extends Page {
9 9
10 this.selector = { 10 this.selector = {
11 rule: $('#rule'), 11 rule: $('#rule'),
12 - page: $('.select-giftcard-page') 12 + page: $('.select-giftcard-page'),
  13 + giftcard: $('.giftcard')
13 }; 14 };
14 this.init(); 15 this.init();
  16 + this.bindEvents();
15 } 17 }
16 18
17 init() { 19 init() {
@@ -21,7 +23,20 @@ class SelectGiftCard extends Page { @@ -21,7 +23,20 @@ class SelectGiftCard extends Page {
21 } 23 }
22 24
23 bindEvents() { 25 bindEvents() {
24 - console.log('bindEvents'); 26 + this.selector.giftcard.on('click', this.checkboxClickHandle.bind(this));
  27 + }
  28 +
  29 + /**
  30 + * 选择礼品卡
  31 + */
  32 + checkboxClickHandle(event) {
  33 + let theGiftCard = $(event.delegateTarget);
  34 +
  35 + if (theGiftCard.hasClass('checked')) {
  36 + theGiftCard.removeClass('checked');
  37 + } else {
  38 + theGiftCard.addClass('checked');
  39 + }
25 } 40 }
26 } 41 }
27 42
@@ -92,6 +92,18 @@ $title-font-color: #fff; @@ -92,6 +92,18 @@ $title-font-color: #fff;
92 font-size: 40px; 92 font-size: 40px;
93 color: #b0b0b0; 93 color: #b0b0b0;
94 } 94 }
  95 +
  96 + > .checkbox > .checked-icon {
  97 + display: none;
  98 + }
  99 + }
95 } 100 }
  101 +
  102 + .checked > .card-body > .checkbox > .checked-icon {
  103 + display: block;
  104 + }
  105 +
  106 + .checked > .card-body > .checkbox > .no-checked-icon {
  107 + display: none;
96 } 108 }
97 } 109 }
@@ -372,6 +372,13 @@ function coupon(count, orderInfo, orderComputeData) { @@ -372,6 +372,13 @@ function coupon(count, orderInfo, orderComputeData) {
372 } 372 }
373 373
374 /** 374 /**
  375 + * 处理礼品卡数据
  376 + */
  377 +function handleGiftCards(params) {
  378 + return params;
  379 +}
  380 +
  381 +/**
375 * JIT 拆单数据处理 382 * JIT 拆单数据处理
376 */ 383 */
377 function transformJit(packageList) { 384 function transformJit(packageList) {
@@ -479,6 +486,7 @@ module.exports = { @@ -479,6 +486,7 @@ module.exports = {
479 tranformPayment, 486 tranformPayment,
480 yohoCoinCompute, 487 yohoCoinCompute,
481 coupon, 488 coupon,
  489 + handleGiftCards,
482 transformJit, 490 transformJit,
483 unionInfoHandle 491 unionInfoHandle
484 }; 492 };