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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "handpos-client",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "手持POS",
5
5
  "main": "src/index.js",
6
6
  "directories": {
@@ -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.$pospost(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
+ 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.$pospost(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
- }
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
+ }