Authored by yyq

Merge branch 'feature/invoice' into release/5.9

@@ -125,7 +125,8 @@ const orderSubmitAsync = (uid, cartType, addressId, deliveryTime, deliveryWay, p @@ -125,7 +125,8 @@ const orderSubmitAsync = (uid, cartType, addressId, deliveryTime, deliveryWay, p
125 invoices_type: other.invoicesType, 125 invoices_type: other.invoicesType,
126 invoices_title: other.invoicesTitle, 126 invoices_title: other.invoicesTitle,
127 invoice_content: other.invoicesContent, 127 invoice_content: other.invoicesContent,
128 - receiverMobile: other.receiverMobile 128 + receiverMobile: other.receiverMobile,
  129 + buyerTaxNumber: other.taxNumber
129 }); 130 });
130 } 131 }
131 132
@@ -70,6 +70,15 @@ const submit = (uid, cartType, p, remoteIp) => { @@ -70,6 +70,15 @@ const submit = (uid, cartType, p, remoteIp) => {
70 p.addressId = crypto.decrypt('', `${p.addressId}`); 70 p.addressId = crypto.decrypt('', `${p.addressId}`);
71 } 71 }
72 72
  73 + // 5.8.1 发票优化需求
  74 + // 只接受电子发票(1 纸质 2 电子),发票内容为明细(id 12:明细)
  75 + if (p.invoicesType) {
  76 + Object.assign(p, {
  77 + invoicesType: 2,
  78 + invoicesContent: 12
  79 + });
  80 + }
  81 +
73 return ensureApi.orderSubmitAsync(uid, cartType, p.addressId, p.deliveryTime, 82 return ensureApi.orderSubmitAsync(uid, cartType, p.addressId, p.deliveryTime,
74 p.deliveryWay, p.paymentType, p.paymentId, p.printPrice, p, remoteIp).then(result => { 83 p.deliveryWay, p.paymentType, p.paymentId, p.printPrice, p, remoteIp).then(result => {
75 if (result.code === 200) { 84 if (result.code === 200) {
@@ -77,21 +77,22 @@ @@ -77,21 +77,22 @@
77 <script id="invoice-chose-tpl" type="text/html"> 77 <script id="invoice-chose-tpl" type="text/html">
78 <div class="invoice-close"><i class="iconfont">&#xe60d;</i></div> 78 <div class="invoice-close"><i class="iconfont">&#xe60d;</i></div>
79 <p class="invoice-header">发票信息</p> 79 <p class="invoice-header">发票信息</p>
80 - <ul class="invoice-type">  
81 - <li class="el-invoice focus">电子发票</li>  
82 - <li class="pa-invoice">纸质发票</li>  
83 - </ul>  
84 <div class="invoice-content el-content"> 80 <div class="invoice-content el-content">
  81 + <p class="invoice-type-text">
  82 + <span class="row-title">发&nbsp;票&nbsp;类&nbsp;型:</span>
  83 + 电子发票
  84 + </p>
  85 +
85 <p class="el-tip"> 86 <p class="el-tip">
86 ※ 电子发票是税务局认可的有效凭证,其法律效力、基本用途及使用规定同纸质发票,如需纸质发票可自行下载打印。<br> 87 ※ 电子发票是税务局认可的有效凭证,其法律效力、基本用途及使用规定同纸质发票,如需纸质发票可自行下载打印。<br>
87 - <a href="/help/detail?id=33&contId=139" target="_blank">什么是电子发票?</a> 88 + <a href="/help/detail?id=33&contId=139" target="_blank">查看发票须知</a>
88 </p> 89 </p>
89 90
90 <ul> 91 <ul>
91 <li class="invoice-title invoice-row"> 92 <li class="invoice-title invoice-row">
92 <span class="row-title"> 93 <span class="row-title">
93 <em>*</em> 94 <em>*</em>
94 -票抬头 95 +&nbsp;票&nbsp;抬&nbsp;头:
95 </span> 96 </span>
96 <div class="row-content"> 97 <div class="row-content">
97 <span class="radio-wrap"> 98 <span class="radio-wrap">
@@ -100,36 +101,41 @@ @@ -100,36 +101,41 @@
100 <span class="radio-wrap"> 101 <span class="radio-wrap">
101 <label class="rbt-2 radio-btn" data-id="2"></label> 单位 102 <label class="rbt-2 radio-btn" data-id="2"></label> 单位
102 </span> 103 </span>
103 -  
104 - <div class="company-row hide"> 104 + </div>
  105 + </li>
  106 + <li class="invoice-title-name invoice-row company-row hide">
  107 + <span class="row-title">
  108 + <em>*</em>
  109 + 单&nbsp;位&nbsp;名&nbsp;称:
  110 + </span>
  111 + <div class="row-content">
105 <input id="company-name" class="company-name" type="text" placeholder="请填写单位名称"> 112 <input id="company-name" class="company-name" type="text" placeholder="请填写单位名称">
106 - <span class="input-tip invoice-title-tip red hide"> 113 + <span class="input-tip company-name-tip red hide">
107 <span class="iconfont">&#xe629;</span> 114 <span class="iconfont">&#xe629;</span>
108 - 请填写发票抬头 115 + <em>请填写发票抬头</em>
109 </span> 116 </span>
110 </div> 117 </div>
111 - </div>  
112 </li> 118 </li>
113 - <li class="invoice-goods-type invoice-row"> 119 + <li class="invoice-tax-num invoice-row company-row hide">
114 <span class="row-title"> 120 <span class="row-title">
115 <em>*</em> 121 <em>*</em>
116 - 发票内容 122 + 税&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号
117 </span> 123 </span>
118 <div class="row-content"> 124 <div class="row-content">
119 - {{#each invoices.invoiceContentList}}  
120 - <span class="radio-wrap">  
121 - <label class="radio-btn rbc-{{invoices_type_id}}{{#if @first}} on{{/if}}" data-id="{{invoices_type_id}}" data-name="{{invoices_type_name}}"></label> {{invoices_type_name}} 125 + <input id="company-tax-num" class="company-tax-num" type="text" placeholder="请输入纳税人识别号">
  126 + <span class="input-tip company-tax-tip red hide">
  127 + <span class="iconfont">&#xe629;</span>
  128 + <em>请填写纳税人识别号</em>
122 </span> 129 </span>
123 - {{/each}}  
124 </div> 130 </div>
125 </li> 131 </li>
126 <li class="receiver invoice-row" data-full="{{receiverMobile}}" data-hide="{{hideReceiverMobile}}"> 132 <li class="receiver invoice-row" data-full="{{receiverMobile}}" data-hide="{{hideReceiverMobile}}">
127 <span class="row-title"> 133 <span class="row-title">
128 <em>*</em> 134 <em>*</em>
129 -机号码: 135 +&nbsp;机&nbsp;号&nbsp;码:
130 </span> 136 </span>
131 <div class="row-content"> 137 <div class="row-content">
132 - <input id="receiver-phone" class="receiver-phone" type="text"> 138 + <input id="receiver-phone" class="receiver-phone" type="text" placeholder="可通过手机号码在发票服务平台查询">
133 <span class="input-tip receiver-tip red hide"> 139 <span class="input-tip receiver-tip red hide">
134 <span class="iconfont">&#xe629;</span> 140 <span class="iconfont">&#xe629;</span>
135 <em></em> 141 <em></em>
@@ -135,7 +135,6 @@ @@ -135,7 +135,6 @@
135 {{/if}} 135 {{/if}}
136 </div> 136 </div>
137 <p>发票抬头:{{title}}</p> 137 <p>发票抬头:{{title}}</p>
138 - <p>发票内容:{{contentValue}}</p>  
139 {{^}} 138 {{^}}
140 <p>暂不需要发票 139 <p>暂不需要发票
141 {{/if}} 140 {{/if}}
@@ -23,9 +23,18 @@ function validateInvoice($el, info) { @@ -23,9 +23,18 @@ function validateInvoice($el, info) {
23 // 发票抬头 23 // 发票抬头
24 if (!info.titleName) { 24 if (!info.titleName) {
25 pass = false; 25 pass = false;
26 - $('.invoice-title-tip', $el).removeClass('hide'); 26 + $('.company-name-tip', $el).removeClass('hide');
27 } else { 27 } else {
28 - $('.invoice-title-tip', $el).addClass('hide'); 28 + $('.company-name-tip', $el).addClass('hide');
  29 + }
  30 +
  31 + if (info.titleId === 2) {
  32 + if (!info.taxNumber) {
  33 + pass = false;
  34 + $('.company-tax-tip', $el).removeClass('hide');
  35 + } else {
  36 + $('.company-tax-tip', $el).addClass('hide');
  37 + }
29 } 38 }
30 39
31 // 收票人手机号 40 // 收票人手机号
@@ -38,7 +47,7 @@ function validateInvoice($el, info) { @@ -38,7 +47,7 @@ function validateInvoice($el, info) {
38 } else if (info.receiver === defaultReceiver.hide) { 47 } else if (info.receiver === defaultReceiver.hide) {
39 $receiverTip.addClass('hide'); 48 $receiverTip.addClass('hide');
40 } else if (!/^[0-9]{11}$/.test(info.receiver)) { 49 } else if (!/^[0-9]{11}$/.test(info.receiver)) {
41 - $receiverTip.removeClass('hide').find('em').html('手机号码不正确'); 50 + $receiverTip.removeClass('hide').find('em').html('请输入正确手机号');
42 pass = false; 51 pass = false;
43 } else { 52 } else {
44 $receiverTip.addClass('hide'); 53 $receiverTip.addClass('hide');
@@ -49,29 +58,9 @@ function validateInvoice($el, info) { @@ -49,29 +58,9 @@ function validateInvoice($el, info) {
49 } 58 }
50 59
51 function bindInvoiceEvent($el) { 60 function bindInvoiceEvent($el) {
52 - var $invoiceTypeWrap = $('.invoice-type', $el),  
53 - $titleWrap = $('.invoice-title', $el),  
54 - $goodsTypeWrap = $('.invoice-goods-type', $el),  
55 - $receiver = $('.receiver', $el), 61 + var $titleWrap = $('.invoice-title', $el),
56 $companyRow = $('.company-row', $el); 62 $companyRow = $('.company-row', $el);
57 63
58 - $invoiceTypeWrap.on('click', 'li', function() {  
59 - var $this = $(this);  
60 -  
61 - if ($this.hasClass('focus')) {  
62 - return;  
63 - }  
64 -  
65 - if ($this.hasClass('el-invoice')) {  
66 - $receiver.removeClass('hide');  
67 - } else {  
68 - $receiver.addClass('hide');  
69 - }  
70 -  
71 - $this.siblings('.focus').removeClass('focus');  
72 - $this.addClass('focus');  
73 - });  
74 -  
75 $titleWrap.on('click', '.radio-btn', function() { 64 $titleWrap.on('click', '.radio-btn', function() {
76 var $this = $(this), 65 var $this = $(this),
77 id = $this.data('id'); 66 id = $this.data('id');
@@ -90,17 +79,6 @@ function bindInvoiceEvent($el) { @@ -90,17 +79,6 @@ function bindInvoiceEvent($el) {
90 $this.addClass('on'); 79 $this.addClass('on');
91 }); 80 });
92 81
93 - $goodsTypeWrap.on('click', '.radio-btn', function() {  
94 - var $this = $(this);  
95 -  
96 - if ($this.hasClass('on')) {  
97 - return;  
98 - }  
99 -  
100 - $goodsTypeWrap.find('.on').removeClass('on');  
101 - $this.addClass('on');  
102 - });  
103 -  
104 $el.on('click', '.invoice-close', function() { 82 $el.on('click', '.invoice-close', function() {
105 $('.btn-close', $el).trigger('click'); 83 $('.btn-close', $el).trigger('click');
106 }); 84 });
@@ -109,48 +87,35 @@ function bindInvoiceEvent($el) { @@ -109,48 +87,35 @@ function bindInvoiceEvent($el) {
109 function bindInvoiceInfo($el, info) { 87 function bindInvoiceInfo($el, info) {
110 info = info || {}; 88 info = info || {};
111 89
112 - // 发票类型  
113 - if (info.invocesType === 1) {  
114 - $('.pa-invoice', $el).trigger('click');  
115 - }  
116 -  
117 if (info.titleId) { 90 if (info.titleId) {
118 $('.rbt-' + info.titleId).trigger('click'); 91 $('.rbt-' + info.titleId).trigger('click');
119 92
120 - if (info.titleId === 2 && info.titleName) {  
121 - $('#company-name', $el).val(info.titleName); 93 + if (info.titleId === 2) {
  94 + $('#company-name', $el).val(info.titleName || '');
  95 + $('#company-tax-num', $el).val(info.taxNumber || '');
122 } 96 }
123 } 97 }
124 98
125 - if (info.contentId) {  
126 - $('.rbc-' + info.contentId, $el).trigger('click');  
127 - }  
128 -  
129 $('#receiver-phone', $el).val(info.receiver || defaultReceiver.hide || ''); 99 $('#receiver-phone', $el).val(info.receiver || defaultReceiver.hide || '');
130 } 100 }
131 101
132 function packInvoiceInfo($el) { 102 function packInvoiceInfo($el) {
133 - var $goodsType = $('.invoice-goods-type .on', $el);  
134 - var resData = {}, 103 + var resData = { // 5.8.1需求,只支持电子发票(type: 2),发票内容只能开明细(id:12)
  104 + invocesType: 2,
  105 + contentId: 12,
  106 + contentName: '明细'
  107 + },
135 receiver = $('#receiver-phone', $el).val(); 108 receiver = $('#receiver-phone', $el).val();
136 109
137 - if ($('.pa-invoice', $el).hasClass('focus')) {  
138 - resData.invocesType = 1;  
139 - } else {  
140 - resData.invocesType = 2;  
141 - }  
142 -  
143 resData.titleId = $('.invoice-title .on', $el).data('id') || 1; 110 resData.titleId = $('.invoice-title .on', $el).data('id') || 1;
144 111
145 if (resData.titleId * 1 === 1) { 112 if (resData.titleId * 1 === 1) {
146 resData.titleName = '个人'; 113 resData.titleName = '个人';
147 } else { 114 } else {
148 resData.titleName = $('#company-name', $el).val(); 115 resData.titleName = $('#company-name', $el).val();
  116 + resData.taxNumber = $('#company-tax-num', $el).val();
149 } 117 }
150 118
151 - resData.contentId = $goodsType.data('id');  
152 - resData.contentName = $goodsType.data('name');  
153 -  
154 if (receiver) { 119 if (receiver) {
155 resData.receiver = receiver; 120 resData.receiver = receiver;
156 } 121 }
@@ -186,7 +151,7 @@ function invoiceEditDialog(baseInfo) { @@ -186,7 +151,7 @@ function invoiceEditDialog(baseInfo) {
186 btns: [ 151 btns: [
187 { 152 {
188 id: 'save-invoice', 153 id: 'save-invoice',
189 - name: '保存发票信息', 154 + name: '提交',
190 btnClass: ['save-invoice'], 155 btnClass: ['save-invoice'],
191 cb: function() { 156 cb: function() {
192 var info = packInvoiceInfo(invoice.$el); 157 var info = packInvoiceInfo(invoice.$el);
@@ -258,6 +223,7 @@ exports.getInvoice = function() { @@ -258,6 +223,7 @@ exports.getInvoice = function() {
258 invoicesType: invoiceInfo.invocesType, 223 invoicesType: invoiceInfo.invocesType,
259 invoicesTitle: invoiceInfo.titleName, 224 invoicesTitle: invoiceInfo.titleName,
260 invoicesContent: invoiceInfo.contentId, 225 invoicesContent: invoiceInfo.contentId,
  226 + taxNumber: invoiceInfo.taxNumber || '',
261 receiver: invoiceInfo.receiver === defaultReceiver.hide ? defaultReceiver.full : invoiceInfo.receiver 227 receiver: invoiceInfo.receiver === defaultReceiver.hide ? defaultReceiver.full : invoiceInfo.receiver
262 }; 228 };
263 }; 229 };
@@ -1555,10 +1555,12 @@ @@ -1555,10 +1555,12 @@
1555 .ensure-invoice-dialog { 1555 .ensure-invoice-dialog {
1556 $red: #d0021b; 1556 $red: #d0021b;
1557 1557
1558 - width: 440px; 1558 + width: 690px;
  1559 + padding: 20px 58px;
1559 font-size: 14px; 1560 font-size: 14px;
1560 color: #444; 1561 color: #444;
1561 background-color: #fff; 1562 background-color: #fff;
  1563 + box-sizing: border-box;
1562 1564
1563 > .close { 1565 > .close {
1564 display: none; 1566 display: none;
@@ -1601,31 +1603,17 @@ @@ -1601,31 +1603,17 @@
1601 } 1603 }
1602 1604
1603 .invoice-header { 1605 .invoice-header {
1604 - font-size: 18px;  
1605 - padding-bottom: 10px; 1606 + font-size: 14px;
  1607 + padding: 24px 0 20px;
1606 border-bottom: 1px solid #e8e8e8; 1608 border-bottom: 1px solid #e8e8e8;
1607 } 1609 }
1608 1610
1609 - .invoice-type {  
1610 - padding: 20px 0;  
1611 -  
1612 - > li {  
1613 - width: 98px;  
1614 - height: 28px;  
1615 - line-height: 28px;  
1616 - text-align: center;  
1617 - font-size: 14px;  
1618 - margin-right: 17px;  
1619 - border: 1px solid #505050;  
1620 - color: #505050;  
1621 - display: inline-block;  
1622 - cursor: pointer; 1611 + .invoice-content {
  1612 + font-weight: 300;
1623 } 1613 }
1624 1614
1625 - .focus {  
1626 - border-color: #d0021b;  
1627 - color: #d0021b;  
1628 - } 1615 + .row-title {
  1616 + font-weight: normal;
1629 } 1617 }
1630 1618
1631 .el-tip { 1619 .el-tip {
@@ -1634,15 +1622,24 @@ @@ -1634,15 +1622,24 @@
1634 line-height: 1.5; 1622 line-height: 1.5;
1635 1623
1636 > a { 1624 > a {
1637 - color: $red;  
1638 display: inline-block; 1625 display: inline-block;
1639 padding-top: 12px; 1626 padding-top: 12px;
  1627 + font-weight: 500;
  1628 + }
  1629 + }
  1630 +
  1631 + .invoice-type-text {
  1632 + line-height: 20px;
  1633 + padding: 20px 10px;
  1634 +
  1635 + .row-title {
  1636 + margin-right: 10px;
1640 } 1637 }
1641 } 1638 }
1642 1639
1643 .invoice-row { 1640 .invoice-row {
1644 padding-top: 16px; 1641 padding-top: 16px;
1645 - padding-left: 84px; 1642 + padding-left: 92px;
1646 overflow: hidden; 1643 overflow: hidden;
1647 1644
1648 .row-content { 1645 .row-content {
@@ -1652,7 +1649,7 @@ @@ -1652,7 +1649,7 @@
1652 .row-title { 1649 .row-title {
1653 line-height: 30px; 1650 line-height: 30px;
1654 position: absolute; 1651 position: absolute;
1655 - margin-left: -84px; 1652 + margin-left: -92px;
1656 1653
1657 > em { 1654 > em {
1658 color: $red; 1655 color: $red;
@@ -1669,9 +1666,11 @@ @@ -1669,9 +1666,11 @@
1669 } 1666 }
1670 1667
1671 input { 1668 input {
1672 - width: 194px;  
1673 - height: 26px; 1669 + width: 210px;
  1670 + height: 30px;
1674 padding: 0 10px; 1671 padding: 0 10px;
  1672 + background: #f5f5f5;
  1673 + border: 1px solid #e0e0e0;
1675 } 1674 }
1676 1675
1677 .red { 1676 .red {
@@ -1684,15 +1683,17 @@ @@ -1684,15 +1683,17 @@
1684 padding-bottom: 10px; 1683 padding-bottom: 10px;
1685 1684
1686 .btn { 1685 .btn {
1687 - width: 130px;  
1688 - height: 28px;  
1689 - line-height: 28px; 1686 + width: 140px;
  1687 + height: 40px;
  1688 + line-height: 38px;
  1689 + box-sizing: border-box;
1690 } 1690 }
1691 1691
1692 .save-invoice { 1692 .save-invoice {
1693 background-color: #000; 1693 background-color: #000;
1694 color: #fff; 1694 color: #fff;
1695 font-weight: 300; 1695 font-weight: 300;
  1696 + margin-right: 30px;
1696 } 1697 }
1697 } 1698 }
1698 } 1699 }