石广澎
2024-05-08 b920b4a7e70ffdeb7308131cb3d6a10dff9e3451
pages/pay/scanpay.vue
@@ -21,7 +21,7 @@
        <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">
      <u-radio-group v-model="payWay" 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">
@@ -91,7 +91,7 @@
              parseFloat((couponInfo.thresholdValue / 100).toFixed(2))
            }}元减{{ parseFloat((couponInfo.discount / 100).toFixed(2)) }}元
          </view>
          <u-radio @change="radioChange($event,3)" :name="bankCard.id" activeColor="#D41F28"
          <u-radio @change="radioChange($event,3, bankCard.id)" :name="3" activeColor="#D41F28"
                   :customStyle="{ marginLeft: '10rpx' }">
          </u-radio>
        </view>
@@ -114,32 +114,6 @@
      <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>
@@ -204,8 +178,7 @@
  queryShop,
  queryMyDiscount,
  getScoreWorth,
  getOpenId,
  getUserId,
  userLogin,
  queryScore,
  queryMyUseSweepPayMaxCoupon,
  getWechatConfigInfo,
@@ -274,28 +247,18 @@
      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({
      userLogin({
        platform: this.platform,
        params: {
          code: opt.code
          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()
        }
        this.getToken(res)
      }).catch(() => {
        uni.hideLoading()
      })
@@ -331,9 +294,25 @@
    this.canReset = true
  },
  methods: {
    radioChange(e, item) {
    getToken(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()
      }
    },
    radioChange(e, item, bankCardId) {
      this.bordShow = false
      this.payWay = item
      if(bankCardId){
        this.bankCardId = bankCardId
      }
    },
    // 更新金额
    changeMoney(str) {
@@ -528,27 +507,42 @@
    },
    //跳转营销页面
    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
      if (!this.isNew) { //是会员
        if (this.integral > 0 || this.couponInfo) { //有优惠券或积分
          if (this.payWay == 3 && (this.shopInfo.bank_pay_use_score_flag || this.shopInfo
              .bank_pay_use_coupon_flag)) { //银行卡支付
            uni.navigateTo({
              url: `/pages/pay/discountpay?shopInfo=${shopInfo}&integral=${this.integral}&scoreWorth=${this.scoreWorth}&money=${this.money}&payWay=${this.payWay}&bankCardId=${this.bankCardId}`
            })
            return false
          } 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)) {
            uni.navigateTo({
              url: `/pages/pay/discountpay?shopInfo=${shopInfo}&integral=${this.integral}&scoreWorth=${this.scoreWorth}&money=${this.money}&payWay=${this.payWay}&bankCardId=${this.bankCardId}`
            })
            return false
          } else if (this.discount.shopDiscount != 1) {
            uni.navigateTo({
              url: `/pages/pay/discountpay?shopInfo=${shopInfo}&integral=${this.integral}&scoreWorth=${this.scoreWorth}&money=${this.money}&payWay=${this.payWay}&bankCardId=${this.bankCardId}`
            })
            return false
          } else {
            return true
          }
        } else if (this.discount.shopDiscount != 1) {
          uni.navigateTo({
            url: `/pages/pay/discountpay?shopInfo=${shopInfo}&integral=${this.integral}&scoreWorth=${this.scoreWorth}&money=${this.money}&payWay=${this.payWay}&bankCardId=${this.bankCardId}`
          })
          return false
        } else {
          return true
        }
      } else {
        toDiscount = false
        return true
      }
      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() {
@@ -592,7 +586,9 @@
                this.aliPay(res.paymentData)
              }
            } else if (res.toPayMethod == 3) {
              window.location.href = res.paymentUrl
              // window.location.href = res.paymentUrl
              this.smscode = ''
              this.codeShow = true
            }
          } catch (e) {
            //TODO handle the exception
@@ -607,20 +603,25 @@
    // 微信支付
    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)}`
            })
          }
        });
        WeixinJSBridge.invoke(
            'getBrandWCPayRequest', {
              "appId": res.appId, //公众号ID,由商户传入
              "timeStamp": res.timeStamp, //时间戳,自1970年以来的秒数
              "nonceStr": res.nonceStr, //随机串
              "package": res.package,
              "signType": res.signType, //微信签名方式:
              "paySign": res.paySign //微信签名
            },
            (res) => {
              if (res.err_msg == "get_brand_wcpay_request:ok") {
                // 使用以上方式判断前端返回,微信团队郑重提示:
                //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
                uni.navigateTo({
                  url: `/pages/pay/paySuccess?orderId=${this.orderId}&youHuiInfo=${JSON
                      .stringify(this.youHuiInfo)}`
                })
              }
            });
      }, 200)
    },
    //支付宝支付