handpos-client 1.0.2 → 1.0.4
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/components/garbage/GarbagePayWay.vue +233 -199
- package/src/components/main/CardMain.vue +47 -47
- package/src/service/CheckCard.js +111 -103
- 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 +84 -0
package/src/service/CheckCard.js
CHANGED
|
@@ -1,103 +1,111 @@
|
|
|
1
|
-
import Vue from 'vue'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @author GaoChengLong
|
|
5
|
-
* @date 2018/12/7 16:38
|
|
6
|
-
* 轮询检测卡并且读卡获取卡信息
|
|
7
|
-
*/
|
|
8
|
-
export default class CheckCard {
|
|
9
|
-
|
|
10
|
-
constructor(components) {
|
|
11
|
-
this.self = components
|
|
12
|
-
// 助记执行次数
|
|
13
|
-
this.count = 0
|
|
14
|
-
// 承诺函数助记符
|
|
15
|
-
this.resolve = null
|
|
16
|
-
// 拒绝函数助记符
|
|
17
|
-
this.reject = null
|
|
18
|
-
// 计时器
|
|
19
|
-
this.timeOut = null
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
doAction() {
|
|
23
|
-
return new Promise((resolve, reject) => {
|
|
24
|
-
this.resolve = resolve
|
|
25
|
-
this.reject = reject
|
|
26
|
-
let obj = this
|
|
27
|
-
this.timeOut = window.setInterval(() => {
|
|
28
|
-
obj.checkCard(obj)
|
|
29
|
-
}, 1000)
|
|
30
|
-
})
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
commit() {
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
rollback() {
|
|
38
|
-
this.self.cardInfo = {}
|
|
39
|
-
this.self.userInfo = {}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// 检测是否有卡
|
|
43
|
-
async checkCard(obj) {
|
|
44
|
-
if (obj.count === 0) {
|
|
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
|
-
this
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
this.self
|
|
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
|
-
}
|
|
1
|
+
import Vue from 'vue'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @author GaoChengLong
|
|
5
|
+
* @date 2018/12/7 16:38
|
|
6
|
+
* 轮询检测卡并且读卡获取卡信息
|
|
7
|
+
*/
|
|
8
|
+
export default class CheckCard {
|
|
9
|
+
|
|
10
|
+
constructor(components) {
|
|
11
|
+
this.self = components
|
|
12
|
+
// 助记执行次数
|
|
13
|
+
this.count = 0
|
|
14
|
+
// 承诺函数助记符
|
|
15
|
+
this.resolve = null
|
|
16
|
+
// 拒绝函数助记符
|
|
17
|
+
this.reject = null
|
|
18
|
+
// 计时器
|
|
19
|
+
this.timeOut = null
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
doAction() {
|
|
23
|
+
return new Promise((resolve, reject) => {
|
|
24
|
+
this.resolve = resolve
|
|
25
|
+
this.reject = reject
|
|
26
|
+
let obj = this
|
|
27
|
+
this.timeOut = window.setInterval(() => {
|
|
28
|
+
obj.checkCard(obj)
|
|
29
|
+
}, 1000)
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
commit() {
|
|
34
|
+
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
rollback() {
|
|
38
|
+
this.self.cardInfo = {}
|
|
39
|
+
this.self.userInfo = {}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// 检测是否有卡
|
|
43
|
+
async checkCard(obj) {
|
|
44
|
+
if (obj.count === 0) {
|
|
45
|
+
if (Vue.phoneBuild){
|
|
46
|
+
obj.self.$showMessage('正在检查卡槽是否有卡', 'success', 1000)
|
|
47
|
+
}else {
|
|
48
|
+
obj.self.$showAlert('正在检查卡槽是否有卡', 'success', 2000)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (obj.count % 10 === 0 && obj.count !== 0) {
|
|
52
|
+
// 关闭定时器
|
|
53
|
+
clearInterval(obj.timeOut)
|
|
54
|
+
// 弹出框,如果点确定则退出到主界面,如果点取消则继续轮询
|
|
55
|
+
obj.errorInfo('未检测到卡,请检查卡槽是否有卡或异物!', obj.resolve)
|
|
56
|
+
} else if (obj.count % 2 === 0) {
|
|
57
|
+
this.self.$closeAlert()
|
|
58
|
+
let ret = await Vue.AndroidPlugin.hasCard(obj.count)
|
|
59
|
+
if (ret) {
|
|
60
|
+
// 关闭定时器
|
|
61
|
+
clearInterval(obj.timeOut)
|
|
62
|
+
obj.readCard()
|
|
63
|
+
}
|
|
64
|
+
obj.count++
|
|
65
|
+
} else {
|
|
66
|
+
obj.count++
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async readCard() {
|
|
71
|
+
// this指针被指向CheckCard
|
|
72
|
+
if (Vue.phoneBuild){
|
|
73
|
+
this.self.$showMessage('正在读卡,请稍后', 'success', 1000)
|
|
74
|
+
}else {
|
|
75
|
+
this.self.$showAlert('正在读卡,请稍后', 'success', 1000)
|
|
76
|
+
}
|
|
77
|
+
// 清空cardInfo缓存
|
|
78
|
+
this.self.cardInfo = {}
|
|
79
|
+
this.self.userInfo = {}
|
|
80
|
+
let jo = await Vue.AndroidPlugin.read()
|
|
81
|
+
this.self.$closeAlert()
|
|
82
|
+
if (jo.code === 200) {
|
|
83
|
+
this.self.cardInfo = jo.msg
|
|
84
|
+
// 读卡成功,已成功拿到卡信息,现在开始执行下一个服务
|
|
85
|
+
this.resolve(true)
|
|
86
|
+
} else if (jo.code === 500) {
|
|
87
|
+
this.errorInfo(jo.msg + ',请检查卡是否插好!')
|
|
88
|
+
} else {
|
|
89
|
+
this.errorInfo('调用读卡器失败,请联系管理员!')
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* 错误提示框,点确定则返回到主界面,点取消则继续执行轮询
|
|
95
|
+
* */
|
|
96
|
+
errorInfo(msg) {
|
|
97
|
+
this.count = 0
|
|
98
|
+
this.self.$showNewMessage('错误', msg + '(点击\'确定\'返回主页,点击\'取消\'继续读卡)', ['confirm', 'cancel'], 'newmgs')
|
|
99
|
+
.then((res) => {
|
|
100
|
+
if (res === 'confirm') {
|
|
101
|
+
this.self.back()
|
|
102
|
+
this.resolve(false)
|
|
103
|
+
} else {
|
|
104
|
+
let obj = this
|
|
105
|
+
this.timeOut = window.setInterval(() => {
|
|
106
|
+
obj.checkCard(obj)
|
|
107
|
+
}, 1000)
|
|
108
|
+
}
|
|
109
|
+
})
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -1,101 +1,101 @@
|
|
|
1
|
-
import co from 'co'
|
|
2
|
-
import Vue from 'vue'
|
|
3
|
-
|
|
4
|
-
export default class GarbagePayWay {
|
|
5
|
-
constructor (components) {
|
|
6
|
-
console.log('GarbagePayWay.js被初始化')
|
|
7
|
-
this.self = components
|
|
8
|
-
// 承诺函数助记符
|
|
9
|
-
this.resolve = null
|
|
10
|
-
// 拒绝函数助记符
|
|
11
|
-
this.reject = null
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// 该服务为异步服务,故此doAction中只返回Promise对象,并不对其进行执行操作
|
|
15
|
-
doAction () {
|
|
16
|
-
this.self.$goto('garbage-pay-way', {
|
|
17
|
-
garbage: this.self.garbage,
|
|
18
|
-
userInfo: this.self.userInfo,
|
|
19
|
-
obj: this
|
|
20
|
-
}, 'self', this.self.back)
|
|
21
|
-
return new Promise((resolve, reject) => {
|
|
22
|
-
// 只要不执行承诺或者拒绝函数该服务就永远不会切换到下一个服务
|
|
23
|
-
this.resolve = resolve
|
|
24
|
-
this.reject = reject
|
|
25
|
-
})
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
commit () {
|
|
29
|
-
console.log('GarbagePayWay.js被提交')
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
rollback () {
|
|
33
|
-
console.log('GarbagePayWay.js被回滚')
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
setComponents (components) {
|
|
37
|
-
this.self = components
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
getQR () {
|
|
41
|
-
let attach = this.getAttach()
|
|
42
|
-
let gen = this.generateScan(this.self, attach)
|
|
43
|
-
return co(gen)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// 组织attach - 垃圾费专用
|
|
47
|
-
getAttach () {
|
|
48
|
-
let attach = {}
|
|
49
|
-
// 用户编号
|
|
50
|
-
attach[Vue.PosUtil.posParam.userCondition] = this.self.userInfo[Vue.PosUtil.posParam.userCondition]
|
|
51
|
-
attach.f_terminal_num = Vue.PosUtil.Sn
|
|
52
|
-
// 实交金额
|
|
53
|
-
attach.f_collection = this.self.garbage.money
|
|
54
|
-
attach.f_user_name = this.self.userInfo.f_user_name
|
|
55
|
-
attach.f_address = this.self.userInfo.f_address
|
|
56
|
-
attach.f_pay_type = '垃圾费'
|
|
57
|
-
// 实交金额(如果存在账户余额)
|
|
58
|
-
attach.f_totalcost = attach.f_collection
|
|
59
|
-
attach.number = this.self.garbage.list.length
|
|
60
|
-
attach.isHand = 2
|
|
61
|
-
return attach
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// 支付下单 - 垃圾费专用
|
|
65
|
-
* generateScan (self, attach) {
|
|
66
|
-
// 支付金额元转分(测试环境支付金额统一改为1分)
|
|
67
|
-
let money = Vue.PosUtil.posParam.isTest ? 1 : Vue.PosUtil.yuan2fen(this.self.garbage.money)
|
|
68
|
-
|
|
69
|
-
// post去后台给微信下单并生成二维码和流水号
|
|
70
|
-
self.$
|
|
71
|
-
config: self.$PosUtil.posParam.config,
|
|
72
|
-
f_revenue: Vue.PosUtil.posParam.revenue,
|
|
73
|
-
pay_way: self.payInfo.pay_way,
|
|
74
|
-
money: money + '',
|
|
75
|
-
attach: attach
|
|
76
|
-
}, {resolveMsg: null, rejectMsg: null}).then((ret) => {
|
|
77
|
-
// 下单成功
|
|
78
|
-
if (ret.data.code === 200) {
|
|
79
|
-
self.payInfo.url = ret.data.url
|
|
80
|
-
self.payInfo.f_serial_id = ret.data.f_out_trade_no
|
|
81
|
-
self.$goto('garbage-scan-native', {
|
|
82
|
-
payInfo: self.payInfo,
|
|
83
|
-
garbageInfo: self.garbage,
|
|
84
|
-
userInfo: self.userInfo,
|
|
85
|
-
obj: this.next
|
|
86
|
-
}, 'self', self.back)
|
|
87
|
-
// 设置下一个服务状态为扫码支付,开始需要去轮询数据库
|
|
88
|
-
this.next.isQR = true
|
|
89
|
-
this.resolve(true)
|
|
90
|
-
} else {
|
|
91
|
-
// 下单失败
|
|
92
|
-
self.$back('下单失败,请重新下单')
|
|
93
|
-
this.resolve(false)
|
|
94
|
-
}
|
|
95
|
-
}).catch((ret) => {
|
|
96
|
-
console.log('垃圾费下单异常,异常返回==>', ret)
|
|
97
|
-
self.$back('下单失败,请重新下单')
|
|
98
|
-
this.resolve(false)
|
|
99
|
-
})
|
|
100
|
-
}
|
|
101
|
-
}
|
|
1
|
+
import co from 'co'
|
|
2
|
+
import Vue from 'vue'
|
|
3
|
+
|
|
4
|
+
export default class GarbagePayWay {
|
|
5
|
+
constructor (components) {
|
|
6
|
+
console.log('GarbagePayWay.js被初始化')
|
|
7
|
+
this.self = components
|
|
8
|
+
// 承诺函数助记符
|
|
9
|
+
this.resolve = null
|
|
10
|
+
// 拒绝函数助记符
|
|
11
|
+
this.reject = null
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// 该服务为异步服务,故此doAction中只返回Promise对象,并不对其进行执行操作
|
|
15
|
+
doAction () {
|
|
16
|
+
this.self.$goto('garbage-pay-way', {
|
|
17
|
+
garbage: this.self.garbage,
|
|
18
|
+
userInfo: this.self.userInfo,
|
|
19
|
+
obj: this
|
|
20
|
+
}, 'self', this.self.back)
|
|
21
|
+
return new Promise((resolve, reject) => {
|
|
22
|
+
// 只要不执行承诺或者拒绝函数该服务就永远不会切换到下一个服务
|
|
23
|
+
this.resolve = resolve
|
|
24
|
+
this.reject = reject
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
commit () {
|
|
29
|
+
console.log('GarbagePayWay.js被提交')
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
rollback () {
|
|
33
|
+
console.log('GarbagePayWay.js被回滚')
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
setComponents (components) {
|
|
37
|
+
this.self = components
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
getQR () {
|
|
41
|
+
let attach = this.getAttach()
|
|
42
|
+
let gen = this.generateScan(this.self, attach)
|
|
43
|
+
return co(gen)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// 组织attach - 垃圾费专用
|
|
47
|
+
getAttach () {
|
|
48
|
+
let attach = {}
|
|
49
|
+
// 用户编号
|
|
50
|
+
attach[Vue.PosUtil.posParam.userCondition] = this.self.userInfo[Vue.PosUtil.posParam.userCondition]
|
|
51
|
+
attach.f_terminal_num = Vue.PosUtil.Sn
|
|
52
|
+
// 实交金额
|
|
53
|
+
attach.f_collection = this.self.garbage.money
|
|
54
|
+
attach.f_user_name = this.self.userInfo.f_user_name
|
|
55
|
+
attach.f_address = this.self.userInfo.f_address
|
|
56
|
+
attach.f_pay_type = '垃圾费'
|
|
57
|
+
// 实交金额(如果存在账户余额)
|
|
58
|
+
attach.f_totalcost = attach.f_collection
|
|
59
|
+
attach.number = this.self.garbage.list.length
|
|
60
|
+
attach.isHand = 2
|
|
61
|
+
return attach
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// 支付下单 - 垃圾费专用
|
|
65
|
+
* generateScan (self, attach) {
|
|
66
|
+
// 支付金额元转分(测试环境支付金额统一改为1分)
|
|
67
|
+
let money = Vue.PosUtil.posParam.isTest ? 1 : Vue.PosUtil.yuan2fen(this.self.garbage.money)
|
|
68
|
+
|
|
69
|
+
// post去后台给微信下单并生成二维码和流水号
|
|
70
|
+
self.$resetpost(Vue.ProxyUrl + 'rs/logic/' + Vue.PosUtil.posParam.module + 'GetCode', {
|
|
71
|
+
config: self.$PosUtil.posParam.config,
|
|
72
|
+
f_revenue: Vue.PosUtil.posParam.revenue,
|
|
73
|
+
pay_way: self.payInfo.pay_way,
|
|
74
|
+
money: money + '',
|
|
75
|
+
attach: attach
|
|
76
|
+
}, {resolveMsg: null, rejectMsg: null}).then((ret) => {
|
|
77
|
+
// 下单成功
|
|
78
|
+
if (ret.data.code === 200) {
|
|
79
|
+
self.payInfo.url = ret.data.url
|
|
80
|
+
self.payInfo.f_serial_id = ret.data.f_out_trade_no
|
|
81
|
+
self.$goto('garbage-scan-native', {
|
|
82
|
+
payInfo: self.payInfo,
|
|
83
|
+
garbageInfo: self.garbage,
|
|
84
|
+
userInfo: self.userInfo,
|
|
85
|
+
obj: this.next
|
|
86
|
+
}, 'self', self.back)
|
|
87
|
+
// 设置下一个服务状态为扫码支付,开始需要去轮询数据库
|
|
88
|
+
this.next.isQR = true
|
|
89
|
+
this.resolve(true)
|
|
90
|
+
} else {
|
|
91
|
+
// 下单失败
|
|
92
|
+
self.$back('下单失败,请重新下单')
|
|
93
|
+
this.resolve(false)
|
|
94
|
+
}
|
|
95
|
+
}).catch((ret) => {
|
|
96
|
+
console.log('垃圾费下单异常,异常返回==>', ret)
|
|
97
|
+
self.$back('下单失败,请重新下单')
|
|
98
|
+
this.resolve(false)
|
|
99
|
+
})
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -1,116 +1,116 @@
|
|
|
1
|
-
import Vue from 'vue'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @author System
|
|
5
|
-
* @date 2024/01/26
|
|
6
|
-
* 垃圾费轮询数据库服务,默认不启用,直接跳过该服务
|
|
7
|
-
*/
|
|
8
|
-
export default class GarbageScanNative {
|
|
9
|
-
constructor () {
|
|
10
|
-
console.log('GarbageScanNative.js被初始化')
|
|
11
|
-
// 承诺函数助记符
|
|
12
|
-
this.resolve = null
|
|
13
|
-
// 拒绝函数助记符
|
|
14
|
-
this.reject = null
|
|
15
|
-
// 是否为扫码支付的方式进入该服务
|
|
16
|
-
this.isQR = false
|
|
17
|
-
// 计时器
|
|
18
|
-
this.timer1 = null
|
|
19
|
-
this.timer2 = null
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
doAction () {
|
|
23
|
-
console.log('GarbageScanNative.js被启动')
|
|
24
|
-
// 在进入该服务之前,如果为扫码支付的话,需要在上一个服务把该服务的isQR值修改为true
|
|
25
|
-
if (this.isQR) {
|
|
26
|
-
return new Promise((resolve, reject) => {
|
|
27
|
-
this.resolve = resolve
|
|
28
|
-
this.reject = reject
|
|
29
|
-
})
|
|
30
|
-
} else {
|
|
31
|
-
return true
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
commit () {
|
|
36
|
-
console.log('GarbageScanNative.js被提交')
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
rollback () {
|
|
40
|
-
console.log('GarbageScanNative.js被回滚')
|
|
41
|
-
window.clearInterval(this.timer1)
|
|
42
|
-
window.clearInterval(this.timer2)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
setComponents (components) {
|
|
46
|
-
this.self = components
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
startService () {
|
|
50
|
-
this.timer1 = window.setInterval(() => {
|
|
51
|
-
this.outOfPage(this, this.self)
|
|
52
|
-
}, 1000)
|
|
53
|
-
this.timer2 = window.setInterval(() => {
|
|
54
|
-
this.setRemainTime(this, this.self)
|
|
55
|
-
}, 5000)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
outOfPage (obj, components) {
|
|
59
|
-
// 调用定时器
|
|
60
|
-
if (components.countDown > 16 && !components.isTimeout && components.second > 0) {
|
|
61
|
-
--components.second
|
|
62
|
-
--components.countDown
|
|
63
|
-
components.isTimeout = false
|
|
64
|
-
} else if (components.countDown > 1 && !components.isTimeout) {
|
|
65
|
-
--components.countDown
|
|
66
|
-
--components.second
|
|
67
|
-
components.isTimeout = true
|
|
68
|
-
components.setAddress()
|
|
69
|
-
} else if (components.countDown > 0 && components.isTimeout) {
|
|
70
|
-
--components.countDown
|
|
71
|
-
--components.second
|
|
72
|
-
window.clearInterval(obj.timer2)
|
|
73
|
-
} else {
|
|
74
|
-
// 超时 停止计时器
|
|
75
|
-
window.clearInterval(obj.timer1)
|
|
76
|
-
if (components.iserro) {
|
|
77
|
-
obj.resolve(false)
|
|
78
|
-
components.$back('error')
|
|
79
|
-
} else {
|
|
80
|
-
obj.resolve(false)
|
|
81
|
-
components.$back('timeOut')
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
setRemainTime (obj, components) {
|
|
87
|
-
obj.getOrderInfo(obj, components)
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
getOrderInfo(obj, self) {
|
|
91
|
-
// if (!Vue.AndroidPlugin.isAndroid && !Vue.AndroidPlugin.isPc) {
|
|
92
|
-
// self.$showNewMessage('提示', '缴费完成,点击"确认"返回主界面重新读卡购气', ['confirm'], 'newmgs').then(() => {
|
|
93
|
-
// window.setInterval(self.callBack('toMain'),6000)
|
|
94
|
-
// })
|
|
95
|
-
// this.resolve(true)
|
|
96
|
-
// }
|
|
97
|
-
|
|
98
|
-
let data = {
|
|
99
|
-
f_serial_id: self.payInfo.f_serial_id
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
self.$
|
|
103
|
-
resolveMsg: null, rejectMsg: null
|
|
104
|
-
}).then((ret) => {
|
|
105
|
-
if (ret.data.length === 1) {
|
|
106
|
-
self.$showNewMessage('提示', '缴费完成,点击"确认"返回主界面重新读卡购气', ['confirm'], 'newmgs').then(() => {
|
|
107
|
-
self.callBack('toMain')
|
|
108
|
-
})
|
|
109
|
-
this.resolve(true)
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
).catch((ret) => {
|
|
113
|
-
self.hasError(ret)
|
|
114
|
-
})
|
|
115
|
-
}
|
|
116
|
-
}
|
|
1
|
+
import Vue from 'vue'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @author System
|
|
5
|
+
* @date 2024/01/26
|
|
6
|
+
* 垃圾费轮询数据库服务,默认不启用,直接跳过该服务
|
|
7
|
+
*/
|
|
8
|
+
export default class GarbageScanNative {
|
|
9
|
+
constructor () {
|
|
10
|
+
console.log('GarbageScanNative.js被初始化')
|
|
11
|
+
// 承诺函数助记符
|
|
12
|
+
this.resolve = null
|
|
13
|
+
// 拒绝函数助记符
|
|
14
|
+
this.reject = null
|
|
15
|
+
// 是否为扫码支付的方式进入该服务
|
|
16
|
+
this.isQR = false
|
|
17
|
+
// 计时器
|
|
18
|
+
this.timer1 = null
|
|
19
|
+
this.timer2 = null
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
doAction () {
|
|
23
|
+
console.log('GarbageScanNative.js被启动')
|
|
24
|
+
// 在进入该服务之前,如果为扫码支付的话,需要在上一个服务把该服务的isQR值修改为true
|
|
25
|
+
if (this.isQR) {
|
|
26
|
+
return new Promise((resolve, reject) => {
|
|
27
|
+
this.resolve = resolve
|
|
28
|
+
this.reject = reject
|
|
29
|
+
})
|
|
30
|
+
} else {
|
|
31
|
+
return true
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
commit () {
|
|
36
|
+
console.log('GarbageScanNative.js被提交')
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
rollback () {
|
|
40
|
+
console.log('GarbageScanNative.js被回滚')
|
|
41
|
+
window.clearInterval(this.timer1)
|
|
42
|
+
window.clearInterval(this.timer2)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
setComponents (components) {
|
|
46
|
+
this.self = components
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
startService () {
|
|
50
|
+
this.timer1 = window.setInterval(() => {
|
|
51
|
+
this.outOfPage(this, this.self)
|
|
52
|
+
}, 1000)
|
|
53
|
+
this.timer2 = window.setInterval(() => {
|
|
54
|
+
this.setRemainTime(this, this.self)
|
|
55
|
+
}, 5000)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
outOfPage (obj, components) {
|
|
59
|
+
// 调用定时器
|
|
60
|
+
if (components.countDown > 16 && !components.isTimeout && components.second > 0) {
|
|
61
|
+
--components.second
|
|
62
|
+
--components.countDown
|
|
63
|
+
components.isTimeout = false
|
|
64
|
+
} else if (components.countDown > 1 && !components.isTimeout) {
|
|
65
|
+
--components.countDown
|
|
66
|
+
--components.second
|
|
67
|
+
components.isTimeout = true
|
|
68
|
+
components.setAddress()
|
|
69
|
+
} else if (components.countDown > 0 && components.isTimeout) {
|
|
70
|
+
--components.countDown
|
|
71
|
+
--components.second
|
|
72
|
+
window.clearInterval(obj.timer2)
|
|
73
|
+
} else {
|
|
74
|
+
// 超时 停止计时器
|
|
75
|
+
window.clearInterval(obj.timer1)
|
|
76
|
+
if (components.iserro) {
|
|
77
|
+
obj.resolve(false)
|
|
78
|
+
components.$back('error')
|
|
79
|
+
} else {
|
|
80
|
+
obj.resolve(false)
|
|
81
|
+
components.$back('timeOut')
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
setRemainTime (obj, components) {
|
|
87
|
+
obj.getOrderInfo(obj, components)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
getOrderInfo(obj, self) {
|
|
91
|
+
// if (!Vue.AndroidPlugin.isAndroid && !Vue.AndroidPlugin.isPc) {
|
|
92
|
+
// self.$showNewMessage('提示', '缴费完成,点击"确认"返回主界面重新读卡购气', ['confirm'], 'newmgs').then(() => {
|
|
93
|
+
// window.setInterval(self.callBack('toMain'),6000)
|
|
94
|
+
// })
|
|
95
|
+
// this.resolve(true)
|
|
96
|
+
// }
|
|
97
|
+
|
|
98
|
+
let data = {
|
|
99
|
+
f_serial_id: self.payInfo.f_serial_id
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
self.$resetpost(Vue.ProxyUrl + 'rs/logic/' + Vue.PosUtil.posParam.revenue + 'getSellGasInfo', { data: data }, {
|
|
103
|
+
resolveMsg: null, rejectMsg: null
|
|
104
|
+
}).then((ret) => {
|
|
105
|
+
if (ret.data.length === 1) {
|
|
106
|
+
self.$showNewMessage('提示', '缴费完成,点击"确认"返回主界面重新读卡购气', ['confirm'], 'newmgs').then(() => {
|
|
107
|
+
self.callBack('toMain')
|
|
108
|
+
})
|
|
109
|
+
this.resolve(true)
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
).catch((ret) => {
|
|
113
|
+
self.hasError(ret)
|
|
114
|
+
})
|
|
115
|
+
}
|
|
116
|
+
}
|