Commit 32640d29 authored by Xuguangxing's avatar Xuguangxing

feat: 处理原生浏览器和微信浏览器差异

parent cc662a3e
...@@ -68,9 +68,25 @@ export default { ...@@ -68,9 +68,25 @@ export default {
}; };
}, },
methods: { methods: {
getToken() {
const that = this;
window.xyqbNativeEvent = function(res) {
const json = typeof res === 'string' ? JSON.parse(res) : res;
if (json.event === 'getTokenSuccess') {
const appData = json.data || {};
if (appData && appData.token) {
localStorage.get('vccToken', appData.token);
that.$nextTick(() => {
window.location.reload();
});
}
}
};
this.nativeBridge.getToken();
},
checkLogin() { checkLogin() {
const vccToken = localStorage.get('vccToken'); const vccToken = localStorage.get('vccToken');
const needLogin = vccToken ? true : false; const needLogin = vccToken ? false : true;
if (needLogin) { if (needLogin) {
if (isApp) this.nativeBridge = new Bridge(); if (isApp) this.nativeBridge = new Bridge();
else if (isWxMp) this.nativeBridge = new MpBridge(); else if (isWxMp) this.nativeBridge = new MpBridge();
...@@ -85,10 +101,8 @@ export default { ...@@ -85,10 +101,8 @@ export default {
newUrl: `/pages/user/login` newUrl: `/pages/user/login`
}); });
} else if (isApp) { } else if (isApp) {
// todo 向app要一个scheme // native调用getToken
this.nativeBridge.openNewUrl({ this.getToken();
newUrl: ``
});
} else { } else {
this.$dialog({ this.$dialog({
message: '请在App或小程序中参与活动~', message: '请在App或小程序中参与活动~',
...@@ -100,10 +114,11 @@ export default { ...@@ -100,10 +114,11 @@ export default {
} }
}); });
} }
return needLogin;
}, },
joinGroup() { joinGroup() {
// 参团 // 参团
if (!this.checkLogin()) { if (this.checkLogin()) {
// todo // todo
return; return;
} }
...@@ -111,7 +126,7 @@ export default { ...@@ -111,7 +126,7 @@ export default {
}, },
createGroup() { createGroup() {
// 开团 // 开团
if (!this.checkLogin()) { if (this.checkLogin()) {
// todo // todo
return; return;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment