石广澎
2024-04-10 ec86b0d4daaba8c289da728ea6ca3b8156c3a535
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
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
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
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
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
389
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
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
<!-- 扫码支付 -->
<template>
  <view class="page">
    <view class="shop u-flex u-row-between">
      <view class="u-m-r-30">
        <view class="u-font-28 color-666 u-m-b-10">付款给</view>
        <view class="u-font-34 font-bold color-333">{{ shopInfo.shop_name }}</view>
      </view>
      <image :src="shopInfo.logo_image||'/static/imgs/store-logo.png'" class="avg-img"></image>
    </view>
    <view class="u-p-48 bg-fff u-flex-1 content">
      <view class="u-font-28 color-666">金额</view>
      <view class="u-p-v-20 u-flex u-border-bottom u-relative">
        <view class="money-icon color-333">¥</view>
        <view class="u-flex-1 u-flex u-m-l-10" style="height: 80rpx;">
          <view v-if="money" class="money-num">{{ money }}</view>
          <view :class="['cursor',{'cursor-act':!money&&bordShow}]"></view>
          <view v-if="!money" class="u-font-50 color-999">请输入金额</view>
          <view :class="['cursor',{'cursor-act':money&&bordShow}]"></view>
        </view>
        <view class="mask" @click="showBord"></view>
      </view>
      <view class="u-font-28 color-666 u-m-t-60">选择支付方式</view>
      <u-radio-group v-model="bankCardId" placement="column">
        <view v-if="platform == 5" class="u-border-bottom u-p-v-20 u-flex u-row-between">
          <image src="@/static/imgs/pay-zfb.png" class="pay-icon"></image>
          <view class="flex-1">
            <view class="u-font-30 color-333">支付宝</view>
            <text v-if="isNew" class="tag u-m-t-10">会员享优惠</text>
            <text v-if="!isNew&&token&&shopInfo.use_score_flag&&shopInfo.app_pay_use_score_flag"
                  class="u-font-24 color-999 u-m-t-10">
              可用
              <text class="color-red">{{ integral }}</text>
              积分
            </text>
          </view>
          <view v-if="token&&couponInfo&&shopInfo.user_coupon_flag&&shopInfo.app_pay_use_coupon_flag" class="tag-pain">
            满{{
              parseFloat((couponInfo.thresholdValue / 100).toFixed(2))
            }}元减{{ parseFloat((couponInfo.discount / 100).toFixed(2)) }}元
          </view>
          <u-radio @change="radioChange($event,5)" :name="5" activeColor="#D41F28"
                   :customStyle="{ marginLeft: '10rpx' }"></u-radio>
        </view>
        <view v-if="platform == 2" class="u-border-bottom u-p-v-20 u-flex u-row-between">
          <image src="@/static/imgs/pay-wx.png" class="pay-icon"></image>
          <view class="flex-1">
            <view class="u-font-30 color-333">微信</view>
            <text v-if="isNew" class="tag u-m-t-10">会员享优惠</text>
            <text v-if="!isNew&&token&&shopInfo.use_score_flag&&shopInfo.app_pay_use_score_flag"
                  class="u-font-24 color-999 u-m-t-10">
              可用
              <text class="color-red">{{ integral }}</text>
              积分
            </text>
          </view>
          <view v-if="token&&couponInfo&&shopInfo.user_coupon_flag&&shopInfo.app_pay_use_coupon_flag" class="tag-pain">
            满{{
              parseFloat((couponInfo.thresholdValue / 100).toFixed(2))
            }}元减{{ parseFloat((couponInfo.discount / 100).toFixed(2)) }}元
          </view>
          <u-radio @change="radioChange($event,2)" :name="2" activeColor="#D41F28"
                   :customStyle="{ marginLeft: '10rpx' }">
          </u-radio>
        </view>
        <navigator v-if="shuaka&&token&&bankCard!=-1" class="shuka" url="/pages/pay/shuaKa/shuaKa">
          <image src="/static/shuaka/shuaka.png" mode=""></image>
        </navigator>
        <view v-if="bankCard.id" class="u-border-bottom u-p-v-20 u-flex">
          <view @click="bordShow=false;bankCardOpen=true" class="flex-1 u-flex">
            <image :src="bankCardStyle.logo" class="pay-icon"></image>
            <view>
              <view class="u-font-30 color-333 u-flex">
                {{ bankCard.bankName }}({{ cardType[bankCard.cardType] }})({{ bankCard.cardNo }})
                <u-icon name="arrow-right"
                        color="#000">
                </u-icon>
              </view>
              <!-- <text v-if="isNew" class="tag u-m-t-10">会员享优惠</text> -->
              <text v-if="!isNew&&shopInfo.use_score_flag&&shopInfo.bank_pay_use_score_flag"
                    class="u-font-24 color-999 u-m-t-10">
                可用
                <text class="color-red">{{ integral }}</text>
                积分
              </text>
            </view>
          </view>
          <view v-if="!isNew&&shopInfo.user_coupon_flag&&shopInfo.bank_pay_use_coupon_flag&&couponInfo"
                class="tag-pain">
            满{{
              parseFloat((couponInfo.thresholdValue / 100).toFixed(2))
            }}元减{{ parseFloat((couponInfo.discount / 100).toFixed(2)) }}元
          </view>
          <u-radio @change="radioChange($event,3)" :name="bankCard.id" activeColor="#D41F28"
                   :customStyle="{ marginLeft: '10rpx' }">
          </u-radio>
        </view>
      </u-radio-group>
      <navigator v-if="bankCard==-1&&bindCard&&token&&!isNew" class="shuka" url="/pages/pay/bindCard/bindCard">
        <image src="/static/bangka.png" mode=""></image>
      </navigator>
      <navigator v-if="bankCard==-1&&!isNew" url="/pages/pay/bindCard/bindCard"
                 class="u-border-bottom u-p-v-20 u-flex u-row-between">
        <view class="u-flex-1 u-flex ">
          <image class="pay-icon" :src="bankCardStyle.logo" mode=""></image>
          <view class="flex-1 u-m-l-20">
            <view class="u-font-30 color-333">银行卡</view>
            <view class="u-font-24 color-red">绑卡可享更多优惠</view>
          </view>
        </view>
        <u-radio disabled activeColor="#D41F28" :customStyle="{ marginLeft: '30rpx' }">
        </u-radio>
      </navigator>
      <navigator v-if="isNew" class="reg-btn" :url="'/pages/pay/register?cid='+cid">
        <image src="/static/register-btn.png" mode=""></image>
      </navigator>
      <!--            <view class="btn">
        <wx-open-launch-weapp class="wx-app" id="launch-btn" appid="wxfc579973fbdde096"
          username="gh_3676c3af5dda" path="pages/index/index" env-version="release">
          <script type="text/wxtag-template">
            <style>
              .btn {
                border: none;
                position: absolute;
                top: 0;
                right: 0;
                bottom: 0;
                left: 0;
                width: 100%;
                border-radius: 50px;
                text-align: center;
                line-height: 100%;
                color: #BF3B00;
                font-size: 18px;
                font-weight: 600;
                background: linear-gradient(180deg, rgba(253, 222, 95, 1) 0%, rgba(254, 172, 31, 1) 71%, rgba(254, 186, 40, 1) 100%);
               }
            </style>
            <button class="btn">打开小程序</button>
          </script>
        </wx-open-launch-weapp>
      </view>-->
    </view>
 
 
    <button class="pay-it" @click="pay">付款</button>
    <!-- 选择银行卡 -->
    <u-popup mode="bottom" :closeable="true" :show="bankCardOpen" :round="10" @close="bankCardOpen = false">
      <view class="u-font-32 color-333 u-text-center u-p-30 u-border-bottom">选择银行支付</view>
      <scroll-view scroll-y class="u-p-h-30 bankCard-list">
        <block v-for="(item,i) in bankCardList" :key="i">
          <view @click="chooseBankCard(item)" class="u-border-bottom u-p-v-30 u-flex">
            <view class="flex-1 u-flex">
              <image :src="bankCardStyle.logo" class="pay-icon"></image>
              <view>
                <view class="u-font-26 color-333">{{ item.bankName }}</view>
                <view class="u-m-t-10 u-font-28 color-333">{{ cardType[item.cardType] }}({{ item.cardNo }})
                </view>
              </view>
            </view>
            <u-icon name="checkbox-mark" :color="bankCardId==item.id?'#D31F28':'#fff'" size="22"></u-icon>
          </view>
        </block>
        <navigator url="/pages/pay/bindCard/bindCard" class="u-border-bottom u-p-v-30 u-flex">
          <view class="add-icon">
            <u-icon name="plus" bold color="#D31F28"></u-icon>
          </view>
          <view class="u-font-28 color-333 u-m-l-20">使用新卡支付</view>
        </navigator>
      </scroll-view>
    </u-popup>
    <!-- 数字键盘 -->
    <u-popup :show="bordShow" :overlay="false" @close="bordShow = false">
      <key-bord @changeMoney="changeMoney" :num.sync="money" @close="bordShow = false" @pay="pay"></key-bord>
    </u-popup>
    <!-- 支付验证码 -->
    <u-popup :show="codeShow" closeable mode="center" @close="codeShow = false">
      <view class="u-p-h-40 u-p-b-40">
        <view class="u-text-center u-p-t-20 u-m-b-30 u-font-34">请输入手机验证码</view>
        <view class="u-text-center u-m-b-20 color-666">{{ shopInfo.shop_name }}</view>
        <view class="u-flex u-row-center font-bold u-m-b-40">
          <text class="u-font-42">¥</text>
          <text
              class="u-font-money">{{ money }}
          </text>
        </view>
        <u-code-input @finish="bankPay" v-model="smscode" mode="box" :focus="true"></u-code-input>
      </view>
 
    </u-popup>
  </view>
</template>
 
<script>
import {
  config,
  cardType,
  ACCESSTOKEN
} from '@/common/config.js';
import {
  headBand,
  bankCardStyle,
  myBankCard,
  queryShop,
  queryMyDiscount,
  getScoreWorth,
  getOpenId,
  getUserId,
  queryScore,
  queryMyUseSweepPayMaxCoupon,
  getWechatConfigInfo,
  saveWxOrder,
  tlPay
} from '@/common/api/index'
import wx from 'weixin-js-sdk'; // 使用js-sdk
import {
  activityInfo
} from '@/common/api/shuaka'
 
export default {
  data() {
    return {
      platform: this.$utils.getPlat(),
      cardType: cardType,
      cid: '',
      bordShow: false, // 显示键盘
      scoreWorth: 0,
      shopInfo: {
        shop_name: '',
        scan_flag: '',
        use_score_flag: 0, //商铺是否可用积分 0否 1是
        user_coupon_flag: 0, //商铺是否可用优惠券 0否 1是
        app_pay_use_score_flag: 0, //微信/支付宝是否可用积分 0否 1是
        app_pay_use_coupon_flag: 0, //微信/支付宝是否可用优惠券 0否 1是
        bank_pay_use_score_flag: 0, //银行卡支付是否可用积分 0否 1是
        bank_pay_use_coupon_flag: 0, //银行卡支付是否可用优惠券 0否 1是
      },
      money: '', // 金额
      integral: 0, // 使用积分
      couponInfo: null, // 优惠券内容
      payWay: 3, //支付方式 5 支付宝 2 微信 3银行卡
      token: null,
      isNew: false, // 是否新用户,新用户查询不到积分和银行卡
      codeShow: false, // 银行卡支付验证码输入弹窗
      smscode: '', // 银行卡支付验证码
      thpinfo: null,
      bankCardStyle: {
        color: '',
        logo: ''
      },
      bankCardList: [], //银行卡列表
      bankCard: -1, // 选中银行卡
      bankCardId: null, // 选中银行卡
      bankCardOpen: false,
      canReset: false,
      end: 0,
      count: 0,
      shuaka: null, //刷卡活动
      bindCard: false, // 绑卡有礼
      discount: {
        memberGradeName: '',
        shopDiscount: 10
      },
      aLiUserId: ''
    };
  },
  onLoad(opt) {
    this.isNew = uni.getStorageSync('IS_NEW')
    uni.showLoading()
    this.payWay = this.platform
    if (opt.cid) {
      this.cid = opt.cid
      uni.setStorageSync('CID', opt.cid)
      this.init()
    }
    if (opt.code || opt.auth_code) {
      let type = this.platform
      let code = opt.code
      if (this.platform == 5) {
        code = opt.auth_code
      }
      this.end++
      getOpenId({
        params: {
          code: opt.code
        }
      }).then(res => {
        this.count++
        if (this.count >= this.end) {
          uni.hideLoading()
        }
        this.token = res.token.accessToken
        uni.setStorageSync(ACCESSTOKEN, res.token.accessToken)
        uni.setStorageSync('IS_NEW', res.isNew)
        this.isNew = res.isNew
        if (!res.isNew) {
          this.getUserInfo()
        }
      }).catch(() => {
        uni.hideLoading()
      })
    } else {
      if (process.env.NODE_ENV === 'development') {
        console.log('开发环境');
      } else {
        console.log('生产环境');
        const redirect_uri = encodeURIComponent(window.location.href.split('?')[0] + '?cid=' + this.cid)
        if (this.platform == 2) {
          window.location.href =
              `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${config.wx_appid}&redirect_uri=${redirect_uri}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`
        } else if (this.platform == 5) {
          window.location.href =
              `https://openauth.alipay.com/oauth2/publicAppAuthorize.htm?app_id=${config.ali_appid}&scope=auth_base&redirect_uri=${redirect_uri}&state=STATE`
        }
      }
    }
 
  },
  onShow() {
    this.token = uni.getStorageSync(ACCESSTOKEN) || null
    this.bordShow = false
    this.bankCardOpen = false
    this.codeShow = false
    this.smscode = ''
    if (this.canReset && this.token && !this.isNew) {
      this.end = 0
      this.count = 0
      uni.showLoading()
      this.getUserInfo()
    }
    this.canReset = true
  },
  methods: {
    radioChange(e, item) {
      this.bordShow = false
      this.payWay = item
    },
    // 更新金额
    changeMoney(str) {
      this.money = str;
    },
    // 展示键盘
    showBord() {
      this.bordShow = true;
    },
    init() {
      this.end += 5
      //获取商铺信息
      queryShop({
        params: {
          cid: this.cid
        }
      }).then(res => {
        this.count++
        if (this.count >= this.end) {
          uni.hideLoading()
        }
        if (res.logo_image) {
          try {
            let arr = JSON.parse(res.logo_image)
            res.logo_image = config.sftpURL + arr[0].path
          } catch (e) {
            //TODO handle the exception
            res.logo_image = ''
          }
        }
        this.shopInfo = res
      }).catch(() => {
        uni.hideLoading()
      })
      // 刷卡有礼
      activityInfo().then(res => {
        this.count++
        if (this.count >= this.end) {
          uni.hideLoading()
        }
        this.shuaka = res
      }).catch(() => {
        uni.hideLoading()
      })
      // 首绑有礼
      headBand().then(res => {
        this.count++
        if (this.count >= this.end) {
          uni.hideLoading()
        }
        this.bindCard = res
      }).catch(() => {
        uni.hideLoading()
      })
      // 积分价值
      getScoreWorth().then(res => {
        this.count++
        if (this.count >= this.end) {
          uni.hideLoading()
        }
        this.scoreWorth = res.settingVal
      }).catch(() => {
        uni.hideLoading()
      })
      //获取银行卡风格配置
      bankCardStyle().then(res => {
        this.count++
        if (this.count >= this.end) {
          uni.hideLoading()
        }
        try {
          let arr = JSON.parse(res.logo)
          res.logo = config.sftpURL + arr[0].path
        } catch (e) {
          //TODO handle the exception
          res.logo = ''
        }
        this.bankCardStyle = res
        uni.setStorageSync('bankCardStyle', res)
      }).catch(() => {
        uni.hideLoading()
      })
      if (this.platform == 2) {
        this.end += 1
        //获取微信jsSdk配置
        const uri = encodeURIComponent(window.location)
        getWechatConfigInfo({
          url: uri
        }).then(res => {
          this.count++
          if (this.count >= this.end) {
            uni.hideLoading()
          }
          wx.config({
            debug: false, // 开启调试模式
            appId: res.appId, // 必填,公众号的唯一标识
            timestamp: res.timestamp, // 必填,生成签名的时间戳
            nonceStr: res.noncestr, // 必填,生成签名的随机串
            signature: res.signature, // 必填,签名
            jsApiList: ['chooseWXPay'], // 必填,需要使用的 JS 接口列表
            openTagList: [
              'wx-open-launch-weapp'
            ] // 可选,需要使用的开放标签列表,例如['wx-open-launch-app']
          });
        }).catch(() => {
          uni.hideLoading()
        })
      }
 
    },
    // 获取会员相关信息
    getUserInfo() {
      this.end += 4
 
      queryMyDiscount({
        shopId: this.shopInfo.id
      }).then(res => {
        this.count++
        if (this.count >= this.end) {
          uni.hideLoading()
        }
        res.shopDiscount = parseFloat(res.shopDiscount / 10)
        this.discount = res
        uni.setStorageSync('DISCOUNT_INFO', res)
      }).catch(() => {
        this.count++
        if (this.count >= this.end) {
          uni.hideLoading()
        }
      })
      //获取用户银行卡
      myBankCard().then(res => {
        this.count++
        if (this.count >= this.end) {
          uni.hideLoading()
        }
        this.bankCardList = res.rows
        if (res.rows[0]) {
          this.bankCard = res.rows[0]
          if (this.platform == 3) {
            this.bankCardId = res.rows[0].id
          }
        } else {
          this.bankCard = -1
        }
      }).catch(() => {
        this.count++
        if (this.count >= this.end) {
          uni.hideLoading()
        }
      })
      //获取用户积分
      queryScore().then(res => {
        this.count++
        if (this.count >= this.end) {
          uni.hideLoading()
        }
        this.integral = res.totalScore
      }).catch(() => {
        this.count++
        if (this.count >= this.end) {
          uni.hideLoading()
        }
      })
      //获取用户优惠券
      queryMyUseSweepPayMaxCoupon({
        params: {
          shopId: this.shopInfo.id
        }
      }).then(res => {
 
        this.count++
        if (this.count >= this.end) {
          uni.hideLoading()
        }
        this.couponInfo = res
      }).catch(() => {
        this.count++
        if (this.count >= this.end) {
          uni.hideLoading()
        }
      })
    },
    // 选择银行卡
    chooseBankCard(item) {
      this.payWay = 3
      this.bankCard = item;
      this.$nextTick(() => {
        this.bankCardId = item.id
        this.bankCardOpen = false
      })
    },
    //跳转营销页面
    toDiscount() {
      let toDiscount = false
      //不是会员
      if (this.isNew) toDiscount = false
      //没有积分、没有优惠券、没有店铺优惠
      if (this.integral == 0 && !this.couponInfo && this.discount.shopDiscount == 1) toDiscount = false
      const shopInfo = encodeURIComponent(JSON.stringify(this.shopInfo))
      //有店铺优惠
      if (this.discount.shopDiscount != 1) {
        toDiscount = true
      }
      if (this.payWay == 3 && (this.shopInfo.bank_pay_use_score_flag || this.shopInfo.bank_pay_use_coupon_flag)) { //银行卡支付
        toDiscount = true
      } else if ((this.shopInfo.use_score_flag && this.shopInfo.app_pay_use_score_flag) || (this.shopInfo.user_coupon_flag && this.shopInfo.app_pay_use_coupon_flag)) {
        toDiscount = true
      } else {
        toDiscount = false
      }
      uni.navigateTo({
        url: `/pages/pay/discountpay?shopInfo=${shopInfo}&integral=${this.integral}&scoreWorth=${this.scoreWorth}&money=${this.money}&payWay=${this.payWay}&bankCardId=${this.bankCardId}`
      })
      return toDiscount
    },
    //确认支付
    pay() {
      if (uni.$u.test.isEmpty(this.money)) {
        uni.$u.toast('请输入金额!')
        return
      }
      this.bordShow = false
      // return this.toDiscount() //判断是否需要跳转营销页面
      if (this.toDiscount()) {
        // 金额 this.money
        uni.showLoading()
        const params = {
          money: parseFloat((this.money * 100).toPrecision(12)),
          shopId: this.shopInfo.id,
          cid: this.cid,
          payWay: this.payWay,
          score: 0,
          couponDetailId: ''
        }
        if (this.payWay == 3) {
          params.bankCardId = this.bankCardId
        }
        //生成订单
        saveWxOrder(params).then(res => {
          uni.hideLoading()
          try {
            this.orderId = res.orderId
            res.youHuiInfo.shopName = this.shopInfo.shop_name
            this.youHuiInfo = res.youHuiInfo
            if (res.toPayMethod == 1) {
              if (this.payWay == 3) {
                this.smscode = ''
                this.codeShow = true
              }
            } else if (res.toPayMethod == 2) {
              if (this.payWay == 2) {
                this.wxPay(res.paymentData)
              }
              if (this.payWay == 5) {
                this.aliPay(res.paymentData)
              }
            } else if (res.toPayMethod == 3) {
              window.location.href = res.paymentUrl
            }
          } catch (e) {
            //TODO handle the exception
            console.error(e);
          }
        }).catch(() => {
          uni.hideLoading()
        })
      }
 
    },
    // 微信支付
    wxPay(res) {
      setTimeout(() => {
        wx.chooseWXPay({
          timestamp: res.timeStamp, // 支付签名时间戳
          nonceStr: res.nonceStr, // 支付签名随机串,不长于 32 位
          package: res.package, // 统一支付接口返回的prepay_id参数值,提交格式如:prepay_id=\*\*\*)
          signType: res.signType, // 微信支付V3的传入 RSA ,微信支付V2的传入格式与V2统一下单的签名格式保持一致
          paySign: res.paySign, // 支付签名
          success: function (res) {
            // 支付成功后的回调函数
            uni.navigateTo({
              url: `/pages/pay/paySuccess?orderId=${this.orderId}&youHuiInfo=${JSON
                  .stringify(this.youHuiInfo)}`
            })
          }
        });
      }, 200)
    },
    //支付宝支付
    aliPay(res) {
      ap.tradePay({
        tradeNO: res.tradeNO
      }, (res) => {
        if (res.resultCode == 9000) {
          uni.navigateTo({
            url: `/pages/pay/paySuccess?orderId=${this.orderId}&youHuiInfo=${JSON
                .stringify(this.youHuiInfo)}`
          })
          // 支付成功
        } else if (res.resultCode == 8000 || res.resultCode == 6001) {
          // 正在处理中 || 取消
        } else {
          // 支付失败
        }
      });
    },
    //银行卡支付
    bankPay(e) {
      uni.showLoading()
      tlPay({
        orderId: this.orderId,
        payWay: 3,
        bankCardId: this.bankCardId,
        smscode: e,
      }).then(res => {
        uni.hideLoading()
        uni.hideKeyboard()
        this.codeShow = false
        uni.navigateTo({
          url: `/pages/pay/paySuccess?orderId=${this.orderId}&youHuiInfo=${JSON
              .stringify(this.youHuiInfo)}`
        })
      }).catch(() => {
        uni.hideLoading()
      })
    }
  }
};
</script>
 
<style scoped lang="scss">
.page {
  height: calc(100vh - 0px);
  display: flex;
  flex-direction: column;
}
 
.shop {
  padding: 50rpx 64rpx;
}
 
.avg-img {
  width: 94rpx;
  height: 94rpx;
  border-radius: 10rpx;
  background-color: #ffffff;
}
 
.content {
  border-radius: 40rpx 40rpx 0 0;
}
 
.money {
  font-size: 40rpx;
  color: #333;
}
 
.money-icon {
  font-size: 70rpx;
  // font-weight: bold;
  margin-right: 20rpx;
}
 
.money-num {
  font-size: 96rpx;
  // font-weight: bold;
}
 
.pay-it {
  position: absolute;
  width: 686rpx;
  height: 98rpx;
  bottom: 0;
  border-radius: 10rpx;
  font-size: 34rpx;
  color: #ffffff;
  background-color: #de2d35;
  margin: 32rpx;
}
 
.bank-card-ad {
  padding-top: 50rpx;
  background-image: url(~@/static/bank-card-ad1.png);
  background-size: 100% auto;
  background-position: top center;
  background-repeat: no-repeat;
}
 
.pay-icon {
  align-self: flex-start;
  width: 48rpx;
  height: 48rpx;
  margin-right: 20rpx;
}
 
.tag {
  background-color: #F35656;
  font-size: 20rpx;
  color: #fff;
  border-radius: 4rpx;
  line-height: 1;
  padding: 4rpx;
}
 
.tag-pain {
  border: 1px solid #D31F28;
  font-size: 22rpx;
  color: #D31F28;
  border-radius: 4rpx;
  line-height: 1;
  padding: 8rpx 4rpx;
}
 
.mask {
  position: absolute;
  width: 100%;
  height: 100%;
  left: 0;
  bottom: 0;
  z-index: 101;
  background-color: rgba(0, 0, 0, 0);
}
 
@keyframes cursor-blinks {
  0% {
    opacity: 1;
    display: block;
  }
 
  50% {
    opacity: 0;
    display: none;
  }
 
  100% {
    opacity: 1;
    display: block;
  }
}
 
.cursor {
  border-left: 1px solid transparent;
  height: 80rpx;
}
 
.cursor-act {
  border-left: 1px solid #333;
  animation: cursor-blinks 1s infinite steps(1, start);
}
 
.reg-btn {
  display: block;
  margin-top: 30rpx;
  width: 654rpx;
  height: 198rpx;
 
  image {
    width: 100%;
    height: 100%;
  }
}
 
.u-font-money {
  font-size: 60rpx;
}
 
.bankCard-list {
  height: 50vh;
  width: 750rpx;
  box-sizing: border-box;
 
  .pay-icon {
    align-self: center;
  }
}
 
.add-icon {
  width: 50rpx;
  height: 50rpx;
  border-radius: 25rpx;
  background: #ffc0c38f;
  display: flex;
  align-items: center;
  justify-content: center;
}
 
.shuka {
  width: 678rpx;
  height: 45rpx;
  position: relative;
  left: -10rpx;
 
  image {
    width: 100%;
    height: 100%;
  }
}
 
.btn {
  /* position: fixed;
  bottom: 100rpx; */
  margin: 0 auto;
  margin-top: 120rpx;
  position: relative;
  width: 680rpx;
  height: 100rpx;
}
 
.wx-app {
  position: absolute;
  width: 680rpx;
  height: 100rpx;
}
</style>