From d5306c224a91b37869d2b96ba03d5a7152bd11e2 Mon Sep 17 00:00:00 2001
From: 石广澎 <shiguangpeng@163.com>
Date: 星期一, 23 十二月 2024 21:20:26 +0800
Subject: [PATCH] feat(支持线上订单支付 ):

---
 common/config.js    |    6 +-
 main.js             |    3 +
 pay/scanpay.vue     |   78 ++++++++++++++++++++++++++++++++++----
 common/api/index.js |    4 ++
 4 files changed, 78 insertions(+), 13 deletions(-)

diff --git a/common/api/index.js b/common/api/index.js
index 8dd96e6..5fe978d 100644
--- a/common/api/index.js
+++ b/common/api/index.js
@@ -13,6 +13,10 @@
 export const queryShopByShopId = (params, config = {}) => http.get(URL +
     '/payfour-merchant/v1/web/aggregatePayAllin/queryShopByShopId', params, config)
 
+/* 鏍规嵁璁㈠崟id */
+export const getOnlineId = (params, config = {}) => http.get(URL +
+    '/payfour-merchant/v1/web/aggregatePayAllin/getOnlineId', params, config)
+
 /*缁熶竴鎺堟潈*/
 export const userLogin = (params, config = {}) => {
     let path = '/payfour-merchant/v1/web/aggregatePayAllin/getOpenId' //寰俊鎺堟潈
diff --git a/common/config.js b/common/config.js
index 1d50911..02b3bb9 100644
--- a/common/config.js
+++ b/common/config.js
@@ -6,14 +6,14 @@
     baseURL: '/dev-api',
     // baseURL: 'http://172.16.2.117:8080',
     wx_appid: 'wx4c146dba764dcb05',
-    ali_appid: '2021004149689887'
+    ali_appid: '2021004193639959'
 }
 // 娴嬭瘯
 const test = {
     webURL: 'https://sfzf.cpbtsoft.cn',
-    baseURL: 'https://sfzf.cpbtsoft.cn/dev-api',
+    baseURL: 'https://sfzf.cpbtsoft.cn/prod-api',
     wx_appid: 'wx4c146dba764dcb05',
-    ali_appid: '2021004149689887'
+    ali_appid: '2021004193639959'
 }
 // 姝e紡
 const prod = {
diff --git a/main.js b/main.js
index 1165588..0ca00cd 100644
--- a/main.js
+++ b/main.js
@@ -1,6 +1,7 @@
 import App from './App'
 import Vue from 'vue'
-
+import Vconsole from 'vconsole';
+new Vconsole();
 import uView from '@/uni_modules/uview-ui'
 Vue.use(uView)
 
diff --git a/pay/scanpay.vue b/pay/scanpay.vue
index bcffe02..afecb67 100644
--- a/pay/scanpay.vue
+++ b/pay/scanpay.vue
@@ -66,7 +66,6 @@
                   {{ $utils.accMul(couponInfo.discount, 10) }}鎶樺埜
                 </view>
               </block>
-
               <view v-else class="u-font-28 lh-1 u-tips-color">璇烽�夋嫨</view>
               <u-icon class="u-m-l-10" name="arrow-right" color="#999" size="16"></u-icon>
             </view>
@@ -159,6 +158,7 @@
 import {
   queryShopByCid,
   queryShopByShopId,
+  getOnlineId,
   userLogin,
   queryUseSweepPayCoupon,
   getWechatConfigInfo,
@@ -178,12 +178,12 @@
       buyerNote: '',
       showRemark: false,
       UNIONID: null,
-      payWay: this.$utils.getPlat(), //2 缁翠俊 5鏀粯瀹� 15浜戦棯浠�
+      payWay: this.$utils.getPlat(), //2 寰俊 5鏀粯瀹� 15浜戦棯浠�
       cid: '', //鐮佺墝id  C鎵獴闈欐�佺爜鏃舵湁
       activityQrcodeId: '', //鍔ㄦ�佹敹娆剧爜  C鎵獴鍔ㄦ�佺爜鏃舵湁
       shopId: '', //鍟嗘埛id  C鎵獴鍔ㄦ�佺爜鏃舵湁
       bordShow: false, // 鏄剧ず閿洏
-      orderId: '',
+      orderId: '', //鍐�浼橀偖绾夸笂璁㈠崟id
       shopInfo: {
         cusid: '',
         shopName: '',
@@ -248,6 +248,7 @@
   onLoad(opt) {
     uni.setStorageSync('CID', opt.cid)
     uni.setStorageSync('SHOPID', opt.shopId)
+    uni.setStorageSync('ORDERID', opt.orderId)
     uni.setStorageSync('SMONEY', opt.smoney)
     uni.setStorageSync('AQCI', opt.activityQrcodeId)
     this.UNIONID = uni.getStorageSync('UNIONID') || null
@@ -258,9 +259,12 @@
     } else {
       this.bordShow = true
     }
+    if (opt.orderId) {
+      this.orderId = opt.orderId
+      this.init()
+    }
     if (opt.activityQrcodeId) {
       this.activityQrcodeId = opt.activityQrcodeId
-      // this.getOrderInfo()
     }
     if (opt.shopId) {
       this.shopId = opt.shopId
@@ -399,6 +403,12 @@
           shopId: this.shopId
         }
       }
+      if (this.orderId) {
+        api = getOnlineId
+        params = {
+          onlineId: this.orderId
+        }
+      }
       //鑾峰彇鍟嗛摵淇℃伅
       api({
         params
@@ -409,6 +419,17 @@
           res.logoImage = config.baseURL + res.logoImage
         }
         this.shopInfo = res
+        if(this.orderId){
+          this.money = res.totaPrice
+          if(res.couponId){
+            this.couponInfo = {
+              id: res.couponId,
+              thresholdValue: res.thresholdValue,
+              discount: res.discount,
+              discountType: res.discountType,
+            }
+          }
+        }
       }).catch((err) => {
         clearTimeout(timer)
         this.shopInfo.scanFlag = 0
@@ -433,11 +454,39 @@
           wx.ready( ()=> {
             wx.hideAllNonBaseMenuItem();
             if(CHECK_LOCATION){
-              this.wxGetLocation()
+              this.wxGetLocation(null)
             }
           })
         })
       }
+      if(this.payWay == 5){
+        ap.hideOptionButton();
+        this.apGetLocation(null)
+      }
+    },
+    apGetLocation(callback){
+      ap.getLocation((res)=> {
+        console.log('apGetLocation',res)
+          if(res.latitude){
+            this.lat = parseFloat(res.latitude).toFixed(6); // 绾害锛屾诞鐐规暟锛岃寖鍥翠负90 ~ -90
+            this.lng = parseFloat(res.longitude).toFixed(6); // 缁忓害锛屾诞鐐规暟锛岃寖鍥翠负180 ~ -180銆�
+            if(callback) callback()
+          }else{
+            uni.showModal({
+              title: '鎻愮ず',
+              content: "鑾峰彇鍦扮悊浣嶇疆澶辫触锛屾棤娉曡繘琛屾敮浠橈紒",
+              confirmText: '閲嶆柊鎺堟潈',
+              cancelText: '閫�鍑�',
+              success: ret=>{
+                if(ret.confirm){
+                  this.apGetLocation(callback)
+                }else{
+                  this.clickDone()
+                }
+              }
+            })
+          }
+        })
     },
     wxGetLocation(callback){
       wx.getLocation({
@@ -455,19 +504,21 @@
               cancelText: '閫�鍑�',
               success: ret=>{
                 if(ret.confirm){
-                  this.wxGetLocation()
+                  this.wxGetLocation(callback)
                 }else{
                   this.clickDone()
                 }
               }
             })
           }
-
         }
       });
     },
     // 鑾峰彇浼氬憳鐩稿叧淇℃伅
     showCoupon() {
+      if(this.orderId){
+        return
+      }
       if (this.UNIONID||this.payWay==5) {
         if (uni.$u.test.isEmpty(this.money)) {
           uni.$u.toast('璇疯緭鍏ラ噾棰濓紒')
@@ -482,6 +533,7 @@
     },
     //鑾峰彇鐢ㄦ埛浼樻儬鍒�
     queryUseSweepPayCoupon() {
+      //2 寰俊 5鏀粯瀹� 15浜戦棯浠�
       const applyPayWayStr = {
         2: 1,
         5: 2,
@@ -528,7 +580,12 @@
         return
       }
       if(!this.lat){
-        this.wxGetLocation(this.pay)
+        if(this.payWay == 2){
+          this.wxGetLocation(this.pay)
+        }
+        if(this.payWay == 5){
+          this.apGetLocation(this.pay)
+        }
       }else{
         this.pay()
       }
@@ -542,7 +599,7 @@
       this.bordShow = false
       // 閲戦 this.money
       uni.showLoading()
-      const params = {
+      let params = {
         money: this.$utils.accMul(this.money,100),
         shopId: this.shopInfo.id,
         payWay: this.payWay,
@@ -558,6 +615,9 @@
       if (this.cid) {
         params.cid = this.cid
       }
+      if (this.orderId) {
+        params = {onlineId: this.onlineId}
+      }
       //鐢熸垚璁㈠崟
       saveOrder(params).then(res => {
         uni.hideLoading()

--
Gitblit v1.9.1