handpos-client 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/service/GarbagePayWay.js +101 -101
- package/src/service/GarbageScanNative.js +116 -116
- package/src/service/PayWay.js +121 -121
- package/src/service/ScanNative.js +118 -118
- package/src/service/WriteCard.js +262 -262
- package/src/service/util.js +0 -2
package/src/service/WriteCard.js
CHANGED
|
@@ -1,262 +1,262 @@
|
|
|
1
|
-
import co from 'co'
|
|
2
|
-
import Vue from 'vue'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @author GaoChengLong Waki
|
|
6
|
-
* @date 2018/12/11 10:55
|
|
7
|
-
* 写卡服务
|
|
8
|
-
*
|
|
9
|
-
*/
|
|
10
|
-
export default class WriteCard {
|
|
11
|
-
constructor() {
|
|
12
|
-
console.log("WriteCard.js被初始化")
|
|
13
|
-
// 组件对象 在上一个服务被赋值
|
|
14
|
-
this.self = null
|
|
15
|
-
// 参数对象 在上一个服务被赋值
|
|
16
|
-
this.parame = null
|
|
17
|
-
this.timeOut = null
|
|
18
|
-
this.TimeOutObj = null
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
async doAction() {
|
|
22
|
-
console.log("WriteCard.js被启动")
|
|
23
|
-
await this.writeCard()
|
|
24
|
-
// 都走到这一步了,不论写卡的成功与否,都提交,因为收费记录已经写在数据库中,可以查到数据
|
|
25
|
-
return true
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
setComponents(components) {
|
|
29
|
-
this.self = components
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
async writeCard() {
|
|
33
|
-
if (this.TimeOutObj) {
|
|
34
|
-
await window.clearInterval(this.TimeOutObj)
|
|
35
|
-
}
|
|
36
|
-
await this.writeCardGen()
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
toReback() {
|
|
40
|
-
return co(this.writeBackGen())
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
toPrint() {
|
|
44
|
-
if (Vue.PosUtil.posParam.autoPrint) {
|
|
45
|
-
this.doPrint()
|
|
46
|
-
} else {
|
|
47
|
-
this.isPrint()
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
doPrint() {
|
|
52
|
-
let reprints = this.printGen()
|
|
53
|
-
return co(reprints)
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
commit() {
|
|
57
|
-
console.log("WriteCard.js被提交")
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
rollback() {
|
|
61
|
-
console.log("WriteCard.js被回滚")
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
timeoutAutoBack() {
|
|
65
|
-
if (Vue.PosUtil.posParam.AutoBack) {
|
|
66
|
-
this.TimeOutObj = window.setInterval(() => {
|
|
67
|
-
this.self.back('toMain')
|
|
68
|
-
}, Vue.PosUtil.posParam.AutoBackTime)
|
|
69
|
-
} else {
|
|
70
|
-
console.log('写卡失败等待重写写卡,不自动退出')
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
async isPrint() {
|
|
75
|
-
await this.self.$showNewMessage('提示', '退出前是否需要打印小票,点击"确认"打印,"取消"不打印', ['confirm', 'cancel'], 'newmgs').then((res) => {
|
|
76
|
-
this.self.$dispatch('openCountdown', this)
|
|
77
|
-
if (res === 'confirm') {
|
|
78
|
-
this.doPrint()
|
|
79
|
-
} else {
|
|
80
|
-
this.self.back('toMain')
|
|
81
|
-
}
|
|
82
|
-
})
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
* writeBack() {
|
|
86
|
-
this.self.backData.f_write_card = this.self.isWrited
|
|
87
|
-
this.self.backData.isback = (this.self.failCount < this.self.writeRetryTime)
|
|
88
|
-
return this.self.$
|
|
89
|
-
resolveMsg: null,
|
|
90
|
-
rejectMsg: null
|
|
91
|
-
})
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
* writeBackGen() {
|
|
95
|
-
let writebackret
|
|
96
|
-
try {
|
|
97
|
-
writebackret = yield co(this.writeBack())
|
|
98
|
-
if (writebackret.data.code === 200) {
|
|
99
|
-
if (Vue.PosUtil.posParam.noPrint) {
|
|
100
|
-
this.self.message = '写卡完成!稍后返回首页!!'
|
|
101
|
-
this.timeOut = window.setInterval(() => {
|
|
102
|
-
this.self.$dispatch('stopAudio')
|
|
103
|
-
this.self.back('toMain')
|
|
104
|
-
}, 6000)
|
|
105
|
-
} else {
|
|
106
|
-
this.toPrint()
|
|
107
|
-
}
|
|
108
|
-
} else if (writebackret.data.code === 201) {
|
|
109
|
-
this.self.back('写卡失败,退款成功!')
|
|
110
|
-
} else if (writebackret.data.code === 500) {
|
|
111
|
-
this.self.writeCard()
|
|
112
|
-
} else {
|
|
113
|
-
this.isPrint('写卡失败,退款失败,请打印凭证至营业厅处理!', '')
|
|
114
|
-
}
|
|
115
|
-
} catch (error) {
|
|
116
|
-
console.log(error)
|
|
117
|
-
if (!writebackret) {
|
|
118
|
-
this.self.message = '保存写卡结果失败,请检查网络连接正常再点击重新保存按钮'
|
|
119
|
-
this.self.isbackerro = true
|
|
120
|
-
}
|
|
121
|
-
if (error.status) {
|
|
122
|
-
this.self.$dispatch('stopAudio')
|
|
123
|
-
this.self.back('退款失败,请联系营业厅处理!')
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
* printGen() {
|
|
129
|
-
this.self.printFail = false
|
|
130
|
-
this.self.index = 0
|
|
131
|
-
this.self.message = '正在打印凭据,请稍等!'
|
|
132
|
-
let pres = this.print()
|
|
133
|
-
if (pres.code === 200) {
|
|
134
|
-
this.self.index = 0
|
|
135
|
-
this.self.message = '打印成功!稍后返回首页!!'
|
|
136
|
-
this.timeOut = window.setInterval(() => {
|
|
137
|
-
this.self.back('toMain')
|
|
138
|
-
}, 5000)
|
|
139
|
-
} else {
|
|
140
|
-
this.self.index = 2
|
|
141
|
-
this.self.message = '打印异常!请确保小票打印纸正常(无缺纸或无卡纸现象)和POS机电量充足(电量不足可直接插上电源)后,点击“重新打印”!'
|
|
142
|
-
this.self.printFail = true
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
async getParamGen() {
|
|
147
|
-
return await this.self.$
|
|
148
|
-
data: {f_card_id: this.self.cardInfo.CardID, f_alias: this.self.cardInfo.Factory, f_terminal_num: Vue.PosUtil.Sn}
|
|
149
|
-
}, {resolveMsg: null, rejectMsg: '获取写卡参数失败'})
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
async writeCardGen() {
|
|
153
|
-
let data = {
|
|
154
|
-
id: Number(this.self.stairPrice.id),
|
|
155
|
-
f_user_id: this.self.userInfo.f_user_id
|
|
156
|
-
}
|
|
157
|
-
this.self.isdone = false
|
|
158
|
-
this.self.isfail = false
|
|
159
|
-
this.self.index = 0
|
|
160
|
-
let cardParams, writeRes
|
|
161
|
-
try {
|
|
162
|
-
cardParams = await this.getParamGen()
|
|
163
|
-
if (!cardParams) {
|
|
164
|
-
this.self.index = 2
|
|
165
|
-
this.self.message = '获取写卡参数失败,请重新写卡或联系工作人员!'
|
|
166
|
-
this.self.isWrited = '写卡失败'
|
|
167
|
-
this.self.isdone = true
|
|
168
|
-
this.self.isfail = true
|
|
169
|
-
if (this.self.failCount <= this.self.writeRetryTime) {
|
|
170
|
-
co(this.writeBackGen())
|
|
171
|
-
}
|
|
172
|
-
return
|
|
173
|
-
}
|
|
174
|
-
let params = Vue.PosUtil.writeCardParams(cardParams, this.self)
|
|
175
|
-
this.self.message = '正在校验卡号...'
|
|
176
|
-
let readinfo = await Vue.AndroidPlugin.read()
|
|
177
|
-
if (readinfo.code !== 200 || readinfo.msg.CardID !== this.self.cardInfo.CardID) {
|
|
178
|
-
this.self.index = 2
|
|
179
|
-
this.self.message = '卡号校验失败,请使用正确的燃气卡重新写卡'
|
|
180
|
-
this.self.isWrited = '写卡失败'
|
|
181
|
-
if (this.self.failCount <= this.self.writeRetryTime) {
|
|
182
|
-
co(this.writeBackGen())
|
|
183
|
-
}
|
|
184
|
-
return
|
|
185
|
-
}
|
|
186
|
-
this.self.message = '卡号校验成功!正在写卡...'
|
|
187
|
-
writeRes = await Vue.AndroidPlugin.sell(params)
|
|
188
|
-
this.self.backData = Object.assign({}, writeRes.msg, this.self.backData)
|
|
189
|
-
if (writeRes.code === 200) {
|
|
190
|
-
this.self.index = 0
|
|
191
|
-
this.self.message = '写卡完成,正在更新写卡状态...'
|
|
192
|
-
this.self.isWrited = '已写卡'
|
|
193
|
-
this.self.$dispatch('stopAudio')
|
|
194
|
-
this.self.$dispatch('openquit')
|
|
195
|
-
this.self.isdone = true
|
|
196
|
-
this.self.isfail = false
|
|
197
|
-
co(this.writeBackGen())
|
|
198
|
-
} else {
|
|
199
|
-
this.self.index = 1
|
|
200
|
-
var errorMsg = writeRes.msg ? (!writeRes.msg.Err ? writeRes.msg.Exception : writeRes.msg.Err) : '写卡未知错误!'
|
|
201
|
-
this.self.message = errorMsg + ' 写卡失败!请重新写卡或联系工作人员!'
|
|
202
|
-
this.self.isWrited = '写卡失败'
|
|
203
|
-
if (this.self.failCount >= this.self.writeRetryTime) {
|
|
204
|
-
this.self.isdone = true
|
|
205
|
-
this.self.isfail = true
|
|
206
|
-
}
|
|
207
|
-
co(this.writeBackGen())
|
|
208
|
-
}
|
|
209
|
-
} catch (error) {
|
|
210
|
-
console.log('error', error.stack)
|
|
211
|
-
this.self.index = 1
|
|
212
|
-
this.self.message = '写卡异常!请重新写卡或联系工作人员!'
|
|
213
|
-
this.self.isWrited = '写卡失败'
|
|
214
|
-
this.self.isdone = true
|
|
215
|
-
this.self.isfail = true
|
|
216
|
-
co(this.writeBackGen())
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
print() {
|
|
221
|
-
// 清空打印内容
|
|
222
|
-
let printContent = []
|
|
223
|
-
// 抬头
|
|
224
|
-
var comName = Vue.PosUtil.posParam.companyName
|
|
225
|
-
|
|
226
|
-
printContent.push({type: 3, text: comName, fontsize: 3, isbold: true, align: 'center'})
|
|
227
|
-
printContent.push({type: 3, text: '自 助 购 气 凭 证', fontsize: 3, isbold: true, align: 'center'})
|
|
228
|
-
printContent.push({type: 3, text: '----------------------------', fontsize: 3, isbold: true, align: 'center'})
|
|
229
|
-
// 小票信息
|
|
230
|
-
printContent.push({type: 3, text: '用户编号:' + this.self.userInfo.f_userinfo_code, fontsize: 2, isbold: true, align: 'left'})
|
|
231
|
-
// 卡表用户显示卡号
|
|
232
|
-
// if (this.self.userInfo.f_meter_type !== '机表' && this.self.userInfo.f_meter_type !== '物联网表') {
|
|
233
|
-
// printContent.push({type: 3, text: '用户卡号:' + this.self.cardInfo.CardID, fontsize: 2, isbold: true, align: 'left'})
|
|
234
|
-
// }
|
|
235
|
-
printContent.push({type: 3, text: '用户姓名:' + this.self.userInfo.f_user_name, fontsize: 2, isbold: true, align: 'left'})
|
|
236
|
-
printContent.push({type: 3, text: '用户地址:' + this.self.userInfo.f_address, fontsize: 2, isbold: true, align: 'left'})
|
|
237
|
-
// 机表物联网表显示购买金额
|
|
238
|
-
if (this.self.userInfo.f_meter_type !== '机表' && this.self.userInfo.f_meter_type !== '物联网表' && this.self.userInfo.f_collection_type !== '按金额') {
|
|
239
|
-
printContent.push({type: 3, text: '购 气 量:' + this.self.stairPrice.f_pregas + '方', fontsize: 2, isbold: true, align: 'left'})
|
|
240
|
-
}
|
|
241
|
-
printContent.push({type: 3, text: '本次缴费:' + this.self.stairPrice.f_collection + '元', fontsize: 2, isbold: true, align: 'left'})
|
|
242
|
-
printContent.push({type: 3, text: '大 写:' + Vue.PosUtil.convertCurrency(this.self.stairPrice.f_collection), fontsize: 2, isbold: true, align: 'left'})
|
|
243
|
-
printContent.push({type: 3, text: '购气日期:' + Vue.PosUtil.getNowDate('yyyy-MM-dd'), fontsize: 2, isbold: true, align: 'left'})
|
|
244
|
-
printContent.push({type: 3, text: '终 端 号:' + Vue.PosUtil.Sn, fontsize: 2, isbold: true, align: 'left'})
|
|
245
|
-
printContent.push({type: 3, text: '支付流水号:' + this.self.stairPrice.f_serial_id, fontsize: 2, isbold: true, align: 'left'})
|
|
246
|
-
if (this.self.userInfo.f_meter_type !== '机表' && this.self.userInfo.f_meter_type !== '物联网表') {
|
|
247
|
-
printContent.push({type: 3, text: '写卡结果:' + this.self.isWrited, fontsize: 2, isbold: true, align: 'left'})
|
|
248
|
-
}
|
|
249
|
-
printContent.push({type: 3, text: '----------------------------', fontsize: 3, isbold: true, align: 'center'})
|
|
250
|
-
// 后台自定义打票内容
|
|
251
|
-
if (Vue.PosUtil.posParam.customizePrint && Vue.PosUtil.posParam.customizePrint.print) {
|
|
252
|
-
for (let p = 0; p < Vue.PosUtil.posParam.customizePrint.texts.length; p++) {
|
|
253
|
-
printContent.push({type: 3, text: Vue.PosUtil.posParam.customizePrint.texts[p], fontsize: Vue.PosUtil.posParam.customizePrint.size, isbold: true, align: 'left'})
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
printContent.push({type: 3, text: '', fontsize: 3, isbold: true, align: 'center'})
|
|
257
|
-
// 走纸
|
|
258
|
-
printContent.push({type: 4, value: 5, unit: 'pixel'})
|
|
259
|
-
// 打印
|
|
260
|
-
return Vue.AndroidPlugin.print(printContent)
|
|
261
|
-
}
|
|
262
|
-
}
|
|
1
|
+
import co from 'co'
|
|
2
|
+
import Vue from 'vue'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @author GaoChengLong Waki
|
|
6
|
+
* @date 2018/12/11 10:55
|
|
7
|
+
* 写卡服务
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
export default class WriteCard {
|
|
11
|
+
constructor() {
|
|
12
|
+
console.log("WriteCard.js被初始化")
|
|
13
|
+
// 组件对象 在上一个服务被赋值
|
|
14
|
+
this.self = null
|
|
15
|
+
// 参数对象 在上一个服务被赋值
|
|
16
|
+
this.parame = null
|
|
17
|
+
this.timeOut = null
|
|
18
|
+
this.TimeOutObj = null
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async doAction() {
|
|
22
|
+
console.log("WriteCard.js被启动")
|
|
23
|
+
await this.writeCard()
|
|
24
|
+
// 都走到这一步了,不论写卡的成功与否,都提交,因为收费记录已经写在数据库中,可以查到数据
|
|
25
|
+
return true
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
setComponents(components) {
|
|
29
|
+
this.self = components
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async writeCard() {
|
|
33
|
+
if (this.TimeOutObj) {
|
|
34
|
+
await window.clearInterval(this.TimeOutObj)
|
|
35
|
+
}
|
|
36
|
+
await this.writeCardGen()
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
toReback() {
|
|
40
|
+
return co(this.writeBackGen())
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
toPrint() {
|
|
44
|
+
if (Vue.PosUtil.posParam.autoPrint) {
|
|
45
|
+
this.doPrint()
|
|
46
|
+
} else {
|
|
47
|
+
this.isPrint()
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
doPrint() {
|
|
52
|
+
let reprints = this.printGen()
|
|
53
|
+
return co(reprints)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
commit() {
|
|
57
|
+
console.log("WriteCard.js被提交")
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
rollback() {
|
|
61
|
+
console.log("WriteCard.js被回滚")
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
timeoutAutoBack() {
|
|
65
|
+
if (Vue.PosUtil.posParam.AutoBack) {
|
|
66
|
+
this.TimeOutObj = window.setInterval(() => {
|
|
67
|
+
this.self.back('toMain')
|
|
68
|
+
}, Vue.PosUtil.posParam.AutoBackTime)
|
|
69
|
+
} else {
|
|
70
|
+
console.log('写卡失败等待重写写卡,不自动退出')
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async isPrint() {
|
|
75
|
+
await this.self.$showNewMessage('提示', '退出前是否需要打印小票,点击"确认"打印,"取消"不打印', ['confirm', 'cancel'], 'newmgs').then((res) => {
|
|
76
|
+
this.self.$dispatch('openCountdown', this)
|
|
77
|
+
if (res === 'confirm') {
|
|
78
|
+
this.doPrint()
|
|
79
|
+
} else {
|
|
80
|
+
this.self.back('toMain')
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
* writeBack() {
|
|
86
|
+
this.self.backData.f_write_card = this.self.isWrited
|
|
87
|
+
this.self.backData.isback = (this.self.failCount < this.self.writeRetryTime)
|
|
88
|
+
return this.self.$resetpost(Vue.ProxyUrl + 'rs/logic/' + Vue.PosUtil.posParam.revenue + 'writeBack', {data: this.self.backData}, {
|
|
89
|
+
resolveMsg: null,
|
|
90
|
+
rejectMsg: null
|
|
91
|
+
})
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
* writeBackGen() {
|
|
95
|
+
let writebackret
|
|
96
|
+
try {
|
|
97
|
+
writebackret = yield co(this.writeBack())
|
|
98
|
+
if (writebackret.data.code === 200) {
|
|
99
|
+
if (Vue.PosUtil.posParam.noPrint) {
|
|
100
|
+
this.self.message = '写卡完成!稍后返回首页!!'
|
|
101
|
+
this.timeOut = window.setInterval(() => {
|
|
102
|
+
this.self.$dispatch('stopAudio')
|
|
103
|
+
this.self.back('toMain')
|
|
104
|
+
}, 6000)
|
|
105
|
+
} else {
|
|
106
|
+
this.toPrint()
|
|
107
|
+
}
|
|
108
|
+
} else if (writebackret.data.code === 201) {
|
|
109
|
+
this.self.back('写卡失败,退款成功!')
|
|
110
|
+
} else if (writebackret.data.code === 500) {
|
|
111
|
+
this.self.writeCard()
|
|
112
|
+
} else {
|
|
113
|
+
this.isPrint('写卡失败,退款失败,请打印凭证至营业厅处理!', '')
|
|
114
|
+
}
|
|
115
|
+
} catch (error) {
|
|
116
|
+
console.log(error)
|
|
117
|
+
if (!writebackret) {
|
|
118
|
+
this.self.message = '保存写卡结果失败,请检查网络连接正常再点击重新保存按钮'
|
|
119
|
+
this.self.isbackerro = true
|
|
120
|
+
}
|
|
121
|
+
if (error.status) {
|
|
122
|
+
this.self.$dispatch('stopAudio')
|
|
123
|
+
this.self.back('退款失败,请联系营业厅处理!')
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
* printGen() {
|
|
129
|
+
this.self.printFail = false
|
|
130
|
+
this.self.index = 0
|
|
131
|
+
this.self.message = '正在打印凭据,请稍等!'
|
|
132
|
+
let pres = this.print()
|
|
133
|
+
if (pres.code === 200) {
|
|
134
|
+
this.self.index = 0
|
|
135
|
+
this.self.message = '打印成功!稍后返回首页!!'
|
|
136
|
+
this.timeOut = window.setInterval(() => {
|
|
137
|
+
this.self.back('toMain')
|
|
138
|
+
}, 5000)
|
|
139
|
+
} else {
|
|
140
|
+
this.self.index = 2
|
|
141
|
+
this.self.message = '打印异常!请确保小票打印纸正常(无缺纸或无卡纸现象)和POS机电量充足(电量不足可直接插上电源)后,点击“重新打印”!'
|
|
142
|
+
this.self.printFail = true
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
async getParamGen() {
|
|
147
|
+
return await this.self.$resetpost(Vue.ProxyUrl + 'rs/logic/' + Vue.PosUtil.posParam.revenue + 'stairCard', {
|
|
148
|
+
data: {f_card_id: this.self.cardInfo.CardID, f_alias: this.self.cardInfo.Factory, f_terminal_num: Vue.PosUtil.Sn}
|
|
149
|
+
}, {resolveMsg: null, rejectMsg: '获取写卡参数失败'})
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
async writeCardGen() {
|
|
153
|
+
let data = {
|
|
154
|
+
id: Number(this.self.stairPrice.id),
|
|
155
|
+
f_user_id: this.self.userInfo.f_user_id
|
|
156
|
+
}
|
|
157
|
+
this.self.isdone = false
|
|
158
|
+
this.self.isfail = false
|
|
159
|
+
this.self.index = 0
|
|
160
|
+
let cardParams, writeRes
|
|
161
|
+
try {
|
|
162
|
+
cardParams = await this.getParamGen()
|
|
163
|
+
if (!cardParams) {
|
|
164
|
+
this.self.index = 2
|
|
165
|
+
this.self.message = '获取写卡参数失败,请重新写卡或联系工作人员!'
|
|
166
|
+
this.self.isWrited = '写卡失败'
|
|
167
|
+
this.self.isdone = true
|
|
168
|
+
this.self.isfail = true
|
|
169
|
+
if (this.self.failCount <= this.self.writeRetryTime) {
|
|
170
|
+
co(this.writeBackGen())
|
|
171
|
+
}
|
|
172
|
+
return
|
|
173
|
+
}
|
|
174
|
+
let params = Vue.PosUtil.writeCardParams(cardParams, this.self)
|
|
175
|
+
this.self.message = '正在校验卡号...'
|
|
176
|
+
let readinfo = await Vue.AndroidPlugin.read()
|
|
177
|
+
if (readinfo.code !== 200 || readinfo.msg.CardID !== this.self.cardInfo.CardID) {
|
|
178
|
+
this.self.index = 2
|
|
179
|
+
this.self.message = '卡号校验失败,请使用正确的燃气卡重新写卡'
|
|
180
|
+
this.self.isWrited = '写卡失败'
|
|
181
|
+
if (this.self.failCount <= this.self.writeRetryTime) {
|
|
182
|
+
co(this.writeBackGen())
|
|
183
|
+
}
|
|
184
|
+
return
|
|
185
|
+
}
|
|
186
|
+
this.self.message = '卡号校验成功!正在写卡...'
|
|
187
|
+
writeRes = await Vue.AndroidPlugin.sell(params)
|
|
188
|
+
this.self.backData = Object.assign({}, writeRes.msg, this.self.backData)
|
|
189
|
+
if (writeRes.code === 200) {
|
|
190
|
+
this.self.index = 0
|
|
191
|
+
this.self.message = '写卡完成,正在更新写卡状态...'
|
|
192
|
+
this.self.isWrited = '已写卡'
|
|
193
|
+
this.self.$dispatch('stopAudio')
|
|
194
|
+
this.self.$dispatch('openquit')
|
|
195
|
+
this.self.isdone = true
|
|
196
|
+
this.self.isfail = false
|
|
197
|
+
co(this.writeBackGen())
|
|
198
|
+
} else {
|
|
199
|
+
this.self.index = 1
|
|
200
|
+
var errorMsg = writeRes.msg ? (!writeRes.msg.Err ? writeRes.msg.Exception : writeRes.msg.Err) : '写卡未知错误!'
|
|
201
|
+
this.self.message = errorMsg + ' 写卡失败!请重新写卡或联系工作人员!'
|
|
202
|
+
this.self.isWrited = '写卡失败'
|
|
203
|
+
if (this.self.failCount >= this.self.writeRetryTime) {
|
|
204
|
+
this.self.isdone = true
|
|
205
|
+
this.self.isfail = true
|
|
206
|
+
}
|
|
207
|
+
co(this.writeBackGen())
|
|
208
|
+
}
|
|
209
|
+
} catch (error) {
|
|
210
|
+
console.log('error', error.stack)
|
|
211
|
+
this.self.index = 1
|
|
212
|
+
this.self.message = '写卡异常!请重新写卡或联系工作人员!'
|
|
213
|
+
this.self.isWrited = '写卡失败'
|
|
214
|
+
this.self.isdone = true
|
|
215
|
+
this.self.isfail = true
|
|
216
|
+
co(this.writeBackGen())
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
print() {
|
|
221
|
+
// 清空打印内容
|
|
222
|
+
let printContent = []
|
|
223
|
+
// 抬头
|
|
224
|
+
var comName = Vue.PosUtil.posParam.companyName
|
|
225
|
+
|
|
226
|
+
printContent.push({type: 3, text: comName, fontsize: 3, isbold: true, align: 'center'})
|
|
227
|
+
printContent.push({type: 3, text: '自 助 购 气 凭 证', fontsize: 3, isbold: true, align: 'center'})
|
|
228
|
+
printContent.push({type: 3, text: '----------------------------', fontsize: 3, isbold: true, align: 'center'})
|
|
229
|
+
// 小票信息
|
|
230
|
+
printContent.push({type: 3, text: '用户编号:' + this.self.userInfo.f_userinfo_code, fontsize: 2, isbold: true, align: 'left'})
|
|
231
|
+
// 卡表用户显示卡号
|
|
232
|
+
// if (this.self.userInfo.f_meter_type !== '机表' && this.self.userInfo.f_meter_type !== '物联网表') {
|
|
233
|
+
// printContent.push({type: 3, text: '用户卡号:' + this.self.cardInfo.CardID, fontsize: 2, isbold: true, align: 'left'})
|
|
234
|
+
// }
|
|
235
|
+
printContent.push({type: 3, text: '用户姓名:' + this.self.userInfo.f_user_name, fontsize: 2, isbold: true, align: 'left'})
|
|
236
|
+
printContent.push({type: 3, text: '用户地址:' + this.self.userInfo.f_address, fontsize: 2, isbold: true, align: 'left'})
|
|
237
|
+
// 机表物联网表显示购买金额
|
|
238
|
+
if (this.self.userInfo.f_meter_type !== '机表' && this.self.userInfo.f_meter_type !== '物联网表' && this.self.userInfo.f_collection_type !== '按金额') {
|
|
239
|
+
printContent.push({type: 3, text: '购 气 量:' + this.self.stairPrice.f_pregas + '方', fontsize: 2, isbold: true, align: 'left'})
|
|
240
|
+
}
|
|
241
|
+
printContent.push({type: 3, text: '本次缴费:' + this.self.stairPrice.f_collection + '元', fontsize: 2, isbold: true, align: 'left'})
|
|
242
|
+
printContent.push({type: 3, text: '大 写:' + Vue.PosUtil.convertCurrency(this.self.stairPrice.f_collection), fontsize: 2, isbold: true, align: 'left'})
|
|
243
|
+
printContent.push({type: 3, text: '购气日期:' + Vue.PosUtil.getNowDate('yyyy-MM-dd'), fontsize: 2, isbold: true, align: 'left'})
|
|
244
|
+
printContent.push({type: 3, text: '终 端 号:' + Vue.PosUtil.Sn, fontsize: 2, isbold: true, align: 'left'})
|
|
245
|
+
printContent.push({type: 3, text: '支付流水号:' + this.self.stairPrice.f_serial_id, fontsize: 2, isbold: true, align: 'left'})
|
|
246
|
+
if (this.self.userInfo.f_meter_type !== '机表' && this.self.userInfo.f_meter_type !== '物联网表') {
|
|
247
|
+
printContent.push({type: 3, text: '写卡结果:' + this.self.isWrited, fontsize: 2, isbold: true, align: 'left'})
|
|
248
|
+
}
|
|
249
|
+
printContent.push({type: 3, text: '----------------------------', fontsize: 3, isbold: true, align: 'center'})
|
|
250
|
+
// 后台自定义打票内容
|
|
251
|
+
if (Vue.PosUtil.posParam.customizePrint && Vue.PosUtil.posParam.customizePrint.print) {
|
|
252
|
+
for (let p = 0; p < Vue.PosUtil.posParam.customizePrint.texts.length; p++) {
|
|
253
|
+
printContent.push({type: 3, text: Vue.PosUtil.posParam.customizePrint.texts[p], fontsize: Vue.PosUtil.posParam.customizePrint.size, isbold: true, align: 'left'})
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
printContent.push({type: 3, text: '', fontsize: 3, isbold: true, align: 'center'})
|
|
257
|
+
// 走纸
|
|
258
|
+
printContent.push({type: 4, value: 5, unit: 'pixel'})
|
|
259
|
+
// 打印
|
|
260
|
+
return Vue.AndroidPlugin.print(printContent)
|
|
261
|
+
}
|
|
262
|
+
}
|