Showing
8 changed files
with
131 additions
and
20 deletions
@@ -16,7 +16,14 @@ const getProductInfo = (req, res, next) => { | @@ -16,7 +16,14 @@ const getProductInfo = (req, res, next) => { | ||
16 | }).catch(next); | 16 | }).catch(next); |
17 | }; | 17 | }; |
18 | 18 | ||
19 | +// 获取优惠券列表 | ||
20 | +const getCoupons = (req, res, next) => { | ||
21 | + service.getCoupons(req.user.uid).then(data => { | ||
22 | + res.send(data); | ||
23 | + }).catch(next); | ||
24 | +}; | ||
19 | 25 | ||
20 | module.exports = { | 26 | module.exports = { |
21 | - getProductInfo | 27 | + getProductInfo, |
28 | + getCoupons | ||
22 | }; | 29 | }; |
@@ -17,13 +17,15 @@ const index = (req, res, next) => { | @@ -17,13 +17,15 @@ const index = (req, res, next) => { | ||
17 | let uid = req.user.uid; | 17 | let uid = req.user.uid; |
18 | let params = req.query; | 18 | let params = req.query; |
19 | 19 | ||
20 | +// params = {bundle: 1124, sku: '809291,789238'}; | ||
20 | easypay.getEasypayOrderData(params, uid).then(result => { | 21 | easypay.getEasypayOrderData(params, uid).then(result => { |
21 | let header = headerModel.setSimpleHeaderData() || {}; | 22 | let header = headerModel.setSimpleHeaderData() || {}; |
22 | 23 | ||
23 | - Object.assign(result, { | ||
24 | - stepper: stepper, | ||
25 | - couponUnsupport: true // 限定发售不支持优惠券 | ||
26 | - }); | 24 | + result.stepper = stepper; |
25 | + | ||
26 | + if (params.limitcode) { // 限定发售不支持优惠券 | ||
27 | + result.couponUnsupport = true; | ||
28 | + } | ||
27 | 29 | ||
28 | res.render('order-ensure', { | 30 | res.render('order-ensure', { |
29 | page: 'easypay', | 31 | page: 'easypay', |
@@ -9,6 +9,7 @@ | @@ -9,6 +9,7 @@ | ||
9 | const Promise = require('bluebird'); | 9 | const Promise = require('bluebird'); |
10 | const co = Promise.coroutine; | 10 | const co = Promise.coroutine; |
11 | const _ = require('lodash'); | 11 | const _ = require('lodash'); |
12 | +const api = global.yoho.API; | ||
12 | const helpers = global.yoho.helpers; | 13 | const helpers = global.yoho.helpers; |
13 | 14 | ||
14 | const productAPI = require('./product-api'); | 15 | const productAPI = require('./product-api'); |
@@ -375,6 +376,39 @@ const getProductInfoAsync = (pid) => { | @@ -375,6 +376,39 @@ const getProductInfoAsync = (pid) => { | ||
375 | })(); | 376 | })(); |
376 | }; | 377 | }; |
377 | 378 | ||
379 | +// 获取优惠券列表 | ||
380 | +const getCoupons = (uid) => api.get('', { | ||
381 | + method: 'app.Shopping.listCoupon', | ||
382 | + uid: uid | ||
383 | +}).then(result => { | ||
384 | + | ||
385 | + if (result.code === 200) { | ||
386 | + let unuse = []; | ||
387 | + let use = []; | ||
388 | + | ||
389 | + _.forEach(result.data.unusable_coupons, i => { | ||
390 | + unuse.push({ | ||
391 | + code: i.coupon_code, | ||
392 | + name: i.coupon_name, | ||
393 | + value: i.coupon_value, | ||
394 | + canuse: false | ||
395 | + }); | ||
396 | + }); | ||
397 | + _.forEach(result.data.usable_coupons, i => { | ||
398 | + use.push({ | ||
399 | + code: i.coupon_code, | ||
400 | + name: i.coupon_name, | ||
401 | + value: i.coupon_value | ||
402 | + }); | ||
403 | + }); | ||
404 | + | ||
405 | + result.data = _.concat(use, unuse); | ||
406 | + } | ||
407 | + | ||
408 | + return result; | ||
409 | +}); | ||
410 | + | ||
378 | module.exports = { | 411 | module.exports = { |
379 | - getProductInfoAsync // 获取某一个商品详情主页面 | 412 | + getProductInfoAsync, // 获取某一个商品详情主页面 |
413 | + getCoupons // 获取优惠券列表 | ||
380 | }; | 414 | }; |
@@ -7,15 +7,21 @@ | @@ -7,15 +7,21 @@ | ||
7 | 7 | ||
8 | const api = global.yoho.API; | 8 | const api = global.yoho.API; |
9 | 9 | ||
10 | -const getEasyPaymentAsync = (goods, uid) => { | ||
11 | - return api.get('', { | 10 | +const getEasyPaymentAsync = (uid, goods, activity) => { |
11 | + let param = { | ||
12 | method: 'app.Shopping.easyPayment', | 12 | method: 'app.Shopping.easyPayment', |
13 | uid: uid, | 13 | uid: uid, |
14 | cart_type: 'ordinary', | 14 | cart_type: 'ordinary', |
15 | product_sku_list: goods, | 15 | product_sku_list: goods, |
16 | yoho_coin_mode: 0, | 16 | yoho_coin_mode: 0, |
17 | is_support_apple_pay: 'N' | 17 | is_support_apple_pay: 'N' |
18 | - }, {code: 200}); | 18 | + }; |
19 | + | ||
20 | + if (activity) { | ||
21 | + param.activity_id = activity; | ||
22 | + } | ||
23 | + | ||
24 | + return api.get('', param, {code: 200}); | ||
19 | }; | 25 | }; |
20 | 26 | ||
21 | 27 | ||
@@ -71,7 +77,14 @@ const getEasypayComputeAsync = (uid, cartType, paymentType, deliveryWay, other) | @@ -71,7 +77,14 @@ const getEasypayComputeAsync = (uid, cartType, paymentType, deliveryWay, other) | ||
71 | Object.assign(param, { | 77 | Object.assign(param, { |
72 | product_sku_list: other.productSkuList | 78 | product_sku_list: other.productSkuList |
73 | }); | 79 | }); |
80 | + | ||
81 | + if (other.bundle) { | ||
82 | + Object.assign(param, { | ||
83 | + activity_id: other.bundle | ||
84 | + }); | ||
85 | + } | ||
74 | } | 86 | } |
87 | + | ||
75 | } | 88 | } |
76 | 89 | ||
77 | return api.get('', param); | 90 | return api.get('', param); |
@@ -151,6 +164,12 @@ const easypayOrderSubmitAsync = (uid, cartType, addressId, deliveryTime, deliver | @@ -151,6 +164,12 @@ const easypayOrderSubmitAsync = (uid, cartType, addressId, deliveryTime, deliver | ||
151 | Object.assign(param, { | 164 | Object.assign(param, { |
152 | product_sku_list: other.productSkuList | 165 | product_sku_list: other.productSkuList |
153 | }); | 166 | }); |
167 | + | ||
168 | + if (other.bundle) { | ||
169 | + Object.assign(param, { | ||
170 | + activity_id: other.bundle | ||
171 | + }); | ||
172 | + } | ||
154 | } | 173 | } |
155 | 174 | ||
156 | return api.get('', param); | 175 | return api.get('', param); |
@@ -126,29 +126,37 @@ const _handelPaymentInfo = (d) => { | @@ -126,29 +126,37 @@ const _handelPaymentInfo = (d) => { | ||
126 | }; | 126 | }; |
127 | 127 | ||
128 | const _getLimitProductData = (params) => { | 128 | const _getLimitProductData = (params) => { |
129 | - let info = { | ||
130 | - type: 'limitcode', | ||
131 | - buy_number: 1 | ||
132 | - }; | 129 | + let resList = []; |
133 | 130 | ||
134 | - if (params.sku && params.skn && params.limitcode) { | ||
135 | - Object.assign(info, { | 131 | + if (params.limitcode && params.sku && params.skn) { |
132 | + resList.push({ | ||
133 | + type: 'limitcode', | ||
134 | + buy_number: 1, | ||
136 | sku: params.sku, | 135 | sku: params.sku, |
137 | skn: params.skn, | 136 | skn: params.skn, |
138 | limitproductcode: params.limitcode | 137 | limitproductcode: params.limitcode |
139 | }); | 138 | }); |
140 | - | ||
141 | - return JSON.stringify([info]); | 139 | + } else if (params.bundle && params.sku) { |
140 | + resList = []; | ||
141 | + | ||
142 | + _.forEach(_.split(params.sku, ',', 10), val => { | ||
143 | + resList.push({ | ||
144 | + type: 'bundle', | ||
145 | + sku: parseInt(val, 10), | ||
146 | + buy_number: 1 | ||
147 | + }); | ||
148 | + }); | ||
142 | } | 149 | } |
143 | 150 | ||
144 | - return false; | 151 | + return resList.length ? JSON.stringify(resList) : false; |
145 | }; | 152 | }; |
146 | 153 | ||
147 | const getEasypayOrderData = (params, uid) => { | 154 | const getEasypayOrderData = (params, uid) => { |
148 | let resData = {}; | 155 | let resData = {}; |
149 | let strInfo = _getLimitProductData(params); | 156 | let strInfo = _getLimitProductData(params); |
157 | + let bundle = params.bundle ? parseInt(params.bundle, 10) : false; | ||
150 | 158 | ||
151 | - return easypayApi.getEasyPaymentAsync(strInfo, uid).then(result => { | 159 | + return easypayApi.getEasyPaymentAsync(uid, strInfo, bundle).then(result => { |
152 | let d = _.get(result, 'data', false); | 160 | let d = _.get(result, 'data', false); |
153 | 161 | ||
154 | if (d) { | 162 | if (d) { |
@@ -15,6 +15,8 @@ const easypay = require(`${cRoot}/easypay`); | @@ -15,6 +15,8 @@ const easypay = require(`${cRoot}/easypay`); | ||
15 | 15 | ||
16 | router.get('/index/getProductInfo', cart.getProductInfo); | 16 | router.get('/index/getProductInfo', cart.getProductInfo); |
17 | 17 | ||
18 | +router.get('/coupon/list', cart.getCoupons); // 优惠券列表 | ||
19 | + | ||
18 | router.get('/address/list', address.getList); // 省市区列表信息 | 20 | router.get('/address/list', address.getList); // 省市区列表信息 |
19 | router.get('/address/area', address.getArea); // 省市区列表信息 | 21 | router.get('/address/area', address.getArea); // 省市区列表信息 |
20 | router.post('/address/delete', address.delAddress); // 删除地址 | 22 | router.post('/address/delete', address.delAddress); // 删除地址 |
@@ -158,6 +158,37 @@ | @@ -158,6 +158,37 @@ | ||
158 | </div> | 158 | </div> |
159 | </div> | 159 | </div> |
160 | 160 | ||
161 | + {{#with shopping_cart_data}} | ||
162 | + {{#isY is_multi_package}} | ||
163 | + <div class="multi-package-row"> | ||
164 | + 温馨提示:您购买的商品<em class="red">分属不同仓库</em>,需要调拨,将被拆分成多个包裹送达 | ||
165 | + <span class="iconfont show-package"></span> | ||
166 | + <div class="package-list hide"> | ||
167 | + <div class="package-up-icon"></div> | ||
168 | + {{#each ../package_list}} | ||
169 | + <div class="package-item"> | ||
170 | + <p class="package-title bold">包裹{{math @index '+' 1}}:{{#if @first}}总仓发货{{^}}异地调拨{{/if}}</p> | ||
171 | + {{#if showToggle}} | ||
172 | + <span class="iconfont toggle-icon left-icon"></span> | ||
173 | + <span class="iconfont toggle-icon right-icon"></span> | ||
174 | + {{/if}} | ||
175 | + <div class="package-goods-wrap"> | ||
176 | + <ul class="package-goods clearfix"> | ||
177 | + {{#each goods_list}} | ||
178 | + <li class="left"> | ||
179 | + <img class="lazy package-goods-img" data-original="{{image goods_images 90 90}}"> | ||
180 | + </li> | ||
181 | + {{/each}} | ||
182 | + </ul> | ||
183 | + </div> | ||
184 | + <p class="package-shipping">运费:¥{{shopping_cost}}元</p> | ||
185 | + </div> | ||
186 | + {{/each}} | ||
187 | + </div> | ||
188 | + </div> | ||
189 | + {{/isY}} | ||
190 | + {{/with}} | ||
191 | + | ||
161 | <table class="goods-table"> | 192 | <table class="goods-table"> |
162 | <thead> | 193 | <thead> |
163 | <tr> | 194 | <tr> |
@@ -87,6 +87,10 @@ function compute(coin) { | @@ -87,6 +87,10 @@ function compute(coin) { | ||
87 | if (queryInfo.limitcode) { | 87 | if (queryInfo.limitcode) { |
88 | d.limitcode = queryInfo.limitcode; | 88 | d.limitcode = queryInfo.limitcode; |
89 | } | 89 | } |
90 | + | ||
91 | + if (queryInfo.bundle) { | ||
92 | + d.bundle = queryInfo.bundle; | ||
93 | + } | ||
90 | } | 94 | } |
91 | 95 | ||
92 | $.ajax({ | 96 | $.ajax({ |
@@ -147,7 +151,7 @@ if ($('#use-coupons').length) { | @@ -147,7 +151,7 @@ if ($('#use-coupons').length) { | ||
147 | // 优惠券 | 151 | // 优惠券 |
148 | $.ajax({ | 152 | $.ajax({ |
149 | type: 'GET', | 153 | type: 'GET', |
150 | - url: '/cart/easypay/coupons' | 154 | + url: '/cart/coupon/list' |
151 | }).then(function(data) { | 155 | }).then(function(data) { |
152 | if (data.code === 200) { | 156 | if (data.code === 200) { |
153 | $('#coupon-list').prepend(couponsTpl({ | 157 | $('#coupon-list').prepend(couponsTpl({ |
@@ -263,6 +267,10 @@ $('#go-pay').click(function() { | @@ -263,6 +267,10 @@ $('#go-pay').click(function() { | ||
263 | if (queryInfo.limitcode) { | 267 | if (queryInfo.limitcode) { |
264 | d.limitcode = queryInfo.limitcode; | 268 | d.limitcode = queryInfo.limitcode; |
265 | } | 269 | } |
270 | + | ||
271 | + if (queryInfo.bundle) { | ||
272 | + d.bundle = queryInfo.bundle; | ||
273 | + } | ||
266 | } | 274 | } |
267 | 275 | ||
268 | $.ajax({ | 276 | $.ajax({ |
-
Please register or login to post a comment