invoiceCode.js
3.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
// tabWorkOrder/pages/invoiceCode/invoiceCode.js
import commonApi from '~/api/api'
Page({
/**
* 页面的初始数据
*/
data: {
isloading: false,
codeInfo: {},
isShadeShow: false,
shadeObj: {
type: 'success',
title: '申请成功',
tipTxt: '已经开票成功,无法申请重开,有问题建议线下联系总部'
},
editFormData: [{
label: '销售方名称',
name: 'enterpriseName'
}, {
label: '开票金额',
name: 'invoiceAmount',
prefix: '¥'
}, {
label: '票通订单号',
name: 'tradeNo'
}, {
label: '生成时间',
name: 'tradeTime'
}, {
label: '二维码有效期',
name: 'expireTime'
}]
},
handleConfirm() {
let { codeInfo, isloading } = this.data
if (isloading) {
return true
}
const params = {
orderCode: codeInfo.bizOrderCode
}
wx.$util.showLoading()
this.setData({
isloading: true
})
commonApi.getOrderCode(params).then(res => {
console.log(res, 'res---')
let { invoiceInfo, invoiceIssueQrcode } = res.data
if (invoiceInfo) {
// 开票成功、开票失败
wx.$router.redirectTo("tabWorkOrder.invoiceResult", {
obj: {
// code - 0000:成功;其他:失败
code: invoiceInfo.code,
bizOrderCode: invoiceIssueQrcode.bizOrderCode,
invoiceAmount: invoiceIssueQrcode.invoiceAmount,
createdDate: invoiceIssueQrcode.createdDate,
imgUrl: invoiceInfo.imgUrl,
msg: invoiceInfo.msg
}
})
}
}).finally(() => {
wx.$util.hideLoading()
this.setData({
isloading: false
})
})
},
handleCancelInvoice() {
let { codeInfo, isloading } = this.data
console.log(codeInfo, '---')
if (isloading) {
return true
}
const params = {
qrcodeNo: codeInfo.qrcodeNo
}
this.setData({
isloading: true
})
commonApi.cancelInvoiceQrcode(params).then(res => {
console.log(res, 'res---')
let { code, data } = res
if(code == 0) {
this.setData({
isShadeShow: true,
'shadeObj.type': data.code == 0 ? 'success' : 'error',
'shadeObj.title': data.code == 0 ? '申请成功' : '申请失败',
'shadeObj.tipTxt': data.code == 0 ? '原开票二维码已经作废,请选择发票类型重新开票' : data.message,
})
}
}).finally(() => {
this.setData({
isloading: false
})
})
},
handleShadeConfirm() {
let { shadeObj } = this.data
this.setData({
isShadeShow: false
})
shadeObj.type == 'success' ? this.handleNewInvoce() : this.handleConfirm()
},
handleNewInvoce() {
let { codeInfo } = this.data
codeInfo.orderCode = codeInfo?.bizOrderCode || ''
getApp().globalData.selectInvoiceObj = { isOpen: true, codeInfo: JSON.parse(JSON.stringify(codeInfo)) };
wx.$router.back()
},
handleBack() {
let { isloading } = this.data
if (isloading) {
return true
}
getApp().globalData.selectInvoiceObj = { isOpen: false };
wx.$router.back()
},
onRoute(res) {
console.log(res)
this.setData({
codeInfo: JSON.parse(JSON.stringify(res.obj))
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})