From 1ca571a40509a7a6cfdf51316025f3692f62122f Mon Sep 17 00:00:00 2001
From: 石广澎 <shiguangpeng@163.com>
Date: 星期五, 12 四月 2024 19:42:14 +0800
Subject: [PATCH] feat(微信支付): 支持通联收银宝代理商模式
---
pages/pay/scanpay.vue | 137 ++++++++++++++++++---------------
pages/pay/discountpay.vue | 57 +++++++++----
common/api/index.js | 11 ++
3 files changed, 123 insertions(+), 82 deletions(-)
diff --git a/common/api/index.js b/common/api/index.js
index ec53346..acb54f9 100644
--- a/common/api/index.js
+++ b/common/api/index.js
@@ -33,7 +33,14 @@
/* 鏀粯瀹濇櫘閫氭巿鏉冪櫥褰� */
export const getUserId = (params, config = {}) => http.get(URL + '/service-merchant/v1/web/h5PayAli/getUserIdByCode',
params, config = {});
-
+export const userLogin = (params, config = {}) => {
+ let path = '/service-merchant/v1/web/aggregatePayAllin/getOpenId'
+ if(params.platform==5){
+ path = '/service-merchant/v1/web/h5PayAli/getUserIdByCode'
+ }
+ return http.get(URL + path,
+ params, config = {})
+};
/* 鑾峰彇鐢ㄦ埛绉垎 */
export const queryScore = (params, config = {}) => http.get(URL +
'/service-merchant/v1/web/aggregatePayAllin/queryScore', params, config = {});
@@ -109,4 +116,4 @@
/* 鑾峰彇棣栫粦鏈夌ぜ */
export const headBand = (params, config = {}) => http.get(URL +
'/service-shop/v1/shop/wechat/activity/headBand/detail',
- params, config = {});
\ No newline at end of file
+ params, config = {});
diff --git a/pages/pay/discountpay.vue b/pages/pay/discountpay.vue
index bd0169b..df0683a 100644
--- a/pages/pay/discountpay.vue
+++ b/pages/pay/discountpay.vue
@@ -371,24 +371,45 @@
})
},
// 寰俊鏀粯
- 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)}`
- })
- }
- });
- }, 200)
- },
+ 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)}`
+ })
+ }
+ });
+ }, 200)*/
+ setTimeout(() => {
+ 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)
+ },
//鏀粯瀹濇敮浠�
aliPay(res) {
ap.tradePay({
diff --git a/pages/pay/scanpay.vue b/pages/pay/scanpay.vue
index 44c7ec0..15e5350 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">
@@ -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,6 +294,19 @@
this.canReset = true
},
methods: {
+ 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) {
this.bordShow = false
this.payWay = item
@@ -528,27 +504,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() {
@@ -606,7 +597,7 @@
},
// 寰俊鏀粯
wxPay(res) {
- setTimeout(() => {
+ /*setTimeout(() => {
wx.chooseWXPay({
timestamp: res.timeStamp, // 鏀粯绛惧悕鏃堕棿鎴�
nonceStr: res.nonceStr, // 鏀粯绛惧悕闅忔満涓诧紝涓嶉暱浜� 32 浣�
@@ -621,6 +612,28 @@
})
}
});
+ }, 200)*/
+
+ setTimeout(() => {
+ 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