Authored by yyq

Merge branch 'feature/homeInvoice' into release/6.1

... ... @@ -109,20 +109,68 @@ function validateInvoice($el, info) {
return pass;
}
function supplyInvoice(info) {
function viewInvoice(code) {
if (!code) {
return;
}
$.ajax({
url: '/home/invoice/detail',
type: 'GET',
data: {orderCode: code}
}).done(function(res) {
if (res.code !== 200) {
return;
}
new Dialog({
className: 'invoice-me-page invoice-detail-dialog',
content: detailTpl(res.data)
}).show();
});
}
function supplyInvoice(info, cb) {
$.ajax({
url: '/home/invoice/supply',
type: 'POST',
data: info
}).done(function(res) {
var _dg, _btn;
cb && cb(res); // eslint-disable-line
if (res.code === 200) {
history.go(0);
if (res.data.issueType === 2) {
_btn = {
name: '查看发票',
cb: function() {
viewInvoice(res.data.order_code);
}
};
} else {
_btn = {name: '我知道了'};
}
_dg = new Dialog({
className: 'invoice-me-page supply-success-dialog',
content: '<h2>提交成功</h2><p>您的服务申请已提交,您可以在我的发票中下载电子发票</p>',
btns: [{
id: 'close-dg',
name: _btn.name,
btnClass: ['close-dg'],
cb: function() {
_dg.close();
_btn.cb && _btn.cb();
}
}]
}).show();
}
});
}
$('#me-invoice-orders').on('click', '.supply-invoice', function() {
var code = $(this).data('id');
var $this = $(this);
var dg = new Dialog({
className: 'invoice-me-page invoice-supply-dialog',
content: invoiceTpl,
... ... @@ -133,10 +181,24 @@ $('#me-invoice-orders').on('click', '.supply-invoice', function() {
cb: function() {
var info = packInvoiceInfo(dg.$el);
if (validateInvoice(dg.$el, info)) {
info.orderCode = code;
supplyInvoice(info);
if (!validateInvoice(dg.$el, info)) {
return;
}
info.orderCode = $(this).data('id');
supplyInvoice(info, function(data) {
if (data.code !== 200) {
return;
}
dg.close();
if (+data.issueType === 2) {
$this.removeClass('supply-invoice').addClass('view-invoice').text('查看发票');
} else {
$this.removeClass('supply-invoice').addClass('on-invoice').text('开票中');
}
});
}
}, {
id: 'cancel-apply',
... ... @@ -151,20 +213,5 @@ $('#me-invoice-orders').on('click', '.supply-invoice', function() {
// 事件绑定
bindSupplyDialogEvent(dg.$el);
}).on('click', '.view-invoice', function() {
var code = $(this).data('id');
$.ajax({
url: '/home/invoice/detail',
type: 'GET',
data: {orderCode: code}
}).done(function(res) {
if (res.code !== 200) {
return;
}
new Dialog({
className: 'invoice-me-page invoice-detail-dialog',
content: detailTpl(res.data)
}).show();
});
viewInvoice($(this).data('id'));
});
... ...
... ... @@ -241,4 +241,21 @@
}
}
}
&.supply-success-dialog {
background-color: #fff;
font-size: 14px;
.content {
width: 300px;
padding: 0 30px 40px;
line-height: 2;
color: #444;
h2 {
font-size: 18px;
margin-bottom: 26px;
}
}
}
}
... ...