diff --git a/api/modules/common.js b/api/modules/common.js
index 630cebd..65fe454 100644
--- a/api/modules/common.js
+++ b/api/modules/common.js
@@ -144,6 +144,15 @@ export default {
});
},
+ wechatPageH5(data) {
+ return request({
+ url: "/common/wechatPageH5",
+ method: "GET",
+ data,
+ needLogin: true,
+ });
+ },
+
aliH5(data) {
return request({
url: "/common/aliH5",
diff --git a/components/login/logins.vue b/components/login/logins.vue
index 9871a50..7d1a199 100644
--- a/components/login/logins.vue
+++ b/components/login/logins.vue
@@ -33,19 +33,21 @@
created() {
if (this.wcCode) {
this.actionLogin(this.wcCode, '', 1);
- }
- // 验证是否需要登录
- if (this.type == 2) {
- this.isLogin()
- }
- // #ifdef H5
- // 如果是支付宝h5自动完成登陆
- if (this.type == 0) {
- if (this.$utils.isInAliBrowser()) {
- this.login()
+ } else {
+ // 验证是否需要登录
+ if (this.type == 2) {
+ this.isLogin()
+ }
+ // #ifdef H5
+ // 如果是支付宝h5自动完成登陆
+ if (this.type == 0) {
+ if (this.$utils.isInAliBrowser() || this.$utils.isInWeChatBrowser()) {
+ this.login()
+ }
}
+ // #endif
}
- // #endif
+
},
methods: {
async login({
@@ -90,7 +92,6 @@
const res = await this.$api.common.aliH5();
// 获取微信应用的 appid
const appid = res.data.appid;
-
ap.getAuthCode({
appId: appid,
scopes: ['auth_base'],
@@ -110,15 +111,18 @@
} else if (this.$utils.isInWeChatBrowser()) {
// 微信h5登陆
// 从后端API获取微信H5相关信息
- const res = await this.$api.common.wechatH5();
+ const res = await this.$api.common.wechatPageH5();
// 获取微信应用的 appid
const appid = res.data.appid;
+ const component_appid = res.data.component_appid
// 获取当前页面的重定向地址并进行编码
let redirect_uri = window.location.href;
- redirect_uri = encodeURIComponent(redirect_uri);
+ var fruits = redirect_uri.split("?");
+ // console.log(fruits, 'fruits')
+ redirect_uri = encodeURIComponent(fruits[0]);
// 构建微信授权链接,包含应用的appid、重定向地址等参数
- const wxAuthUrl =
- `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${redirect_uri}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`;
+ // const wxAuthUrl = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${redirect_uri}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect`;
+ const wxAuthUrl = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${redirect_uri}&response_type=code&scope=snsapi_base&state=STATE&component_appid=${component_appid}#wechat_redirect`
// 通过重定向将用户导向微信授权页面
window.location.href = wxAuthUrl;
return;
@@ -153,7 +157,6 @@
user_info,
store_id
} = res.data;
-
uni.setStorageSync("token_" + store_id, token);
uni.setStorageSync("user_info", user_info);
if (this.type != 0) {
@@ -166,7 +169,6 @@
this.backPage()
return;
}
-
uni.$u.toast(res.message);
} catch (e) {
uni.hideLoading();
diff --git a/env.js b/env.js
index 21519d4..108bb12 100644
--- a/env.js
+++ b/env.js
@@ -3,7 +3,8 @@ const env = {
NETWORK_TIME_OUT: 15000,
version: "0.1",
store_id: 1,
- mini_id: 0
+ mini_id: 0,
+ is_page: 1
};
// #ifdef H5
// 生产环境
diff --git a/subPackages/inPersonToPay/index/index.vue b/subPackages/inPersonToPay/index/index.vue
index 69bd125..5963d8e 100644
--- a/subPackages/inPersonToPay/index/index.vue
+++ b/subPackages/inPersonToPay/index/index.vue
@@ -73,10 +73,7 @@
-
-
-
-
+
@@ -108,7 +105,8 @@
payCurrent: false,
coupon: [],
activeCoupon: {},
- mch_id: 0
+ mch_id: 0,
+ wcCode: -1
}
},
computed: {
@@ -122,43 +120,26 @@
}
},
async onLoad(query) {
-
- if (!this.$utils.isInAliBrowser()) {
- return uni.showModal({
- title: '提示',
- content: '请使用支付宝扫码',
- showCancel: false
- })
+ if (query.wxcode) {
+ this.wcCode = query.wxcode
+ query.mch_id = uni.getStorageSync('pay_mch_id')
+ } else {
+ if (query.state) {
+ return uni.showModal({
+ title: '提示',
+ content: '登录失败'
+ })
+ }
+ this.wcCode = ''
+ if (query.mch_id > 0) {
+ uni.setStorageSync('pay_mch_id', query.mch_id)
+ }
}
-
let qrCode = '';
-
- // #ifdef MP-ALIPAY
- let qrQuery = ''
- if (query.query && query.query.qrCode) {
- qrQuery = query.query.qrCode; // 存储二维码码
- } else {
- qrQuery = uni.getStorageSync('qrcode')
- }
- qrCode = decodeURIComponent(qrQuery || ''); // 适用于支付宝小程序
- // #endif
-
- // #ifdef MP-WEIXIN
- qrCode = decodeURIComponent(query.q || '');
- // #endif
-
- // #ifdef MP
- const params = this.$utils.oneValues(qrCode)
- // #endif
-
- // #ifdef H5
- const params = query
- // #endif
-
+ const params = query
const {
mch_id
} = params;
-
this.mch_id = mch_id || 0
this.$nextTick(() => {
this.init()
@@ -256,11 +237,11 @@
break;
case 2:
- return uni.showModal({
- title: '提示',
- content: '请使用支付宝扫码',
- showCancel: false
- })
+ // return uni.showModal({
+ // title: '提示',
+ // content: '请使用支付宝扫码',
+ // showCancel: false
+ // })
// #ifndef MP
await this.wechatPayNow({
payType,
@@ -286,9 +267,7 @@
order_no,
order_type
})
-
break;
-
default:
break;
}
diff --git a/subPackages/login/login/index.vue b/subPackages/login/login/index.vue
index f90df75..315f97f 100644
--- a/subPackages/login/login/index.vue
+++ b/subPackages/login/login/index.vue
@@ -15,9 +15,16 @@ export default {
wcCode: undefined
};
},
- onLoad({ wxcode } = {}) {
+ onLoad({ wxcode, state } = {}) {
if (wxcode) {
this.wcCode = wxcode
+ } else {
+ if (state) {
+ return uni.showModal({
+ title: '提示',
+ content: '登录失败'
+ })
+ }
}
},
methods: {},