|
@@ -43,7 +43,7 @@ export default {
|
|
|
// 初始化微信
|
|
|
// initWxJsSdkConfig(['chooseWXPay', 'scanQRCode', 'checkJsApi']);
|
|
|
// 如果用户不选择登录,则不走登录逻辑
|
|
|
- this.isInit = true;
|
|
|
+ const query = getUrlParams();
|
|
|
this.$router.replace({
|
|
|
path: 'login',
|
|
|
query: query,
|
|
@@ -53,6 +53,8 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
getCode() {
|
|
|
+ console.log(56, this.$route);
|
|
|
+ debugger;
|
|
|
const { code = '' } = getUrlParams(); // 截取路径中的code,如果没有就去微信授权,如果已经获取到了就直接传code给后台获取openId
|
|
|
const local = `${window.location.href}`.replace(/openWx/g, '');
|
|
|
// return;
|
|
@@ -77,27 +79,40 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
async getOpenId(code) {
|
|
|
- // 通过code获取 openId等用户信息,/api/user/wechat/login 为后台接口
|
|
|
- const { appid, secret } = getAppIdByGroupIdAndMallId({
|
|
|
- groupId: this.$route.params.groupId,
|
|
|
- mallId: this.$route.params.mallId,
|
|
|
- type: 'all',
|
|
|
- });
|
|
|
- // ?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code
|
|
|
- const res = await WxJsOpenId({
|
|
|
- appid,
|
|
|
- secret,
|
|
|
- code,
|
|
|
- grant_type: 'authorization_code',
|
|
|
- });
|
|
|
- if (res?.expires_in && res?.openid) {
|
|
|
- this.$store.commit('SET_OPENID', res.openid);
|
|
|
+ try {
|
|
|
+ this.$store.commit('SET_OPENID', 'odJnI0-Y6ZJap-Ow9nmJH-4WyxhU');
|
|
|
// 判断用户是否需要登录,
|
|
|
await this.checkIsLogin(() => {
|
|
|
this.$router.replace({
|
|
|
path: 'home',
|
|
|
});
|
|
|
});
|
|
|
+ /*// 通过code获取 openId等用户信息,/api/user/wechat/login 为后台接口
|
|
|
+ const { appid, secret } = getAppIdByGroupIdAndMallId({
|
|
|
+ groupId: this.$route.params.groupId,
|
|
|
+ mallId: this.$route.params.mallId,
|
|
|
+ type: 'all',
|
|
|
+ });
|
|
|
+ console.log(86, appid, secret, code);
|
|
|
+ // return;
|
|
|
+ // ?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code
|
|
|
+ const res = await WxJsOpenId({
|
|
|
+ appid,
|
|
|
+ secret,
|
|
|
+ code,
|
|
|
+ grant_type: 'authorization_code',
|
|
|
+ });
|
|
|
+ if (res?.expires_in && res?.openid) {
|
|
|
+ this.$store.commit('SET_OPENID', res.openid);
|
|
|
+ // 判断用户是否需要登录,
|
|
|
+ await this.checkIsLogin(() => {
|
|
|
+ this.$router.replace({
|
|
|
+ path: 'home',
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }*/
|
|
|
+ } catch (err) {
|
|
|
+ console.log(106, err);
|
|
|
}
|
|
|
},
|
|
|
},
|