From 2640a9e7cb2d6d5dbb5da86139458e5267271f2c Mon Sep 17 00:00:00 2001
From: 石广澎 <shiguangpeng@163.com>
Date: 星期二, 16 四月 2024 16:52:33 +0800
Subject: [PATCH] feat(支付): 云商通快捷支付打开

---
 pages/pay/scanpay.vue |  157 ++++++++++++++++++++++++++--------------------------
 1 files changed, 79 insertions(+), 78 deletions(-)

diff --git a/pages/pay/scanpay.vue b/pages/pay/scanpay.vue
index 44c7ec0..790e6d5 100644
--- a/pages/pay/scanpay.vue
+++ b/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, // 缁熶竴鏀粯鎺ュ彛杩斿洖鐨刾repay_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, //鍏紬鍙稩D锛岀敱鍟嗘埛浼犲叆
+              "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灏嗗湪鐢ㄦ埛鏀粯鎴愬姛鍚庤繑鍥瀘k锛屼絾骞朵笉淇濊瘉瀹冪粷瀵瑰彲闈犮��
+                uni.navigateTo({
+                  url: `/pages/pay/paySuccess?orderId=${this.orderId}&youHuiInfo=${JSON
+                      .stringify(this.youHuiInfo)}`
+                })
+              }
+            });
       }, 200)
     },
     //鏀粯瀹濇敮浠�

--
Gitblit v1.9.1