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