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.
@@ -1,121 +1,121 @@
1
- import co from 'co'
2
- import Vue from 'vue'
3
-
4
- export default class PayWay {
5
- constructor (components) {
6
- console.log('PayWay.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('pay-way', {
17
- userInfo: this.self.userInfo,
18
- cardInfo: this.self.cardInfo,
19
- stairPrice: this.self.chargePrice,
20
- obj: this
21
- }, 'self', this.self.back)
22
- return new Promise((resolve, reject) => {
23
- // 只要不执行承诺或者拒绝函数该服务就永远不会切换到下一个服务
24
- this.resolve = resolve
25
- this.reject = reject
26
- })
27
- }
28
-
29
- commit () {
30
- console.log('PayWay.js被提交')
31
- }
32
-
33
- rollback () {
34
- console.log('PayWay.js被回滚')
35
- }
36
-
37
- setComponents (components) {
38
- this.self = components
39
- }
40
-
41
- getQR () {
42
- let attach = this.getAttach()
43
- let gen = this.generateScan(this.self, attach)
44
- return co(gen)
45
- }
46
- // 组织attach
47
- getAttach () {
48
- let attach = {}
49
- // 用户编号
50
- attach.f_userinfo_code = this.self.userInfo.f_userinfo_code
51
- attach.f_userinfo_id = this.self.userInfo.f_userinfo_id
52
- attach.f_userfiles_id = this.self.userInfo.f_userfiles_id
53
- attach.f_user_name = this.self.userInfo.f_user_name
54
- attach.f_address = this.self.userInfo.f_address
55
- attach.f_pregas = this.self.stairPrice.f_pregas
56
- // 应交金额
57
- attach.f_preamount = this.self.stairPrice.f_preamount
58
- attach.f_payment = this.self.stairPrice.f_payment
59
- attach.f_terminal_num = Vue.PosUtil.Sn
60
- // 实交金额
61
- attach.f_collection = (this.self.stairPrice.f_collection - 0).toFixed(2)
62
- // 实交金额(如果存在账户余额)
63
- attach.f_totalcost = attach.f_collection
64
-
65
- // 特殊参数
66
- if (this.self.userInfo.f_meter_type === '机表') {
67
- // 区分气表类型
68
- attach.isHand = 1
69
- // 实际缴纳滞纳金
70
- attach.f_overdue = this.self.stairPrice.f_delaypay
71
- // 抄表记录编号
72
- attach.hand_ids = this.self.stairPrice.hand_ids
73
- } else if (this.self.userInfo.f_meter_type === '物联网表') {
74
- attach.isHand = -1
75
- } else {
76
- // 卡表
77
- attach.isHand = 0
78
- attach.isGasValue = this.self.userInfo.f_collection_type === '按金额' ? 1 : 0
79
- attach.f_card_id = this.self.cardInfo.CardID
80
- attach.f_times = this.self.cardInfo.Times + 1
81
- }
82
- return attach
83
- }
84
- // 支付下单
85
- * generateScan (self, attach) {
86
- // 支付金额元转分(测试环境支付金额统一改为1分)
87
- let money = Vue.PosUtil.posParam.isTest ? 1 : Vue.PosUtil.yuan2fen(this.self.stairPrice.f_collection)
88
- // post去后台给微信下单并生成二维码和流水号
89
- self.$pospost(Vue.ProxyUrl + 'rs/logic/' + Vue.PosUtil.posParam.module + 'GetCode', {
90
- config: self.$PosUtil.posParam.config,
91
- f_revenue: Vue.PosUtil.posParam.revenue,
92
- pay_way: self.stairPrice.pay_way,
93
- money: money + '',
94
- attach: attach
95
- }, {resolveMsg: null, rejectMsg: null}).then((ret) => {
96
- // 下单成功
97
- if (ret.data.code === 200) {
98
- self.stairPrice.url = ret.data.url
99
- self.stairPrice.f_serial_id = ret.data.f_out_trade_no
100
- self.$goto('scannative', {
101
- userInfo: self.userInfo,
102
- cardInfo: self.cardInfo,
103
- stairPrice: self.stairPrice,
104
- obj: this.next
105
- }, 'self', self.back)
106
- // 设置下一个服务状态为扫码支付,开始需要去轮询数据库
107
- this.next.isQR = true
108
- this.resolve(true)
109
- } else {
110
- // 下单失败
111
- self.$back('getBillError')
112
- this.resolve(false)
113
- }
114
- }
115
- ).catch((ret) => {
116
- console.log('下单异常,异常返回==>', ret)
117
- self.$back('getBillError')
118
- this.resolve(false)
119
- })
120
- }
121
- }
1
+ import co from 'co'
2
+ import Vue from 'vue'
3
+
4
+ export default class PayWay {
5
+ constructor (components) {
6
+ console.log('PayWay.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('pay-way', {
17
+ userInfo: this.self.userInfo,
18
+ cardInfo: this.self.cardInfo,
19
+ stairPrice: this.self.chargePrice,
20
+ obj: this
21
+ }, 'self', this.self.back)
22
+ return new Promise((resolve, reject) => {
23
+ // 只要不执行承诺或者拒绝函数该服务就永远不会切换到下一个服务
24
+ this.resolve = resolve
25
+ this.reject = reject
26
+ })
27
+ }
28
+
29
+ commit () {
30
+ console.log('PayWay.js被提交')
31
+ }
32
+
33
+ rollback () {
34
+ console.log('PayWay.js被回滚')
35
+ }
36
+
37
+ setComponents (components) {
38
+ this.self = components
39
+ }
40
+
41
+ getQR () {
42
+ let attach = this.getAttach()
43
+ let gen = this.generateScan(this.self, attach)
44
+ return co(gen)
45
+ }
46
+ // 组织attach
47
+ getAttach () {
48
+ let attach = {}
49
+ // 用户编号
50
+ attach.f_userinfo_code = this.self.userInfo.f_userinfo_code
51
+ attach.f_userinfo_id = this.self.userInfo.f_userinfo_id
52
+ attach.f_userfiles_id = this.self.userInfo.f_userfiles_id
53
+ attach.f_user_name = this.self.userInfo.f_user_name
54
+ attach.f_address = this.self.userInfo.f_address
55
+ attach.f_pregas = this.self.stairPrice.f_pregas
56
+ // 应交金额
57
+ attach.f_preamount = this.self.stairPrice.f_preamount
58
+ attach.f_payment = this.self.stairPrice.f_payment
59
+ attach.f_terminal_num = Vue.PosUtil.Sn
60
+ // 实交金额
61
+ attach.f_collection = (this.self.stairPrice.f_collection - 0).toFixed(2)
62
+ // 实交金额(如果存在账户余额)
63
+ attach.f_totalcost = attach.f_collection
64
+
65
+ // 特殊参数
66
+ if (this.self.userInfo.f_meter_type === '机表') {
67
+ // 区分气表类型
68
+ attach.isHand = 1
69
+ // 实际缴纳滞纳金
70
+ attach.f_overdue = this.self.stairPrice.f_delaypay
71
+ // 抄表记录编号
72
+ attach.hand_ids = this.self.stairPrice.hand_ids
73
+ } else if (this.self.userInfo.f_meter_type === '物联网表') {
74
+ attach.isHand = -1
75
+ } else {
76
+ // 卡表
77
+ attach.isHand = 0
78
+ attach.isGasValue = this.self.userInfo.f_collection_type === '按金额' ? 1 : 0
79
+ attach.f_card_id = this.self.cardInfo.CardID
80
+ attach.f_times = this.self.cardInfo.Times + 1
81
+ }
82
+ return attach
83
+ }
84
+ // 支付下单
85
+ * generateScan (self, attach) {
86
+ // 支付金额元转分(测试环境支付金额统一改为1分)
87
+ let money = Vue.PosUtil.posParam.isTest ? 1 : Vue.PosUtil.yuan2fen(this.self.stairPrice.f_collection)
88
+ // post去后台给微信下单并生成二维码和流水号
89
+ self.$resetpost(Vue.ProxyUrl + 'rs/logic/' + Vue.PosUtil.posParam.module + 'GetCode', {
90
+ config: self.$PosUtil.posParam.config,
91
+ f_revenue: Vue.PosUtil.posParam.revenue,
92
+ pay_way: self.stairPrice.pay_way,
93
+ money: money + '',
94
+ attach: attach
95
+ }, {resolveMsg: null, rejectMsg: null}).then((ret) => {
96
+ // 下单成功
97
+ if (ret.data.code === 200) {
98
+ self.stairPrice.url = ret.data.url
99
+ self.stairPrice.f_serial_id = ret.data.f_out_trade_no
100
+ self.$goto('scannative', {
101
+ userInfo: self.userInfo,
102
+ cardInfo: self.cardInfo,
103
+ stairPrice: self.stairPrice,
104
+ obj: this.next
105
+ }, 'self', self.back)
106
+ // 设置下一个服务状态为扫码支付,开始需要去轮询数据库
107
+ this.next.isQR = true
108
+ this.resolve(true)
109
+ } else {
110
+ // 下单失败
111
+ self.$back('getBillError')
112
+ this.resolve(false)
113
+ }
114
+ }
115
+ ).catch((ret) => {
116
+ console.log('下单异常,异常返回==>', ret)
117
+ self.$back('getBillError')
118
+ this.resolve(false)
119
+ })
120
+ }
121
+ }
@@ -1,118 +1,118 @@
1
- import Vue from 'vue'
2
-
3
- /**
4
- * @author GaoChengLong Waki
5
- * @date 2018/12/10 18:12
6
- * 轮询数据库服务,默认不启用,直接跳过该服务
7
- */
8
- export default class ScanNative {
9
- constructor () {
10
- console.log('ScanNative.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('ScanNative.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('ScanNative.js被提交')
37
- }
38
-
39
- rollback () {
40
- console.log('ScanNative.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
- let condition = 'f_serial_id = \'' + self.stairPrice.f_serial_id + '\''
92
- // 查询语句参数
93
- let param = {
94
- condition: condition
95
- }
96
- self.$pospost(Vue.ProxyUrl + 'rs/sql/getSellGasInfo', {data: param}, {
97
- resolveMsg: null, rejectMsg: null
98
- }).then((ret) => {
99
- if (ret.data.length === 1) {
100
- self.stairPrice.id = ret.data[0].id
101
- // 停止计时器
102
- window.clearInterval(obj.timer1)
103
- window.clearInterval(obj.timer2)
104
- self.$goto('order-info', {
105
- userInfo: self.userInfo,
106
- cardInfo: self.cardInfo,
107
- status: 3,
108
- stairPrice: self.stairPrice,
109
- obj: obj.next
110
- }, 'self', self.callBack)
111
- }
112
- }
113
- ).catch((ret) => {
114
- self.hasError(ret)
115
- })
116
- }
117
-
118
- }
1
+ import Vue from 'vue'
2
+
3
+ /**
4
+ * @author GaoChengLong Waki
5
+ * @date 2018/12/10 18:12
6
+ * 轮询数据库服务,默认不启用,直接跳过该服务
7
+ */
8
+ export default class ScanNative {
9
+ constructor () {
10
+ console.log('ScanNative.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('ScanNative.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('ScanNative.js被提交')
37
+ }
38
+
39
+ rollback () {
40
+ console.log('ScanNative.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
+ let condition = 'f_serial_id = \'' + self.stairPrice.f_serial_id + '\''
92
+ // 查询语句参数
93
+ let param = {
94
+ condition: condition
95
+ }
96
+ self.$resetpost(Vue.ProxyUrl + 'rs/sql/getSellGasInfo', {data: param}, {
97
+ resolveMsg: null, rejectMsg: null
98
+ }).then((ret) => {
99
+ if (ret.data.length === 1) {
100
+ self.stairPrice.id = ret.data[0].id
101
+ // 停止计时器
102
+ window.clearInterval(obj.timer1)
103
+ window.clearInterval(obj.timer2)
104
+ self.$goto('order-info', {
105
+ userInfo: self.userInfo,
106
+ cardInfo: self.cardInfo,
107
+ status: 3,
108
+ stairPrice: self.stairPrice,
109
+ obj: obj.next
110
+ }, 'self', self.callBack)
111
+ }
112
+ }
113
+ ).catch((ret) => {
114
+ self.hasError(ret)
115
+ })
116
+ }
117
+
118
+ }