Commit 9cc3457db426273ad9c5ba8292bad83d910bfa99
1 parent
4e3fc8e3
payType 34
Showing
5 changed files
with
420 additions
and
0 deletions
dist 2.zip
0 → 100644
No preview for this file type
dist 3.zip
0 → 100644
No preview for this file type
dist.zip
0 → 100644
No preview for this file type
src/api/plateNumber/plateNumber.js
0 → 100644
src/components/pay.vue
0 → 100644
| 1 | +<template> | ||
| 2 | + <div> | ||
| 3 | + <div class="car-wrap"> | ||
| 4 | + <div class="carBG" :class="carWrapBG | formateColor"> | ||
| 5 | + <p class="carNumber">{{carNumber}}</p> | ||
| 6 | + <p class="payFee">{{(orderFee/100).toFixed(2)}}元</p> | ||
| 7 | + </div> | ||
| 8 | + </div> | ||
| 9 | + | ||
| 10 | + <ul class="fee-wrap"> | ||
| 11 | + <li> | ||
| 12 | + <span>停车场</span> | ||
| 13 | + <span>{{ parkName }}</span> | ||
| 14 | + </li> | ||
| 15 | + <li> | ||
| 16 | + <span>入场时间</span> | ||
| 17 | + <span>{{ inparktime }}</span> | ||
| 18 | + </li> | ||
| 19 | + <li> | ||
| 20 | + <span>出场时间</span> | ||
| 21 | + <span>{{ outtime }}</span> | ||
| 22 | + </li> | ||
| 23 | + | ||
| 24 | + <li> | ||
| 25 | + <span>停车时长</span> | ||
| 26 | + <span>{{ $utils.dateFormat(staytime) }}</span> | ||
| 27 | + </li> | ||
| 28 | + | ||
| 29 | + <li> | ||
| 30 | + <span>总金额</span> | ||
| 31 | + <span>{{(due/100).toFixed(2)}} 元</span> | ||
| 32 | + </li> | ||
| 33 | + | ||
| 34 | + <li> | ||
| 35 | + <span>优惠金额</span> | ||
| 36 | + <span>{{(discountFee/100).toFixed(2)}} 元</span> | ||
| 37 | + </li> | ||
| 38 | + | ||
| 39 | + | ||
| 40 | + | ||
| 41 | + <li> | ||
| 42 | + <span>待缴金额</span> | ||
| 43 | + <span>{{(orderFee/100).toFixed(2)}} 元</span> | ||
| 44 | + </li> | ||
| 45 | + | ||
| 46 | + </ul> | ||
| 47 | + <div style="padding: 20px 18px"> | ||
| 48 | + <div class="toPay" @click="toPay">{{clientBrowser}}支付</div> | ||
| 49 | + </div> | ||
| 50 | + | ||
| 51 | + <div v-if="appOrderTimeout.length>0"> | ||
| 52 | + <p class="tip"> | ||
| 53 | + 温馨提示: | ||
| 54 | + </p> | ||
| 55 | + <p style="color: #666;padding: 0 18px;"> | ||
| 56 | + {{appOrderTimeout}} | ||
| 57 | + </p> | ||
| 58 | + </div> | ||
| 59 | + | ||
| 60 | + | ||
| 61 | + | ||
| 62 | + </div> | ||
| 63 | +</template> | ||
| 64 | + | ||
| 65 | +<script> | ||
| 66 | + | ||
| 67 | +let Base64 = require('js-base64').Base64 | ||
| 68 | + | ||
| 69 | +import {aliPay, getOpenId, vxPayQuery, bankH5Pay} from '@/api/orderPay/orderPay' | ||
| 70 | + | ||
| 71 | +export default { | ||
| 72 | + name: 'dynCodePay', | ||
| 73 | + data() { | ||
| 74 | + return { | ||
| 75 | + carWrapBG: 0, | ||
| 76 | + carNumber: '', // 车牌 | ||
| 77 | + parkName: '', // 停车场名称 | ||
| 78 | + inparktime: '', // 入场时间 | ||
| 79 | + outtime: '', // 出场时间 | ||
| 80 | + staytime: '', // 停车时长 | ||
| 81 | + orderFee: '', // 需要支付的费用 | ||
| 82 | + due: '', // 总金额 | ||
| 83 | + discountFee: '', // 优惠金额 | ||
| 84 | + arrearageActFee: 0, | ||
| 85 | + arrearageDiscFee: 0, | ||
| 86 | + arrearageActFee: 0, | ||
| 87 | + clientBrowser: '', // 客户端 | ||
| 88 | + paySrcType: 101, //支付的类型 101 是本次 103是历史欠费 | ||
| 89 | + orderId: '', //支付的订单 | ||
| 90 | + webAppCode: '', // 微信code | ||
| 91 | + appOrderTimeout: '', // 超时描述 | ||
| 92 | + } | ||
| 93 | + }, | ||
| 94 | + created() { | ||
| 95 | + // 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 | ||
| 104 | + // this.arrearageTotalFee = this.$route.query.arrearageTotalFee // 应收 | ||
| 105 | + // this.arrearageDiscFee = this.$route.query.arrearageDiscFee // 优惠 | ||
| 106 | + // this.arrearageActFee = this.$route.query.arrearageActFee // 实收 | ||
| 107 | + this.clientBrowser = this.$utils.clientBrowser() //支付方式 | ||
| 108 | + // this.paySrcType = this.$route.query.codeType // 实收 | ||
| 109 | + this.orderId = this.$route.query.orderId | ||
| 110 | + // console.log(this.orderId) | ||
| 111 | + // this.appOrderTimeout = this.$route.query.appOrderTimeout | ||
| 112 | + if (this.clientBrowser == "微信") { | ||
| 113 | + this.webAppCode = this.getCode(); | ||
| 114 | + } | ||
| 115 | + | ||
| 116 | + }, | ||
| 117 | + methods: { | ||
| 118 | + getCode() { | ||
| 119 | + var appID = this.$utils.myVxAppId; | ||
| 120 | + // alert(appID) | ||
| 121 | + var code = this.getUrlParam('code'); | ||
| 122 | + 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_userinfo&state=1#wechat_redirect' | ||
| 125 | + } else { | ||
| 126 | + return code; | ||
| 127 | + } | ||
| 128 | + }, | ||
| 129 | + 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 | ||
| 134 | + }, | ||
| 135 | + toPay() { | ||
| 136 | + let me = this | ||
| 137 | + let _order = [] | ||
| 138 | + | ||
| 139 | + console.log(this.orderId) | ||
| 140 | + if (this.paySrcType == 103) { | ||
| 141 | + this.orderId = JSON.parse(this.orderId) | ||
| 142 | + this.orderId.forEach(item => { | ||
| 143 | + _order.push({ | ||
| 144 | + orderId: item | ||
| 145 | + }) | ||
| 146 | + }) | ||
| 147 | + this.orderId = [] | ||
| 148 | + this.orderId = _order | ||
| 149 | + } | ||
| 150 | + | ||
| 151 | + if (this.clientBrowser == '支付宝') { // 支付宝支付 | ||
| 152 | + var aliParams = {}; | ||
| 153 | + aliParams.orderId = this.orderId; | ||
| 154 | + // aliParams.carNumber = this.carNumber; | ||
| 155 | + aliParams.payType = 1;// 1:支付宝 2:微信 3:银联 10:H5 4微信公众号 | ||
| 156 | + aliParams.terminalSource = 7;//请求端来源 1: 任你停 2:pda 3:微信公共号 7:H5扫码 10页面支付 | ||
| 157 | + aliParams.paySrcType = this.paySrcType;//101停车支付 | ||
| 158 | + // aliParams.orgId = this.$utils.myOrgId, | ||
| 159 | + // aliParams.backType = 2, | ||
| 160 | + // aliParams.recordArreaInfos = JSON.stringify(this.orderId); | ||
| 161 | + console.log(aliParams) | ||
| 162 | + aliPay(aliParams).then(response => { | ||
| 163 | + console.log(response) | ||
| 164 | + if (response.code == 0) {//进场 | ||
| 165 | + document.write(response.data);//打开支付表单 | ||
| 166 | + } else {//其他情况如【该卡号场内已存在】 | ||
| 167 | + console.log(response.message); | ||
| 168 | + } | ||
| 169 | + | ||
| 170 | + }) | ||
| 171 | + } | ||
| 172 | + | ||
| 173 | + if (this.clientBrowser == '农行') { // 农行支付 | ||
| 174 | + var bankabcParams = {}; | ||
| 175 | + bankabcParams.orderId = this.orderId; | ||
| 176 | + bankabcParams.carNumber = this.carNumber; | ||
| 177 | + bankabcParams.payType = 34;// 1:支付宝 2:微信 3:银联 10:H5 4微信公众号 | ||
| 178 | + bankabcParams.terminalSource = 7;//请求端来源 1: 任你停 2:pda 3:微信公共号 7:H5扫码 10页面支付 | ||
| 179 | + bankabcParams.paySrcType = this.paySrcType;//101停车支付 | ||
| 180 | + bankabcParams.orgId = this.$utils.myOrgId, | ||
| 181 | + bankabcParams.backType = 2, | ||
| 182 | + bankabcParams.PaymentLinkType = 1 | ||
| 183 | + bankabcParams.recordArreaInfos = JSON.stringify(this.orderId); | ||
| 184 | + console.log(bankabcParams) | ||
| 185 | + 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) { | ||
| 194 | + // alert('当前页面在新容器'); | ||
| 195 | + AlipayJSBridge.call('startApp', { | ||
| 196 | + appId: '30603024', // 固定值 | ||
| 197 | + param: { | ||
| 198 | + type: "3", // 3: 掌银内H5页面, | ||
| 199 | + tokenId: _token, //商户传过来的tokenId | ||
| 200 | + paySystem: "", //商户传过来的paySystem, 没有则传空字符串 | ||
| 201 | + payType: "1111", //商户传过来的payType,没有则传'1111' | ||
| 202 | + webviewURL: "https://wxgzh.renniting.cn/wechatwuxi/Chifeng/TEST/sweeping_payment/codepay/index.html#/payResult", //商户传过来的回跳地址 | ||
| 203 | + remark: "其他参数", //扩展备用 | ||
| 204 | + showProgress: 'NO', | ||
| 205 | + backBehavior: 'back' | ||
| 206 | + }, | ||
| 207 | + }, function (result) { | ||
| 208 | + | ||
| 209 | + }); | ||
| 210 | + } else { | ||
| 211 | + // alert('当前页面在旧容器'); | ||
| 212 | + // 旧支付方式 | ||
| 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 | + | ||
| 215 | + } | ||
| 216 | + } else { | ||
| 217 | + alert('支付失败') | ||
| 218 | + } | ||
| 219 | + | ||
| 220 | + // console.log(_token) | ||
| 221 | + // let _data = 'method=invokePayFromBrowser&tokenID='+_token | ||
| 222 | + // let cryData = CryptoJS.encrypt(_data, 'G9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvM3', 'EkpTEA3FbZFGGq8Y') | ||
| 223 | + // | ||
| 224 | + // let baseCRY = Base64.encode(cryData) | ||
| 225 | + // console.log(baseCRY) | ||
| 226 | + // window.location.href='bankabc:' + encodeURIComponent('{"method":"invokePayFromBrowser","param":'+baseCRY+'}') | ||
| 227 | + // // 即为加密后的数据。其中paramsEncode是需要加密的数据、 | ||
| 228 | + // // keyStr是加密时使用的key,与服务端一致、hash是偏移量,是一个随机生成的16位字符串。 | ||
| 229 | + }) | ||
| 230 | + } | ||
| 231 | + | ||
| 232 | + if (this.clientBrowser == '微信') { // 微信支付 | ||
| 233 | + //第一步获取openid | ||
| 234 | + var codeParams = { | ||
| 235 | + code: this.webAppCode, | ||
| 236 | + appId: this.$utils.myVxAppId | ||
| 237 | + }; | ||
| 238 | + getOpenId(codeParams).then(res => { | ||
| 239 | + if (res.code == 0) { | ||
| 240 | + me.vxPay(res.data, this.orderId) | ||
| 241 | + } else if (res.code == 40163) { //code been used, hints[重复code问题] | ||
| 242 | + alert('请重新扫码') | ||
| 243 | + console.log(res.message); | ||
| 244 | + } else { | ||
| 245 | + alert('请重新扫码') | ||
| 246 | + } | ||
| 247 | + }) | ||
| 248 | + | ||
| 249 | + } | ||
| 250 | + | ||
| 251 | + }, | ||
| 252 | + vxPay(openIdData, orderIdData) { | ||
| 253 | + let vm = this | ||
| 254 | + var wxParams = {}; | ||
| 255 | + wxParams.orderId = orderIdData; | ||
| 256 | + // wxParams.backType = 2, | ||
| 257 | + // wxParams.orgId = this.$utils.myOrgId, | ||
| 258 | + wxParams.payType = 4;// 1:支付宝 2:微信 3:银联 10:H5 4微信公众号 | ||
| 259 | + wxParams.terminalSource = 7;//请求端来源 1: 任你停 2:pda 3:微信公共号 7:H5扫码 10页面支付 | ||
| 260 | + // wxParams.carNumber = this.carNumber; | ||
| 261 | + // wxParams.paySrcType = this.paySrcType;//101停车支付 | ||
| 262 | + // wxParams.recordArreaInfos = JSON.stringify(orderIdData); | ||
| 263 | + wxParams.openId = openIdData; | ||
| 264 | + wxParams.appId = this.$utils.myVxAppId; | ||
| 265 | + vxPayQuery(wxParams).then(res => { | ||
| 266 | + if (res.code == 0) { // | ||
| 267 | + if (res.data) { | ||
| 268 | + var data = res.data; | ||
| 269 | + console.log(JSON.stringify(data)); | ||
| 270 | + if (typeof WeixinJSBridge === 'undefined') { // 微信浏览器内置对象。参考微信官方文档 | ||
| 271 | + if (document.addEventListener) { | ||
| 272 | + document.addEventListener('WeixinJSBridgeReady', vm.onBridgeReady(data), false) | ||
| 273 | + } else if (document.attachEvent) { | ||
| 274 | + document.attachEvent('WeixinJSBridgeReady', vm.onBridgeReady(data)) | ||
| 275 | + document.attachEvent('onWeixinJSBridgeReady', vm.onBridgeReady(data)) | ||
| 276 | + } | ||
| 277 | + } else { | ||
| 278 | + console.log('准备调用微信支付') | ||
| 279 | + vm.onBridgeReady(data) | ||
| 280 | + } | ||
| 281 | + } else { | ||
| 282 | + alert("没有找到返回值"); | ||
| 283 | + } | ||
| 284 | + } else { | ||
| 285 | + console.log(res.message); | ||
| 286 | + alert(res.message); | ||
| 287 | + } | ||
| 288 | + }) | ||
| 289 | + }, | ||
| 290 | + onBridgeReady(params) { | ||
| 291 | + let me = this | ||
| 292 | + console.log('调用微信支付WeixinJSBridge') | ||
| 293 | + WeixinJSBridge.invoke( | ||
| 294 | + 'getBrandWCPayRequest', params, | ||
| 295 | + // | ||
| 296 | + // 'getBrandWCPayRequest', { // 下面参数内容都是后台返回的 | ||
| 297 | + // 'appId': data.appId, // 公众号名称,由商户传入 | ||
| 298 | + // 'timeStamp': data.timeStamp, // 时间戳 | ||
| 299 | + // 'nonceStr': data.nonceStr, // 随机串 | ||
| 300 | + // 'package': data.package, // 预支付id | ||
| 301 | + // 'signType': data.signType, // 微信签名方式 | ||
| 302 | + // 'paySign': data.paySign // 微信签名 | ||
| 303 | + // }, | ||
| 304 | + function (res) { | ||
| 305 | + // 使用以上方式判断前端返回,微信团队郑重提示:res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。 | ||
| 306 | + if (res.err_msg === 'get_brand_wcpay_request:ok') { | ||
| 307 | + console.log('成功') | ||
| 308 | + alert('支付成功') | ||
| 309 | + } else { | ||
| 310 | + console.log('失败') | ||
| 311 | + alert('支付失败') | ||
| 312 | + me.$router.go(-2); | ||
| 313 | + } | ||
| 314 | + } | ||
| 315 | + ) | ||
| 316 | + }, | ||
| 317 | + }, | ||
| 318 | + filters: {} | ||
| 319 | +} | ||
| 320 | +</script> | ||
| 321 | + | ||
| 322 | +<style scoped lang="scss"> | ||
| 323 | + .car-wrap { | ||
| 324 | + padding: 7px 7px; | ||
| 325 | + background: #FFF; | ||
| 326 | + } | ||
| 327 | + | ||
| 328 | + .carBG { | ||
| 329 | + width: 100%; | ||
| 330 | + height: 130px; | ||
| 331 | + } | ||
| 332 | + | ||
| 333 | + .carBlue { | ||
| 334 | + background: url("../assets/images/blueBG.png") no-repeat; | ||
| 335 | + background-size: 100% 100%; | ||
| 336 | + } | ||
| 337 | + | ||
| 338 | + .carYellow { | ||
| 339 | + background: url("../assets/images/yellowBG.png") no-repeat; | ||
| 340 | + background-size: 100% 100%; | ||
| 341 | + } | ||
| 342 | + | ||
| 343 | + .carGreen { | ||
| 344 | + background: url("../assets/images/greenBG.png") no-repeat; | ||
| 345 | + background-size: 100% 100%; | ||
| 346 | + } | ||
| 347 | + | ||
| 348 | + .carWhite { | ||
| 349 | + background: url("../assets/images/whiteBG.png") no-repeat; | ||
| 350 | + background-size: 100% 100%; | ||
| 351 | + } | ||
| 352 | + | ||
| 353 | + .carBlack { | ||
| 354 | + background: url("../assets/images/blackBG.png") no-repeat; | ||
| 355 | + background-size: 100% 100%; | ||
| 356 | + } | ||
| 357 | + | ||
| 358 | + .carNumber { | ||
| 359 | + padding: 20px 0 10px; | ||
| 360 | + font-size: 30px; | ||
| 361 | + text-align: center; | ||
| 362 | + } | ||
| 363 | + | ||
| 364 | + .payFee { | ||
| 365 | + font-size: 24px; | ||
| 366 | + color: #FF7B7B; | ||
| 367 | + text-align: center; | ||
| 368 | + } | ||
| 369 | + | ||
| 370 | + .fee-wrap { | ||
| 371 | + background: #FFF; | ||
| 372 | + padding: 0 18px; | ||
| 373 | + > li { | ||
| 374 | + display: flex; | ||
| 375 | + justify-content: space-between; | ||
| 376 | + height: 30px; | ||
| 377 | + line-height: 30px; | ||
| 378 | + border-bottom: 1px solid #EAEAEA; | ||
| 379 | + &:last-child { | ||
| 380 | + border-bottom: 0; | ||
| 381 | + } | ||
| 382 | + } | ||
| 383 | + | ||
| 384 | + } | ||
| 385 | + | ||
| 386 | + .toPay { | ||
| 387 | + width: 100%; | ||
| 388 | + height: 44px; | ||
| 389 | + margin: 0 auto; | ||
| 390 | + line-height: 44px; | ||
| 391 | + text-align: center; | ||
| 392 | + background: linear-gradient(180deg, #3885D9 0%, #4194EF 100%); | ||
| 393 | + border-radius: 4px; | ||
| 394 | + border: 1px solid #0D72E2; | ||
| 395 | + font-size: 20px; | ||
| 396 | + color: #FFF; | ||
| 397 | + cursor: pointer; | ||
| 398 | + } | ||
| 399 | + | ||
| 400 | + .tip { | ||
| 401 | + padding-left: 40px; | ||
| 402 | + background: url("../assets/images/tip.png") no-repeat 18px center; | ||
| 403 | + background-size: 16px 16px; | ||
| 404 | + color: #666; | ||
| 405 | + } | ||
| 406 | +</style> |