Blame view

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