Blame view

src/views/cards/renew.vue 18.1 KB
555e2a0e   刘淇   续费会员卡
1
2
3
4
5
6
  <template>
    <div>
      <ul class="choose-area">
  
  
        <li>
89d61651   刘淇   西城购买月卡
7
          <div style="color: #666">停车场</div>
555e2a0e   刘淇   续费会员卡
8
9
10
11
12
13
14
15
16
17
18
19
          <div >{{renewData.parkName}}</div>
          <!--<div class="arrow">></div>-->
          <!--<div class="arrow">></div>-->
        </li>
  
  
        <!--<li>-->
        <!--<div style="color: #666">卡名称</div>-->
        <!--<div>微纳园卡</div>-->
        <!--</li>-->
  
        <li>
89d61651   刘淇   西城购买月卡
20
21
22
          <div style="color: #666">卡类型</div>
          <!--<div >{{renewData.cardName}}</div>-->
          <div >月卡</div>
555e2a0e   刘淇   续费会员卡
23
24
25
26
27
28
  
          <!--<div class="arrow">></div>-->
        </li>
  
  
        <li>
89d61651   刘淇   西城购买月卡
29
          <div style="color: #666">车牌</div>
555e2a0e   刘淇   续费会员卡
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
          <div>{{renewData.carNumber}}</div>
          <!--<div class="arrow">></div>-->
        </li>
  
        <li>
          <div style="color: #A31414">生效时间</div>
          <div style="color: #A31414" >{{renewData.expDate }}</div>
          <!--<div class="arrow">></div>-->
        </li>
  
        <li>
          <div style="color: #666">有效期至</div>
          <div>{{ $utils.timestampToTime(endTimeFunc) }}</div>
        </li>
  
  
        <li>
          <div style="color: #666">购买数量</div>
          <div class="choose-num">
555e2a0e   刘淇   续费会员卡
49
            <span @click="reduceCarNum">-</span>
6e6de4e6   刘淇   修改整体颜色
50
51
            <span>{{cardNum}}</span>
            <span @click="addCardNum">+</span>
555e2a0e   刘淇   续费会员卡
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
          </div>
        </li>
  
        <li>
          <div style="color: #666">单价</div>
          <div>¥{{ (unitPrice/100).toFixed(2)}}</div>
        </li>
  
  
        <li>
          <div style="color: #666">优惠金额</div>
          <div>¥{{(disPrice/100).toFixed(2)}}</div>
        </li>
  
        <li>
          <div style="color: #666">应付金额</div>
          <div style="color: #A31414">¥{{(needPay/100).toFixed(2)}}</div>
        </li>
  
      </ul>
  
89d61651   刘淇   西城购买月卡
73
74
75
76
77
78
79
      <!--<div style="padding:15px;text-align: center">-->
        <!--<check-icon :value.sync="agreement">-->
        <!--</check-icon>-->
        <!--<p style="display: inline-block;height: 23px;line-height: 23px;">我已阅读并同意 <span style="color: blue"-->
                                                                                       <!--@click="showHideOnBlur=true">《购买须知》</span>-->
        <!--</p>-->
      <!--</div>-->
555e2a0e   刘淇   续费会员卡
80
81
82
  
  
      <div style="margin-top: 34px" class="leftRightPadding">
6e6de4e6   刘淇   修改整体颜色
83
        <mt-button type="primary" size="large" @click="toPay">确定购买</mt-button>
555e2a0e   刘淇   续费会员卡
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
      </div>
  
  
  
      <div v-transfer-dom>
        <x-dialog v-model="showHideOnBlur" class="dialog-demo" hide-on-blur>
          <div class="agreen-box">
            <p>
              1. 本停车卡为指定停车场有效使用,为特定的场地停车权限,请按照停车场场地自主选择购买。
            </p>
            <p>
              2. 月卡(季卡)一经售出,概不退卡,允许车牌变更1次(有效期内)。
            </p>
            <p>
              3. 年卡可以支持车牌变更3次(有效期内),年卡退卡需要按照原价扣除已经使用月份(不满一个月按照一个月计算)并退回已开具发票。
            </p>
            <p>
              4. 停车场管理方对车辆及车内财务无看管保全义务,车主须遵守停车场管理规定将车辆停在车场的停车位内,乱停车辆引起的贴条和拖车等后果由车主自行承担。
            </p>
            <p>
              5. 友情提醒:妥善关闭和锁定已停车入位的车辆,不在车内放置现金和其它贵重物品,其它停车规定须遵守所辖停车场的管理规定(参见停车场公示)。
            </p>
          </div>
          <div @click="showHideOnBlur=false">
            <span class="vux-close">X</span>
          </div>
        </x-dialog>
      </div>
  
  
    </div>
  </template>
  
  <script>
  import { TransferDomDirective as TransferDom } from "vux";
  import {
    queryParkListForVipCard,
    queryVipCardInfoByPlNo,
    queryUserCars,
    weixinpay,
89d61651   刘淇   西城购买月卡
124
125
126
127
    createVipCardOrder,
    createVipCardOrderForH5,
    publicUnifiedOrderForH5,
    getOpenIdByCode
555e2a0e   刘淇   续费会员卡
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
  } from "@/api/cards/cards";
  import { timestampToTime } from "../../utils/utils.js";
  export default {
    name: "renew",
    directives: {
      TransferDom
    },
    data() {
      return {
        startDate:new Date(),
        dateVal: "",
        startData: "",
        endDate: "",
        parkName: "",
        parkNo: "",
        cardNum: 1, // 卡数量
        unitPrice: 0, // 单价
        disPrice: 0, // 优惠金额
        needPay: 0, // 应付
        agreement: false,
        typeNum: 1, // 卡类型判断
        showHideOnBlur: false, // 购买协议
        createVipCardOrder: {}, // 创建订单对象
        orderId: "", // 订单号
        renewData: {} // 续费数据
      };
    },
89d61651   刘淇   西城购买月卡
155
156
157
158
159
    created() {
      if (this.$utils.clientBrowser() == "微信") {
        this.webAppCode = this.getCode();
      }
    },
555e2a0e   刘淇   续费会员卡
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
    mounted() {
      this.renewData = JSON.parse(sessionStorage.getItem("renewData"));
      console.log(this.renewData);
      this.unitPrice = this.renewData.price;
      this.disPrice = this.renewData.price * ((10 - this.renewData.discount) / 10);
      this.needPay = this.unitPrice - this.disPrice;
      this.typeNum = this.renewData.cardType
      this.startData = this.renewData.expDate
      // this.queryParkListForVipCard();  // 获取停车场
      // this.queryUserCars();  // 获取用户车牌
    },
    computed: {
      // 卡类型 1-年卡;2-半年卡;3-季卡;4-月卡;5-日卡;
      endTimeFunc() {
  
        if (this.startData) {
555e2a0e   刘淇   续费会员卡
176
177
          switch (this.typeNum) {
            case '1':
ec828383   刘淇   卡数量 时间区间
178
179
              this.endDate = this.$moment(this.startData).add(12*this.cardNum, "month").format("YYYY-MM-DD");
              return this.$moment(this.startData).add(12*this.cardNum, "month").format("YYYY-MM-DD");
555e2a0e   刘淇   续费会员卡
180
181
              break;
            case '2':
ec828383   刘淇   卡数量 时间区间
182
183
              this.endDate = this.$moment(this.startData).add(6*this.cardNum, "month").format("YYYY-MM-DD");
              return this.$moment(this.startData).add(6*this.cardNum, "month").format("YYYY-MM-DD");
555e2a0e   刘淇   续费会员卡
184
185
              break;
            case '3':
ec828383   刘淇   卡数量 时间区间
186
187
              this.endDate = this.$moment(this.startData).add(3*this.cardNum, "month").format("YYYY-MM-DD");
              return this.$moment(this.startData).add(3*this.cardNum, "month").format("YYYY-MM-DD");
555e2a0e   刘淇   续费会员卡
188
189
              break;
            case '4':
ec828383   刘淇   卡数量 时间区间
190
191
              this.endDate = this.$moment(this.startData).add(1*this.cardNum, "month").format("YYYY-MM-DD");
              return this.$moment(this.startData).add(1*this.cardNum, "month").format("YYYY-MM-DD");
555e2a0e   刘淇   续费会员卡
192
193
              break;
            case '5':
ec828383   刘淇   卡数量 时间区间
194
195
              this.endDate = this.$moment(this.startData).add(1*this.cardNum, "days").format("YYYY-MM-DD");
              return this.$moment(this.startData).add(1*this.cardNum, "days").format("YYYY-MM-DD");
555e2a0e   刘淇   续费会员卡
196
197
198
199
200
201
202
203
204
205
206
207
208
209
              break;
          }
          // return  this.$moment(this.startData).add(1,"month").format("YYYY-MM-DD");
          // return this.startData.getMonth()+1
        }
        // switch (val){
        //   case 2:
        //     return this.startData.setMonth(this.startData.getMonth()+1);
        //     break;
        // }
      }
    },
    methods: {
  
89d61651   刘淇   西城购买月卡
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
      // 获取code
      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;
        }
      },
      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;
      },
555e2a0e   刘淇   续费会员卡
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
  
  
      clickActionCarNum(e) {
        this.carNumber = e.name;
      },
      addCardNum() { // 增加购买数量
        this.cardNum++;
        this.calcMoney();
      },
      reduceCarNum() { // 增加购买数量
        if (this.cardNum == 1) {
          return;
        }
        this.cardNum--;
        this.calcMoney();
      },
      calcMoney() {
        this.needPay = this.cardNum * (this.unitPrice - this.disPrice);
      },
      //  购买
      toPay() {
  
89d61651   刘淇   西城购买月卡
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
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
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
        // if (!this.agreement) {
        //   this.$vux.toast.text("请同意购买须知", "top");
        //   return;
        // }
        this.getopenid();
  
        // this.createOrder();
      },
      // 获取openid
      getopenid() {
        let jsondata = {
          appId: this.$utils.myVxAppId,
          code: this.webAppCode
        };
        getOpenIdByCode(jsondata).then(data => {
          console.log(data);
          if (data.code == "0") {
            this.openid = data.data;
            this.createVipCardOrderForH5();
          } else {
            this.$vux.toast.text(data.message, "top");
          }
        });
      },
      createVipCardOrderForH5() {
        let jsondata = this.$utils.commonParams();
        jsondata.carNumber = this.renewData.carNumber;
        jsondata.custId = this.renewData.custId;
        jsondata.optType = "1";
        // jsondata.cardCouponsId = "";
        jsondata.terminalSource = "3";
        jsondata.plNo = this.renewData.parkNo; // 停车场id
        jsondata.discountAmount = this.disPrice;
        jsondata.cardCouponsId  = this.renewData.custCardNo; // 卡券编码
        jsondata.cardNo  = this.renewData.cardNo; // 卡券编码
        jsondata.cardType = (this.renewData.cardType).toString(); // 卡类型
        // jsondata.carType = (this.vipCardList.carType).toString(); //  1-大型车;2-小型车
        // jsondata.plNo = this.createVipCardOrder.id; // 1-大型车;2-小型车
        jsondata.price = this.unitPrice.toString(); // 卡单价
        jsondata.totalAmount = (this.needPay).toString(); // 购买的总金额
        jsondata.num = this.cardNum; // 购买数量
        jsondata.effDate = this.$utils.timestampToTime(this.renewData.expDate); // 生效时间
        jsondata.expDate = this.$utils.timestampToTime(this.endTimeFunc); // 失效时间
        // jsondata.carNumber = this.carNumber; // 卡适用车牌
        jsondata.optType = "2"; // 操作类型 1 购买 2 续费
        jsondata.sign = this.$utils.signObject(jsondata);
        createVipCardOrderForH5(jsondata).then(data => {
          console.log(data);
          if (data.code == 0) {
  
            // orderId
            let orderId = data.data.orderId;
            // this.custId = data.data.custId;
            this.publicUnifiedOrderForH5(orderId);
          } else {
            this.$vux.toast.text(data.message, "top");
          }
        });
      },
      publicUnifiedOrderForH5(orderId) {
        let vm = this;
        let jsondata = this.$utils.commonParams();
        jsondata.orderId = orderId; // 订单号
        jsondata.payType = "4"; // /** 支付方式-- 1:支付宝 2:微信 3:银联 4:微信公众号 5 个人账户. */
        jsondata.openId = this.openid
        jsondata.paySrcType = "302"; // //支付单来源 101:停车付款单 102:停车预付单 103:停车补缴单 104 共享车位 201 余额充值单 202 押金充值单 301 会员卡购买单 302 会员卡续费
        jsondata.appId = this.$utils.myVxAppId; // 微信标识符
        jsondata.terminalSource = "3"; // 请求端来源 1: 任你停 2:pda 3:微信公共号
        jsondata.custId = this.renewData.custId;
        jsondata.payFee = this.needPay;
        // jsondata.paySource = "3";
        jsondata.cardNo  = this.renewData.cardNo; // 卡券编码
        jsondata.couponPersonId = this.renewData.custCardNo;
        // jsondata.openId = sessionStorage.getItem("wx_openId");
        jsondata.sign = this.$utils.signObject(jsondata);
        publicUnifiedOrderForH5(jsondata).then(res => {
          console.log(data);
          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("没有找到返回值");
            }
          } else {
            alert(res.message);
          }
        });
555e2a0e   刘淇   续费会员卡
348
349
350
351
352
353
354
355
356
357
358
359
360
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
      },
      createOrder() {
        console.log(this.createVipCardOrder);
        let me = this;
        let jsondata = this.$utils.commonParams();
        jsondata.plNo = this.renewData.parkNo; // 停车场id
        jsondata.cardNo = this.renewData.cardNo; // 卡券编码
        jsondata.cardType = this.renewData.cardType; // 卡类型
        jsondata.carType = this.renewData.carType; //  1-大型车;2-小型车
        // jsondata.plNo = this.createVipCardOrder.id; // 1-大型车;2-小型车
        jsondata.price = this.renewData.price; // 卡单价
        jsondata.totalAmount = (this.needPay).toString(); // 购买的总金额
        jsondata.num = (this.cardNum).toString(); // 购买数量
        jsondata.effDate = this.renewData.expDate; // 生效时间
        jsondata.expDate = this.$utils.timestampToTime(this.endTimeFunc); // 失效时间
        jsondata.carNumber = this.renewData.carNumber; // 卡适用车牌
        jsondata.optType = "2"; // 操作类型 1 购买 2 续费
        jsondata.forceBuy = "1";
        jsondata.cardCouponsId = this.renewData.custCardNo
        jsondata.sign = this.$utils.signObject(jsondata);
        createVipCardOrder(jsondata).then(data => {
          console.log(data);
          // orderId
          if (data.code == 0) {
            this.orderId = data.data.orderId;
            this.vxPay();
          } else {
            this.$vux.toast.text(data.message, "top");
          }
        });
      },
      vxPay() {
        let vm = this;
        let jsondata = this.$utils.commonParams();
        jsondata.orderId = this.orderId; // 订单号
        jsondata.payType = "4"; // 支付方式-- 1:支付宝 2:微信 3:银联.
        jsondata.paySrcType = "302"; // 支付单来源 101:停车付款单 102:停车预付单 103:停车补缴单 104 共享车位 201 余额充值单 202 押金充值单 301 会员卡购买单 302 会员卡续费
        jsondata.appId = this.$utils.myVxAppId; // 微信标识符
        jsondata.terminalSource = "3"; // 请求端来源 1: 任你停 2:pda 3:微信公共号
        jsondata.paySource = "3";
        jsondata.couponPersonId = "";
6e6de4e6   刘淇   修改整体颜色
389
        jsondata.openId = sessionStorage.getItem("wx_openId"); // o0Moh6eQhTm5bZVqT6wjdSUsZonM   sessionStorage.getItem("wx_openId")
555e2a0e   刘淇   续费会员卡
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
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
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
        jsondata.sign = this.$utils.signObject(jsondata);
        weixinpay(jsondata).then(res => {
          console.log(data);
          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("没有找到返回值");
            }
          } else {
            alert(res.message);
          }
        });
      },
      onBridgeReady(params) {
        let me = this;
        console.log("调用微信支付WeixinJSBridge");
        WeixinJSBridge.invoke(
          "getBrandWCPayRequest", params,
          //
          // '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("成功");
              this.$vux.toast.text("支付成功", "top");
              me.$router.go(-2);
            } else {
              console.log("失败");
              alert("支付失败");
              me.$router.go(-2);
            }
          }
        );
      }
    }
  };
  </script>
  
  <style scoped lang="scss">
    .choose-area {
      background: #fff;
      padding: 0 10px;
    }
  
    .choose-area > li {
      padding-right: 20px;
      position: relative;
      height: 38px;
      line-height: 38px;
      border-bottom: 1px solid #EFEFEF;
      display: flex;
      justify-content: space-between;
      .arrow {
        position: absolute;
        right: 0;
        top: 0;
        font-size: 16px;
      }
      &:last-child {
        border-bottom: 0;
      }
    }
  
    .choose-num {
      height: 28px;
      margin-top: 5px;
      line-height: 28px;
      display: flex;
      border: 1px solid #D8D8D8;
      span {
        display: inline-block;
        &:nth-of-type(1) {
          width: 28px;
          height: 28px;
          text-align: center;
          cursor: pointer;
        }
        &:nth-of-type(2) {
          width: 50px;
          text-align: center;
          border-left: 1px solid #D8D8D8;
          border-right: 1px solid #D8D8D8;
        }
        &:nth-of-type(3) {
          width: 28px;
          height: 28px;
          text-align: center;
          cursor: pointer;
        }
      }
    }
  
    .parkArea {
      padding-top: 10px;
      padding-bottom: 10px;
      margin-top: 10px;
      background: #fff;
      color: #999;
    }
  
    .parkAreaTitle {
      display: flex;
      justify-content: space-between;
      color: #666;
    }
  
    .parkMore {
      cursor: pointer;
    }
  
    .park-list-wrap {
      width: 80%;
      max-height: 70%;
      overflow-y: scroll;
      border-radius: 5px;
    }
  
    .park-list {
      /*width: 80%;*/
      li {
        padding-left: 20px;
        line-height: 25px;
      }
    }
  
    .agreen-box {
      padding: 15px;
      text-align: left;
      p {
        margin-bottom: 15px;
      }
    }
  
    .vux-close {
      margin-top: 8px;
      margin-bottom: 8px;
      font-size: 18px;
    }
  
    /deep/ .picker-items {
      width: 100%
    }
  
  
  </style>