Blame view

src/views/parkPay/orderPay.vue 15 KB
0c49c87e   liuqimichale   微信公众号 初始化
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
  <template>
    <div>
      <div class="car-wrap">
        <div class="carBG" :class="carWrapBG | formateColor">
          <p class="carNumber">{{carNumber}}</p>
          <p class="payFee">{{(arrearageActFee/100).toFixed(2)}}元</p>
        </div>
      </div>
  
      <ul class="fee-wrap">
        <li>
          <span>待缴金额</span>
          <span>{{(arrearageActFee/100).toFixed(2)}}</span>
        </li>
        <li>
          <span>优惠金额</span>
          <span>{{(arrearageDiscFee/100).toFixed(2)}}</span>
        </li>
        <li>
          <span>应付金额</span>
          <span>{{(arrearageActFee/100).toFixed(2)}}</span>
        </li>
      </ul>
c14fb301   liuqimichale   赤峰 输入车牌停车记录
24
  
f36d25ac   刘淇   西城家园
25
26
      <!--<p style="margin-top: 20px;padding-left: 15px;">停车引导员工号(非必填)</p>-->
      <!--<mt-field style="font-size: 14px;color: #333;" label="" placeholder="请输入员工号" type="number" v-model="tollNumber" :attr="{ oninput: 'if(value.length>7)value=value.slice(0,7)' }" ></mt-field>-->
c14fb301   liuqimichale   赤峰 输入车牌停车记录
27
28
  
  
0c49c87e   liuqimichale   微信公众号 初始化
29
      <div style="padding: 20px 18px">
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
30
        <div class="toPay" @click="toPay">{{clientBrowser}}支付</div>
0c49c87e   liuqimichale   微信公众号 初始化
31
32
      </div>
  
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
33
      <div v-if="appOrderTimeout.length>0">
0c49c87e   liuqimichale   微信公众号 初始化
34
35
36
37
38
39
40
41
42
43
44
45
46
47
        <p class="tip">
          温馨提示:
        </p>
        <p style="color: #666;padding: 0 18px;">
          {{appOrderTimeout}}
        </p>
      </div>
  
  
  
    </div>
  </template>
  
  <script>
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
48
49
50
51
  // import CryptoJS from '../utils/AES.js'
  // let Base64 = require('js-base64').Base64
  import {  MessageBox } from 'mint-ui';
  import { aliPay, getOpenId, vxPayQuery, bankH5Pay, queryParkingRecordPageByCarNumbers } from '@/api/orderPay/orderPay'
0c49c87e   liuqimichale   微信公众号 初始化
52
53
54
55
56
57
  
  export default {
    name: 'orderPay',
    data() {
      return {
        carWrapBG: 0,
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
58
        carNumber: '',
0c49c87e   liuqimichale   微信公众号 初始化
59
60
61
        arrearageActFee: 0,
        arrearageDiscFee: 0,
        arrearageActFee: 0,
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
62
63
64
        parkingData: [], //  在停数据
        historyList: [], // 历史欠费数据
        clientBrowser: '', // 客户端
0c49c87e   liuqimichale   微信公众号 初始化
65
66
67
68
        paySrcType: '', //支付的类型   101 是本次   103是历史欠费
        orderId: '',  //支付的订单
        webAppCode: '', // 微信code
        appOrderTimeout: '', // 超时描述
c14fb301   liuqimichale   赤峰 输入车牌停车记录
69
        tollNumber:'', // 收费员员工号
0c49c87e   liuqimichale   微信公众号 初始化
70
71
72
73
74
75
76
77
      }
    },
    created() {
      this.carWrapBG = this.$route.query.carColor //车牌颜色
      this.carNumber = this.$route.query.carNumber
      this.arrearageTotalFee = this.$route.query.arrearageTotalFee // 应收
      this.arrearageDiscFee = this.$route.query.arrearageDiscFee // 优惠
      this.arrearageActFee = this.$route.query.arrearageActFee // 实收
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
78
      this.clientBrowser = this.$utils.clientBrowser() //支付方式
0c49c87e   liuqimichale   微信公众号 初始化
79
      this.paySrcType = this.$route.query.paySrcType // 实收
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
80
      this.orderId = this.$route.query.ordeID
0c49c87e   liuqimichale   微信公众号 初始化
81
      console.log(this.orderId)
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
82
83
84
85
86
      this.appOrderTimeout = this.$route.query.appOrderTimeout
      if (this.clientBrowser == "微信") {
        this.webAppCode = this.getCode();
      }
  
0c49c87e   liuqimichale   微信公众号 初始化
87
  
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
88
89
90
  
    },
    mounted(){
0c49c87e   liuqimichale   微信公众号 初始化
91
  
0c49c87e   liuqimichale   微信公众号 初始化
92
93
94
95
96
97
98
99
100
101
102
103
    },
    methods: {
      getCode() {
        var appID = this.$utils.myVxAppId;
        var code = this.getUrlParam('code');
        var local = window.location.href;
        if (code == null || code === '') {
          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'
        } else {
          return code;
        }
      },
0c49c87e   liuqimichale   微信公众号 初始化
104
105
106
107
108
109
      getUrlParam(name) {
        var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)');
        var r = window.location.search.substr(1).match(reg)
        if (r != null) return unescape(r[2])
        return null
      },
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
110
      toPay() {
0c49c87e   liuqimichale   微信公众号 初始化
111
        let me = this
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
112
113
114
115
116
117
118
119
120
121
122
123
124
125
        let _order = []
  
        console.log(this.orderId)
        if (this.paySrcType == 103) {
          this.orderId = JSON.parse(this.orderId)
          this.orderId.forEach(item => {
            _order.push({
              orderId: item
            })
          })
          this.orderId = []
          this.orderId = _order
        }
  
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
126
  
943f9186   刘淇   支持支付宝
127
        if (this.clientBrowser == '支付宝') { // 支付宝支付
f36d25ac   刘淇   西城家园
128
          console.log('1')
943f9186   刘淇   支持支付宝
129
130
131
132
          let me = this
          var aliParams = {};
          aliParams.orderId = this.orderId;
          aliParams.carNumber = this.carNumber;
f36d25ac   刘淇   西城家园
133
134
          aliParams.payType = '1';// 1:支付宝 2:微信 3:银联 10:H5   4微信公众号
          aliParams.terminalSource = '3';//请求端来源 1: 任你停 2:pda 3:微信公共号 7:H5扫码 10页面支付
943f9186   刘淇   支持支付宝
135
136
          aliParams.paySrcType = this.paySrcType;//101停车支付
          aliParams.orgId = this.$utils.myOrgId
f36d25ac   刘淇   西城家园
137
          aliParams.backType = '2'
943f9186   刘淇   支持支付宝
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
          aliParams.backDeveloperCode = this.tollNumber
          aliParams.recordArreaInfos = JSON.stringify(this.orderId);
          console.log(aliParams)
          aliPay(aliParams).then(response => {
            console.log(response)
            if (response.code == 0) {//进场
              document.write(response.data);//打开支付表单
            } else if(response.code == 1002){//其他情况如【该卡号场内已存在】
              console.log(response.message);
              MessageBox.confirm('', {
                message: response.message,
                title: '温馨提示',
                showCancelButton:false,
                confirmButtonText: '确定',
              }).then(action => {
                if (action == 'confirm') {     //确认的回调
                  console.log('确定');
                  this.$router.go(-1)
                }
              }).catch(err => {
                if (err == 'cancel') {     //取消的回调
                  console.log('取消');
                }
              });
            }else{
              alert(response.message)
            }
  
          })
        }
  
  
7850cc26   liuqimichale   赤峰微信公众号 -- 临停支付
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
        if (this.clientBrowser == '微信') { // 微信支付
          let _openId = sessionStorage.getItem('openIdData')
          if(_openId){
            me.vxPay(_openId, this.orderId)
          }else{
            //第一步获取openid
            var codeParams = {
              code: this.webAppCode,
              appId: this.$utils.myVxAppId
            };
            getOpenId(codeParams).then(res => {
              if (res.code == 0) {
                me.vxPay(res.data, this.orderId)
                sessionStorage.setItem('openIdData',res.data)
              } else if (res.code == 40163) { //code been used, hints[重复code问题]
e4f61055   刘淇   赤峰正式环境 默认蒙D车牌
185
                alert('请重新支付!重复code问题')
7850cc26   liuqimichale   赤峰微信公众号 -- 临停支付
186
                console.log(res.message);
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
187
              } else {
e4f61055   刘淇   赤峰正式环境 默认蒙D车牌
188
                alert('请重新支付')
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
189
              }
7850cc26   liuqimichale   赤峰微信公众号 -- 临停支付
190
191
            })
          }
0c49c87e   liuqimichale   微信公众号 初始化
192
        }
0c49c87e   liuqimichale   微信公众号 初始化
193
      },
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
194
195
196
197
198
      vxPay(openIdData, orderIdData) {
        let vm = this
        var wxParams = {};
        wxParams.orderId = orderIdData;
        wxParams.backType = 2,
7850cc26   liuqimichale   赤峰微信公众号 -- 临停支付
199
200
        wxParams.orgId = this.$utils.myOrgId,
        wxParams.payType = 4;// 1:支付宝 2:微信 3:银联 10:H5   4微信公众号
f36d25ac   刘淇   西城家园
201
        wxParams.terminalSource = 3;//请求端来源 1: 任你停 2:pda 3:微信公共号 7:H5扫码 10页面支付
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
202
203
204
205
        wxParams.carNumber = this.carNumber;
        wxParams.paySrcType = this.paySrcType;//101停车支付
        wxParams.recordArreaInfos = JSON.stringify(orderIdData);
        wxParams.openId = openIdData;
c14fb301   liuqimichale   赤峰 输入车牌停车记录
206
        wxParams.backDeveloperCode = this.tollNumber,
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
        wxParams.appId = this.$utils.myVxAppId;
        vxPayQuery(wxParams).then(res => {
          if (res.code == 0) { //
            if (res.data) {
              var data = res.data;
              console.log(JSON.stringify(data));
              if (typeof WeixinJSBridge === 'undefined') { // 微信浏览器内置对象。参考微信官方文档
                if (document.addEventListener) {
                  document.addEventListener('WeixinJSBridgeReady', vm.onBridgeReady(data), false)
                } else if (document.attachEvent) {
                  document.attachEvent('WeixinJSBridgeReady', vm.onBridgeReady(data))
                  document.attachEvent('onWeixinJSBridgeReady', vm.onBridgeReady(data))
                }
              } else {
                console.log('准备调用微信支付')
                vm.onBridgeReady(data)
              }
            } else {
              alert("没有找到返回值");
            }
c14fb301   liuqimichale   赤峰 输入车牌停车记录
227
          } else if(res.code == 1002){//其他情况如【该卡号场内已存在】
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
228
            console.log(res.message);
c14fb301   liuqimichale   赤峰 输入车牌停车记录
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
            MessageBox.confirm('', {
              message: res.message,
              title: '温馨提示',
              showCancelButton:false,
              confirmButtonText: '确定',
            }).then(action => {
              if (action == 'confirm') {     //确认的回调
                console.log('确定');
                this.$router.go(-1)
              }
            }).catch(err => {
              if (err == 'cancel') {     //取消的回调
                console.log('取消');
              }
            });
          }else{
            alert(res.message)
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
246
247
248
          }
        })
      },
0c49c87e   liuqimichale   微信公众号 初始化
249
      onBridgeReady(params) {
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
250
        let me = this
0c49c87e   liuqimichale   微信公众号 初始化
251
252
        console.log('调用微信支付WeixinJSBridge')
        WeixinJSBridge.invoke(
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
253
          'getBrandWCPayRequest', params,
0c49c87e   liuqimichale   微信公众号 初始化
254
255
256
257
258
259
260
261
262
263
264
265
266
          //
          // 'getBrandWCPayRequest', { // 下面参数内容都是后台返回的
          //   'appId': data.appId, // 公众号名称,由商户传入
          //   'timeStamp': data.timeStamp, // 时间戳
          //   'nonceStr': data.nonceStr, // 随机串
          //   'package': data.package, // 预支付id
          //   'signType': data.signType, // 微信签名方式
          //   'paySign': data.paySign // 微信签名
          // },
          function (res) {
            // 使用以上方式判断前端返回,微信团队郑重提示:res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
            if (res.err_msg === 'get_brand_wcpay_request:ok') {
              console.log('成功')
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
267
268
269
270
271
              var salt = me.$utils.myCommonSalt(32);
              let wxparams = {
                pageNum: 1,
                pageSize: 10000,
                parkState: 10,
f36d25ac   刘淇   西城家园
272
                terminalSource: 3,
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
273
274
275
276
277
278
279
280
281
282
283
284
                carNumber: me.carNumber,
                app_id: me.$utils.myVarAppid,
                deviceInfo: me.$utils.myDeviceInfo,
                salt: salt,
                sign_type: "md5",
                token:'',
              }
              wxparams.sign = me.$utils.signObject(wxparams)
              queryParkingRecordPageByCarNumbers(wxparams).then(response => {
                console.log(response)
                me.parkList = response.data.dataList
  
7850cc26   liuqimichale   赤峰微信公众号 -- 临停支付
285
286
                // alert(JSON.stringify(me.parkList))
                // alert(me.parkList.length)
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
287
288
289
290
291
292
293
294
295
                if(me.parkList.length == 0){
                  me.$router.push({
                    path:'parkRecord',
                    query:{
                      carNumber: me.carNumber,
                      carNumberColor: me.carWrapBG,
                      parkFlag: 0 //  0表示在停    1表示历史
                    }
                  })
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
296
  
7850cc26   liuqimichale   赤峰微信公众号 -- 临停支付
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
                }else{
                  me.parkingData = me.parkList.filter(item => {
                    return item.parkState == '10'
                  })
                  console.log(me.parkingData)
                  me.historyList = me.parkList.filter(item => {
                    return item.parkState == '20'
                  })
                  console.log(me.historyList)
  
                  if(me.historyList.length>0){
                    MessageBox.confirm('', {
                      message: '您当前有历史欠费 是否立即补缴?',
                      title: '温馨提示',
                      confirmButtonText: '去补缴',
                      cancelButtonText: '取消'
                    }).then(action => {
                      if (action == 'confirm') {     //确认的回调
                        console.log('确定');
                        me.$router.push({
                          path:'parkRecord',
                          query:{
                            carNumber: me.carNumber,
                            carNumberColor: me.carWrapBG,
                            parkFlag: 1 //  0表示在停    1表示历史
                          }
                        })
                      }
                    }).catch(err => {
                      if (err == 'cancel') {     //取消的回调
                        console.log('取消');
                      }
                    });
                  }else{
  
                    if(me.paySrcType==101){  //缴费了本次
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
333
334
335
336
337
338
339
340
                      me.$router.push({
                        path:'parkRecord',
                        query:{
                          carNumber: me.carNumber,
                          carNumberColor: me.carWrapBG,
                          parkFlag: 0 //  0表示在停    1表示历史
                        }
                      })
7850cc26   liuqimichale   赤峰微信公众号 -- 临停支付
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
                    }else{
                      MessageBox.confirm('', {
                        message: '您当前有在停订单 是否立即支付?',
                        title: '温馨提示',
                        confirmButtonText: '去支付',
                        cancelButtonText: '取消'
                      }).then(action => {
                        if (action == 'confirm') {     //确认的回调
                          console.log('确定');
                          me.$router.push({
                            path:'parkRecord',
                            query:{
                              carNumber: me.carNumber,
                              carNumberColor: me.carWrapBG,
                              parkFlag: 0 //  0表示在停    1表示历史
                            }
                          })
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
358
                        }
7850cc26   liuqimichale   赤峰微信公众号 -- 临停支付
359
360
361
362
363
                      }).catch(err => {
                        if (err == 'cancel') {     //取消的回调
                          console.log('取消');
                        }
                      });
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
364
                    }
7850cc26   liuqimichale   赤峰微信公众号 -- 临停支付
365
366
  
                  }
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
367
368
                }
  
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
369
370
  
  
7850cc26   liuqimichale   赤峰微信公众号 -- 临停支付
371
              })
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
372
373
374
  
  
  
0c49c87e   liuqimichale   微信公众号 初始化
375
376
377
            } else {
              console.log('失败')
              alert('支付失败')
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
378
              me.$router.go(-2);
0c49c87e   liuqimichale   微信公众号 初始化
379
380
381
382
383
            }
          }
        )
      },
    },
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
384
385
    filters: {
    }
0c49c87e   liuqimichale   微信公众号 初始化
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
  }
  </script>
  
  <style scoped lang="scss">
    .car-wrap {
      padding: 7px 7px;
      background: #FFF;
    }
  
    .carBG {
      width: 100%;
      height: 130px;
    }
  
    .carBlue {
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
401
      background: url("../../assets/images/blueBG.png") no-repeat;
0c49c87e   liuqimichale   微信公众号 初始化
402
403
404
405
      background-size: 100% 100%;
    }
  
    .carYellow {
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
406
      background: url("../../assets/images/yellowBG.png") no-repeat;
0c49c87e   liuqimichale   微信公众号 初始化
407
408
409
410
      background-size: 100% 100%;
    }
  
    .carGreen {
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
411
      background: url("../../assets/images/greenBG.png") no-repeat;
0c49c87e   liuqimichale   微信公众号 初始化
412
413
414
415
      background-size: 100% 100%;
    }
  
    .carWhite {
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
416
      background: url("../../assets/images/whiteBG.png") no-repeat;
0c49c87e   liuqimichale   微信公众号 初始化
417
418
419
420
      background-size: 100% 100%;
    }
  
    .carBlack {
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
421
      background: url("../../assets/images/blackBG.png") no-repeat;
0c49c87e   liuqimichale   微信公众号 初始化
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
      background-size: 100% 100%;
    }
  
    .carNumber {
      padding: 20px 0 10px;
      font-size: 30px;
      color: #fff;
      text-align: center;
    }
  
    .payFee {
      font-size: 24px;
      color: #FF7B7B;
      text-align: center;
    }
  
    .fee-wrap {
      background: #FFF;
      padding: 0 18px;
      > li {
        display: flex;
        justify-content: space-between;
        height: 30px;
        line-height: 30px;
        border-bottom: 1px solid #EAEAEA;
        &:last-child {
          border-bottom: 0;
        }
      }
  
    }
  
    .toPay {
      width: 100%;
      height: 44px;
      margin: 0 auto;
      line-height: 44px;
      text-align: center;
      background: linear-gradient(180deg, #3885D9 0%, #4194EF 100%);
      border-radius: 4px;
      border: 1px solid #0D72E2;
      font-size: 20px;
      color: #FFF;
      cursor: pointer;
    }
  
    .tip {
      padding-left: 40px;
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
470
      background: url("../../assets/images/tip.png") no-repeat 18px center;
0c49c87e   liuqimichale   微信公众号 初始化
471
472
473
474
      background-size: 16px 16px;
      color: #666;
    }
  </style>