Commit 9269cefa118435c86fa33fb398dd55c3913b1f6b
1 parent
21822556
黄石分支 -- 支付
Showing
6 changed files
with
150 additions
and
98 deletions
src/api/orderPay/orderPay.js
| ... | ... | @@ -17,6 +17,7 @@ export function getOpenId(params) { // 获取OpenId |
| 17 | 17 | }) |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | + | |
| 20 | 21 | export function vxPayQuery(params) { // 微信 |
| 21 | 22 | return request({ |
| 22 | 23 | url: 'weixinpay/publicUnifiedOrder', |
| ... | ... | @@ -25,5 +26,27 @@ export function vxPayQuery(params) { // 微信 |
| 25 | 26 | }) |
| 26 | 27 | } |
| 27 | 28 | |
| 29 | +// 新接口银联 | |
| 30 | + | |
| 31 | +export function doPay(params) { // 微信 | |
| 32 | + return request({ | |
| 33 | + url: 'unionpay/doPay', | |
| 34 | + method: 'post', | |
| 35 | + data: params | |
| 36 | + }) | |
| 37 | +} | |
| 38 | + | |
| 39 | + | |
| 40 | +// 创建订单 | |
| 41 | + | |
| 42 | +export function doOrderCreate(params) { // 创建订单 | |
| 43 | + return request({ | |
| 44 | + url: 'unionpay/doOrderCreate', | |
| 45 | + method: 'post', | |
| 46 | + data: params | |
| 47 | + }) | |
| 48 | +} | |
| 49 | + | |
| 50 | + | |
| 28 | 51 | |
| 29 | 52 | ... | ... |
src/assets/images/carBlack.png
src/assets/images/carYellow.png
src/components/orderPay.vue
| ... | ... | @@ -40,7 +40,7 @@ |
| 40 | 40 | </template> |
| 41 | 41 | |
| 42 | 42 | <script> |
| 43 | -import {aliPay, getOpenId, vxPayQuery} from '@/api/orderPay/orderPay' | |
| 43 | +import {aliPay, getOpenId, vxPayQuery, doPay, doOrderCreate} from '@/api/orderPay/orderPay' | |
| 44 | 44 | |
| 45 | 45 | export default { |
| 46 | 46 | name: 'orderPay', |
| ... | ... | @@ -56,6 +56,7 @@ export default { |
| 56 | 56 | orderId: '', //支付的订单 |
| 57 | 57 | webAppCode: '', // 微信code |
| 58 | 58 | appOrderTimeout: '', // 超时描述 |
| 59 | + isAndroid: '', // 终端类型 | |
| 59 | 60 | } |
| 60 | 61 | }, |
| 61 | 62 | created() { |
| ... | ... | @@ -66,8 +67,13 @@ export default { |
| 66 | 67 | this.arrearageActFee = this.$route.query.arrearageActFee // 实收 |
| 67 | 68 | this.clientBrowser = this.$utils.clientBrowser() //支付方式 |
| 68 | 69 | this.paySrcType = this.$route.query.paySrcType // 实收 |
| 69 | - this.orderId = this.$route.query.ordeID | |
| 70 | - this.appOrderTimeout = this.$route.query.appOrderTimeout | |
| 70 | + this.orderId = this.$route.query.ordeID // 订单号 | |
| 71 | + console.log(this.orderId) | |
| 72 | + this.appOrderTimeout = this.$route.query.appOrderTimeout //提示 | |
| 73 | + | |
| 74 | + let userAgent = navigator.userAgent; | |
| 75 | + this.isAndroid = userAgent.indexOf('Android') > -1 || userAgent.indexOf('Adr') > -1; //android终端 | |
| 76 | + | |
| 71 | 77 | if (this.clientBrowser == "微信") { |
| 72 | 78 | this.webAppCode = this.getCode(); |
| 73 | 79 | } |
| ... | ... | @@ -75,7 +81,7 @@ export default { |
| 75 | 81 | methods: { |
| 76 | 82 | getCode() { |
| 77 | 83 | var appID = this.$utils.myVxAppId; |
| 78 | - var code = this.$route.query.code | |
| 84 | + var code = this.getUrlParam('code'); | |
| 79 | 85 | var local = window.location.href; |
| 80 | 86 | if (code == null || code === '') { |
| 81 | 87 | 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' |
| ... | ... | @@ -83,38 +89,53 @@ export default { |
| 83 | 89 | return code; |
| 84 | 90 | } |
| 85 | 91 | }, |
| 86 | - toPay() { | |
| 87 | - let me = this | |
| 88 | - let _order = [] | |
| 89 | - this.orderId = JSON.parse(this.orderId) | |
| 90 | - console.log(this.orderId) | |
| 91 | - if (this.paySrcType == 103) { | |
| 92 | - this.orderId.forEach(item => { | |
| 93 | - _order.push({ | |
| 94 | - orderId: item | |
| 95 | - }) | |
| 96 | - }) | |
| 97 | - this.orderId = [] | |
| 98 | - this.orderId = _order | |
| 99 | - } | |
| 92 | + doOrderCreate(orderID) { // 欠费创建订单号 | |
| 93 | + var jsondata = { | |
| 94 | + orderBigType: 100, | |
| 95 | + payOrderType: this.paySrcType, | |
| 96 | + parkOrderIds: orderID, | |
| 97 | + terminalSource: 7, | |
| 98 | + operName: '', | |
| 99 | + operCode: '', | |
| 100 | + }; | |
| 101 | + // jsondata = JSON.stringify(jsondata); | |
| 102 | + doOrderCreate(jsondata).then(res => { | |
| 103 | + console.log(res) | |
| 104 | + this.orderId = res.data.rltOrderId | |
| 105 | + console.log(this.orderId) | |
| 106 | + this.dopay(this.orderId) | |
| 107 | + }) | |
| 100 | 108 | |
| 109 | + }, | |
| 110 | + getUrlParam(name) { | |
| 111 | + var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)'); | |
| 112 | + var r = window.location.search.substr(1).match(reg) | |
| 113 | + if (r != null) return unescape(r[2]) | |
| 114 | + return null | |
| 115 | + }, | |
| 116 | + dopay(orderID) { | |
| 117 | + let me = this | |
| 101 | 118 | if (this.clientBrowser == '支付宝') { // 支付宝支付 |
| 102 | - var aliParams = {}; | |
| 103 | - console.log(this.orderId) | |
| 104 | - console.log(typeof this.orderId) | |
| 105 | - aliParams.orderId = this.orderId; | |
| 106 | - aliParams.carNumber = this.carNumber; | |
| 107 | - aliParams.payType = 1;// 1:支付宝 2:微信 3:银联 10:H5 4微信公众号 | |
| 108 | - aliParams.terminalSource = 7;//请求端来源 1: 任你停 2:pda 3:微信公共号 7:H5扫码 10页面支付 | |
| 109 | - aliParams.paySrcType = this.paySrcType;//101停车支付 | |
| 110 | - aliParams.orgId = this.$utils.myOrgId, | |
| 111 | - aliParams.backType = 2, | |
| 112 | - aliParams.recordArreaInfos = JSON.stringify(this.orderId); | |
| 113 | - | |
| 114 | - aliPay(aliParams).then(response => { | |
| 119 | + var jsondata = { | |
| 120 | + orderBigType: 100, | |
| 121 | + payOrderType: this.paySrcType, | |
| 122 | + rltOrderId: orderID, | |
| 123 | + payType: 1, // 1 是支付宝 2是微信 | |
| 124 | + terminalSource: 7, | |
| 125 | + orderActFee: this.arrearageActFee, | |
| 126 | + orderTotalFee: this.arrearageTotalFee, | |
| 127 | + orderDicountFee: this.arrearageDiscFee, | |
| 128 | + payUserId: '', | |
| 129 | + terminalOS: this.isAndroid ? 'AND' : 'IOS', | |
| 130 | + couponType: 1, //优惠类型 | |
| 131 | + couponCode: this.arrearageDiscFee, | |
| 132 | + }; | |
| 133 | + | |
| 134 | + doPay(jsondata).then(response => { | |
| 115 | 135 | console.log(response) |
| 116 | 136 | if (response.code == 0) {//进场 |
| 117 | - document.write(response.data);//打开支付表单 | |
| 137 | + window.location.href = response.data.h5PayRequest | |
| 138 | + // document.write(response.data);//打开支付表单 | |
| 118 | 139 | } else {//其他情况如【该卡号场内已存在】 |
| 119 | 140 | console.log(response.message); |
| 120 | 141 | } |
| ... | ... | @@ -130,57 +151,82 @@ export default { |
| 130 | 151 | }; |
| 131 | 152 | getOpenId(codeParams).then(res => { |
| 132 | 153 | if (res.code == 0) { |
| 133 | - me.vxPay(res.data, this.orderId) | |
| 154 | + // me.vxPay(res.data, this.orderId) | |
| 155 | + | |
| 156 | + var jsondata = { | |
| 157 | + orderBigType: 100, | |
| 158 | + payOrderType: this.paySrcType, | |
| 159 | + rltOrderId: orderID, | |
| 160 | + payType: 2, // 1 是支付宝 2是微信 | |
| 161 | + terminalSource: 7, | |
| 162 | + orderActFee: this.arrearageActFee, | |
| 163 | + orderTotalFee: this.arrearageTotalFee, | |
| 164 | + orderDicountFee: this.arrearageDiscFee, | |
| 165 | + payUserId: res.data, | |
| 166 | + terminalOS: this.isAndroid ? 'AND' : 'IOS', | |
| 167 | + couponType: 1, //优惠类型 | |
| 168 | + couponCode: this.arrearageDiscFee, | |
| 169 | + }; | |
| 170 | + | |
| 171 | + doPay(jsondata).then(response => { | |
| 172 | + console.log(response) | |
| 173 | + if (res.code == 0) { // | |
| 174 | + //alertMsg("出场成功"); | |
| 175 | + if (res.data) { | |
| 176 | + var data = res.data; | |
| 177 | + console.log(JSON.stringify(data)); | |
| 178 | + if (typeof WeixinJSBridge === 'undefined') { // 微信浏览器内置对象。参考微信官方文档 | |
| 179 | + if (document.addEventListener) { | |
| 180 | + document.addEventListener('WeixinJSBridgeReady', vm.onBridgeReady(data), false) | |
| 181 | + } else if (document.attachEvent) { | |
| 182 | + document.attachEvent('WeixinJSBridgeReady', vm.onBridgeReady(data)) | |
| 183 | + document.attachEvent('onWeixinJSBridgeReady', vm.onBridgeReady(data)) | |
| 184 | + } | |
| 185 | + } else { | |
| 186 | + console.log('准备调用微信支付') | |
| 187 | + vm.onBridgeReady(data) | |
| 188 | + } | |
| 189 | + } else { | |
| 190 | + alert("没有找到返回值"); | |
| 191 | + } | |
| 192 | + } else { | |
| 193 | + alert('支付错误') | |
| 194 | + console.log(res.message); | |
| 195 | + alert(res.message); | |
| 196 | + } | |
| 197 | + | |
| 198 | + }) | |
| 199 | + | |
| 134 | 200 | } else if (res.code == 40163) { //code been used, hints[重复code问题] |
| 201 | + alert('获取opendid错误--------') | |
| 135 | 202 | alert(res.message) |
| 136 | 203 | console.log(res.message); |
| 137 | 204 | } else { |
| 205 | + alert('获取opendid错误') | |
| 138 | 206 | alert(res.message) |
| 139 | 207 | } |
| 140 | 208 | }) |
| 141 | 209 | |
| 142 | 210 | } |
| 143 | - | |
| 144 | 211 | }, |
| 145 | - vxPay(openIdData, orderIdData) { | |
| 146 | - var wxParams = {}; | |
| 147 | - wxParams.orderId = orderIdData; | |
| 148 | - wxParams.backType = 2, | |
| 149 | - wxParams.orgId = this.$utils.myOrgId, | |
| 150 | - wxParams.payType = 4;// 1:支付宝 2:微信 3:银联 10:H5 4微信公众号 | |
| 151 | - wxParams.terminalSource = 7;//请求端来源 1: 任你停 2:pda 3:微信公共号 7:H5扫码 10页面支付 | |
| 152 | - wxParams.carNumber = this.carNumber; | |
| 153 | - wxParams.paySrcType = this.paySrcType;//101停车支付 | |
| 154 | - wxParams.recordArreaInfos = JSON.stringify(orderIdData); | |
| 155 | - wxParams.openId = openIdData; | |
| 156 | - wxParams.appId = this.$utils.myVxAppId; | |
| 157 | - vxPayQuery(wxParams).then( res => { | |
| 158 | - if (res.code == 0) { // | |
| 159 | - //alertMsg("出场成功"); | |
| 160 | - if (res.data) { | |
| 161 | - var data = res.data; | |
| 162 | - console.log(JSON.stringify(data)); | |
| 163 | - if (typeof WeixinJSBridge === 'undefined') { // 微信浏览器内置对象。参考微信官方文档 | |
| 164 | - if (document.addEventListener) { | |
| 165 | - document.addEventListener('WeixinJSBridgeReady', vm.onBridgeReady(data), false) | |
| 166 | - } else if (document.attachEvent) { | |
| 167 | - document.attachEvent('WeixinJSBridgeReady', vm.onBridgeReady(data)) | |
| 168 | - document.attachEvent('onWeixinJSBridgeReady', vm.onBridgeReady(data)) | |
| 169 | - } | |
| 170 | - } else { | |
| 171 | - console.log('准备调用微信支付') | |
| 172 | - vm.onBridgeReady(data) | |
| 173 | - } | |
| 174 | - } else { | |
| 175 | - alert("没有找到返回值"); | |
| 176 | - } | |
| 177 | - } else { | |
| 178 | - console.log(res.message); | |
| 179 | - alert(res.message); | |
| 180 | - } | |
| 181 | - }) | |
| 212 | + toPay() { | |
| 213 | + let me = this | |
| 214 | + let _order = [] | |
| 215 | + // this.orderId = JSON.parse(this.orderId) | |
| 216 | + console.log(this.orderId) | |
| 217 | + if (this.paySrcType == 103) { | |
| 218 | + this.orderId = JSON.parse(this.orderId) | |
| 219 | + this.doOrderCreate(this.orderId) | |
| 220 | + } else { | |
| 221 | + console.log(this.orderId) | |
| 222 | + console.log(typeof this.orderId) | |
| 223 | + | |
| 224 | + this.dopay(this.orderId) | |
| 225 | + } | |
| 226 | + | |
| 182 | 227 | }, |
| 183 | - onBridgeReady (data) { | |
| 228 | + | |
| 229 | + onBridgeReady(data) { | |
| 184 | 230 | console.log('调用微信支付WeixinJSBridge') |
| 185 | 231 | var vm = this |
| 186 | 232 | WeixinJSBridge.invoke( |
| ... | ... | @@ -197,7 +243,7 @@ export default { |
| 197 | 243 | function (res) { |
| 198 | 244 | // 使用以上方式判断前端返回,微信团队郑重提示:res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。 |
| 199 | 245 | if (res.err_msg === 'get_brand_wcpay_request:ok') { |
| 200 | - console.log('成功') | |
| 246 | + console.log('成功') | |
| 201 | 247 | } else { |
| 202 | 248 | console.log('失败') |
| 203 | 249 | alert('支付失败') |
| ... | ... | @@ -206,27 +252,7 @@ export default { |
| 206 | 252 | ) |
| 207 | 253 | }, |
| 208 | 254 | }, |
| 209 | - filters: { | |
| 210 | - // formateColor(val) { // 0:蓝牌;1:黄牌;2:白牌;3:黑牌;4:绿色 | |
| 211 | - // switch (val) { | |
| 212 | - // case 0: | |
| 213 | - // return 'carBlue' | |
| 214 | - // break; | |
| 215 | - // case 1: | |
| 216 | - // return 'carYellow' | |
| 217 | - // break; | |
| 218 | - // case 2: | |
| 219 | - // return 'carWhite' | |
| 220 | - // break; | |
| 221 | - // case 3: | |
| 222 | - // return ' carBlack' | |
| 223 | - // break; | |
| 224 | - // case 4: | |
| 225 | - // return 'carGreen' | |
| 226 | - // break; | |
| 227 | - // } | |
| 228 | - // } | |
| 229 | - } | |
| 255 | + | |
| 230 | 256 | } |
| 231 | 257 | </script> |
| 232 | 258 | ... | ... |
src/components/parkRecord.vue
| ... | ... | @@ -15,7 +15,7 @@ |
| 15 | 15 | <div v-show="currentTabActive==0"> |
| 16 | 16 | |
| 17 | 17 | <div v-if="parkingData.length>0"> |
| 18 | - <p class="free-tip" v-if="parkingData[0].parkDuration<=1800">停车30分钟内无需缴费,请直接离场。</p> | |
| 18 | + <p class="free-tip" v-if="parkingData[0].parkDuration<=2100">停车30分钟内无需缴费,请直接离场。</p> | |
| 19 | 19 | |
| 20 | 20 | <div class="cost-main" v-for="i in parkingData"> |
| 21 | 21 | <ul class="cost-header"> |
| ... | ... | @@ -34,7 +34,7 @@ |
| 34 | 34 | <p>停车时长:{{ $utils.dateFormat(i.parkDuration)}}</p> |
| 35 | 35 | <div class="out-wrap"> |
| 36 | 36 | <p class="mon-wrap">¥{{(i.unPayFee/100).toFixed(2)}}</p> |
| 37 | - <p class="out-btn" @click="toPayCurrent(i)" v-if="parkingData[0].parkDuration>1800">出场缴费</p> | |
| 37 | + <p class="out-btn" @click="toPayCurrent(i)" v-if="parkingData[0].parkDuration>2100">出场缴费</p> | |
| 38 | 38 | </div> |
| 39 | 39 | </div> |
| 40 | 40 | </div> |
| ... | ... | @@ -133,7 +133,7 @@ export default { |
| 133 | 133 | return { |
| 134 | 134 | tabList: [ // 切换数据 |
| 135 | 135 | { text: '在停缴费', id: 1 }, |
| 136 | - { text: '离场待缴', id: 2 }, | |
| 136 | + { text: '欠费待缴', id: 2 }, | |
| 137 | 137 | ], |
| 138 | 138 | carColor: 1,// 车牌颜色 |
| 139 | 139 | currentTabActive: 1, // 显示当前哪个 | ... | ... |
src/utils/utils.js
| ... | ... | @@ -95,7 +95,10 @@ export default { |
| 95 | 95 | |
| 96 | 96 | myDeviceInfo: 'BC0703A4-AFB0-4B51-9089-9B7487C0CC6E', // 公共请求设备信息 |
| 97 | 97 | |
| 98 | - myVxAppId: 'wxa1a66cc7d263afe6' , // 微信赤峰 appid wx2af2bab90d433c86 //黄石 appid wxa1a66cc7d263afe6 | |
| 98 | + myVxAppId: 'wxa1a66cc7d263afe6', | |
| 99 | + // 测试环境 微信赤峰 appid wxff4cebaedbf4f886 | |
| 100 | + // 微信赤峰 appid wx2af2bab90d433c86 | |
| 101 | + // 黄石 appid wxa1a66cc7d263afe6 | |
| 99 | 102 | |
| 100 | 103 | myOrgId: '10079', // 归属地 赤峰id 10003 黄石 10079 |
| 101 | 104 | ... | ... |