Authored by 郝肖肖

merage feature balancePage

@@ -65,6 +65,8 @@ const getAddressList = (req, res, next) => { @@ -65,6 +65,8 @@ const getAddressList = (req, res, next) => {
65 _.each(result.data, (d) => { 65 _.each(result.data, (d) => {
66 d.address_id = crypto.encryption(config.crypto.common, d.address_id + ''); 66 d.address_id = crypto.encryption(config.crypto.common, d.address_id + '');
67 d.address = cleanHtml.htmlDecode(d.address); 67 d.address = cleanHtml.htmlDecode(d.address);
  68 + d.complete_mobile = d.mobile;
  69 + d.mobile = d.mobile.substr(0, 3) + '****' + d.mobile.substr(7);
68 }); 70 });
69 71
70 defaultAd && (defaultAd.focus = true); 72 defaultAd && (defaultAd.focus = true);
@@ -17,7 +17,7 @@ const api = global.yoho.API; @@ -17,7 +17,7 @@ const api = global.yoho.API;
17 */ 17 */
18 const getAddressDataAsync = (uid, limit) => { 18 const getAddressDataAsync = (uid, limit) => {
19 return api.get('', { 19 return api.get('', {
20 - method: 'app.address.gethidden', 20 + method: 'app.address.get',
21 uid: uid, 21 uid: uid,
22 limit: limit 22 limit: limit
23 }).then(result => { 23 }).then(result => {
@@ -68,8 +68,8 @@ const btnMap = { @@ -68,8 +68,8 @@ const btnMap = {
68 }; 68 };
69 69
70 const invoiceText = { 70 const invoiceText = {
71 - 1: '纸质',  
72 - 2: '电子' 71 + 1: '纸质发票',
  72 + 2: '电子发票'
73 }; 73 };
74 74
75 75
@@ -525,7 +525,7 @@ const getOrderDetail = (uid, code) => { @@ -525,7 +525,7 @@ const getOrderDetail = (uid, code) => {
525 _.forEach(detail.btns, btn => { 525 _.forEach(detail.btns, btn => {
526 if (btn.isPayBtn) { 526 if (btn.isPayBtn) {
527 btn.payUrl = helpers.urlFormat('/shopping/pay/online', { 527 btn.payUrl = helpers.urlFormat('/shopping/pay/online', {
528 - code: detail.orderCode 528 + code: detail.order_code
529 }); 529 });
530 } 530 }
531 }); 531 });
@@ -548,6 +548,7 @@ const getOrderDetail = (uid, code) => { @@ -548,6 +548,7 @@ const getOrderDetail = (uid, code) => {
548 548
549 if (detail.invoice) { 549 if (detail.invoice) {
550 detail.invoice.typeText = invoiceText[detail.invoice.type]; 550 detail.invoice.typeText = invoiceText[detail.invoice.type];
  551 + detail.invoice.pdfUrl = detail.invoice.showInvoice && detail.invoice.pdfUrl ? detail.invoice.pdfUrl : '';
551 } else { 552 } else {
552 detail.invoice = false; 553 detail.invoice = false;
553 } 554 }
@@ -19,7 +19,12 @@ @@ -19,7 +19,12 @@
19 <h4 class="status-title">发票信息</h4> 19 <h4 class="status-title">发票信息</h4>
20 {{# invoice}} 20 {{# invoice}}
21 {{#if typeText}} 21 {{#if typeText}}
22 - <p class="text">发票类型:{{typeText}}</p> 22 + <p class="text">
  23 + 发票类型:{{typeText}}
  24 + {{#if pdfUrl}}
  25 + <a class="btn white invoice-down" href="{{pdfUrl}}">电子发票下载</a>
  26 + {{/if}}
  27 + </p>
23 {{/if}} 28 {{/if}}
24 {{#if title}} 29 {{#if title}}
25 <p class="text">发票抬头:{{title}}</p> 30 <p class="text">发票抬头:{{title}}</p>
@@ -83,7 +83,7 @@ const index = (req, res, next) => { @@ -83,7 +83,7 @@ const index = (req, res, next) => {
83 83
84 // 订单金额计算 84 // 订单金额计算
85 const compute = (req, res, next) => { 85 const compute = (req, res, next) => {
86 - orderModel.compute(req.user.uid, req.query.coin).then(result => { 86 + orderModel.compute(req.user.uid, req.body.coin).then(result => {
87 res.send(result); 87 res.send(result);
88 }).catch(next); 88 }).catch(next);
89 }; 89 };
@@ -23,6 +23,29 @@ const _orderApi = uid => api.get('', { @@ -23,6 +23,29 @@ const _orderApi = uid => api.get('', {
23 }); 23 });
24 24
25 /** 25 /**
  26 + * 计算有货币可用数量
  27 + * @param uid [int] user id
  28 + */
  29 +const _yohoCoinPayRule = data => {
  30 +
  31 + if (!data.total_yoho_coin_num) {
  32 + return data;
  33 + }
  34 +
  35 + data.yoho_coin_num = _.round(data.yoho_coin * 100);
  36 + data.yoho_coin = data.yoho_coin.toFixed(2);
  37 + data.yoho_msg = '';
  38 +
  39 + if (data.total_yoho_coin_num < 100) {
  40 + data.yoho_msg = `抱歉,您的有货币不足,有货币满${data.yoho_coin_pay_rule.num_limit}个方可使用`;
  41 + } else if (data.yoho_coin_num <= 0) {
  42 + data.yoho_msg = '抱歉,您的订单实付款不满足有货币使用条件';
  43 + }
  44 +
  45 + return data;
  46 +};
  47 +
  48 +/**
26 * 结算页面 49 * 结算页面
27 * @param uid [int] user id 50 * @param uid [int] user id
28 */ 51 */
@@ -54,7 +77,8 @@ const index = uid => { @@ -54,7 +77,8 @@ const index = uid => {
54 } 77 }
55 }); 78 });
56 79
57 - theData.yoho_coin = _.round(theData.yoho_coin * 100); // 有货币稀释(round浮点精度问题) 80 + // 计算有货币使用
  81 + Object.assign(theData, _yohoCoinPayRule(theData));
58 82
59 shopping.balanceCoin = theData.use_yoho_coin; 83 shopping.balanceCoin = theData.use_yoho_coin;
60 84
@@ -115,7 +139,14 @@ const compute = (uid, yohoCoin) => { @@ -115,7 +139,14 @@ const compute = (uid, yohoCoin) => {
115 coin = yohoCoin / 100; 139 coin = yohoCoin / 100;
116 } 140 }
117 141
118 - return _computeApi(uid, deliveryWay, paymentType, coin).then(result => result); 142 + return _computeApi(uid, deliveryWay, paymentType, coin).then(result => {
  143 +
  144 + if (result.code === 200) {
  145 + Object.assign(result.data, _yohoCoinPayRule(result.data));
  146 + }
  147 +
  148 + return result;
  149 + });
119 }; 150 };
120 151
121 /** 152 /**
@@ -146,10 +177,17 @@ const _submit = (uid, other) => { @@ -146,10 +177,17 @@ const _submit = (uid, other) => {
146 payment_type: other.payment_type 177 payment_type: other.payment_type
147 }; 178 };
148 179
  180 + if (other.invoices_type && parseInt(other.invoices_type, 10) === 2) {
  181 + Object.assign(apiParms, {
  182 + receiverMobile: other.invoices_mobile
  183 + });
  184 + }
  185 +
149 if (other.invoices_title) { 186 if (other.invoices_title) {
150 Object.assign(apiParms, { 187 Object.assign(apiParms, {
  188 + invoices_type: other.invoices_type,
151 invoices_title: other.invoices_title, 189 invoices_title: other.invoices_title,
152 - invoices_type_id: other.invoices_type_id 190 + invoice_content: other.invoice_content
153 }); 191 });
154 } 192 }
155 193
@@ -27,7 +27,7 @@ router.get('/cart/data', cartCtrl.getCartData); @@ -27,7 +27,7 @@ router.get('/cart/data', cartCtrl.getCartData);
27 27
28 // 结算 28 // 结算
29 router.get('/order', auth, order.index); 29 router.get('/order', auth, order.index);
30 -router.get('/order/compute', auth, order.compute); 30 +router.post('/order/compute', auth, order.compute);
31 router.post('/order/submit', auth, order.orderSub); 31 router.post('/order/submit', auth, order.orderSub);
32 32
33 // 支付 33 // 支付
@@ -135,21 +135,7 @@ @@ -135,21 +135,7 @@
135 <span class="coin-ctrl">使用有货币</span> 135 <span class="coin-ctrl">使用有货币</span>
136 </p> 136 </p>
137 <div class="content hide"> 137 <div class="content hide">
138 - <div class="using-coin">  
139 - 本次使用有货币  
140 - <input id="input-coin" class="input coin-input" type="text" data-max="{{yoho_coin}}">  
141 -  
142 - 您当前共有有货币<em class="blue">{{yoho_coin}}</em>  
143 -  
144 - <span id="coin-tip" class="coin-tip block blue vhide">抵扣¥<em class="balance-coin"></em></span>  
145 - <span id="coin-sure" class="btn disable">确定</span>  
146 - </div>  
147 - <div class="used-coin hide">  
148 - 本次使用有货币<em id="coin-used" class="blue"></em>个,本次抵扣<span class="blue">¥<em id="coin-deduction"></em></span>  
149 -  
150 - <span class="btn white modify">修改</span>  
151 - <span class="btn white cancel">取消使用</span>  
152 - </div> 138 + {{> order/yoho-coin}}
153 </div> 139 </div>
154 </div> 140 </div>
155 <div class="remark"> 141 <div class="remark">
@@ -215,10 +201,20 @@ @@ -215,10 +201,20 @@
215 <script id="invoice-dialog-tpl" type="text/html"> 201 <script id="invoice-dialog-tpl" type="text/html">
216 <p class="dialog-title">发票信息</p> 202 <p class="dialog-title">发票信息</p>
217 <ul class="invoice-tab"> 203 <ul class="invoice-tab">
218 - <li class="btn paper-invoice">纸质发票</li> 204 + <li class="btn paper-invoice" data-type=2>电子发票</li>
  205 + <li class="btn paper-invoice white" data-type=1>纸质发票</li>
219 </ul> 206 </ul>
220 207
221 <div class="invoice-entity el"> 208 <div class="invoice-entity el">
  209 + <div class="row clearfix electron-group receipt-depict electron-group">
  210 + <div>
  211 + ※ 电子发票是税务局认可的有效凭证,其法律效力、基本用途及使用规定同纸质发票,<br />
  212 + 如需纸质发票可自行下载打印。
  213 + </div>
  214 + <div class="receipt-desc">
  215 + <a href="/help?category_id=99" target="_blank">什么是电子发票</a>
  216 + </div>
  217 + </div>
222 <div class="row clearfix"> 218 <div class="row clearfix">
223 <span class="label"> 219 <span class="label">
224 <em class="required-mark">*</em> 220 <em class="required-mark">*</em>
@@ -258,8 +254,24 @@ @@ -258,8 +254,24 @@
258 </div> 254 </div>
259 </div> 255 </div>
260 </div> 256 </div>
  257 + <div class="row clearfix electron-group">
  258 + <span class="label">
  259 + <em class="required-mark">*</em>
  260 + 收票人手机:
  261 + </span>
  262 + <div class="row-content">
  263 + <div class="invoice-content-radio-group">
  264 + <input value="{{invoice_mobile}}" class='input invoice-mobile' type="text" maxlength="11" placeholder="请填写收票人手机">
  265 + <span class="input-tip invoice-mobile-tip blue hide">
  266 + <span class="iconfont">&#xe60c;</span>
  267 + 请输入正确的手机号
  268 + </span>
  269 + </div>
  270 + </div>
  271 + </div>
261 </div> 272 </div>
262 </script> 273 </script>
  274 +
263 </div> 275 </div>
264 {{/ content}} 276 {{/ content}}
265 </div> 277 </div>
@@ -108,10 +108,13 @@ @@ -108,10 +108,13 @@
108 108
109 {{# if invalidPros}} 109 {{# if invalidPros}}
110 <div class="cart-pro-list invalid-pros"> 110 <div class="cart-pro-list invalid-pros">
  111 + <div class="title">
  112 + <span class="main">失效商品</span>
  113 + </div>
111 <div class="pro-list"> 114 <div class="pro-list">
112 {{#each invalidPros}} 115 {{#each invalidPros}}
113 <ul> 116 <ul>
114 - <li class="chk" data-product_info='{"goods_type": "invalid", "buy_number": {{buy_number}}, "selected": "{{selected}}", "product_sku": "{{product_sku}}", "promotion_id": 0}'> 117 + <li class="chk" data-product_info='{"goods_type": "invalid", "buy_number": {{buy_number}}, "selected": "{{selected}}", "product_sku": "{{product_sku}}", "promotion_id": 0}' title="失效">
115 <span class="iconfont warning">&#xe625;</span> 118 <span class="iconfont warning">&#xe625;</span>
116 </li> 119 </li>
117 <li> 120 <li>
  1 +<p id="coin-tip" class="blue">{{yoho_msg}}</p>
  2 +<div>
  3 + 有货币满<em class="blue">{{yoho_coin_pay_rule.num_limit}}</em>个即可使用,每次使用有货币为<em class="blue">{{yoho_coin_pay_rule.num_limit}}</em>的整数倍
  4 + <span class="yoho-coin-help">?
  5 + <span class="coin-help-dialog hide">
  6 + <span class="arrow-left"></span>
  7 + <div class="coin-dialog-title">有货币使用条件:</div>
  8 + <div class="coin-dialog-content">
  9 + <p>(1)订单金额大于20元(含20元)</p>
  10 + <p>(2)有货币数量大于{{yoho_coin_pay_rule.num_limit}}个(含{{yoho_coin_pay_rule.num_limit}}个)</p>
  11 + <p>(3)每笔支付不得超过应付金额的{{yoho_coin_pay_rule.max_pay_rate_desc}}</p>
  12 + <p>备注:使用有货币数量为{{yoho_coin_pay_rule.num_limit}}的整数倍,<br />100个有货币抵1元。</p>
  13 + </div>
  14 + </span>
  15 + </span>
  16 +</div>
  17 +<div>您当前共有有货币<em class="blue">{{total_yoho_coin_num}}</em>个,可用<em class="blue">{{yoho_coin_num}}</em></div>
  18 +<div>本次使用有货币<em class="blue">{{yoho_coin_num}}</em>个 抵扣<em class="blue">¥{{yoho_coin}}</em></div>
  19 +<div>
  20 + <span id="coin-sure" class="btn {{#unless yoho_coin_num}}disable{{/unless}}" data-yoho_coin_num="{{yoho_coin_num}}">确定</span>
  21 + <span class="btn white cancel">取消</span>
  22 +</div>
@@ -23,25 +23,14 @@ module.exports = { @@ -23,25 +23,14 @@ module.exports = {
23 cookieDomain: 'yohoblk.com', 23 cookieDomain: 'yohoblk.com',
24 domains: { 24 domains: {
25 // singleApi: 'http://single.yoho.cn/', 25 // singleApi: 'http://single.yoho.cn/',
26 - // api: 'http://api.yoho.cn/',  
27 - // service: 'http://service.yoho.cn/',  
28 - // search: 'http://search.yohoops.org/yohosearch/'  
29 -  
30 - // singleApi: 'http://single.yoho.cn/',  
31 // api: 'http://api.yoho.yohoops.org/', 26 // api: 'http://api.yoho.yohoops.org/',
32 // service: 'http://service.yoho.yohoops.org/', 27 // service: 'http://service.yoho.yohoops.org/',
33 // search: 'http://search.yohoops.org/yohosearch/' 28 // search: 'http://search.yohoops.org/yohosearch/'
34 29
35 - // api: 'http://dev-api.yohops.com:9999/',  
36 - // service: 'http://dev-service.yohops.com:9999/',  
37 - // liveApi: 'http://testapi.live.yohops.com:9999/',  
38 - // singleApi: 'http://api-test1.yohops.com:9999/'  
39 -  
40 -  
41 api: 'http://api-test3.yohops.com:9999/', 30 api: 'http://api-test3.yohops.com:9999/',
42 service: 'http://service-test3.yohops.com:9999/', 31 service: 'http://service-test3.yohops.com:9999/',
43 - liveApi: 'http://testapi.live.yohops.com:9999/',  
44 singleApi: 'http://api-test3.yohops.com:9999/', 32 singleApi: 'http://api-test3.yohops.com:9999/',
  33 + liveApi: 'http://testapi.live.yohops.com:9999/',
45 search: 'http://search.yohoops.org/yohosearch/' 34 search: 'http://search.yohoops.org/yohosearch/'
46 }, 35 },
47 useOneapm: false, 36 useOneapm: false,
@@ -584,7 +584,7 @@ Cart = { @@ -584,7 +584,7 @@ Cart = {
584 var invalidEles; 584 var invalidEles;
585 var products = []; 585 var products = [];
586 var dialog = new _confirm({ 586 var dialog = new _confirm({
587 - content: '您确定要清除失效商品吗?', 587 + content: '<p style="font-size:25px;margin-bottom:20px;">清除失效商品</p><p>确定要清除失效商品吗?</p>',
588 cb: function() { 588 cb: function() {
589 dialog.close(); 589 dialog.close();
590 590
@@ -14,26 +14,14 @@ var minusPlus = { @@ -14,26 +14,14 @@ var minusPlus = {
14 plus: '&#xe639;' 14 plus: '&#xe639;'
15 }; 15 };
16 16
17 -var $coin = $('#input-coin'),  
18 - $coinTip = $('#coin-tip'),  
19 - $coinSure = $('#coin-sure'),  
20 - $coinUsed = $('#coin-used'),  
21 - $coinDeduction = $('#coin-deduction'),  
22 - coinMax = +$coin.data('max'),  
23 - coinStatus = {  
24 - err: '请输入一个正整数',  
25 - max: '您的有货币不足',  
26 - success: '抵扣¥',  
27 - maxUse: '您最多使用',  
28 - muPostfix: '个有货币'  
29 - };  
30 -var $balanceCost = $('#balance-cost');  
31 -  
32 var $printPrice = $('#print-price'); 17 var $printPrice = $('#print-price');
33 18
34 var $invoice = $('#invoice-content'); 19 var $invoice = $('#invoice-content');
35 20
36 -var balanceTpl = require('../../tpl/shopping/balance.hbs'); 21 +var $coinRemarkContent = $('.coin-and-remark .coin .content');
  22 +
  23 +var balanceTpl = require('../../tpl/shopping/balance.hbs'),
  24 + yohoCoinTpl = require('../../tpl/shopping/yoho-coin.hbs');
37 25
38 var pkgCache = {}; 26 var pkgCache = {};
39 27
@@ -140,57 +128,9 @@ $('.coin-ctrl, .remark-ctrl').click(function() { @@ -140,57 +128,9 @@ $('.coin-ctrl, .remark-ctrl').click(function() {
140 $this.parent('.title').siblings('.content').toggleClass('hide'); 128 $this.parent('.title').siblings('.content').toggleClass('hide');
141 }); 129 });
142 130
143 -// 使用有货币输入框联动  
144 -$coin.on('propertychange input', function() {  
145 - var c = $.trim($coin.val());  
146 - var err = true;  
147 -  
148 - if (c === '') {  
149 -  
150 - // 输入框为空,确定按钮不可点  
151 - $coinTip.addClass('vhide');  
152 - $coinSure.addClass('disable');  
153 - return;  
154 - } else if (!/^[1-9]\d*$/.test(c)) {  
155 -  
156 - // 验证输入不为正整数  
157 - $coinTip.text(coinStatus.err);  
158 - } else if (+c > coinMax) {  
159 -  
160 - // 有货币不足  
161 - $coinTip.text(coinStatus.max);  
162 - } else if (+c > $balanceCost.data('cost') * 100) {  
163 -  
164 - // 输入的有货币大于订单额度  
165 - $coinTip.text(coinStatus.maxUse + ($balanceCost.data('cost') * 100) + coinStatus.muPostfix);  
166 - } else {  
167 - err = false;  
168 - $coinTip.text(coinStatus.success + (c / 100).toFixed(2));  
169 -  
170 - // 已使用面板的数据显示更新  
171 - $coinUsed.html(c);  
172 - $coinDeduction.html((c / 100).toFixed(2));  
173 - }  
174 -  
175 - if (err) {  
176 - $coinSure.addClass('disable');  
177 - $coinTip.removeClass('vhide');  
178 - } else {  
179 - $coinSure.removeClass('disable');  
180 - $coinTip.addClass('vhide');  
181 - }  
182 -});  
183 -  
184 -/**  
185 - * 切换使用有货币面板显示  
186 - */  
187 -function toggleCoinPanel() {  
188 - $('.using-coin, .used-coin').toggleClass('hide');  
189 -}  
190 -  
191 function compute(coin) { 131 function compute(coin) {
192 $.ajax({ 132 $.ajax({
193 - type: 'GET', 133 + type: 'POST',
194 url: '/shopping/order/compute', 134 url: '/shopping/order/compute',
195 data: { 135 data: {
196 coin: coin 136 coin: coin
@@ -204,46 +144,18 @@ function compute(coin) { @@ -204,46 +144,18 @@ function compute(coin) {
204 cost = cost.toFixed(2); 144 cost = cost.toFixed(2);
205 145
206 $('#balance-list').html(balanceTpl(data.data)); 146 $('#balance-list').html(balanceTpl(data.data));
  147 + $coinRemarkContent.html(yohoCoinTpl(data.data));
207 } 148 }
208 }); 149 });
209 } 150 }
210 151
211 // 获取已使用的有货币 152 // 获取已使用的有货币
212 function getCoinUsed() { 153 function getCoinUsed() {
213 - var coin = $coinUsed.text(); 154 + var coin = $('.coin-and-remark').find('#coin-sure').data('yoho_coin_num') || 0;
214 155
215 return coin === '' ? 0 : parseInt(coin, 10); // 使用parseInt可以排除异常情况的转化影响 156 return coin === '' ? 0 : parseInt(coin, 10); // 使用parseInt可以排除异常情况的转化影响
216 } 157 }
217 158
218 -$coinSure.click(function() {  
219 - if ($coinSure.hasClass('disable')) {  
220 - return;  
221 - }  
222 -  
223 - suredCoin = getCoinUsed();  
224 -  
225 - // 切换显示  
226 - compute(suredCoin);  
227 -  
228 - toggleCoinPanel();  
229 -});  
230 -  
231 -$('.used-coin').on('click', '.modify', function() {  
232 - toggleCoinPanel();  
233 -}).on('click', '.cancel', function() {  
234 - $coin.val('').trigger('input');  
235 -  
236 - // reset used coin panel show  
237 - $coinUsed.html('0');  
238 - $coinDeduction.html('0');  
239 -  
240 - compute(0);  
241 -  
242 - // 隐藏有货币面板并重置子面板显示  
243 - $('.coin-ctrl.iconfont').trigger('click');  
244 - toggleCoinPanel();  
245 -});  
246 -  
247 // 添加备注-是否打印价格 159 // 添加备注-是否打印价格
248 $printPrice.printPrice = 'N'; // 默认为false 160 $printPrice.printPrice = 'N'; // 默认为false
249 161
@@ -273,8 +185,10 @@ $('#balance-list').on('click', '#submit-order', function() { @@ -273,8 +185,10 @@ $('#balance-list').on('click', '#submit-order', function() {
273 $invoiceDetail = $invoice.find('.invoice-detail'); 185 $invoiceDetail = $invoice.find('.invoice-detail');
274 186
275 $.extend(reqParam, { 187 $.extend(reqParam, {
  188 + invoices_type: $invoiceDetail.data('type'),
  189 + invoices_mobile: $invoiceDetail.data('mobile'),
276 invoices_title: $invoiceDetail.data('title'), 190 invoices_title: $invoiceDetail.data('title'),
277 - invoices_type_id: $invoiceDetail.data('content') 191 + invoice_content: $invoiceDetail.data('content')
278 }); 192 });
279 } 193 }
280 194
@@ -290,3 +204,33 @@ $('#balance-list').on('click', '#submit-order', function() { @@ -290,3 +204,33 @@ $('#balance-list').on('click', '#submit-order', function() {
290 } 204 }
291 }); 205 });
292 }); 206 });
  207 +
  208 +$coinRemarkContent.on('mouseover mouseout', '.yoho-coin-help', function(event) {
  209 +
  210 + if (event.type === 'mouseover') {
  211 + $('.coin-help-dialog').removeClass('hide');
  212 + } else if (event.type === 'mouseout') {
  213 + $('.coin-help-dialog').addClass('hide');
  214 + }
  215 +
  216 +}).on('click', '#coin-sure', function() { // 确定有货币按钮
  217 +
  218 + if ($(this).hasClass('disable')) {
  219 + return;
  220 + }
  221 +
  222 + suredCoin = getCoinUsed();
  223 +
  224 + // 切换显示
  225 + compute(suredCoin);
  226 +
  227 + // 隐藏有货币面板并重置子面板显示
  228 + $('.coin-ctrl.iconfont').trigger('click');
  229 +}).on('click', '.cancel', function() { // 取消有货币按钮
  230 +
  231 + suredCoin = 0;
  232 + compute(suredCoin);
  233 +
  234 + // 隐藏有货币面板并重置子面板显示
  235 + $('.coin-ctrl.iconfont').trigger('click');
  236 +});
@@ -11,7 +11,8 @@ var checkedInvoiceTpl = require('../../../tpl/shopping/checked-invoice-show.hbs' @@ -11,7 +11,8 @@ var checkedInvoiceTpl = require('../../../tpl/shopping/checked-invoice-show.hbs'
11 11
12 var $invoiceContent = $('#invoice-content'); 12 var $invoiceContent = $('#invoice-content');
13 13
14 -var $invoiceTitleInput; 14 +var $invoiceTitleInput,
  15 + $invoiceMobile;
15 16
16 require('yoho-jquery-placeholder'); 17 require('yoho-jquery-placeholder');
17 18
@@ -19,6 +20,7 @@ require('yoho-jquery-placeholder'); @@ -19,6 +20,7 @@ require('yoho-jquery-placeholder');
19 function validateInvoice($el) { 20 function validateInvoice($el) {
20 var pass = true; 21 var pass = true;
21 var name = $.trim($el.find('.invoice-title-input').val()); 22 var name = $.trim($el.find('.invoice-title-input').val());
  23 + var mobile = $.trim($invoiceMobile.val());
22 24
23 // 发票抬头为单位 25 // 发票抬头为单位
24 if ($el.invoiceTitleType === 2 && name === '') { 26 if ($el.invoiceTitleType === 2 && name === '') {
@@ -26,6 +28,13 @@ function validateInvoice($el) { @@ -26,6 +28,13 @@ function validateInvoice($el) {
26 $el.find('.invoice-title-tip').removeClass('hide'); 28 $el.find('.invoice-title-tip').removeClass('hide');
27 } 29 }
28 30
  31 + if ($el.invoiceType === 2 && $('#address-list li.address.focus').data('mobile') !== mobile) {
  32 + if (!/[1][34578][0-9]{9}/.test(mobile)) {
  33 + pass = false;
  34 + $el.find('.invoice-mobile-tip').removeClass('hide');
  35 + }
  36 + }
  37 +
29 return pass; 38 return pass;
30 } 39 }
31 40
@@ -40,10 +49,26 @@ function invoiceDialogFactory() { @@ -40,10 +49,26 @@ function invoiceDialogFactory() {
40 btnClass: ['save-invoice'], 49 btnClass: ['save-invoice'],
41 name: '保存发票信息', 50 name: '保存发票信息',
42 cb: function() { 51 cb: function() {
43 - var $el = invoice.$el; 52 + var $el = invoice.$el,
  53 + $addressFocus;
  54 +
  55 + var mobile = '',
  56 + invoiceMobile;
44 57
45 if (validateInvoice($el)) { 58 if (validateInvoice($el)) {
  59 +
  60 + if ($el.invoiceType === 2) {
  61 +
  62 + $addressFocus = $('#address-list li.address.focus');
  63 + invoiceMobile = $invoiceMobile.val();
  64 + mobile = $addressFocus.data('mobile') !== invoiceMobile ?
  65 + invoiceMobile : $addressFocus.data('complete-mobile');
  66 + }
  67 +
46 $invoiceContent.html(checkedInvoiceTpl({ 68 $invoiceContent.html(checkedInvoiceTpl({
  69 + invoiceType: $el.invoiceType,
  70 + invoiceMobile: mobile,
  71 + invoiceTypeName: $el.invoiceTypeName,
47 invoiceTitle: $el.invoiceTitleType === 1 ? '个人' : $invoiceTitleInput.val(), 72 invoiceTitle: $el.invoiceTitleType === 1 ? '个人' : $invoiceTitleInput.val(),
48 content: $el.invoiceContent, 73 content: $el.invoiceContent,
49 invoiceContent: $el.find('.invoice-content-radio .checked').next('label').text(), 74 invoiceContent: $el.find('.invoice-content-radio .checked').next('label').text(),
@@ -81,28 +106,62 @@ function showInvoiceDialog() { @@ -81,28 +106,62 @@ function showInvoiceDialog() {
81 var invoiceTitleType = 1, 106 var invoiceTitleType = 1,
82 invoiceContent = $('.invoice-content-radio').first().data('value'); 107 invoiceContent = $('.invoice-content-radio').first().data('value');
83 108
84 - var title; 109 + var title,
  110 + mobile = $('#address-list li.address.focus').data('complete-mobile') || '',
  111 + invoiceTypeName = '电子发票',
  112 + invoiceType = 2;
85 113
86 $invoiceTitleInput = $('.yoho-dialog.invoice .invoice-title-input'); 114 $invoiceTitleInput = $('.yoho-dialog.invoice .invoice-title-input');
  115 + $invoiceMobile = $('.yoho-dialog.invoice .invoice-mobile');
  116 +
  117 + // 电子、纸质发票切换
  118 + $('.invoice-tab li').unbind('click').bind('click', function() {
  119 + var $electronGroup = $('.electron-group');
  120 +
  121 + $(this).removeClass('white').siblings('li').addClass('white');
  122 + dialog.$el.invoiceType = $(this).data('type');
  123 + dialog.$el.invoiceTypeName = $(this).text();
  124 +
  125 + // 纸质
  126 + if ($(this).data('type') === 1) {
  127 + $electronGroup.addClass('hide');
  128 + } else {
  129 + $electronGroup.removeClass('hide');
  130 + }
  131 + });
87 132
88 if (isEditInvoice) { 133 if (isEditInvoice) {
89 title = $invoceDetail.data('title'); 134 title = $invoceDetail.data('title');
90 - 135 + invoiceType = $invoceDetail.data('type') || 2;
91 invoiceTitleType = title === '个人' ? 1 : 2; 136 invoiceTitleType = title === '个人' ? 1 : 2;
92 invoiceContent = $invoceDetail.data('content'); 137 invoiceContent = $invoceDetail.data('content');
93 138
94 if (invoiceTitleType === 2) { 139 if (invoiceTitleType === 2) {
95 $invoiceTitleInput.removeClass('hide').val(title); 140 $invoiceTitleInput.removeClass('hide').val(title);
96 } 141 }
  142 +
  143 + // 初始化电子、纸质tab
  144 + if (invoiceType === 1) {
  145 + $('.invoice-tab li:eq(1)').trigger('click');
  146 + invoiceType = 1;
  147 + invoiceTypeName = '纸质发票';
  148 + } else {
  149 + $('.invoice-tab li:eq(0)').trigger('click');
  150 + mobile = $invoceDetail.data('mobile');
  151 + }
97 } 152 }
98 153
  154 + // 设置默认收货地址手机号
  155 + $invoiceMobile.val(mobile.toString().substr(0, 3) + '****' + mobile.toString().substr(7));
  156 +
99 // 设置radio选中 157 // 设置radio选中
100 $('[data-value=' + invoiceTitleType + '].invoice-title-radio').find('.radio').addClass('checked'); 158 $('[data-value=' + invoiceTitleType + '].invoice-title-radio').find('.radio').addClass('checked');
101 $('[data-value=' + invoiceContent + '].invoice-content-radio').find('.radio').addClass('checked'); 159 $('[data-value=' + invoiceContent + '].invoice-content-radio').find('.radio').addClass('checked');
102 160
103 -  
104 // 存储发票参数 161 // 存储发票参数
105 $.extend(dialog.$el, { 162 $.extend(dialog.$el, {
  163 + invoiceType: invoiceType,
  164 + invoiceTypeName: invoiceTypeName,
106 invoiceTitleType: invoiceTitleType, 165 invoiceTitleType: invoiceTitleType,
107 invoiceContent: invoiceContent 166 invoiceContent: invoiceContent
108 }); 167 });
@@ -160,3 +219,4 @@ $invoiceContent.on('click', '.invoice-radio', function() { @@ -160,3 +219,4 @@ $invoiceContent.on('click', '.invoice-radio', function() {
160 }).on('click', '.modify-invoice', function() { 219 }).on('click', '.modify-invoice', function() {
161 showInvoiceDialog(); 220 showInvoiceDialog();
162 }); 221 });
  222 +
@@ -5,7 +5,6 @@ @@ -5,7 +5,6 @@
5 line-height: 40px; 5 line-height: 40px;
6 text-align: center; 6 text-align: center;
7 background: #f4fbff; 7 background: #f4fbff;
8 -  
9 margin-bottom: $space; 8 margin-bottom: $space;
10 border: 1px solid $borderColor; 9 border: 1px solid $borderColor;
11 10
@@ -67,6 +66,7 @@ @@ -67,6 +66,7 @@
67 66
68 .order-status { 67 .order-status {
69 $basicHeight: 90px; 68 $basicHeight: 90px;
  69 +
70 border-top: 1px solid $borderColor; 70 border-top: 1px solid $borderColor;
71 border-bottom: 1px solid $borderColor; 71 border-bottom: 1px solid $borderColor;
72 position: relative; 72 position: relative;
@@ -191,6 +191,7 @@ @@ -191,6 +191,7 @@
191 width: $normalWidth; 191 width: $normalWidth;
192 text-align: center; 192 text-align: center;
193 } 193 }
  194 +
194 .first { 195 .first {
195 width: calc($goodImgWidth + 2 * $space + $w - $normalWidth + $space / 2); 196 width: calc($goodImgWidth + 2 * $space + $w - $normalWidth + $space / 2);
196 text-align: left; 197 text-align: left;
@@ -203,7 +204,6 @@ @@ -203,7 +204,6 @@
203 } 204 }
204 205
205 .goods-container { 206 .goods-container {
206 -  
207 width: calc($w + 3 * $normalWidth); 207 width: calc($w + 3 * $normalWidth);
208 208
209 .special-column { 209 .special-column {
@@ -272,6 +272,17 @@ @@ -272,6 +272,17 @@
272 min-width: 100px; 272 min-width: 100px;
273 } 273 }
274 } 274 }
  275 +
  276 + .invoice-down {
  277 + color: #d0021b;
  278 + width: 90px;
  279 + margin-top: -24px;
  280 + margin-left: 170px;
  281 + position: absolute;
  282 + font-size: 12px;
  283 + font-weight: 700;
  284 + border: 1px solid #e0e0e0;
  285 + }
275 } 286 }
276 287
277 .status-title { 288 .status-title {
@@ -285,7 +296,6 @@ @@ -285,7 +296,6 @@
285 296
286 .header { 297 .header {
287 padding-right: $space; 298 padding-right: $space;
288 -  
289 } 299 }
290 300
291 .table-body { 301 .table-body {
@@ -317,12 +327,13 @@ @@ -317,12 +327,13 @@
317 &.time { 327 &.time {
318 width: 30% !important; 328 width: 30% !important;
319 } 329 }
  330 +
320 &.city { 331 &.city {
321 width: 30% !important; 332 width: 30% !important;
322 } 333 }
  334 +
323 &.action { 335 &.action {
324 width: 40% !important; 336 width: 40% !important;
325 } 337 }
326 } 338 }
327 -  
328 } 339 }
@@ -256,8 +256,6 @@ $hoverColor: #379ed6; @@ -256,8 +256,6 @@ $hoverColor: #379ed6;
256 } 256 }
257 257
258 .invalid-pros { 258 .invalid-pros {
259 - margin-top: 80px;  
260 - border-top: 1px solid #eee;  
261 color: #999; 259 color: #999;
262 260
263 input { 261 input {
@@ -602,6 +602,77 @@ @@ -602,6 +602,77 @@
602 padding: 15px 20px; 602 padding: 15px 20px;
603 margin: 20px 0; 603 margin: 20px 0;
604 font-size: 14px; 604 font-size: 14px;
  605 +
  606 + > div {
  607 + margin-top: 20px;
  608 +
  609 + &.first-child {
  610 + margin-top: 0;
  611 + }
  612 + }
  613 +
  614 + .yoho-coin-help {
  615 + display: inline-block;
  616 + background-color: #000;
  617 + border-radius: 16px;
  618 + width: 16px;
  619 + height: 16px;
  620 + line-height: 20px;
  621 + text-align: center;
  622 + color: #fff;
  623 + font-size: 14px;
  624 + cursor: pointer;
  625 + margin-left: 20px;
  626 + padding-right: 1px;
  627 + }
  628 +
  629 + .coin-help-dialog {
  630 + width: 280px;
  631 + position: absolute;
  632 + background-color: #fff;
  633 + margin-left: 15px;
  634 + color: #000;
  635 + text-align: left;
  636 + padding: 10px;
  637 + line-height: 22px;
  638 + border: 1px solid #bbb;
  639 + cursor: auto;
  640 + margin-top: -10px;
  641 + font-size: 12px;
  642 + }
  643 +
  644 + .coin-dialog-title {
  645 + font-weight: bold;
  646 + }
  647 +
  648 + .arrow-left {
  649 + position: absolute;
  650 + left: -9px;
  651 + width: 0;
  652 + height: 0;
  653 + border-top: 6px solid transparent;
  654 + border-bottom: 6px solid transparent;
  655 + border-right: 8px solid #bbb;
  656 +
  657 + &:before {
  658 + content: "";
  659 + border-top: 6px solid transparent;
  660 + border-bottom: 6px solid transparent;
  661 + border-right: 8px solid #fff;
  662 + left: 2px;
  663 + top: -6px;
  664 + position: absolute;
  665 + }
  666 + }
  667 +
  668 + em.blue {
  669 + padding: 0 2px;
  670 + }
  671 +
  672 + .btn {
  673 + display: inline-block;
  674 + margin-right: 20px;
  675 + }
605 } 676 }
606 677
607 .coin-input { 678 .coin-input {
@@ -773,6 +844,23 @@ @@ -773,6 +844,23 @@
773 width: 520px; 844 width: 520px;
774 } 845 }
775 } 846 }
  847 +
  848 + .receipt-depict {
  849 + background-color: #f5f5f5;
  850 + color: #444;
  851 + font-size: 14px;
  852 + line-height: 20px;
  853 + width: 100%;
  854 + padding: 20px;
  855 +
  856 + .receipt-desc {
  857 + margin-top: 20px;
  858 +
  859 + a {
  860 + color: #3a3a3a;
  861 + }
  862 + }
  863 + }
776 } 864 }
777 865
778 .address-confirm-dialog { 866 .address-confirm-dialog {
@@ -73,7 +73,7 @@ @@ -73,7 +73,7 @@
73 font-size: 14px; 73 font-size: 14px;
74 color: #1b1b1b; 74 color: #1b1b1b;
75 font-weight: bold; 75 font-weight: bold;
76 - margin: 0 60px 0 224px; 76 + margin-left: 85px;
77 } 77 }
78 78
79 .checkout-total { 79 .checkout-total {
1 {{#each address}} 1 {{#each address}}
2 <li class="address{{#isY is_default}} default{{/isY}}{{#if focus}} focus{{/if}}" 2 <li class="address{{#isY is_default}} default{{/isY}}{{#if focus}} focus{{/if}}"
3 data-id="{{address_id}}" data-name="{{consignee}}" data-mobile="{{mobile}}" 3 data-id="{{address_id}}" data-name="{{consignee}}" data-mobile="{{mobile}}"
4 - data-phone="{{phone}}" data-areacode="{{area_code}}" data-area="{{area}}" data-address="{{address}}"> 4 + data-phone="{{phone}}" data-areacode="{{area_code}}" data-area="{{area}}" data-address="{{address}}" data-complete-mobile="{{complete_mobile}}">
5 <div class="address-header"></div> 5 <div class="address-header"></div>
6 <div class="address-content"> 6 <div class="address-content">
7 <p class="default-or-not"> 7 <p class="default-or-not">
@@ -221,6 +221,7 @@ @@ -221,6 +221,7 @@
221 </div> 221 </div>
222 <div id="remove_selected" class="action hoverable">删除选中的商品</div> 222 <div id="remove_selected" class="action hoverable">删除选中的商品</div>
223 <div id="send_favorite" class="action hoverable">移入收藏夹</div> 223 <div id="send_favorite" class="action hoverable">移入收藏夹</div>
  224 + <div id="clear_invalid_all" class="action hoverable">清除失效商品</div>
224 <div class="selected-num">已选<span>{{selectedNum}}</span></div> 225 <div class="selected-num">已选<span>{{selectedNum}}</span></div>
225 <div class="checkout-total"> 226 <div class="checkout-total">
226 <div class="total-title">商品金额:</div> 227 <div class="total-title">商品金额:</div>
@@ -7,8 +7,10 @@ @@ -7,8 +7,10 @@
7 <label>发票开具</label> 7 <label>发票开具</label>
8 </div> 8 </div>
9 {{#if invoiceTitle}} 9 {{#if invoiceTitle}}
10 - <p class="invoice-detail" data-title="{{invoiceTitle}}" data-content="{{content}}">  
11 - <em>{{invoiceTitle}}</em><em>{{invoiceContent}}</em> 10 + <p class="invoice-detail" data-title="{{invoiceTitle}}" data-content="{{content}}" data-type="{{invoiceType}}" data-mobile="{{invoiceMobile}}">
  11 + <em>{{invoiceTypeName}}</em>
  12 + <em>{{invoiceTitle}}</em>
  13 + <em>{{invoiceContent}}</em>
12 <span class="modify-invoice btn white">修改</span> 14 <span class="modify-invoice btn white">修改</span>
13 </p> 15 </p>
14 {{/if}} 16 {{/if}}
  1 +<p id="coin-tip" class="blue">{{yoho_msg}}</p>
  2 +<div data-yoho_coin_num="{{yoho_coin_num}}">
  3 + 有货币满<em class="blue">{{yoho_coin_pay_rule.num_limit}}</em>个即可使用,每次使用有货币为<em class="blue">{{yoho_coin_pay_rule.num_limit}}</em>的整数倍
  4 + <span class="yoho-coin-help">?
  5 + <span class="coin-help-dialog hide">
  6 + <span class="arrow-left"></span>
  7 + <div class="coin-dialog-title">有货币使用条件:</div>
  8 + <div class="coin-dialog-content">
  9 + <p>(1)订单金额大于20元(含20元)</p>
  10 + <p>(2)有货币数量大于{{yoho_coin_pay_rule.num_limit}}个(含{{yoho_coin_pay_rule.num_limit}}个)</p>
  11 + <p>(3)每笔支付不得超过应付金额的{{yoho_coin_pay_rule.max_pay_rate_desc}}</p>
  12 + <p>备注:使用有货币数量为{{yoho_coin_pay_rule.num_limit}}的整数倍,<br />100个有货币抵1元。</p>
  13 + </div>
  14 + </span>
  15 + </span>
  16 +</div>
  17 +<div>您当前共有有货币<em class="blue">{{total_yoho_coin_num}}</em>个,可用<em class="blue">{{yoho_coin_num}}</em></div>
  18 +<div>本次使用有货币<em class="blue">{{yoho_coin_num}}</em>个 抵扣<em class="blue">¥{{yoho_coin}}</em></div>
  19 +<div>
  20 + <span id="coin-sure" class="btn {{#unless yoho_coin_num}}disable{{/unless}}" data-yoho_coin_num="{{yoho_coin_num}}">确定</span>
  21 + <span class="btn white cancel">取消</span>
  22 +</div>