From 919350c2c012955ea88bcb3e0ba5c8d8fa31525e Mon Sep 17 00:00:00 2001 From: GaoHao <1210693421@qq.com> Date: Mon, 18 Nov 2024 14:59:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=85=E5=80=BC=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- framework/0-conf.js | 6 +++-- framework/1-utils.js | 44 +++++++++++++++++------------------ pages/member/index.vue | 53 ++++++++++++++++++++++++++++++++++-------- store/index.js | 2 ++ 4 files changed, 71 insertions(+), 34 deletions(-) diff --git a/framework/0-conf.js b/framework/0-conf.js index 6a36889..46a29b4 100644 --- a/framework/0-conf.js +++ b/framework/0-conf.js @@ -8,8 +8,10 @@ const proxyApi = "/api" // const proxyApiwws = 'ws://192.168.1.15:9888/netty' // 测试 // const proxyApi = 'https://wxcashiertest.sxczgkj.cn/cashierService' // 测试 // const proxyApiwws = 'wss://wxcashiertest.sxczgkj.cn/netty' // 测试 -const proxyApi = 'https://pre-cashier.sxczgkj.cn/cashierService' // 预发布 -const proxyApiwws = 'wss://pre-cashier.sxczgkj.cn/netty' // 预发布 +// const proxyApi = 'https://pre-cashier.sxczgkj.cn/cashierService' // 预发布 +// const proxyApiwws = 'wss://pre-cashier.sxczgkj.cn/netty' // 预发布 +const proxyApi = 'https://cashier.sxczgkj.cn/cashierService' // 预发布 +const proxyApiwws = 'wss://cashier.sxczgkj.cn/netty' // 预发布 // #endif // #ifdef H5 diff --git a/framework/1-utils.js b/framework/1-utils.js index fc02306..a618669 100644 --- a/framework/1-utils.js +++ b/framework/1-utils.js @@ -267,28 +267,28 @@ const getUserInfo = function (successCallback, failCallback) { // #endif // #ifdef MP-ALIPAY - return new Promise((resolve, reject) => { - my.getAuthCode({ - scopes: 'auth_user', - success: (data) => { - console.log(data) - // 支付宝小程序环境 - my.getAuthUserInfo({ - success: async (infoRes) => { - let res = await Api.userwxlogin({ - code: data.authCode, //临时登录凭证 - rawData: JSON.stringify(infoRes), - source: 'alipay' - }) - if (res.code == 0) { - resolve(res) - } - }, - fail: (err) => {} - }); - } - }); - }) + return new Promise((resolve, reject) => { + my.getAuthCode({ + scopes: 'auth_base', + success: async (data) => { + console.log(data) + // 支付宝小程序环境 + // my.getAuthUserInfo({ + // success: async (infoRes) => { + let res = await Api.userwxlogin({ + code: data.authCode, //临时登录凭证 + // rawData: JSON.stringify(infoRes), + source: 'alipay' + }) + if (res.code == 0) { + resolve(res) + } + // }, + // fail: (err) => {} + // }); + } + }); + }) // #endif } diff --git a/pages/member/index.vue b/pages/member/index.vue index bbed540..1fbe2fc 100644 --- a/pages/member/index.vue +++ b/pages/member/index.vue @@ -315,6 +315,7 @@ }); return false; } + console.log(this.amount) if (this.amount == null || this.amount == '') { uni.showToast({ title: '金额不能为空', @@ -331,15 +332,21 @@ } let res = await this.api.paymemeberIn({ shopId: this.shopId, // 判断显示哪家的作品, - amount: this.amount // 判断显示哪家的作品, + amount: this.amount ,// 判断显示哪家的作品, + // #ifdef MP-WEIXIN + payType: 'wechatPay', + // #endif + // #ifdef MP-ALIPAY + payType: 'aliPay', + // #endif }) if (res.code == 0) { uni.showLoading({ title: '加载中', mask: true }) - // #ifdef MP-WEIXIN uni.requestPayment({ + // #ifdef MP-WEIXIN provider: 'wxpay', //支付类型-固定值 partnerid: res.data.appId, // 微信支付商户号 timeStamp: res.data.timeStamp, // 时间戳(单位:秒) @@ -347,26 +354,53 @@ package: res.data.package, // 固定值 signType: res.data.signType, //固定值 paySign: res.data.paySign, //签名 + // #endif + // #ifdef MP-ALIPAY + provider: 'alipay', //支付类型-固定值 + orderInfo: res.data.tradeNo, // 微信支付商户号 + // #endif success: (res) => { uni.showToast({ title: "支付成功" }) uni.hideLoading() let pages = getCurrentPages() + // #ifdef MP-WEIXIN uni.requestSubscribeMessage({ tmplIds:["AV-KybUHaK3KtFVLqpy6PHccHBS7XeX__mOM4RbufnQ"], complete() { - if ( pages.length > 1) { - _this.shopInfo() + if ( _this.type && _this.type == "topUpActivity") { + uni.pro.navigateBack() } else { - setTimeout(res => { - uni.switchTab({ - url: '/pages/index/index' - }) - }, 500) + if ( pages.length > 1) { + _this.shopInfo() + } else { + setTimeout(res => { + uni.switchTab({ + url: '/pages/index/index' + }) + }, 500) + } } + }, }) + // #endif + // #ifdef MP-ALIPAY + if ( _this.type && _this.type == "topUpActivity") { + uni.pro.navigateBack() + } else { + if ( pages.length > 1) { + _this.shopInfo() + } else { + setTimeout(res => { + uni.switchTab({ + url: '/pages/index/index' + }) + }, 500) + } + } + // #endif @@ -376,7 +410,6 @@ } }); uni.hideLoading() - // #endif } }, diff --git a/store/index.js b/store/index.js index 7f88442..6c3e2aa 100644 --- a/store/index.js +++ b/store/index.js @@ -62,7 +62,9 @@ const store = new Vuex.Store({ }, actions: { loginEvent: async () => { + console.log(2) let res = await uni.utils.getUserInfo(); + console.log(res) uni.cache.set('token', res.data.token); uni.cache.set('miniAppOpenId', res.data.userInfo .miniAppOpenId)