Commit 32640d29 authored by Xuguangxing's avatar Xuguangxing

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

parent cc662a3e
......@@ -68,9 +68,25 @@ export default {
};
},
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() {
const vccToken = localStorage.get('vccToken');
const needLogin = vccToken ? true : false;
const needLogin = vccToken ? false : true;
if (needLogin) {
if (isApp) this.nativeBridge = new Bridge();
else if (isWxMp) this.nativeBridge = new MpBridge();
......@@ -85,10 +101,8 @@ export default {
newUrl: `/pages/user/login`
});
} else if (isApp) {
// todo 向app要一个scheme
this.nativeBridge.openNewUrl({
newUrl: ``
});
// native调用getToken
this.getToken();
} else {
this.$dialog({
message: '请在App或小程序中参与活动~',
......@@ -100,10 +114,11 @@ export default {
}
});
}
return needLogin;
},
joinGroup() {
// 参团
if (!this.checkLogin()) {
if (this.checkLogin()) {
// todo
return;
}
......@@ -111,7 +126,7 @@ export default {
},
createGroup() {
// 开团
if (!this.checkLogin()) {
if (this.checkLogin()) {
// todo
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