Blame view

src/views/parkPay/orderPay.vue 9.43 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
24
  <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>
      <div style="padding: 20px 18px">
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
25
        <div class="toPay" @click="toPay">{{clientBrowser}}支付</div>
0c49c87e   liuqimichale   微信公众号 初始化
26
27
      </div>
  
49f85de6   liuqimichale   黄石微信公众号 -- 临停支付
28
      <div v-if="appOrderTimeout">
0c49c87e   liuqimichale   微信公众号 初始化
29
30
31
32
33
34
35
36
37
38
39
40
41
42
        <p class="tip">
          温馨提示:
        </p>
        <p style="color: #666;padding: 0 18px;">
          {{appOrderTimeout}}
        </p>
      </div>
  
  
  
    </div>
  </template>
  
  <script>
49f85de6   liuqimichale   黄石微信公众号 -- 临停支付
43
  import {aliPay, getOpenId, vxPayQuery, doPay, doOrderCreate} from '@/api/orderPay/orderPay'
0c49c87e   liuqimichale   微信公众号 初始化
44
45
46
47
48
49
  
  export default {
    name: 'orderPay',
    data() {
      return {
        carWrapBG: 0,
49f85de6   liuqimichale   黄石微信公众号 -- 临停支付
50
        carNumber: '京A12312',
0c49c87e   liuqimichale   微信公众号 初始化
51
52
53
        arrearageActFee: 0,
        arrearageDiscFee: 0,
        arrearageActFee: 0,
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
54
        clientBrowser: '', // 客户端
0c49c87e   liuqimichale   微信公众号 初始化
55
56
57
58
        paySrcType: '', //支付的类型   101 是本次   103是历史欠费
        orderId: '',  //支付的订单
        webAppCode: '', // 微信code
        appOrderTimeout: '', // 超时描述
49f85de6   liuqimichale   黄石微信公众号 -- 临停支付
59
        isAndroid: '', // 终端类型
0c49c87e   liuqimichale   微信公众号 初始化
60
61
62
      }
    },
    created() {
0c49c87e   liuqimichale   微信公众号 初始化
63
64
65
66
67
      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   赤峰微信公众号 -- 临停支付
68
      this.clientBrowser = this.$utils.clientBrowser() //支付方式
0c49c87e   liuqimichale   微信公众号 初始化
69
      this.paySrcType = this.$route.query.paySrcType // 实收
49f85de6   liuqimichale   黄石微信公众号 -- 临停支付
70
      this.orderId = this.$route.query.ordeID // 订单号
0c49c87e   liuqimichale   微信公众号 初始化
71
      console.log(this.orderId)
49f85de6   liuqimichale   黄石微信公众号 -- 临停支付
72
73
74
75
76
      this.appOrderTimeout = this.$route.query.appOrderTimeout  //提示
  
      let userAgent = navigator.userAgent;
      this.isAndroid = userAgent.indexOf('Android') > -1 || userAgent.indexOf('Adr') > -1; //android终端
  
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
77
78
79
      if (this.clientBrowser == "微信") {
        this.webAppCode = this.getCode();
      }
0c49c87e   liuqimichale   微信公众号 初始化
80
81
82
83
84
85
86
87
88
89
90
91
    },
    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;
        }
      },
49f85de6   liuqimichale   黄石微信公众号 -- 临停支付
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
      doOrderCreate(orderID) { // 欠费创建订单号
        var jsondata = {
          orderBigType: 100,
          payOrderType: this.paySrcType,
          parkOrderIds: orderID,
          terminalSource: 7,
          operName: '',
          operCode: '',
        };
        // jsondata = JSON.stringify(jsondata);
        doOrderCreate(jsondata).then(res => {
          console.log(res)
          this.orderId = res.data.rltOrderId
          console.log(this.orderId)
          this.dopay(this.orderId)
        })
  
      },
0c49c87e   liuqimichale   微信公众号 初始化
110
111
112
113
114
115
      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
      },
49f85de6   liuqimichale   黄石微信公众号 -- 临停支付
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
      dopay(orderID) {
        let me = this
  
        if (this.clientBrowser == '微信') { // 微信支付
          var vm = this
          //第一步获取openid
          var codeParams = {
            code: this.webAppCode,
            appId: this.$utils.myVxAppId
          };
          getOpenId(codeParams).then(resu => {
            if (resu.code == 0) {
              // me.vxPay(res.data, this.orderId)
  
              var jsondata = {
                orderBigType: 100,
                payOrderType: this.paySrcType,
                rltOrderId: orderID,
                payType: 2, // 1 是支付宝    2是微信
                terminalSource: 7,
                orderActFee: this.arrearageActFee,
                orderTotalFee: this.arrearageTotalFee,
                orderDicountFee: this.arrearageDiscFee,
                payUserId: resu.data,
                terminalOS: this.isAndroid ? 'AND' : 'IOS',
                couponType: 1, //优惠类型
                couponCode: this.arrearageDiscFee,
              };
  
              doPay(jsondata).then(res => {
                console.log(res)
                if (res.code == 0) { //
                  //alertMsg("出场成功");
                  if (res.data) {
                    var data = JSON.parse(res.data.jsPayRequest);
                    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("没有找到返回值");
                  }
                } else {
                  alert('支付错误')
                  console.log(res.message);
                  alert(res.message);
                }
  
              })
  
            } else if (res.code == 40163) { //code been used, hints[重复code问题]
              alert('获取opendid错误--------')
              alert(res.message)
              console.log(res.message);
            } else {
              alert('获取opendid错误')
              alert(res.message)
            }
          })
  
        }
      },
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
186
      toPay() {
0c49c87e   liuqimichale   微信公众号 初始化
187
        let me = this
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
188
        let _order = []
49f85de6   liuqimichale   黄石微信公众号 -- 临停支付
189
        // this.orderId = JSON.parse(this.orderId)
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
190
191
192
        console.log(this.orderId)
        if (this.paySrcType == 103) {
          this.orderId = JSON.parse(this.orderId)
49f85de6   liuqimichale   黄石微信公众号 -- 临停支付
193
194
195
196
          this.doOrderCreate(this.orderId)
        } else {
          console.log(this.orderId)
          console.log(typeof this.orderId)
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
197
  
49f85de6   liuqimichale   黄石微信公众号 -- 临停支付
198
          this.dopay(this.orderId)
0c49c87e   liuqimichale   微信公众号 初始化
199
        }
49f85de6   liuqimichale   黄石微信公众号 -- 临停支付
200
  
0c49c87e   liuqimichale   微信公众号 初始化
201
      },
49f85de6   liuqimichale   黄石微信公众号 -- 临停支付
202
  
0c49c87e   liuqimichale   微信公众号 初始化
203
      onBridgeReady(params) {
0c49c87e   liuqimichale   微信公众号 初始化
204
205
        console.log('调用微信支付WeixinJSBridge')
        WeixinJSBridge.invoke(
49f85de6   liuqimichale   黄石微信公众号 -- 临停支付
206
207
208
209
210
211
212
213
214
215
          'getBrandWCPayRequest', {
            "appId": params.appId,     //公众号名称,由商户传入
            "timeStamp": params.timeStamp,         //时间戳,自1970年以来的秒数
            "nonceStr": params.nonceStr, //随机串
            "package": params.package,
            "signType": params.signType,         //微信签名方式:
            "paySign": params.paySign //微信签名
          },
  
          // 'getBrandWCPayRequest', params,
0c49c87e   liuqimichale   微信公众号 初始化
216
217
218
219
220
221
222
223
224
225
226
227
228
          //
          // '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('成功')
0c49c87e   liuqimichale   微信公众号 初始化
229
230
            } else {
              console.log('失败')
49f85de6   liuqimichale   黄石微信公众号 -- 临停支付
231
              alert('支付失败')
0c49c87e   liuqimichale   微信公众号 初始化
232
233
234
235
236
            }
          }
        )
      },
    },
49f85de6   liuqimichale   黄石微信公众号 -- 临停支付
237
  
0c49c87e   liuqimichale   微信公众号 初始化
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
  }
  </script>
  
  <style scoped lang="scss">
    .car-wrap {
      padding: 7px 7px;
      background: #FFF;
    }
  
    .carBG {
      width: 100%;
      height: 130px;
    }
  
    .carBlue {
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
253
      background: url("../../assets/images/blueBG.png") no-repeat;
0c49c87e   liuqimichale   微信公众号 初始化
254
255
256
257
      background-size: 100% 100%;
    }
  
    .carYellow {
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
258
      background: url("../../assets/images/yellowBG.png") no-repeat;
0c49c87e   liuqimichale   微信公众号 初始化
259
260
261
262
      background-size: 100% 100%;
    }
  
    .carGreen {
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
263
      background: url("../../assets/images/greenBG.png") no-repeat;
0c49c87e   liuqimichale   微信公众号 初始化
264
265
266
267
      background-size: 100% 100%;
    }
  
    .carWhite {
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
268
      background: url("../../assets/images/whiteBG.png") no-repeat;
0c49c87e   liuqimichale   微信公众号 初始化
269
270
271
272
      background-size: 100% 100%;
    }
  
    .carBlack {
bb951693   liuqimichale   赤峰微信公众号 -- 临停支付
273
      background: url("../../assets/images/blackBG.png") no-repeat;
0c49c87e   liuqimichale   微信公众号 初始化
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
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
      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   赤峰微信公众号 -- 临停支付
322
      background: url("../../assets/images/tip.png") no-repeat 18px center;
0c49c87e   liuqimichale   微信公众号 初始化
323
324
325
326
      background-size: 16px 16px;
      color: #666;
    }
  </style>