gukai 1 year ago
parent 639a45ab29
commit b2b0c4c862

@ -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",

@ -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
// APIH5
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();

@ -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
// 生产环境

@ -73,10 +73,7 @@
</view>
</template>
<logins @isLogin="isLogin" :type="$utils.isInAliBrowser() ? 0 : 2"></logins>
<logins v-if="wcCode != -1" @isLogin="isLogin" :wcCode="wcCode" :type="$utils.isInAliBrowser() || $utils.isInWeChatBrowser() ? 0 : 2"></logins>
</view>
</template>
@ -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;
}

@ -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: {},

Loading…
Cancel
Save