Commit ba4828225f61e28ff6ff152b1f40fe8c7d0d3bb5
1 parent
1b936eac
静动态支付
Showing
3 changed files
with
189 additions
and
225 deletions
src/api/plateNumber/plateNumber.js
src/components/dynCodePay.vue
1 | 1 | <template> |
2 | 2 | <div> |
3 | 3 | <div class="car-wrap"> |
4 | - <div class="carBG carBlue" > | |
4 | + <div class="carBG carBlue"> | |
5 | 5 | <p class="carNumber">{{carNumber}}</p> |
6 | 6 | <p class="payFee">{{(orderFee/100).toFixed(2)}}元</p> |
7 | 7 | </div> |
... | ... | @@ -27,7 +27,6 @@ |
27 | 27 | </li> |
28 | 28 | |
29 | 29 | |
30 | - | |
31 | 30 | <li> |
32 | 31 | <span>待缴金额</span> |
33 | 32 | <span>{{(orderFee/100).toFixed(2)}} 元</span> |
... | ... | @@ -48,96 +47,88 @@ |
48 | 47 | </div> |
49 | 48 | |
50 | 49 | |
51 | - | |
52 | 50 | </div> |
53 | 51 | </template> |
54 | 52 | |
55 | 53 | <script> |
56 | 54 | |
57 | 55 | // let Base64 = require('js-base64').Base64 |
58 | - | |
59 | -import { aliPay, getOpenId, vxPayQuery, bankH5Pay } from '@/api/orderPay/orderPay' | |
60 | - | |
56 | +import { aliPay, getOpenId, vxPayQuery, bankH5Pay } from "@/api/orderPay/orderPay"; | |
61 | 57 | export default { |
62 | - name: 'dynCodePay', | |
58 | + name: "dynCodePay", | |
63 | 59 | data() { |
64 | 60 | return { |
65 | 61 | carWrapBG: 0, |
66 | - carNumber: '', // 车牌 | |
67 | - parkName: '', // 停车场名称 | |
68 | - inparktime: '', // 入场时间 | |
69 | - outtime: '', // 出场时间 | |
70 | - staytime: '', // 停车时长 | |
71 | - orderFee: '', // 需要支付的费用 | |
72 | - urlAppid:'', | |
62 | + carNumber: "", // 车牌 | |
63 | + parkName: "", // 停车场名称 | |
64 | + inparktime: "", // 入场时间 | |
65 | + outtime: "", // 出场时间 | |
66 | + staytime: "", // 停车时长 | |
67 | + orderFee: "", // 需要支付的费用 | |
68 | + urlAppid: "", | |
73 | 69 | arrearageActFee: 0, |
74 | 70 | arrearageDiscFee: 0, |
75 | 71 | arrearageActFee: 0, |
76 | - clientBrowser: '', // 客户端 | |
72 | + clientBrowser: "", // 客户端 | |
77 | 73 | paySrcType: 101, //支付的类型 101 是本次 103是历史欠费 |
78 | - orderId: '', //支付的订单 | |
79 | - webAppCode: '', // 微信code | |
80 | - appOrderTimeout: '', // 超时描述 | |
81 | - } | |
74 | + orderId: "", //支付的订单 | |
75 | + webAppCode: "", // 微信code | |
76 | + appOrderTimeout: "" // 超时描述 | |
77 | + }; | |
82 | 78 | }, |
83 | 79 | created() { |
84 | 80 | // this.carWrapBG = this.$route.query.carColor //车牌颜色 |
85 | - this.carNumber = this.$route.query.plateno | |
86 | - this.parkName = this.$route.query.parkName | |
87 | - this.inparktime = this.$route.query.inparktime | |
88 | - this.outtime = this.$route.query.outtime | |
89 | - this.staytime = this.$route.query.staytime | |
90 | - this.orderFee = this.$route.query.orderFee | |
81 | + this.carNumber = this.$route.query.plateno; | |
82 | + this.parkName = this.$route.query.parkName; | |
83 | + this.inparktime = this.$route.query.inparktime; | |
84 | + this.outtime = this.$route.query.outtime; | |
85 | + this.staytime = this.$route.query.staytime; | |
86 | + this.orderFee = this.$route.query.orderFee; | |
91 | 87 | // this.arrearageTotalFee = this.$route.query.arrearageTotalFee // 应收 |
92 | 88 | // this.arrearageDiscFee = this.$route.query.arrearageDiscFee // 优惠 |
93 | 89 | // this.arrearageActFee = this.$route.query.arrearageActFee // 实收 |
94 | - this.clientBrowser = this.$utils.clientBrowser() //支付方式 | |
90 | + this.clientBrowser = this.$utils.clientBrowser(); //支付方式 | |
95 | 91 | // this.paySrcType = this.$route.query.codeType // 实收 |
96 | - this.orderId = this.$route.query.orderId | |
92 | + this.orderId = this.$route.query.orderId; | |
97 | 93 | // console.log(this.orderId) |
98 | 94 | // this.appOrderTimeout = this.$route.query.appOrderTimeout |
99 | - this.urlAppid = this.$route.query.appId | |
95 | + this.urlAppid = this.$route.query.appId; | |
100 | 96 | if (this.clientBrowser == "微信") { |
101 | 97 | this.webAppCode = this.getCode(); |
102 | 98 | } |
103 | - | |
104 | 99 | }, |
105 | 100 | methods: { |
106 | 101 | getCode() { |
107 | - | |
108 | - var appID = this.urlAppid; | |
109 | - | |
110 | - var code = this.getUrlParam('code'); | |
102 | + var appID = this.urlAppid; | |
103 | + var code = this.getUrlParam("code"); | |
111 | 104 | var local = window.location.href; |
112 | - if (code == null || code === '') { | |
113 | - window.location.href = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' + appID + '&redirect_uri=' + encodeURIComponent(local) + '&response_type=code&scope=snsapi_base&state=1#wechat_redirect' | |
105 | + if (code == null || code === "") { | |
106 | + window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + appID + "&redirect_uri=" + encodeURIComponent(local) + "&response_type=code&scope=snsapi_base&state=1#wechat_redirect"; | |
114 | 107 | } else { |
115 | 108 | return code; |
116 | 109 | } |
117 | 110 | }, |
118 | 111 | getUrlParam(name) { |
119 | - var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)'); | |
120 | - var r = window.location.search.substr(1).match(reg) | |
121 | - if (r != null) return unescape(r[2]) | |
122 | - return null | |
112 | + var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); | |
113 | + var r = window.location.search.substr(1).match(reg); | |
114 | + if (r != null) return unescape(r[2]); | |
115 | + return null; | |
123 | 116 | }, |
124 | 117 | toPay() { |
125 | - let me = this | |
126 | - let _order = [] | |
127 | - | |
128 | - console.log(this.orderId) | |
118 | + let me = this; | |
119 | + let _order = []; | |
120 | + console.log(this.orderId); | |
129 | 121 | if (this.paySrcType == 103) { |
130 | - this.orderId = JSON.parse(this.orderId) | |
122 | + this.orderId = JSON.parse(this.orderId); | |
131 | 123 | this.orderId.forEach(item => { |
132 | 124 | _order.push({ |
133 | 125 | orderId: item |
134 | - }) | |
135 | - }) | |
136 | - this.orderId = [] | |
137 | - this.orderId = _order | |
126 | + }); | |
127 | + }); | |
128 | + this.orderId = []; | |
129 | + this.orderId = _order; | |
138 | 130 | } |
139 | - | |
140 | - if (this.clientBrowser == '支付宝') { // 支付宝支付 | |
131 | + if (this.clientBrowser == "支付宝") { // 支付宝支付 | |
141 | 132 | var aliParams = {}; |
142 | 133 | aliParams.orderId = this.orderId; |
143 | 134 | // aliParams.carNumber = this.carNumber; |
... | ... | @@ -147,43 +138,39 @@ export default { |
147 | 138 | // aliParams.orgId = this.$utils.myOrgId, |
148 | 139 | // aliParams.backType = 2, |
149 | 140 | // aliParams.recordArreaInfos = JSON.stringify(this.orderId); |
150 | - console.log(aliParams) | |
141 | + console.log(aliParams); | |
151 | 142 | aliPay(aliParams).then(response => { |
152 | - console.log(response) | |
143 | + console.log(response); | |
153 | 144 | if (response.code == 0) {//进场 |
154 | 145 | document.write(response.data);//打开支付表单 |
155 | 146 | } else {//其他情况如【该卡号场内已存在】 |
156 | 147 | console.log(response.message); |
157 | 148 | } |
158 | - | |
159 | - }) | |
149 | + }); | |
160 | 150 | } |
161 | - | |
162 | - if (this.clientBrowser == '立即') { // 农行支付 | |
151 | + if (this.clientBrowser == "立即") { // 农行支付 | |
163 | 152 | var bankabcParams = {}; |
164 | 153 | bankabcParams.orderId = this.orderId; |
165 | 154 | bankabcParams.carNumber = this.carNumber; |
166 | 155 | bankabcParams.payType = 34;// 1:支付宝 2:微信 3:银联 10:H5 4微信公众号 |
167 | 156 | bankabcParams.terminalSource = 7;//请求端来源 1: 任你停 2:pda 3:微信公共号 7:H5扫码 10页面支付 |
168 | 157 | bankabcParams.paySrcType = this.paySrcType;//101停车支付 |
169 | - bankabcParams.orgId = this.$utils.myOrgId, | |
170 | - bankabcParams.backType = 2, | |
171 | - bankabcParams.PaymentLinkType = 1 | |
158 | + bankabcParams.orgId = this.$utils.myOrgId; | |
159 | + bankabcParams.backType = 2; | |
160 | + bankabcParams.PaymentLinkType = 1; | |
172 | 161 | bankabcParams.recordArreaInfos = JSON.stringify(this.orderId); |
173 | - console.log(bankabcParams) | |
174 | - | |
162 | + console.log(bankabcParams); | |
175 | 163 | bankH5Pay(bankabcParams).then(response => { |
176 | - console.log(response) | |
177 | - if (response.code == '0') { | |
178 | - let res = response.data.PaymentURL | |
179 | - let _token = res.split('TOKEN=')[1] | |
180 | - let OrderNo = response.data.OrderNo | |
181 | - localStorage.setItem('OrderNum', OrderNo) | |
182 | - | |
183 | - if (window.navigator.userAgent.indexOf('Bankabc/Portal') > -1) { | |
164 | + console.log(response); | |
165 | + if (response.code == "0") { | |
166 | + let res = response.data.PaymentURL; | |
167 | + let _token = res.split("TOKEN=")[1]; | |
168 | + let OrderNo = response.data.OrderNo; | |
169 | + localStorage.setItem("OrderNum", OrderNo); | |
170 | + if (window.navigator.userAgent.indexOf("Bankabc/Portal") > -1) { | |
184 | 171 | // alert('当前页面在新容器'); |
185 | - AlipayJSBridge.call('startApp', { | |
186 | - appId: '30603024', // 固定值 | |
172 | + AlipayJSBridge.call("startApp", { | |
173 | + appId: "30603024", // 固定值 | |
187 | 174 | param: { |
188 | 175 | type: "3", // 3: 掌银内H5页面, |
189 | 176 | tokenId: _token, //商户传过来的tokenId |
... | ... | @@ -191,22 +178,19 @@ export default { |
191 | 178 | payType: "1111", //商户传过来的payType,没有则传'1111' |
192 | 179 | webviewURL: "https://wxgzh.renniting.cn/wechatwuxi/Chifeng/TEST/sweeping_payment/codepay/index.html#/payResult", //商户传过来的回跳地址 |
193 | 180 | remark: "其他参数", //扩展备用 |
194 | - showProgress: 'NO', | |
195 | - backBehavior: 'back' | |
196 | - }, | |
197 | - }, function (result) { | |
198 | - | |
181 | + showProgress: "NO", | |
182 | + backBehavior: "back" | |
183 | + } | |
184 | + }, function(result) { | |
199 | 185 | }); |
200 | 186 | } else { |
201 | 187 | // alert('当前页面在旧容器'); |
202 | 188 | // 旧支付方式 |
203 | - window.location.href = 'https://www.abchina.com/luascript/mobilePayLua/' + encodeURI('{"return":{"tokenID":"' + _token + '","backURL":"https://wxgzh.renniting.cn/wechatwuxi/Chifeng/TEST/sweeping_payment/codepay/index.html#/payResult","payType":""}}'); | |
204 | - | |
189 | + window.location.href = "https://www.abchina.com/luascript/mobilePayLua/" + encodeURI("{\"return\":{\"tokenID\":\"" + _token + "\",\"backURL\":\"https://wxgzh.renniting.cn/wechatwuxi/Chifeng/TEST/sweeping_payment/codepay/index.html#/payResult\",\"payType\":\"\"}}"); | |
205 | 190 | } |
206 | 191 | } else { |
207 | - me.$msgbox('提示', '支付失败') | |
192 | + me.$msgbox("提示", "支付失败"); | |
208 | 193 | } |
209 | - | |
210 | 194 | // console.log(_token) |
211 | 195 | // let _data = 'method=invokePayFromBrowser&tokenID='+_token |
212 | 196 | // let cryData = CryptoJS.encrypt(_data, 'G9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvM3', 'EkpTEA3FbZFGGq8Y') |
... | ... | @@ -216,31 +200,28 @@ export default { |
216 | 200 | // window.location.href='bankabc:' + encodeURIComponent('{"method":"invokePayFromBrowser","param":'+baseCRY+'}') |
217 | 201 | // // 即为加密后的数据。其中paramsEncode是需要加密的数据、 |
218 | 202 | // // keyStr是加密时使用的key,与服务端一致、hash是偏移量,是一个随机生成的16位字符串。 |
219 | - }) | |
203 | + }); | |
220 | 204 | } |
221 | - | |
222 | - if (this.clientBrowser == '微信') { // 微信支付 | |
205 | + if (this.clientBrowser == "微信") { // 微信支付 | |
223 | 206 | //第一步获取openid |
224 | 207 | var codeParams = { |
225 | 208 | code: this.webAppCode, |
226 | - appId: this.urlAppid | |
209 | + appId: this.urlAppid | |
227 | 210 | }; |
228 | 211 | getOpenId(codeParams).then(res => { |
229 | 212 | if (res.code == 0) { |
230 | - me.vxPay(res.data, this.orderId) | |
213 | + me.vxPay(res.data, this.orderId); | |
231 | 214 | } else if (res.code == 40163) { //code been used, hints[重复code问题] |
232 | - me.$msgbox('提示', '请重新扫码code重复') | |
215 | + me.$msgbox("提示", "请重新扫码code重复"); | |
233 | 216 | console.log(res.message); |
234 | 217 | } else { |
235 | - me.$msgbox('提示', '请重新扫码') | |
218 | + me.$msgbox("提示", "请重新扫码"); | |
236 | 219 | } |
237 | - }) | |
238 | - | |
220 | + }); | |
239 | 221 | } |
240 | - | |
241 | 222 | }, |
242 | 223 | vxPay(openIdData, orderIdData) { |
243 | - let vm = this | |
224 | + let vm = this; | |
244 | 225 | var wxParams = {}; |
245 | 226 | wxParams.orderId = orderIdData; |
246 | 227 | // wxParams.backType = 2, |
... | ... | @@ -251,37 +232,37 @@ export default { |
251 | 232 | // wxParams.paySrcType = this.paySrcType;//101停车支付 |
252 | 233 | // wxParams.recordArreaInfos = JSON.stringify(orderIdData); |
253 | 234 | wxParams.openId = openIdData; |
254 | - wxParams.appId = this.urlAppid | |
235 | + wxParams.appId = this.urlAppid; | |
255 | 236 | vxPayQuery(wxParams).then(res => { |
256 | 237 | if (res.code == 0) { // |
257 | 238 | if (res.data) { |
258 | 239 | var data = res.data; |
259 | 240 | console.log(JSON.stringify(data)); |
260 | - if (typeof WeixinJSBridge === 'undefined') { // 微信浏览器内置对象。参考微信官方文档 | |
241 | + if (typeof WeixinJSBridge === "undefined") { // 微信浏览器内置对象。参考微信官方文档 | |
261 | 242 | if (document.addEventListener) { |
262 | - document.addEventListener('WeixinJSBridgeReady', vm.onBridgeReady(data), false) | |
243 | + document.addEventListener("WeixinJSBridgeReady", vm.onBridgeReady(data), false); | |
263 | 244 | } else if (document.attachEvent) { |
264 | - document.attachEvent('WeixinJSBridgeReady', vm.onBridgeReady(data)) | |
265 | - document.attachEvent('onWeixinJSBridgeReady', vm.onBridgeReady(data)) | |
245 | + document.attachEvent("WeixinJSBridgeReady", vm.onBridgeReady(data)); | |
246 | + document.attachEvent("onWeixinJSBridgeReady", vm.onBridgeReady(data)); | |
266 | 247 | } |
267 | 248 | } else { |
268 | - console.log('准备调用微信支付') | |
269 | - vm.onBridgeReady(data) | |
249 | + console.log("准备调用微信支付"); | |
250 | + vm.onBridgeReady(data); | |
270 | 251 | } |
271 | 252 | } else { |
272 | - vm.$msgbox('提示', '没有找到返回值') | |
253 | + vm.$msgbox("提示", "没有找到返回值"); | |
273 | 254 | } |
274 | 255 | } else { |
275 | 256 | console.log(res.message); |
276 | - vm.$msgbox('提示', '支付失败') | |
257 | + vm.$msgbox("提示", "支付失败"); | |
277 | 258 | } |
278 | - }) | |
259 | + }); | |
279 | 260 | }, |
280 | 261 | onBridgeReady(params) { |
281 | - let me = this | |
282 | - console.log('调用微信支付WeixinJSBridge') | |
262 | + let me = this; | |
263 | + console.log("调用微信支付WeixinJSBridge"); | |
283 | 264 | WeixinJSBridge.invoke( |
284 | - 'getBrandWCPayRequest', params, | |
265 | + "getBrandWCPayRequest", params, | |
285 | 266 | // |
286 | 267 | // 'getBrandWCPayRequest', { // 下面参数内容都是后台返回的 |
287 | 268 | // 'appId': data.appId, // 公众号名称,由商户传入 |
... | ... | @@ -291,22 +272,22 @@ export default { |
291 | 272 | // 'signType': data.signType, // 微信签名方式 |
292 | 273 | // 'paySign': data.paySign // 微信签名 |
293 | 274 | // }, |
294 | - function (res) { | |
275 | + function(res) { | |
295 | 276 | // 使用以上方式判断前端返回,微信团队郑重提示:res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。 |
296 | - if (res.err_msg === 'get_brand_wcpay_request:ok') { | |
297 | - console.log('成功') | |
298 | - me.$msgbox('提示', '支付成功') | |
277 | + if (res.err_msg === "get_brand_wcpay_request:ok") { | |
278 | + console.log("成功"); | |
279 | + me.$msgbox("提示", "支付成功"); | |
299 | 280 | } else { |
300 | - console.log('失败') | |
301 | - me.$msgbox('提示', '支付失败') | |
281 | + console.log("失败"); | |
282 | + me.$msgbox("提示", "支付失败"); | |
302 | 283 | me.$router.go(-2); |
303 | 284 | } |
304 | 285 | } |
305 | - ) | |
306 | - }, | |
286 | + ); | |
287 | + } | |
307 | 288 | }, |
308 | 289 | filters: {} |
309 | -} | |
290 | +}; | |
310 | 291 | </script> |
311 | 292 | |
312 | 293 | <style scoped lang="scss"> | ... | ... |
src/components/pay.vue
1 | 1 | <template> |
2 | 2 | <div> |
3 | 3 | <div class="car-wrap"> |
4 | - <div class="carBG carBlue" > | |
4 | + <div class="carBG carBlue"> | |
5 | 5 | <p class="carNumber">{{carNumber}}</p> |
6 | 6 | <p class="payFee">{{(orderFee/100).toFixed(2)}}元</p> |
7 | 7 | </div> |
... | ... | @@ -37,7 +37,6 @@ |
37 | 37 | </li> |
38 | 38 | |
39 | 39 | |
40 | - | |
41 | 40 | <li> |
42 | 41 | <span>待缴金额</span> |
43 | 42 | <span>{{(orderFee/100).toFixed(2)}} 元</span> |
... | ... | @@ -58,97 +57,91 @@ |
58 | 57 | </div> |
59 | 58 | |
60 | 59 | |
61 | - | |
62 | 60 | </div> |
63 | 61 | </template> |
64 | 62 | |
65 | 63 | <script> |
66 | 64 | |
67 | -let Base64 = require('js-base64').Base64 | |
68 | - | |
69 | -import {aliPay, getOpenId, vxPayQuery, bankH5Pay} from '@/api/orderPay/orderPay' | |
70 | - | |
65 | +let Base64 = require("js-base64").Base64; | |
66 | +import { aliPay, getOpenId, vxPayQuery, bankH5Pay } from "@/api/orderPay/orderPay"; | |
71 | 67 | export default { |
72 | - name: 'dynCodePay', | |
68 | + name: "dynCodePay", | |
73 | 69 | data() { |
74 | 70 | return { |
75 | 71 | carWrapBG: 0, |
76 | - carNumber: '', // 车牌 | |
77 | - parkName: '', // 停车场名称 | |
78 | - inparktime: '', // 入场时间 | |
79 | - outtime: '', // 出场时间 | |
80 | - staytime: '', // 停车时长 | |
81 | - orderFee: '', // 需要支付的费用 | |
82 | - due: '', // 总金额 | |
83 | - discountFee: '', // 优惠金额 | |
72 | + carNumber: "", // 车牌 | |
73 | + parkName: "", // 停车场名称 | |
74 | + inparktime: "", // 入场时间 | |
75 | + outtime: "", // 出场时间 | |
76 | + staytime: "", // 停车时长 | |
77 | + orderFee: "", // 需要支付的费用 | |
78 | + due: "", // 总金额 | |
79 | + discountFee: "", // 优惠金额 | |
84 | 80 | arrearageActFee: 0, |
85 | 81 | arrearageDiscFee: 0, |
86 | 82 | arrearageActFee: 0, |
87 | - clientBrowser: '', // 客户端 | |
83 | + clientBrowser: "", // 客户端 | |
88 | 84 | paySrcType: 101, //支付的类型 101 是本次 103是历史欠费 |
89 | - orderId: '', //支付的订单 | |
90 | - webAppCode: '', // 微信code | |
91 | - appOrderTimeout: '', // 超时描述 | |
92 | - } | |
85 | + orderId: "", //支付的订单 | |
86 | + webAppCode: "", // 微信code | |
87 | + appOrderTimeout: "" // 超时描述 | |
88 | + }; | |
93 | 89 | }, |
94 | 90 | created() { |
95 | 91 | // this.carWrapBG = this.$route.query.carColor //车牌颜色 |
96 | - this.carNumber = this.$route.query.plateno | |
97 | - this.parkName = this.$route.query.parkName | |
98 | - this.inparktime = this.$route.query.inparktime | |
99 | - this.outtime = this.$route.query.outtime | |
100 | - this.staytime = this.$route.query.staytime | |
101 | - this.orderFee = this.$route.query.orderFee | |
102 | - this.due = this.$route.query.due | |
103 | - this.discountFee = this.$route.query.discountFee | |
92 | + this.carNumber = this.$route.query.plateno; | |
93 | + this.parkName = this.$route.query.parkName; | |
94 | + this.inparktime = this.$route.query.inparktime; | |
95 | + this.outtime = this.$route.query.outtime; | |
96 | + this.staytime = this.$route.query.staytime; | |
97 | + this.orderFee = this.$route.query.orderFee; | |
98 | + this.due = this.$route.query.due; | |
99 | + this.discountFee = this.$route.query.discountFee; | |
104 | 100 | // this.arrearageTotalFee = this.$route.query.arrearageTotalFee // 应收 |
105 | 101 | // this.arrearageDiscFee = this.$route.query.arrearageDiscFee // 优惠 |
106 | 102 | // this.arrearageActFee = this.$route.query.arrearageActFee // 实收 |
107 | - this.clientBrowser = this.$utils.clientBrowser() //支付方式 | |
103 | + this.clientBrowser = this.$utils.clientBrowser(); //支付方式 | |
108 | 104 | // this.paySrcType = this.$route.query.codeType // 实收 |
109 | - this.orderId = this.$route.query.orderId | |
105 | + this.orderId = this.$route.query.orderId; | |
110 | 106 | // console.log(this.orderId) |
111 | 107 | // this.appOrderTimeout = this.$route.query.appOrderTimeout |
112 | 108 | if (this.clientBrowser == "微信") { |
113 | 109 | this.webAppCode = this.getCode(); |
114 | 110 | } |
115 | - | |
116 | 111 | }, |
117 | 112 | methods: { |
118 | 113 | getCode() { |
119 | 114 | var appID = this.$utils.myVxAppId; |
120 | 115 | // alert(appID) |
121 | - var code = this.getUrlParam('code'); | |
116 | + var code = this.getUrlParam("code"); | |
122 | 117 | var local = window.location.href; |
123 | - if (code == null || code === '') { | |
124 | - window.location.href = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' + appID + '&redirect_uri=' + encodeURIComponent(local) + '&response_type=code&scope=snsapi_base&state=1#wechat_redirect' | |
118 | + if (code == null || code === "") { | |
119 | + window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + appID + "&redirect_uri=" + encodeURIComponent(local) + "&response_type=code&scope=snsapi_base&state=1#wechat_redirect"; | |
125 | 120 | } else { |
126 | 121 | return code; |
127 | 122 | } |
128 | 123 | }, |
129 | 124 | getUrlParam(name) { |
130 | - var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)'); | |
131 | - var r = window.location.search.substr(1).match(reg) | |
132 | - if (r != null) return unescape(r[2]) | |
133 | - return null | |
125 | + var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); | |
126 | + var r = window.location.search.substr(1).match(reg); | |
127 | + if (r != null) return unescape(r[2]); | |
128 | + return null; | |
134 | 129 | }, |
135 | 130 | toPay() { |
136 | - let me = this | |
137 | - let _order = [] | |
138 | - | |
139 | - console.log(this.orderId) | |
131 | + let me = this; | |
132 | + let _order = []; | |
133 | + console.log(this.orderId); | |
140 | 134 | if (this.paySrcType == 103) { |
141 | - this.orderId = JSON.parse(this.orderId) | |
135 | + this.orderId = JSON.parse(this.orderId); | |
142 | 136 | this.orderId.forEach(item => { |
143 | 137 | _order.push({ |
144 | 138 | orderId: item |
145 | - }) | |
146 | - }) | |
147 | - this.orderId = [] | |
148 | - this.orderId = _order | |
139 | + }); | |
140 | + }); | |
141 | + this.orderId = []; | |
142 | + this.orderId = _order; | |
149 | 143 | } |
150 | - | |
151 | - if (this.clientBrowser == '支付宝') { // 支付宝支付 | |
144 | + if (this.clientBrowser == "支付宝") { // 支付宝支付 | |
152 | 145 | var aliParams = {}; |
153 | 146 | aliParams.orderId = this.orderId; |
154 | 147 | // aliParams.carNumber = this.carNumber; |
... | ... | @@ -158,42 +151,39 @@ export default { |
158 | 151 | // aliParams.orgId = this.$utils.myOrgId, |
159 | 152 | // aliParams.backType = 2, |
160 | 153 | // aliParams.recordArreaInfos = JSON.stringify(this.orderId); |
161 | - console.log(aliParams) | |
154 | + console.log(aliParams); | |
162 | 155 | aliPay(aliParams).then(response => { |
163 | - console.log(response) | |
156 | + console.log(response); | |
164 | 157 | if (response.code == 0) {//进场 |
165 | 158 | document.write(response.data);//打开支付表单 |
166 | 159 | } else {//其他情况如【该卡号场内已存在】 |
167 | 160 | console.log(response.message); |
168 | 161 | } |
169 | - | |
170 | - }) | |
162 | + }); | |
171 | 163 | } |
172 | - | |
173 | - if (this.clientBrowser == '立即') { // 农行支付 | |
164 | + if (this.clientBrowser == "立即") { // 农行支付 | |
174 | 165 | var bankabcParams = {}; |
175 | 166 | bankabcParams.orderId = this.orderId; |
176 | 167 | bankabcParams.carNumber = this.carNumber; |
177 | 168 | bankabcParams.payType = 34;// 1:支付宝 2:微信 3:银联 10:H5 4微信公众号 |
178 | 169 | bankabcParams.terminalSource = 7;//请求端来源 1: 任你停 2:pda 3:微信公共号 7:H5扫码 10页面支付 |
179 | 170 | bankabcParams.paySrcType = this.paySrcType;//101停车支付 |
180 | - bankabcParams.orgId = this.$utils.myOrgId, | |
181 | - bankabcParams.backType = 2, | |
182 | - bankabcParams.PaymentLinkType = 1 | |
171 | + bankabcParams.orgId = this.$utils.myOrgId; | |
172 | + bankabcParams.backType = 2; | |
173 | + bankabcParams.PaymentLinkType = 1; | |
183 | 174 | bankabcParams.recordArreaInfos = JSON.stringify(this.orderId); |
184 | - console.log(bankabcParams) | |
175 | + console.log(bankabcParams); | |
185 | 176 | bankH5Pay(bankabcParams).then(response => { |
186 | - console.log(response) | |
187 | - if (response.code == '0') { | |
188 | - let res = response.data.PaymentURL | |
189 | - let _token = res.split('TOKEN=')[1] | |
190 | - let OrderNo = response.data.OrderNo | |
191 | - localStorage.setItem('OrderNum', OrderNo) | |
192 | - | |
193 | - if (window.navigator.userAgent.indexOf('Bankabc/Portal') > -1) { | |
177 | + console.log(response); | |
178 | + if (response.code == "0") { | |
179 | + let res = response.data.PaymentURL; | |
180 | + let _token = res.split("TOKEN=")[1]; | |
181 | + let OrderNo = response.data.OrderNo; | |
182 | + localStorage.setItem("OrderNum", OrderNo); | |
183 | + if (window.navigator.userAgent.indexOf("Bankabc/Portal") > -1) { | |
194 | 184 | // alert('当前页面在新容器'); |
195 | - AlipayJSBridge.call('startApp', { | |
196 | - appId: '30603024', // 固定值 | |
185 | + AlipayJSBridge.call("startApp", { | |
186 | + appId: "30603024", // 固定值 | |
197 | 187 | param: { |
198 | 188 | type: "3", // 3: 掌银内H5页面, |
199 | 189 | tokenId: _token, //商户传过来的tokenId |
... | ... | @@ -201,22 +191,19 @@ export default { |
201 | 191 | payType: "1111", //商户传过来的payType,没有则传'1111' |
202 | 192 | webviewURL: "https://wxgzh.renniting.cn/wechatwuxi/Chifeng/TEST/sweeping_payment/codepay/index.html#/payResult", //商户传过来的回跳地址 |
203 | 193 | remark: "其他参数", //扩展备用 |
204 | - showProgress: 'NO', | |
205 | - backBehavior: 'back' | |
206 | - }, | |
207 | - }, function (result) { | |
208 | - | |
194 | + showProgress: "NO", | |
195 | + backBehavior: "back" | |
196 | + } | |
197 | + }, function(result) { | |
209 | 198 | }); |
210 | 199 | } else { |
211 | 200 | // alert('当前页面在旧容器'); |
212 | 201 | // 旧支付方式 |
213 | - window.location.href = 'https://www.abchina.com/luascript/mobilePayLua/' + encodeURI('{"return":{"tokenID":"' + _token + '","backURL":"https://wxgzh.renniting.cn/wechatwuxi/Chifeng/TEST/sweeping_payment/codepay/index.html#/payResult","payType":""}}'); | |
214 | - | |
202 | + window.location.href = "https://www.abchina.com/luascript/mobilePayLua/" + encodeURI("{\"return\":{\"tokenID\":\"" + _token + "\",\"backURL\":\"https://wxgzh.renniting.cn/wechatwuxi/Chifeng/TEST/sweeping_payment/codepay/index.html#/payResult\",\"payType\":\"\"}}"); | |
215 | 203 | } |
216 | 204 | } else { |
217 | - me.$msgbox('提示', '支付失败') | |
205 | + me.$msgbox("提示", "支付失败"); | |
218 | 206 | } |
219 | - | |
220 | 207 | // console.log(_token) |
221 | 208 | // let _data = 'method=invokePayFromBrowser&tokenID='+_token |
222 | 209 | // let cryData = CryptoJS.encrypt(_data, 'G9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvM3', 'EkpTEA3FbZFGGq8Y') |
... | ... | @@ -226,10 +213,9 @@ export default { |
226 | 213 | // window.location.href='bankabc:' + encodeURIComponent('{"method":"invokePayFromBrowser","param":'+baseCRY+'}') |
227 | 214 | // // 即为加密后的数据。其中paramsEncode是需要加密的数据、 |
228 | 215 | // // keyStr是加密时使用的key,与服务端一致、hash是偏移量,是一个随机生成的16位字符串。 |
229 | - }) | |
216 | + }); | |
230 | 217 | } |
231 | - | |
232 | - if (this.clientBrowser == '微信') { // 微信支付 | |
218 | + if (this.clientBrowser == "微信") { // 微信支付 | |
233 | 219 | //第一步获取openid |
234 | 220 | var codeParams = { |
235 | 221 | code: this.webAppCode, |
... | ... | @@ -237,20 +223,18 @@ export default { |
237 | 223 | }; |
238 | 224 | getOpenId(codeParams).then(res => { |
239 | 225 | if (res.code == 0) { |
240 | - me.vxPay(res.data, this.orderId) | |
226 | + me.vxPay(res.data, this.orderId); | |
241 | 227 | } else if (res.code == 40163) { //code been used, hints[重复code问题] |
242 | - me.$msgbox('提示', '请重新扫码') | |
228 | + me.$msgbox("提示", "请重新扫码"); | |
243 | 229 | console.log(res.message); |
244 | 230 | } else { |
245 | - me.$msgbox('提示', '请重新扫码') | |
231 | + me.$msgbox("提示", "请重新扫码"); | |
246 | 232 | } |
247 | - }) | |
248 | - | |
233 | + }); | |
249 | 234 | } |
250 | - | |
251 | 235 | }, |
252 | 236 | vxPay(openIdData, orderIdData) { |
253 | - let vm = this | |
237 | + let vm = this; | |
254 | 238 | var wxParams = {}; |
255 | 239 | wxParams.orderId = orderIdData; |
256 | 240 | // wxParams.backType = 2, |
... | ... | @@ -267,31 +251,31 @@ export default { |
267 | 251 | if (res.data) { |
268 | 252 | var data = res.data; |
269 | 253 | console.log(JSON.stringify(data)); |
270 | - if (typeof WeixinJSBridge === 'undefined') { // 微信浏览器内置对象。参考微信官方文档 | |
254 | + if (typeof WeixinJSBridge === "undefined") { // 微信浏览器内置对象。参考微信官方文档 | |
271 | 255 | if (document.addEventListener) { |
272 | - document.addEventListener('WeixinJSBridgeReady', vm.onBridgeReady(data), false) | |
256 | + document.addEventListener("WeixinJSBridgeReady", vm.onBridgeReady(data), false); | |
273 | 257 | } else if (document.attachEvent) { |
274 | - document.attachEvent('WeixinJSBridgeReady', vm.onBridgeReady(data)) | |
275 | - document.attachEvent('onWeixinJSBridgeReady', vm.onBridgeReady(data)) | |
258 | + document.attachEvent("WeixinJSBridgeReady", vm.onBridgeReady(data)); | |
259 | + document.attachEvent("onWeixinJSBridgeReady", vm.onBridgeReady(data)); | |
276 | 260 | } |
277 | 261 | } else { |
278 | - console.log('准备调用微信支付') | |
279 | - vm.onBridgeReady(data) | |
262 | + console.log("准备调用微信支付"); | |
263 | + vm.onBridgeReady(data); | |
280 | 264 | } |
281 | 265 | } else { |
282 | - vm.$msgbox('提示', '没有找到返回值') | |
266 | + vm.$msgbox("提示", "没有找到返回值"); | |
283 | 267 | } |
284 | 268 | } else { |
285 | 269 | console.log(res.message); |
286 | - vm.$msgbox('提示', res.message) | |
270 | + vm.$msgbox("提示", res.message); | |
287 | 271 | } |
288 | - }) | |
272 | + }); | |
289 | 273 | }, |
290 | 274 | onBridgeReady(params) { |
291 | - let me = this | |
292 | - console.log('调用微信支付WeixinJSBridge') | |
275 | + let me = this; | |
276 | + console.log("调用微信支付WeixinJSBridge"); | |
293 | 277 | WeixinJSBridge.invoke( |
294 | - 'getBrandWCPayRequest', params, | |
278 | + "getBrandWCPayRequest", params, | |
295 | 279 | // |
296 | 280 | // 'getBrandWCPayRequest', { // 下面参数内容都是后台返回的 |
297 | 281 | // 'appId': data.appId, // 公众号名称,由商户传入 |
... | ... | @@ -301,23 +285,22 @@ export default { |
301 | 285 | // 'signType': data.signType, // 微信签名方式 |
302 | 286 | // 'paySign': data.paySign // 微信签名 |
303 | 287 | // }, |
304 | - function (res) { | |
288 | + function(res) { | |
305 | 289 | // 使用以上方式判断前端返回,微信团队郑重提示:res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。 |
306 | - if (res.err_msg === 'get_brand_wcpay_request:ok') { | |
307 | - console.log('成功') | |
308 | - me.$msgbox('提示', '支付成功') | |
309 | - | |
290 | + if (res.err_msg === "get_brand_wcpay_request:ok") { | |
291 | + console.log("成功"); | |
292 | + me.$msgbox("提示", "支付成功"); | |
310 | 293 | } else { |
311 | - console.log('失败') | |
312 | - me.$msgbox('提示', '支付失败') | |
294 | + console.log("失败"); | |
295 | + me.$msgbox("提示", "支付失败"); | |
313 | 296 | me.$router.go(-2); |
314 | 297 | } |
315 | 298 | } |
316 | - ) | |
317 | - }, | |
299 | + ); | |
300 | + } | |
318 | 301 | }, |
319 | 302 | filters: {} |
320 | -} | |
303 | +}; | |
321 | 304 | </script> |
322 | 305 | |
323 | 306 | <style scoped lang="scss"> | ... | ... |