Showing
18 changed files
with
872 additions
and
103 deletions
@@ -33,41 +33,6 @@ const index = (req, res, next) => { | @@ -33,41 +33,6 @@ const index = (req, res, next) => { | ||
33 | }).catch(next); | 33 | }).catch(next); |
34 | }; | 34 | }; |
35 | 35 | ||
36 | -// 获取地址列表 | ||
37 | -const addressList = (req, res, next) => { | ||
38 | - oeModel.addressList(req.user.uid).then(data => { | ||
39 | - res.send(data); | ||
40 | - }).catch(next); | ||
41 | -}; | ||
42 | - | ||
43 | -// 获取区域列表 | ||
44 | -const getAreaList = (req, res, next) => { | ||
45 | - oeModel.areaList(req.query.id).then(data => { | ||
46 | - res.send(data); | ||
47 | - }).catch(next); | ||
48 | -}; | ||
49 | - | ||
50 | -// 地址删除 | ||
51 | -const delAddress = (req, res, next) => { | ||
52 | - oeModel.delAddress(req.user.uid, req.body.id).then(data => { | ||
53 | - res.send(data); | ||
54 | - }).catch(next); | ||
55 | -}; | ||
56 | - | ||
57 | -// 地址/更新新增 | ||
58 | -const saveAddress = (req, res, next) => { | ||
59 | - oeModel.saveAddress(req.user.uid, req.body).then(data => { | ||
60 | - res.send(data); | ||
61 | - }).catch(next); | ||
62 | -}; | ||
63 | - | ||
64 | -// 设置默认地址 | ||
65 | -const setDefault = (req, res, next) => { | ||
66 | - oeModel.setDefault(req.user.uid, req.body.id).then(data => { | ||
67 | - res.send(data); | ||
68 | - }).catch(next); | ||
69 | -}; | ||
70 | - | ||
71 | // 获取优惠券列表 | 36 | // 获取优惠券列表 |
72 | const getCoupons = (req, res, next) => { | 37 | const getCoupons = (req, res, next) => { |
73 | oeModel.getCoupons(req.user.uid).then(data => { | 38 | oeModel.getCoupons(req.user.uid).then(data => { |
@@ -77,9 +42,10 @@ const getCoupons = (req, res, next) => { | @@ -77,9 +42,10 @@ const getCoupons = (req, res, next) => { | ||
77 | 42 | ||
78 | // 订单金额计算 | 43 | // 订单金额计算 |
79 | const compute = (req, res, next) => { | 44 | const compute = (req, res, next) => { |
80 | - let cartType = req.query.cartType === '2' ? 'advance' : 'ordinary'; | 45 | + let params = req.body; |
46 | + let cartType = params.cartType === '2' ? 'advance' : 'ordinary'; | ||
81 | 47 | ||
82 | - oeModel.compute(req.user.uid, cartType, req.query).then(data => { | 48 | + oeModel.compute(req.user.uid, cartType, params).then(data => { |
83 | res.send(data); | 49 | res.send(data); |
84 | }).catch(next); | 50 | }).catch(next); |
85 | }; | 51 | }; |
@@ -103,11 +69,6 @@ const submit = (req, res, next) => { | @@ -103,11 +69,6 @@ const submit = (req, res, next) => { | ||
103 | 69 | ||
104 | module.exports = { | 70 | module.exports = { |
105 | index, | 71 | index, |
106 | - addressList, | ||
107 | - getAreaList, | ||
108 | - delAddress, | ||
109 | - saveAddress, | ||
110 | - setDefault, | ||
111 | getCoupons, | 72 | getCoupons, |
112 | compute, | 73 | compute, |
113 | submit | 74 | submit |
@@ -7,6 +7,12 @@ | @@ -7,6 +7,12 @@ | ||
7 | 7 | ||
8 | const api = global.yoho.API; | 8 | const api = global.yoho.API; |
9 | 9 | ||
10 | +/** | ||
11 | + * 购物车结算API | ||
12 | + * @param uid [number] uid | ||
13 | + * @param cartType [string] 购物车类型,ordinary表示普通, advance表示预售 | ||
14 | + * @param yohoCoinMode [number] 是否使用yoho币,1使用,0不使用 | ||
15 | + */ | ||
10 | const getOrderPaymentAsync = (uid, cartType, yohoCoinMode) => api.get('', { | 16 | const getOrderPaymentAsync = (uid, cartType, yohoCoinMode) => api.get('', { |
11 | method: 'app.Shopping.payment', | 17 | method: 'app.Shopping.payment', |
12 | cart_type: cartType, | 18 | cart_type: cartType, |
@@ -15,6 +21,15 @@ const getOrderPaymentAsync = (uid, cartType, yohoCoinMode) => api.get('', { | @@ -15,6 +21,15 @@ const getOrderPaymentAsync = (uid, cartType, yohoCoinMode) => api.get('', { | ||
15 | }); | 21 | }); |
16 | 22 | ||
17 | /** | 23 | /** |
24 | + * 获取用户优惠券信息API | ||
25 | + * @param uid [number] uid | ||
26 | + */ | ||
27 | +const getUesrCouponAsync = (uid) => api.get('', { | ||
28 | + method: 'app.Shopping.listCoupon', | ||
29 | + uid: uid | ||
30 | +}); | ||
31 | + | ||
32 | +/** | ||
18 | * 订单计算API | 33 | * 订单计算API |
19 | * @param uid [number] uid | 34 | * @param uid [number] uid |
20 | * @param cartType [string] 购物车类型,ordinary表示普通, advance表示预售 | 35 | * @param cartType [string] 购物车类型,ordinary表示普通, advance表示预售 |
@@ -93,7 +108,8 @@ const orderSubmitAsync = (uid, cartType, addressId, deliveryTime, deliveryWay, p | @@ -93,7 +108,8 @@ const orderSubmitAsync = (uid, cartType, addressId, deliveryTime, deliveryWay, p | ||
93 | delivery_way: deliveryWay, | 108 | delivery_way: deliveryWay, |
94 | payment_type: paymentType, | 109 | payment_type: paymentType, |
95 | payment_id: paymentId, | 110 | payment_id: paymentId, |
96 | - is_print_price: printPrice | 111 | + is_print_price: printPrice, |
112 | + is_continue_buy: other.continueBuy ? 'Y' : 'N' | ||
97 | }; | 113 | }; |
98 | 114 | ||
99 | // 发票 | 115 | // 发票 |
@@ -139,6 +155,7 @@ const orderSubmitAsync = (uid, cartType, addressId, deliveryTime, deliveryWay, p | @@ -139,6 +155,7 @@ const orderSubmitAsync = (uid, cartType, addressId, deliveryTime, deliveryWay, p | ||
139 | 155 | ||
140 | module.exports = { | 156 | module.exports = { |
141 | getOrderPaymentAsync, | 157 | getOrderPaymentAsync, |
158 | + getUesrCouponAsync, | ||
142 | getOrderComputeAsync, | 159 | getOrderComputeAsync, |
143 | orderSubmitAsync | 160 | orderSubmitAsync |
144 | }; | 161 | }; |
@@ -38,36 +38,7 @@ const index = (uid, cartType) => { | @@ -38,36 +38,7 @@ const index = (uid, cartType) => { | ||
38 | }; | 38 | }; |
39 | 39 | ||
40 | // 获取优惠券列表 | 40 | // 获取优惠券列表 |
41 | -// const getCoupons = (uid) => api.get('', { | ||
42 | -// method: 'app.Shopping.listCoupon', | ||
43 | -// uid: uid | ||
44 | -// }).then(result => { | ||
45 | - | ||
46 | -// if (result.code === 200) { | ||
47 | -// let unuse = []; | ||
48 | -// let use = []; | ||
49 | - | ||
50 | -// _.forEach(result.data.unusable_coupons, i => { | ||
51 | -// unuse.push({ | ||
52 | -// code: i.coupon_code, | ||
53 | -// name: i.coupon_name, | ||
54 | -// value: i.coupon_value, | ||
55 | -// canuse: false | ||
56 | -// }); | ||
57 | -// }); | ||
58 | -// _.forEach(result.data.usable_coupons, i => { | ||
59 | -// use.push({ | ||
60 | -// code: i.coupon_code, | ||
61 | -// name: i.coupon_name, | ||
62 | -// value: i.coupon_value | ||
63 | -// }); | ||
64 | -// }); | ||
65 | - | ||
66 | -// result.data = _.concat(use, unuse); | ||
67 | -// } | ||
68 | - | ||
69 | -// return result; | ||
70 | -// }); | 41 | +const getCoupons = (uid) => ensureApi.getUesrCouponAsync(uid); |
71 | 42 | ||
72 | // 订单计算 | 43 | // 订单计算 |
73 | const compute = (uid, cartType, pa) => { | 44 | const compute = (uid, cartType, pa) => { |
@@ -110,8 +81,7 @@ const submit = (uid, cartType, p) => { | @@ -110,8 +81,7 @@ const submit = (uid, cartType, p) => { | ||
110 | 81 | ||
111 | module.exports = { | 82 | module.exports = { |
112 | index, | 83 | index, |
113 | - | ||
114 | - // getCoupons, | 84 | + getCoupons, |
115 | compute, | 85 | compute, |
116 | submit | 86 | submit |
117 | }; | 87 | }; |
@@ -23,6 +23,8 @@ router.post('/address/save', address.saveAddress); // 新增地址/更新地址 | @@ -23,6 +23,8 @@ router.post('/address/save', address.saveAddress); // 新增地址/更新地址 | ||
23 | router.post('/address/setdefault', address.setDefault); // 设置默认地址 | 23 | router.post('/address/setdefault', address.setDefault); // 设置默认地址 |
24 | 24 | ||
25 | router.get('/ensure', ensure.index); // 限购商品快捷结算页 | 25 | router.get('/ensure', ensure.index); // 限购商品快捷结算页 |
26 | +router.get('/ensure/coupons', ensure.getCoupons); // 限购商品快捷结算页 | ||
27 | +router.post('/ensure/compute', ensure.compute); // 价格重新计算 | ||
26 | 28 | ||
27 | router.get('/easypay', easypay.index); // 限购商品快捷结算页 | 29 | router.get('/easypay', easypay.index); // 限购商品快捷结算页 |
28 | router.post('/easypay/compute', easypay.compute); // 价格重新计算 | 30 | router.post('/easypay/compute', easypay.compute); // 价格重新计算 |
@@ -120,19 +120,83 @@ | @@ -120,19 +120,83 @@ | ||
120 | <label id="modify-invoice">修改</label> | 120 | <label id="modify-invoice">修改</label> |
121 | </div> | 121 | </div> |
122 | </div> | 122 | </div> |
123 | + | ||
124 | + {{# shoppingCartData}} | ||
123 | <div class="extra-wrap"> | 125 | <div class="extra-wrap"> |
124 | <dl> | 126 | <dl> |
125 | - <dt>使用YOHO币</dt> | ||
126 | - <dd></dd> | ||
127 | - <dt>使用红包</dt> | ||
128 | - <dd></dd> | ||
129 | - <dt>添加备注信息</dt> | ||
130 | - <dd></dd> | 127 | + <dt id="use-coupons" class="use-coupons"> |
128 | + <span class="iconfont locker-switch"></span>使用优惠券/优惠码 | ||
129 | + <div class="tip-box right"> | ||
130 | + <p>优惠码不可与优惠券同时使用</p> | ||
131 | + <p class="coupon-err-tip"></p> | ||
132 | + </div> | ||
133 | + </dt> | ||
134 | + <dd> | ||
135 | + <div class="coupon-opt-title"> | ||
136 | + <label class="radio-btn on">使用优惠券</label> | ||
137 | + <label class="radio-btn code">使用优惠码</label> | ||
138 | + <span class="ticket-use-tip hide"> | ||
139 | + 已成功使用<em class="red num">1</em>张优惠券,<em class="red price"></em> | ||
140 | + <b class="cancel-use-ticket">取消使用</b> | ||
141 | + </span> | ||
142 | + <div class="opt-area right"> | ||
143 | + <input type="text" class="coupon-code"> | ||
144 | + <label class="sure-use-code">直接使用</label> | ||
145 | + <label class="sure-use-ticket">确定</label> | ||
146 | + </div> | ||
147 | + </div> | ||
148 | + <div class="coupon-list-wrap"></div> | ||
149 | + </dd> | ||
150 | + <dt><span class="iconfont locker-switch"></span>使用YOHO币</dt> | ||
151 | + <dd id="yoho-coin-box" class="yoho-coin-box" data-coin="{{usedCoinNum}}" data-max={{canUseCoinNum}}> | ||
152 | + <div class="outer-view"> | ||
153 | + <p class="coin-err-tip">{{coinErrorTip}}</p> | ||
154 | + <p>有货币满<span class="red">{{yoho_coin_pay_rule.num_limit}}</span>个即可使用,每次使用有货币为<span class="red">{{yoho_coin_pay_rule.num_limit}}</span>的整数倍</p> | ||
155 | + <i class="iconfont help-icon"></i> | ||
156 | + <div class="coin-tip-help"> | ||
157 | + <p>有货币使用提示:</p> | ||
158 | + <p> | ||
159 | + 1.订单金额大于20元(含20元)<br> | ||
160 | + 2.有货币数量大于{{yoho_coin_pay_rule.num_limit}}个(含{{yoho_coin_pay_rule.num_limit}}个) <br> | ||
161 | + 3.有货币支付上限为每笔订单应付金额的{{yoho_coin_pay_rule.max_pay_rate_desc}} | ||
162 | + </p> | ||
163 | + <p class="rs-text">备注:使用有货币数量为{{yoho_coin_pay_rule.num_limit}}的整数倍,100有货币抵1元</p> | ||
164 | + </div> | ||
165 | + </div> | ||
166 | + <div class="coin-main-view"> | ||
167 | + <p>本次使用有货币<span class="red">{{canUseCoinNum}}</span>个,抵扣 <span class="red">¥{{yoho_coin}}</span></p> | ||
168 | + <p class="grey">您当前共有有货币 <span class="red">{{total_yoho_coin_num}}</span> 个,可用 <span class="red">{{canUseCoinNum}}</span> 个</p> | ||
169 | + <label class="coin-cancel-btn">取消使用</label> | ||
170 | + <label class="coin-use-btn">确定</label> | ||
171 | + </div> | ||
172 | + </dd> | ||
173 | + {{#if red_envelopes}} | ||
174 | + <dt><span class="iconfont locker-switch"></span>使用红包</dt> | ||
175 | + <dd id="red-packet-box" class="red-packet-box"> | ||
176 | + <div> | ||
177 | + <label class="radio-btn"></label> | ||
178 | + 使用红包支付(当前账户红包金额:<em class="red">¥ {{red_envelopes}}</em>) | ||
179 | + <label class="sure-btn" data-num="{{red_envelopes}}">确定</label> | ||
180 | + </div> | ||
181 | + </dd> | ||
182 | + {{/if}} | ||
183 | + <dt><span class="iconfont locker-switch"></span>添加备注信息</dt> | ||
184 | + <dd id="remark-box" class="remark-box"> | ||
185 | + <div class="note-text-box"> | ||
186 | + <p class="tip-text">声明:备注中有关收货人信息、支付方式、配送方式、发票信息等购买要求一律以上面的选择为准,备注无效。</p> | ||
187 | + <textarea class="note-text"></textarea> | ||
188 | + </div> | ||
189 | + <p class="pp-area">是否打印价格: | ||
190 | + <label class="radio-btn on">是</label> | ||
191 | + <label class="radio-btn unprint">否</label> | ||
192 | + <span>(如:送朋友的商品可不打印价格哦!)</span> | ||
193 | + </p> | ||
194 | + </dd> | ||
131 | </dl> | 195 | </dl> |
132 | </div> | 196 | </div> |
133 | - {{# shoppingCartData}} | 197 | + |
134 | <div class="balance-wrap"> | 198 | <div class="balance-wrap"> |
135 | - <ul class="balance-detail"> | 199 | + <ul id="balance-detail" class="balance-detail"> |
136 | {{#each promotion_formula_list}} | 200 | {{#each promotion_formula_list}} |
137 | <li class="promotion-item"> | 201 | <li class="promotion-item"> |
138 | {{#if @first}} | 202 | {{#if @first}} |
@@ -149,7 +213,7 @@ | @@ -149,7 +213,7 @@ | ||
149 | </div> | 213 | </div> |
150 | 214 | ||
151 | <div class="sum-wrap"> | 215 | <div class="sum-wrap"> |
152 | - 应付金额:<span class="price">¥ {{last_order_amount}}</span> | 216 | + 应付金额:<span id="order-price" class="price">¥ {{round last_order_amount 2}}</span> |
153 | <button id="order-submit">提交订单</button> | 217 | <button id="order-submit">提交订单</button> |
154 | </div> | 218 | </div> |
155 | {{/ shoppingCartData}} | 219 | {{/ shoppingCartData}} |
1 | - | ||
2 | - | ||
3 | <script id="address-tpl" type="text/html"> | 1 | <script id="address-tpl" type="text/html"> |
4 | <div class="title">\{{title}}</div> | 2 | <div class="title">\{{title}}</div> |
5 | <p class="prompt">\{{title}}、电话为选填项,其他均为必填项</p> | 3 | <p class="prompt">\{{title}}、电话为选填项,其他均为必填项</p> |
@@ -138,3 +136,70 @@ | @@ -138,3 +136,70 @@ | ||
138 | </ul> | 136 | </ul> |
139 | </div> | 137 | </div> |
140 | </script> | 138 | </script> |
139 | + | ||
140 | +<script id="coupons-tpl" type="text/html"> | ||
141 | + \{{#if usable_coupons}} | ||
142 | + <ul class="usable-list"> | ||
143 | + <li class="useable-title">可用优惠券</li> | ||
144 | + \{{#each usable_coupons}} | ||
145 | + <li> | ||
146 | + <span class="title">\{{coupon_name}}</span> | ||
147 | + <span class="time">\{{coupon_validity}}</span> | ||
148 | + <span class="money">¥ \{{round coupon_value 2}}</span> | ||
149 | + <span class="coupon-radio" data-id="\{{coupon_code}}" data-price="\{{round coupon_value 2}}"></span> | ||
150 | + </li> | ||
151 | + \{{/each}} | ||
152 | + </ul> | ||
153 | + \{{^}} | ||
154 | + <p class="empty-tip">暂无可用优惠券~</p> | ||
155 | + \{{/if}} | ||
156 | + \{{#if unusable_coupons}} | ||
157 | + <ul class="unusable-list"> | ||
158 | + <li class="unuseable-title">未满足使用条件的优惠券</li> | ||
159 | + \{{#each unusable_coupons}} | ||
160 | + <li> | ||
161 | + <span class="title">\{{coupon_name}}</span> | ||
162 | + <span class="time">\{{coupon_validity}}</span> | ||
163 | + <span class="money">¥ \{{round coupon_value 2}}</span> | ||
164 | + </li> | ||
165 | + \{{/each}} | ||
166 | + </ul> | ||
167 | + \{{/if}} | ||
168 | +</script> | ||
169 | + | ||
170 | +<script id="yoho-coin-tpl" type="text/html"> | ||
171 | + <div class="outer-view"> | ||
172 | + <p class="coin-err-tip">\{{coinErrorTip}}</p> | ||
173 | + <p>有货币满<span class="red">\{{yoho_coin_pay_rule.num_limit}}</span>个即可使用,每次使用有货币为<span class="red">\{{yoho_coin_pay_rule.num_limit}}</span>的整数倍</p> | ||
174 | + <i class="iconfont help-icon"></i> | ||
175 | + <div class="coin-tip-help"> | ||
176 | + <p>有货币使用提示:</p> | ||
177 | + <p> | ||
178 | + 1.订单金额大于20元(含20元)<br> | ||
179 | + 2.有货币数量大于\{{yoho_coin_pay_rule.num_limit}}个(含\{{yoho_coin_pay_rule.num_limit}}个) <br> | ||
180 | + 3.有货币支付上限为每笔订单应付金额的\{{yoho_coin_pay_rule.max_pay_rate_desc}} | ||
181 | + </p> | ||
182 | + <p class="rs-text">备注:使用有货币数量为\{{yoho_coin_pay_rule.num_limit}}的整数倍,100有货币抵1元</p> | ||
183 | + </div> | ||
184 | + </div> | ||
185 | + <div class="coin-main-view"> | ||
186 | + <p>本次使用有货币<span class="red">\{{canUseCoinNum}}</span>个,抵扣 <span class="red">¥\{{yoho_coin}}</span></p> | ||
187 | + <p class="grey">您当前共有有货币 <span class="red">\{{total_yoho_coin_num}}</span> 个,可用 <span class="red">\{{canUseCoinNum}}</span> 个</p> | ||
188 | + <label class="coin-cancel-btn">取消使用</label> | ||
189 | + <label class="coin-use-btn">确定</label> | ||
190 | + </div> | ||
191 | +</script> | ||
192 | + | ||
193 | +<script id="promotion-list-tpl" type="text/html"> | ||
194 | + \{{#each promotion_formula_list}} | ||
195 | + <li class="promotion-item"> | ||
196 | + \{{#if @first}} | ||
197 | + <a class="gain-coin-tip" href="/help/?category_id=87" target="_blank"></a> | ||
198 | + <span class="back-coin">共返YOHO币:\{{../gain_yoho_coin}}个</span> | ||
199 | + <span class="total-num"><i>\{{../selected_goods_count}}</i>件商品</span> | ||
200 | + \{{/if}} | ||
201 | + <span class="promotion-name">\{{promotion}}:</span> | ||
202 | + <em class="promotion-val">\{{promotion_amount}}</em> | ||
203 | + </li> | ||
204 | + \{{/each}} | ||
205 | +</script> |
No preview for this file type
@@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
2 | <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" > | 2 | <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" > |
3 | <svg xmlns="http://www.w3.org/2000/svg"> | 3 | <svg xmlns="http://www.w3.org/2000/svg"> |
4 | <metadata> | 4 | <metadata> |
5 | -Created by FontForge 20120731 at Thu Dec 15 10:53:04 2016 | 5 | +Created by FontForge 20120731 at Fri Dec 30 17:59:57 2016 |
6 | By admin | 6 | By admin |
7 | </metadata> | 7 | </metadata> |
8 | <defs> | 8 | <defs> |
@@ -52,6 +52,8 @@ d="M384 640v-513l321 257z" /> | @@ -52,6 +52,8 @@ d="M384 640v-513l321 257z" /> | ||
52 | d="M286 509l-46 -45l272 -272l272 272l-46 45l-226 -226z" /> | 52 | d="M286 509l-46 -45l272 -272l272 272l-46 45l-226 -226z" /> |
53 | <glyph glyph-name="chevron-right" unicode="" | 53 | <glyph glyph-name="chevron-right" unicode="" |
54 | d="M387 158l45 -46l272 272l-272 272l-45 -46l226 -226z" /> | 54 | d="M387 158l45 -46l272 272l-272 272l-45 -46l226 -226z" /> |
55 | + <glyph glyph-name="shoucang" unicode="" | ||
56 | +d="M896 294q66 69 66 166.5t-66 166.5q-68 71 -164 69q-37 -1 -91.5 -29.5t-90.5 -57.5l-37 -28q-6 4 -15.5 12t-38.5 28t-55.5 35t-59 27.5t-56.5 12.5q-93 0 -159 -69t-66 -166.5t66 -166.5l383 -399z" /> | ||
55 | <glyph glyph-name="duihao" unicode="" | 57 | <glyph glyph-name="duihao" unicode="" |
56 | d="M903 577l-68 69l-388 -388l-231 230l-68 -68l299 -298l65 65v0z" /> | 58 | d="M903 577l-68 69l-388 -388l-231 230l-68 -68l299 -298l65 65v0z" /> |
57 | <glyph glyph-name="tongzhi" unicode="" | 59 | <glyph glyph-name="tongzhi" unicode="" |
@@ -103,6 +105,9 @@ q5 37 20 66t39 49t55 31q31 10 66 10q33 0 63 -9.5t53 -28.5t36 -46.5t13 -64.5q0 -2 | @@ -103,6 +105,9 @@ q5 37 20 66t39 49t55 31q31 10 66 10q33 0 63 -9.5t53 -28.5t36 -46.5t13 -64.5q0 -2 | ||
103 | q-12 0 -23.5 4.5t-20.5 12.5q-8 7 -13 18t-5 23z" /> | 105 | q-12 0 -23.5 4.5t-20.5 12.5q-8 7 -13 18t-5 23z" /> |
104 | <glyph glyph-name="add" unicode="" | 106 | <glyph glyph-name="add" unicode="" |
105 | d="M960 262h-410v-410h-76v410h-410v76h410v410h76v-410h410v-76z" /> | 107 | d="M960 262h-410v-410h-76v410h-410v76h410v410h76v-410h410v-76z" /> |
108 | + <glyph glyph-name="search1" unicode="" | ||
109 | +d="M968 47l-163 164q69 108 69 234q0 119 -57.5 219t-157 158.5t-216 58.5t-216 -58.5t-157 -158.5t-57.5 -218.5t57.5 -219t157 -158.5t216.5 -58q124 0 231 69l163 -164q27 -28 65 -28t65 27.5t27 66t-27 66.5zM443.5 134q-127.5 0 -217.5 91.5t-90 220t90 219.5t217.5 91 | ||
110 | +t217.5 -91t90 -219.5t-90 -220t-217.5 -91.5z" /> | ||
106 | <glyph glyph-name="xiangxia" unicode="" | 111 | <glyph glyph-name="xiangxia" unicode="" |
107 | d="M888 620q12 12 28.5 12t28.5 -12v0q12 -12 12 -28.5t-12 -28.5l-406 -405q-12 -12 -28.5 -12t-27.5 12v0q-12 11 -12 27.5t12 28.5zM539 214q11 -12 11 -28.5t-11 -27.5v0q-12 -12 -28.5 -12t-28.5 12l-406 405q-11 12 -11 28.5t11 28.5v0q12 12 28.5 12t28.5 -12z | 112 | d="M888 620q12 12 28.5 12t28.5 -12v0q12 -12 12 -28.5t-12 -28.5l-406 -405q-12 -12 -28.5 -12t-27.5 12v0q-12 11 -12 27.5t12 28.5zM539 214q11 -12 11 -28.5t-11 -27.5v0q-12 -12 -28.5 -12t-28.5 12l-406 405q-11 12 -11 28.5t11 28.5v0q12 12 28.5 12t28.5 -12z |
108 | M539 214z" /> | 113 | M539 214z" /> |
@@ -124,6 +129,9 @@ d="M569 607q-28 66 -74 108.5t-95 56.5t-100 2.5t-91.5 -45t-66 -94t-26.5 -137.5q0 | @@ -124,6 +129,9 @@ d="M569 607q-28 66 -74 108.5t-95 56.5t-100 2.5t-91.5 -45t-66 -94t-26.5 -137.5q0 | ||
124 | q0 76 -26.5 136t-67 92t-92 42.5t-101 -4t-94.5 -56t-72 -104.5z" /> | 129 | q0 76 -26.5 136t-67 92t-92 42.5t-101 -4t-94.5 -56t-72 -104.5z" /> |
125 | <glyph glyph-name="logincheckbutton1" unicode="" | 130 | <glyph glyph-name="logincheckbutton1" unicode="" |
126 | d="M877 896h-730q-61 0 -104 -43t-43 -104v-730q0 -61 43 -104t104 -43h730q61 0 104 43t43 104v730q0 61 -43 104t-104 43zM939 19q0 -26 -18 -44t-44 -18h-730q-26 0 -44 18t-18 44v730q0 26 18 44t44 18h730q26 0 44 -18t18 -44v-730z" /> | 131 | d="M877 896h-730q-61 0 -104 -43t-43 -104v-730q0 -61 43 -104t104 -43h730q61 0 104 43t43 104v730q0 61 -43 104t-104 43zM939 19q0 -26 -18 -44t-44 -18h-730q-26 0 -44 18t-18 44v730q0 26 18 44t44 18h730q26 0 44 -18t18 -44v-730z" /> |
132 | + <glyph glyph-name="like" unicode="" | ||
133 | +d="M703 695q-113 0 -191 -81q-79 81 -191 81t-191 -79t-79 -190q0 -31 6.5 -59.5t20.5 -56t23 -42t26 -39.5q42 -60 127.5 -138t142 -120.5t71.5 -51.5q21 -14 44 -14q25 0 44 14q10 7 30.5 22t66 51t87 72t86 81.5t71.5 83.5q17 25 26 39.5t23 42t20.5 56t6.5 59.5 | ||
134 | +q0 111 -79 190t-191 79z" /> | ||
127 | <glyph glyph-name="aaa" unicode="" | 135 | <glyph glyph-name="aaa" unicode="" |
128 | d="M505 337l2 -2q2 -1 3.5 -1t3.5 1l430 364q2 2 1 5.5t-5 3.5h-435h-424q-4 0 -5 -3.5t1 -5.5zM72 669q-3 2 -6 0.5t-3 -4.5v-584q0 -4 3.5 -5t5.5 1l288 346zM953 669.5q-3 1.5 -5 -0.5l-288 -246l287 -346q3 -2 6 -1t3 5v584q0 3 -3 4.5zM641 406l-131 -111l-5 5 | 136 | d="M505 337l2 -2q2 -1 3.5 -1t3.5 1l430 364q2 2 1 5.5t-5 3.5h-435h-424q-4 0 -5 -3.5t1 -5.5zM72 669q-3 2 -6 0.5t-3 -4.5v-584q0 -4 3.5 -5t5.5 1l288 346zM953 669.5q-3 1.5 -5 -0.5l-288 -246l287 -346q3 -2 6 -1t3 5v584q0 3 -3 4.5zM641 406l-131 -111l-5 5 |
129 | l-125 103l-275 -328q-2 -3 -1 -6t5 -3h396h407q4 0 5 3t-1 6z" /> | 137 | l-125 103l-275 -328q-2 -3 -1 -6t5 -3h396h407q4 0 5 3t-1 6z" /> |
@@ -222,6 +230,11 @@ t-34 14t-14 34t14 34l192 191l-192 192q-14 14 -14 34t14 34t34 14t34 -14l192 -192l | @@ -222,6 +230,11 @@ t-34 14t-14 34t14 34l192 191l-192 192q-14 14 -14 34t14 34t34 14t34 -14l192 -192l | ||
222 | d="M611 55h-39q-10 0 -10 -9q0 -21 -14.5 -36t-35.5 -15t-35.5 15t-14.5 36q0 9 -10 9h-40q-9 0 -9 -9q0 -45 32.5 -77t76.5 -32t76.5 32t32.5 77q0 9 -10 9v0zM920 105q0 6 -3 11q-6 48 -31.5 89t-65.5 69v170q0 96 -55 175t-145 113q-3 42 -34.5 70.5t-73.5 28.5 | 230 | d="M611 55h-39q-10 0 -10 -9q0 -21 -14.5 -36t-35.5 -15t-35.5 15t-14.5 36q0 9 -10 9h-40q-9 0 -9 -9q0 -45 32.5 -77t76.5 -32t76.5 32t32.5 77q0 9 -10 9v0zM920 105q0 6 -3 11q-6 48 -31.5 89t-65.5 69v170q0 96 -55 175t-145 113q-3 42 -34.5 70.5t-73.5 28.5 |
223 | t-73.5 -28.5t-35.5 -70.5q-89 -34 -144 -113t-55 -175v-170q-40 -28 -65.5 -69t-31.5 -89q-4 -8 -2 -16q-1 -7 -1 -15q0 -9 10 -9h796q10 0 10 9q0 7 -1 15q1 3 1 5v0zM569 686q20 -5 39 -12q69 -29 111 -92.5t42 -137.5v-198q0 -6 5 -9q66 -33 87 -102h-682q21 70 87 102 | 231 | t-73.5 -28.5t-35.5 -70.5q-89 -34 -144 -113t-55 -175v-170q-40 -28 -65.5 -69t-31.5 -89q-4 -8 -2 -16q-1 -7 -1 -15q0 -9 10 -9h796q10 0 10 9q0 7 -1 15q1 3 1 5v0zM569 686q20 -5 39 -12q69 -29 111 -92.5t42 -137.5v-198q0 -6 5 -9q66 -33 87 -102h-682q21 70 87 102 |
224 | q5 3 5 9v198q0 85 54 153.5t137 88.5q8 2 8 9v27q0 21 15 35.5t35 14.5t35 -14.5t15 -35.5v-27q0 -7 7 -9v0zM569 686z" /> | 232 | q5 3 5 9v198q0 85 54 153.5t137 88.5q8 2 8 9v27q0 21 15 35.5t35 14.5t35 -14.5t15 -35.5v-27q0 -7 7 -9v0zM569 686z" /> |
233 | + <glyph glyph-name="jian" unicode="" | ||
234 | +d="M512 832q-91 0 -174 -35.5t-143 -95.5t-95 -143t-35 -174t35 -174t95 -142.5t143 -95t174 -35.5t174 35.5t143 95t95.5 142.5t35.5 174t-35.5 174t-95.5 143t-143 95.5t-174 35.5v0zM753 350h-206v0h-69v0h-207v69h207v0v0h69h206v-69v0zM753 350z" /> | ||
235 | + <glyph glyph-name="jia" unicode="" | ||
236 | +d="M512 832q-91 0 -174 -35.5t-143 -95.5t-95.5 -142.5t-35.5 -173.5t35.5 -173.5t95.5 -142.5t143 -95.5t174 -35.5t174 35.5t143 95.5t95.5 142.5t35.5 173.5t-35.5 173.5t-95.5 142.5t-143 95.5t-174 35.5v0zM753 351h-207v-207h-68v207h-207v68h207v207h68v-207h207v-68 | ||
237 | +v0zM753 351z" /> | ||
225 | <glyph glyph-name="wenhao1" unicode="" | 238 | <glyph glyph-name="wenhao1" unicode="" |
226 | d="M512 886q-102 0 -195 -39.5t-160.5 -107t-107 -160.5t-39.5 -195t39.5 -195t107 -160.5t160.5 -107t195 -39.5t195 39.5t160.5 107t107 160.5t39.5 195t-39.5 195t-107 160.5t-160.5 107t-195 39.5zM521 -15q-34 0 -58.5 24t-24.5 58.5t24.5 58.5t58.5 24t58 -24t24 -58 | 239 | d="M512 886q-102 0 -195 -39.5t-160.5 -107t-107 -160.5t-39.5 -195t39.5 -195t107 -160.5t160.5 -107t195 -39.5t195 39.5t160.5 107t107 160.5t39.5 195t-39.5 195t-107 160.5t-160.5 107t-195 39.5zM521 -15q-34 0 -58.5 24t-24.5 58.5t24.5 58.5t58.5 24t58 -24t24 -58 |
227 | q1 -34 -23.5 -58.5t-58.5 -24.5zM738 477q-17 -34 -67 -83q-45 -43 -60 -61q-12 -16 -17 -35q-6 -22 -6 -61l1 -31h-142v30q0 56 9 90q11 38 30 64q17 23 62 71q43 44 52 60q8 13 8 44q0 28 -20 51q-20 21 -61 21q-29 0 -48.5 -9.5t-28.5 -27.5t-12.5 -36t-3.5 -43v-30h-142 | 240 | q1 -34 -23.5 -58.5t-58.5 -24.5zM738 477q-17 -34 -67 -83q-45 -43 -60 -61q-12 -16 -17 -35q-6 -22 -6 -61l1 -31h-142v30q0 56 9 90q11 38 30 64q17 23 62 71q43 44 52 60q8 13 8 44q0 28 -20 51q-20 21 -61 21q-29 0 -48.5 -9.5t-28.5 -27.5t-12.5 -36t-3.5 -43v-30h-142 |
@@ -231,5 +244,14 @@ d="M562 224h109v-111h-109v111zM889 224h109v-111h-109v111zM562 113h109v-110h-109v | @@ -231,5 +244,14 @@ d="M562 224h109v-111h-109v111zM889 224h109v-111h-109v111zM562 113h109v-110h-109v | ||
231 | h222v-111h-222v111zM889 334h109v-111h-109v111zM780 113h109v-111h-109v111zM562 2h218v-110h-218v110zM889 2h109v-110h-109v110z" /> | 244 | h222v-111h-222v111zM889 334h109v-111h-109v111zM780 113h109v-111h-109v111zM562 2h218v-110h-218v110zM889 2h109v-110h-109v110z" /> |
232 | <glyph glyph-name="subtract" unicode="" | 245 | <glyph glyph-name="subtract" unicode="" |
233 | d="M928 418h-832q-13 0 -22.5 -9.5t-9.5 -23t9.5 -22.5t22.5 -9h832q13 0 22.5 9t9.5 22.5t-9.5 23t-22.5 9.5z" /> | 246 | d="M928 418h-832q-13 0 -22.5 -9.5t-9.5 -23t9.5 -22.5t22.5 -9h832q13 0 22.5 9t9.5 22.5t-9.5 23t-22.5 9.5z" /> |
247 | + <glyph glyph-name="shiliangzhinengduixiang" unicode="" | ||
248 | +d="M875 747q-99 98 -231 133t-263.5 0t-229.5 -133q-98 -99 -133 -231t0 -263.5t133 -229.5q73 -74 167 -112.5t194 -38.5q101 0 195 38t168 111q73 74 111 170t38 193t-38 193t-111 170zM810 86q-60 -61 -139.5 -92.5t-159.5 -31.5t-159.5 31.5t-140.5 92.5 | ||
249 | +q-80 81 -108 189.5t1 217t110 189.5q61 61 138 93t160 32t160 -32t138 -93q81 -81 110 -189.5t0 -217t-110 -189.5zM786 595l-485 -485q67 -52 149.5 -67t164 10t142.5 86q93 93 101 224t-72 232zM723 658q-90 71 -211 71q-69 0 -132.5 -26t-112.5 -76q-61 -62 -86 -143 | ||
250 | +t-10 -163.5t67 -150.5z" /> | ||
251 | + <glyph glyph-name="xingzhuangkaobei" unicode="" | ||
252 | +d="M947 179q31 0 54 -23t23 -53.5t-23 -53.5t-54 -23h-51q31 0 54 -23t23 -54t-23 -54t-54 -23h-563q-31 0 -54 23t-23 54v461q0 20 5 30q8 20 28.5 33t43.5 13q128 96 128 205q0 71 0.5 99.5t5.5 58.5t15.5 38.5t29.5 8.5q21 0 46 -11t50 -33.5t41.5 -64.5t16.5 -96 | ||
253 | +q0 -136 -26 -205h256q31 0 54 -23t23 -53.5t-23 -53.5t-54 -23h51q31 0 54 -23t23 -54t-23 -54t-54 -23zM102.5 -128q-42.5 0 -72.5 30t-30 72v410q0 42 30 72t72.5 30t72.5 -30t30 -72v-410q0 -42 -30 -72t-72.5 -30z" /> | ||
254 | + <glyph glyph-name="juxingkaobei" unicode="" | ||
255 | +d="M186 2l391 382l-391 382l131 130l521 -512l-521 -512z" /> | ||
234 | </font> | 256 | </font> |
235 | </defs></svg> | 257 | </defs></svg> |
No preview for this file type
No preview for this file type
public/img/cart/radio-check.png
0 → 100644
![](/fe/yohobuy-node/raw/4953cb53887387d1dd373b14c819b4dc23bd473e/public/img/cart/radio-check.png)
525 Bytes
@@ -5,14 +5,105 @@ | @@ -5,14 +5,105 @@ | ||
5 | */ | 5 | */ |
6 | 6 | ||
7 | var $ = require('yoho-jquery'); | 7 | var $ = require('yoho-jquery'); |
8 | +var Hbs = require('yoho-handlebars'); | ||
8 | 9 | ||
9 | -var order = {}; | 10 | +var $balanceDetail = $('#balance-detail'), |
11 | + $orderPrice = $('#order-price'); | ||
12 | + | ||
13 | +var order = { | ||
14 | + printPrice: 'Y' | ||
15 | + }, | ||
16 | + iconCode = { | ||
17 | + on: '', | ||
18 | + off: '' | ||
19 | + }; | ||
10 | 20 | ||
11 | var payWay, | 21 | var payWay, |
12 | - deliveryWay; | 22 | + deliveryWay, |
23 | + coupon, | ||
24 | + yohoCoin; | ||
25 | +var address = require('./order-new/address'), | ||
26 | + invoice = require('./order-new/invoice'); | ||
27 | + | ||
28 | +var coinTpl = Hbs.compile($('#yoho-coin-tpl').html()); | ||
29 | +var promotionTpl = Hbs.compile($('#promotion-list-tpl').html()); | ||
30 | + | ||
31 | +require('../common'); | ||
32 | + | ||
33 | +order.cartType = window.queryString().type || 1; | ||
34 | + | ||
35 | +// FE Helper | ||
36 | +Hbs.registerHelper('round', function(num, precision) { | ||
37 | + precision = parseFloat('0' + precision, 10) || 2; | ||
38 | + | ||
39 | + return (+num).toFixed(precision); | ||
40 | +}); | ||
41 | + | ||
42 | +// 订单计算 | ||
43 | +// 传有货币数量则使用有货币,否者不使用,更改订单总价有货币使用数量重置为0 | ||
44 | +function compute(coin) { | ||
45 | + var reqData = { | ||
46 | + cartType: order.cartType, | ||
47 | + coin: coin ? coin : 0 | ||
48 | + }; | ||
13 | 49 | ||
14 | -require('./order-new/address'); | ||
15 | -require('./order-new/invoice'); | 50 | + order.coin = reqData.coin; |
51 | + | ||
52 | + // 支付方式 | ||
53 | + if (order.paymentType) { | ||
54 | + reqData.paymentType = order.paymentType; | ||
55 | + } | ||
56 | + | ||
57 | + // 配送方式 | ||
58 | + if (order.deliveryWay) { | ||
59 | + reqData.deliveryWay = order.deliveryWay; | ||
60 | + } | ||
61 | + | ||
62 | + // 优惠券 | ||
63 | + if (order.couponCode) { | ||
64 | + reqData.couponCode = order.couponCode; | ||
65 | + } | ||
66 | + | ||
67 | + // 红包 | ||
68 | + if (order.redEnvelopes) { | ||
69 | + reqData.redEnvelopes = order.redEnvelopes; | ||
70 | + } | ||
71 | + | ||
72 | + $.ajax({ | ||
73 | + type: 'POST', | ||
74 | + url: '/cart/ensure/compute', | ||
75 | + data: reqData | ||
76 | + }).then(function(data) { | ||
77 | + var res; | ||
78 | + | ||
79 | + if (data.code === 200) { | ||
80 | + res = data.data; | ||
81 | + | ||
82 | + // update yoho coin max use num | ||
83 | + yohoCoin.maxCoin = res.canUseCoinNum; | ||
84 | + | ||
85 | + // update yoho coin using | ||
86 | + yohoCoin.$el.html(coinTpl(res)); | ||
87 | + if (!reqData.coin) { | ||
88 | + yohoCoin.$el.removeClass('used'); | ||
89 | + } | ||
90 | + | ||
91 | + // update last order amount | ||
92 | + $orderPrice.html('¥ ' + res.last_order_amount); | ||
93 | + | ||
94 | + // update promotion formula list | ||
95 | + $balanceDetail.html(promotionTpl(res)); | ||
96 | + } else if (data.code === 317) { | ||
97 | + if (coupon.$errorTip) { | ||
98 | + coupon.$errorTip.text(data.message); | ||
99 | + | ||
100 | + if (order.couponCode) { | ||
101 | + delete order.couponCode; | ||
102 | + } | ||
103 | + } | ||
104 | + } | ||
105 | + }); | ||
106 | +} | ||
16 | 107 | ||
17 | // 支付方式 | 108 | // 支付方式 |
18 | payWay = { | 109 | payWay = { |
@@ -53,6 +144,9 @@ payWay = { | @@ -53,6 +144,9 @@ payWay = { | ||
53 | 144 | ||
54 | // 更新订单支付数据 | 145 | // 更新订单支付数据 |
55 | that.updateOrder($this.data()); | 146 | that.updateOrder($this.data()); |
147 | + | ||
148 | + // 重新计算订单价格 | ||
149 | + compute(); | ||
56 | }); | 150 | }); |
57 | }, | 151 | }, |
58 | updateOrder: function(info) { | 152 | updateOrder: function(info) { |
@@ -116,6 +210,9 @@ deliveryWay = { | @@ -116,6 +210,9 @@ deliveryWay = { | ||
116 | 210 | ||
117 | // 更新订单配送方式数据 | 211 | // 更新订单配送方式数据 |
118 | that.updateOrder({way: $this.data('id')}); | 212 | that.updateOrder({way: $this.data('id')}); |
213 | + | ||
214 | + // 重新计算订单价格 | ||
215 | + compute(); | ||
119 | }); | 216 | }); |
120 | 217 | ||
121 | this.$deliveryTime.click(function() { | 218 | this.$deliveryTime.click(function() { |
@@ -146,5 +243,239 @@ deliveryWay = { | @@ -146,5 +243,239 @@ deliveryWay = { | ||
146 | } | 243 | } |
147 | }; | 244 | }; |
148 | 245 | ||
246 | +coupon = { | ||
247 | + $el: $('#use-coupons'), | ||
248 | + init: function() { | ||
249 | + if (!this.$el.length) { | ||
250 | + return; | ||
251 | + } | ||
252 | + | ||
253 | + this.$couponWrap = this.$el.next(); | ||
254 | + | ||
255 | + this.$errorTip = $('.coupon-err-tip', this.$el); | ||
256 | + this.$ticketUseTip = $('.ticket-use-tip', this.$couponWrap); | ||
257 | + | ||
258 | + this.$couponCode = $('.coupon-code', this.$couponWrap); | ||
259 | + this.$couponList = $('.coupon-list-wrap', this.$couponWrap); | ||
260 | + | ||
261 | + this.couponsTpl = Hbs.compile($('#coupons-tpl').html()); | ||
262 | + | ||
263 | + this.getList(); | ||
264 | + this.eventBind(); | ||
265 | + }, | ||
266 | + getList: function() { | ||
267 | + var that = this; | ||
268 | + | ||
269 | + $.ajax({ | ||
270 | + type: 'GET', | ||
271 | + url: '/cart/ensure/coupons' | ||
272 | + }).then(function(data) { | ||
273 | + if (data.code === 200) { | ||
274 | + $('.coupon-list-wrap', that.$couponWrap).html(that.couponsTpl(data.data)); | ||
275 | + that.$radios = that.$couponWrap.find('.coupon-radio'); | ||
276 | + } | ||
277 | + }); | ||
278 | + }, | ||
279 | + eventBind: function() { | ||
280 | + var that = this; | ||
281 | + | ||
282 | + this.$couponWrap.on('click', '.radio-btn', function() { | ||
283 | + var $this = $(this); | ||
284 | + | ||
285 | + if ($this.hasClass('on')) { | ||
286 | + return; | ||
287 | + } | ||
288 | + $this.siblings('.radio-btn.on').removeClass('on'); | ||
289 | + $this.addClass('on').parent().toggleClass('using-code'); | ||
290 | + | ||
291 | + if ($this.hasClass('code')) { | ||
292 | + that.cancelTicketUse(); | ||
293 | + that.$couponList.slideUp(); | ||
294 | + } else { | ||
295 | + that.cancelCodeUse(); | ||
296 | + that.$couponList.slideDown(); | ||
297 | + } | ||
298 | + }).on('click', '.cancel-use-ticket', function() { | ||
299 | + that.cancelTicketUse(); | ||
300 | + }).on('change', '.coupon-code', function() { | ||
301 | + that.$errorTip.empty(); | ||
302 | + }).on('click', '.opt-area > label', function() { | ||
303 | + var $this = $(this); | ||
304 | + var couponId, data; | ||
305 | + | ||
306 | + if ($this.hasClass('sure-use-ticket')) { | ||
307 | + data = that.$radios.filter('.on').data(); | ||
308 | + | ||
309 | + if (data) { | ||
310 | + that.$ticketUseTip.find('.price').text('- ¥' + data.price); | ||
311 | + that.$ticketUseTip.removeClass('hide'); | ||
312 | + couponId = data.id; | ||
313 | + } | ||
314 | + } else { | ||
315 | + couponId = $this.siblings('.coupon-code').val(); | ||
316 | + } | ||
317 | + | ||
318 | + if (couponId) { | ||
319 | + order.couponCode = couponId; | ||
320 | + | ||
321 | + // 重新计算订单价格 | ||
322 | + compute(); | ||
323 | + } | ||
324 | + }).on('click', '.coupon-radio', function() { | ||
325 | + var $this = $(this); | ||
326 | + | ||
327 | + if ($this.hasClass('on')) { | ||
328 | + return; | ||
329 | + } | ||
330 | + | ||
331 | + if (that.$radios) { | ||
332 | + that.$radios.filter('.on').removeClass('on'); | ||
333 | + } | ||
334 | + $this.addClass('on'); | ||
335 | + }); | ||
336 | + }, | ||
337 | + cancelTicketUse: function() { | ||
338 | + if (order.couponCode) { | ||
339 | + this.$ticketUseTip.addClass('hide'); | ||
340 | + this.$radios.filter('.on').removeClass('on'); | ||
341 | + | ||
342 | + delete order.couponCode; | ||
343 | + compute(); // 重新计算订单价格 | ||
344 | + } | ||
345 | + }, | ||
346 | + cancelCodeUse: function() { | ||
347 | + this.$errorTip.empty(); | ||
348 | + this.$couponCode.val(''); | ||
349 | + | ||
350 | + if (order.couponCode) { | ||
351 | + delete order.couponCode; | ||
352 | + compute(); // 重新计算订单价格 | ||
353 | + } | ||
354 | + } | ||
355 | +}; | ||
356 | + | ||
357 | +yohoCoin = { | ||
358 | + $el: $('#yoho-coin-box'), | ||
359 | + init: function() { | ||
360 | + var data; | ||
361 | + | ||
362 | + if (!this.$el.length) { | ||
363 | + return; | ||
364 | + } | ||
365 | + | ||
366 | + data = this.$el.data(); | ||
367 | + | ||
368 | + if (data) { | ||
369 | + order.coin = data.coin || 0; | ||
370 | + this.maxCoin = data.max; | ||
371 | + } | ||
372 | + | ||
373 | + this.eventBind(); | ||
374 | + }, | ||
375 | + eventBind: function() { | ||
376 | + var that = this; | ||
377 | + | ||
378 | + this.$el.on('click', '.coin-use-btn', function() { | ||
379 | + if (order.coin * 1 === this.maxCoin * 1) { | ||
380 | + return; | ||
381 | + } | ||
382 | + | ||
383 | + compute(that.maxCoin); | ||
384 | + }).on('click', '.coin-cancel-btn', function() { | ||
385 | + if (order.coin * 1 === 0) { | ||
386 | + return; | ||
387 | + } | ||
388 | + | ||
389 | + compute(); | ||
390 | + }); | ||
391 | + } | ||
392 | +}; | ||
393 | + | ||
394 | +$('.locker-switch').click(function() { | ||
395 | + var $this = $(this), | ||
396 | + $par = $this.parent(); | ||
397 | + | ||
398 | + $par.toggleClass('open'); | ||
399 | + | ||
400 | + if ($par.hasClass('open')) { | ||
401 | + $this.html(iconCode.on); | ||
402 | + } else { | ||
403 | + $this.html(iconCode.off); | ||
404 | + } | ||
405 | +}); | ||
406 | + | ||
407 | +$('#red-packet-box').on('click', '.radio-btn', function() { | ||
408 | + $(this).toggleClass('on'); | ||
409 | +}).on('click', '.sure-btn', function() { | ||
410 | + var $this = $(this), | ||
411 | + num = $this.data('num'); | ||
412 | + | ||
413 | + if (!num) { | ||
414 | + return; | ||
415 | + } | ||
416 | + | ||
417 | + if ($this.siblings('.on').length) { | ||
418 | + order.redEnvelopes = num; | ||
419 | + } else if (order.redEnvelopes) { | ||
420 | + delete order.redEnvelopes; | ||
421 | + } | ||
422 | + compute(); // 重新计算订单价格 | ||
423 | +}); | ||
424 | + | ||
425 | +$('#remark-box').on('keyup', '.note-text', function() { | ||
426 | + var $this = $(this); | ||
427 | + var val = $.trim($this.val()); | ||
428 | + | ||
429 | + if (val) { | ||
430 | + $this.addClass('has-text'); | ||
431 | + | ||
432 | + if (val.length > 100) { | ||
433 | + val = val.substring(0, 99); | ||
434 | + $this.val(val); | ||
435 | + } | ||
436 | + | ||
437 | + order.remark = val; | ||
438 | + } else { | ||
439 | + $this.removeClass('has-text'); | ||
440 | + } | ||
441 | +}).on('click', '.radio-btn', function() { | ||
442 | + var $this = $(this); | ||
443 | + | ||
444 | + if ($this.hasClass('on')) { | ||
445 | + return; | ||
446 | + } | ||
447 | + | ||
448 | + if ($this.hasClass('unprint')) { | ||
449 | + order.printPrice = 'N'; | ||
450 | + } else { | ||
451 | + order.printPrice = 'Y'; | ||
452 | + } | ||
453 | + | ||
454 | + $this.siblings('.on').removeClass('on'); | ||
455 | + $this.addClass('on'); | ||
456 | +}); | ||
457 | + | ||
458 | +$('#order-submit').click(function() { | ||
459 | + var invoiceInfo = invoice.getInvoice(); | ||
460 | + | ||
461 | + order.addressId = address.getAddress(); | ||
462 | + | ||
463 | + // 发票信息 | ||
464 | + if (invoiceInfo) { | ||
465 | + $.extend(order, invoiceInfo); | ||
466 | + } | ||
467 | + $.ajax({ | ||
468 | + type: 'POST', | ||
469 | + url: '/cart/ensure/submit', | ||
470 | + data: order | ||
471 | + }).then(function(data) { | ||
472 | + if (data.code === 200) { | ||
473 | + location.href = data.data.url; | ||
474 | + } | ||
475 | + }); | ||
476 | +}); | ||
477 | + | ||
149 | payWay.init(); | 478 | payWay.init(); |
150 | deliveryWay.init(); | 479 | deliveryWay.init(); |
480 | +coupon.init(); | ||
481 | +yohoCoin.init(); |
@@ -22,6 +22,8 @@ var addressTpl = hbs.compile($('#address-tpl').html()), | @@ -22,6 +22,8 @@ var addressTpl = hbs.compile($('#address-tpl').html()), | ||
22 | var addrList = {}, | 22 | var addrList = {}, |
23 | addrDefault = ''; | 23 | addrDefault = ''; |
24 | 24 | ||
25 | +var addrSelect; | ||
26 | + | ||
25 | $('.addr-item').each(function() { | 27 | $('.addr-item').each(function() { |
26 | var data = $(this).data(); | 28 | var data = $(this).data(); |
27 | 29 | ||
@@ -168,6 +170,7 @@ function setShowDeliveryAddr(data) { | @@ -168,6 +170,7 @@ function setShowDeliveryAddr(data) { | ||
168 | } | 170 | } |
169 | 171 | ||
170 | if (data) { | 172 | if (data) { |
173 | + addrSelect = data.id; | ||
171 | _h = '寄送至:' + data.area + ' ' + data.address + | 174 | _h = '寄送至:' + data.area + ' ' + data.address + |
172 | '<br>收货人:' + data.consignee + ' ' + data.mobile; | 175 | '<br>收货人:' + data.consignee + ' ' + data.mobile; |
173 | } | 176 | } |
@@ -377,3 +380,8 @@ $('.addr-opt').on('click', 'span', function() { | @@ -377,3 +380,8 @@ $('.addr-opt').on('click', 'span', function() { | ||
377 | }); | 380 | }); |
378 | 381 | ||
379 | setShowDeliveryAddr(); | 382 | setShowDeliveryAddr(); |
383 | + | ||
384 | +// 获取地址信息 | ||
385 | +exports.getAddress = function() { | ||
386 | + return addrSelect; | ||
387 | +}; |
@@ -483,11 +483,351 @@ | @@ -483,11 +483,351 @@ | ||
483 | border: 1px solid $borderColor; | 483 | border: 1px solid $borderColor; |
484 | border-bottom-color: #fff; | 484 | border-bottom-color: #fff; |
485 | 485 | ||
486 | + | ||
486 | dt { | 487 | dt { |
488 | + line-height: 40px; | ||
489 | + | ||
490 | + > .iconfont { | ||
491 | + font-size: 18px; | ||
492 | + margin-right: 10px; | ||
493 | + vertical-align: top; | ||
494 | + cursor: pointer; | ||
495 | + } | ||
496 | + } | ||
497 | + | ||
498 | + dd { | ||
499 | + display: none; | ||
500 | + } | ||
501 | + | ||
502 | + .open + dd { | ||
503 | + display: block; | ||
504 | + } | ||
505 | + } | ||
506 | + | ||
507 | + .use-coupons { | ||
508 | + .tip-box { | ||
509 | + width: 60%; | ||
510 | + color: $red; | ||
511 | + position: relative; | ||
512 | + text-align: right; | ||
513 | + display: none; | ||
514 | + } | ||
515 | + | ||
516 | + .coupon-err-tip { | ||
517 | + width: 100%; | ||
518 | + background-color: #fff; | ||
519 | + position: absolute; | ||
520 | + top: 0; | ||
521 | + } | ||
522 | + | ||
523 | + &.open > .tip-box { | ||
524 | + display: block; | ||
525 | + } | ||
526 | + | ||
527 | + } | ||
528 | + | ||
529 | + .coupon-opt-title { | ||
530 | + height: 50px; | ||
531 | + line-height: 50px; | ||
532 | + padding: 0 30px; | ||
533 | + background-color: #f0f0f0; | ||
534 | + | ||
535 | + .ticket-use-tip { | ||
536 | + margin-left: 20px; | ||
537 | + | ||
538 | + .red { | ||
539 | + color: $red; | ||
540 | + } | ||
541 | + | ||
542 | + .cancel-use-ticket { | ||
543 | + color: #1987cf; | ||
544 | + margin-left: 20px; | ||
545 | + cursor: pointer; | ||
546 | + } | ||
547 | + } | ||
548 | + | ||
549 | + .opt-area { | ||
550 | + line-height: 1; | ||
551 | + margin-top: 13px; | ||
552 | + border: 1px solid #000; | ||
553 | + background-color: #fff; | ||
554 | + | ||
555 | + > input { | ||
556 | + width: 174px; | ||
557 | + line-height: 24px; | ||
558 | + border: none; | ||
559 | + padding: 0 10px; | ||
560 | + font-size: 14px; | ||
561 | + display: none; | ||
562 | + } | ||
563 | + | ||
564 | + > label { | ||
565 | + color: #fff; | ||
566 | + background-color: #000; | ||
567 | + width: 78px; | ||
568 | + height: 24px; | ||
569 | + line-height: 24px; | ||
570 | + text-align: center; | ||
571 | + cursor: pointer; | ||
572 | + display: none; | ||
573 | + } | ||
574 | + | ||
575 | + .sure-use-code { | ||
576 | + float: right; | ||
577 | + } | ||
578 | + | ||
579 | + .sure-use-ticket { | ||
580 | + display: inline-block; | ||
581 | + } | ||
582 | + } | ||
583 | + | ||
584 | + &.using-code .opt-area { | ||
585 | + > * { | ||
586 | + display: inline-block; | ||
587 | + } | ||
588 | + | ||
589 | + .sure-use-ticket { | ||
590 | + display: none; | ||
591 | + } | ||
592 | + } | ||
593 | + } | ||
594 | + | ||
595 | + .coupon-list-wrap { | ||
596 | + padding: 0 30px; | ||
597 | + border: 1px solid #e8e8e8; | ||
598 | + line-height: 18px; | ||
599 | + | ||
600 | + .empty-tip { | ||
601 | + line-height: 24px; | ||
602 | + padding-top: 10px; | ||
603 | + } | ||
604 | + | ||
605 | + li { | ||
606 | + padding: 6px 0; | ||
607 | + } | ||
608 | + | ||
609 | + .unusable-list { | ||
610 | + color: #999; | ||
611 | + border-top: 1px solid #e8e8e8; | ||
612 | + margin: 10px 0; | ||
613 | + } | ||
614 | + | ||
615 | + .useable-title, | ||
616 | + .unuseable-title { | ||
617 | + color: #444; | ||
487 | line-height: 30px; | 618 | line-height: 30px; |
619 | + margin-top: 6px; | ||
620 | + } | ||
621 | + | ||
622 | + .title { | ||
623 | + width: 340px; | ||
624 | + display: inline-block; | ||
625 | + } | ||
626 | + | ||
627 | + .time { | ||
628 | + width: 340px; | ||
629 | + display: inline-block; | ||
630 | + } | ||
631 | + | ||
632 | + .money { | ||
633 | + width: 170px; | ||
634 | + display: inline-block; | ||
635 | + } | ||
636 | + | ||
637 | + .coupon-radio { | ||
638 | + display: inline-block; | ||
639 | + width: 15px; | ||
640 | + height: 15px; | ||
641 | + margin-right: 6px; | ||
642 | + background-image: url(/cart/radio-off.png); | ||
643 | + display: inline-block; | ||
644 | + vertical-align: middle; | ||
645 | + position: relative; | ||
646 | + top: -1px; | ||
647 | + cursor: pointer; | ||
648 | + | ||
649 | + &.on { | ||
650 | + background-image: url(/cart/radio-check.png); | ||
651 | + } | ||
652 | + } | ||
653 | + } | ||
654 | + | ||
655 | + .yoho-coin-box { | ||
656 | + line-height: 24px; | ||
657 | + padding: 10px 30px; | ||
658 | + background-color: #f0f0f0; | ||
659 | + position: relative; | ||
660 | + | ||
661 | + .grey { | ||
662 | + color: #a9a9a9; | ||
663 | + } | ||
664 | + | ||
665 | + .red { | ||
666 | + color: $red; | ||
667 | + } | ||
668 | + | ||
669 | + .outer-view { | ||
670 | + width: 70%; | ||
671 | + position: absolute; | ||
672 | + right: 0; | ||
673 | + top: -32px; | ||
674 | + padding-right: 20px; | ||
675 | + text-align: right; | ||
676 | + | ||
677 | + .help-icon { | ||
678 | + position: absolute; | ||
679 | + right: 0; | ||
680 | + top: 0; | ||
681 | + cursor: pointer; | ||
682 | + | ||
683 | + | ||
684 | + &:hover + .coin-tip-help { | ||
685 | + display: block; | ||
686 | + } | ||
687 | + | ||
688 | + } | ||
689 | + | ||
690 | + } | ||
691 | + | ||
692 | + .help-icon { | ||
693 | + position: absolute; | ||
694 | + right: 0; | ||
695 | + top: 0; | ||
696 | + cursor: pointer; | ||
697 | + | ||
698 | + &:hover + .coin-tip-help { | ||
699 | + display: block; | ||
700 | + } | ||
701 | + } | ||
702 | + | ||
703 | + .coin-tip-help { | ||
704 | + width: 304px; | ||
705 | + padding: 6px 10px; | ||
706 | + line-height: 2; | ||
707 | + border: 1px solid #000; | ||
708 | + background-color: #fff; | ||
709 | + text-align: left; | ||
710 | + position: absolute; | ||
711 | + top: 28px; | ||
712 | + right: -8px; | ||
713 | + display: none; | ||
714 | + | ||
715 | + &:before { | ||
716 | + content: ''; | ||
717 | + width: 12px; | ||
718 | + height: 6px; | ||
719 | + background-image: url('/cart/row.png'); | ||
720 | + display: block; | ||
721 | + position: absolute; | ||
722 | + top: -6px; | ||
723 | + right: 10px; | ||
724 | + } | ||
725 | + | ||
726 | + > p:first-child { | ||
727 | + font-weight: 700; | ||
728 | + } | ||
729 | + | ||
730 | + .rs-text { | ||
731 | + color: #999; | ||
732 | + } | ||
733 | + } | ||
734 | + | ||
735 | + .coin-main-view { | ||
736 | + > * { | ||
737 | + display: inline-block; | ||
738 | + } | ||
739 | + | ||
740 | + > label { | ||
741 | + width: 76px; | ||
742 | + height: 22px; | ||
743 | + line-height: 22px; | ||
744 | + display: inline-block; | ||
745 | + border: 1px solid #000; | ||
746 | + background-color: #fff; | ||
747 | + text-align: center; | ||
748 | + cursor: pointer; | ||
749 | + float: right; | ||
750 | + } | ||
751 | + | ||
752 | + p:first-child { | ||
753 | + margin-right: 40px; | ||
754 | + } | ||
755 | + | ||
756 | + .coin-cancel-btn { | ||
757 | + color: #fff; | ||
758 | + background-color: #000; | ||
759 | + margin-left: 18px; | ||
760 | + | ||
761 | + > span { | ||
762 | + display: none; | ||
763 | + } | ||
764 | + } | ||
765 | + } | ||
766 | + } | ||
767 | + | ||
768 | + .red-packet-box { | ||
769 | + padding: 10px 10px; | ||
770 | + background-color: #f0f0f0; | ||
771 | + line-height: 24px; | ||
772 | + | ||
773 | + .radio-btn { | ||
774 | + margin-right: 0; | ||
775 | + } | ||
776 | + | ||
777 | + .sure-btn { | ||
778 | + width: 78px; | ||
779 | + float: right; | ||
780 | + background-color: #000; | ||
781 | + color: #fff; | ||
782 | + text-align: center; | ||
783 | + margin-right: 20px; | ||
784 | + cursor: pointer; | ||
488 | } | 785 | } |
489 | } | 786 | } |
490 | 787 | ||
788 | + .remark-box { | ||
789 | + padding: 30px 20px 0; | ||
790 | + background-color: #f0f0f0; | ||
791 | + | ||
792 | + .note-text-box { | ||
793 | + border: 1px solid #e0e0e0; | ||
794 | + background-color: #fff; | ||
795 | + overflow: hidden; | ||
796 | + | ||
797 | + .tip-text { | ||
798 | + padding: 10px; | ||
799 | + color: #a9a9a9; | ||
800 | + } | ||
801 | + } | ||
802 | + | ||
803 | + .note-text { | ||
804 | + width: 888px; | ||
805 | + height: 84px; | ||
806 | + padding: 8px 10px; | ||
807 | + font-size: 14px; | ||
808 | + line-height: 1.5; | ||
809 | + border: none; | ||
810 | + resize: none; | ||
811 | + background: none; | ||
812 | + margin-top: -34px; | ||
813 | + } | ||
814 | + | ||
815 | + .has-text { | ||
816 | + background-color: #fff; | ||
817 | + } | ||
818 | + | ||
819 | + .pp-area { | ||
820 | + line-height: 50px; | ||
821 | + padding-bottom: 4px; | ||
822 | + | ||
823 | + > span { | ||
824 | + color: #a9a9a9; | ||
825 | + } | ||
826 | + } | ||
827 | + | ||
828 | + } | ||
829 | + | ||
830 | + | ||
491 | .balance-wrap { | 831 | .balance-wrap { |
492 | font-size: 13px; | 832 | font-size: 13px; |
493 | line-height: 2; | 833 | line-height: 2; |
@@ -645,17 +985,6 @@ | @@ -645,17 +985,6 @@ | ||
645 | position: absolute; | 985 | position: absolute; |
646 | padding-left: 94px; | 986 | padding-left: 94px; |
647 | line-height: 1.5; | 987 | line-height: 1.5; |
648 | - | ||
649 | -/* &:before { | ||
650 | - content: ''; | ||
651 | - width: 16px; | ||
652 | - height: 16px; | ||
653 | - margin-right: 6px; | ||
654 | - background: url('/cart/error-ico.png'); | ||
655 | - display: inline-block; | ||
656 | - position: relative; | ||
657 | - top: 4px; | ||
658 | - }*/ | ||
659 | } | 988 | } |
660 | 989 | ||
661 | .area-box { | 990 | .area-box { |
-
Please register or login to post a comment