|
@@ -49,20 +49,13 @@ export default {
|
|
// messageError:false
|
|
// messageError:false
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- onLoad(page) {
|
|
|
|
- // 如果存在code 则认为是微信登录完成后跳转过来的,直接获取信息跳转首页或者指定页面
|
|
|
|
- let locationLocaturl = window.location.search;
|
|
|
|
- this.code = getUrlParams(locationLocaturl, "code"); // 截取code
|
|
|
|
- if (this.code) {
|
|
|
|
- this.handleGetWXInfo(this.code) //把code传给后台获取用户信息
|
|
|
|
- }
|
|
|
|
- console.log('backUrl',localStorage.getItem('backUrl'))
|
|
|
|
- },
|
|
|
|
|
|
+ onLoad(page) {},
|
|
onShow() {
|
|
onShow() {
|
|
|
|
+ // 判断是否登录 已登录直接跳转首页
|
|
if(this.vuex_hasLogin){
|
|
if(this.vuex_hasLogin){
|
|
- // uni.switchTab({
|
|
|
|
- // url: '../index/index'
|
|
|
|
- // })
|
|
|
|
|
|
+ uni.switchTab({
|
|
|
|
+ url: '../index/index'
|
|
|
|
+ })
|
|
}
|
|
}
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|
|
@@ -166,16 +159,6 @@ export default {
|
|
this.showToast();
|
|
this.showToast();
|
|
});
|
|
});
|
|
},
|
|
},
|
|
- // 微信登录
|
|
|
|
- wechatLogin() {
|
|
|
|
- this.jumpIndex()
|
|
|
|
- // const openId = this.$store.state.vuex_wxinfo?.openId
|
|
|
|
- // if (openId) {
|
|
|
|
- // this.jumpIndex()
|
|
|
|
- // } else {
|
|
|
|
- // this.getCode()
|
|
|
|
- // }
|
|
|
|
- },
|
|
|
|
veteEducCheck(){
|
|
veteEducCheck(){
|
|
this.$u.api.getVeteEducCheck().then(res=>{
|
|
this.$u.api.getVeteEducCheck().then(res=>{
|
|
console.log('res',res);
|
|
console.log('res',res);
|
|
@@ -188,7 +171,7 @@ export default {
|
|
}
|
|
}
|
|
})
|
|
})
|
|
},
|
|
},
|
|
- // 微信已登录则跳转到首页
|
|
|
|
|
|
+ // 跳转到首页
|
|
jumpIndex() {
|
|
jumpIndex() {
|
|
let ret = localStorage.getItem('backUrl')
|
|
let ret = localStorage.getItem('backUrl')
|
|
if (ret && ret.indexOf('phoneLogin') < 0) {
|
|
if (ret && ret.indexOf('phoneLogin') < 0) {
|
|
@@ -222,40 +205,6 @@ export default {
|
|
})
|
|
})
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- // 获取code
|
|
|
|
- getCode () {
|
|
|
|
- const local = window.location.href // 获取页面url
|
|
|
|
- let locationLocaturl = window.location.search;
|
|
|
|
- this.code = getUrlParams(locationLocaturl, "code"); // 截取code
|
|
|
|
- if (this.code) { // 如果没有code,则去请求
|
|
|
|
- this.handleGetWXInfo(this.code) //把code传给后台获取用户信息
|
|
|
|
- } else {
|
|
|
|
- window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${this.config.wxAppid}&redirect_uri=${encodeURIComponent(local)}&response_type=code&scope=snsapi_userinfo&#wechat_redirect`
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- // 通过code获取 openId等用户信息,/api/user/wechat/login 为后台接口
|
|
|
|
- handleGetWXInfo (code) {
|
|
|
|
- uni.showLoading({
|
|
|
|
- title: '加载中'
|
|
|
|
- })
|
|
|
|
- this.$u.api.getWXInfo(code).then((res) => {
|
|
|
|
- if (res.code === 200 ) {
|
|
|
|
- this.$u.vuex('vuex_wxinfo', res.data);
|
|
|
|
- this.jumpIndex()
|
|
|
|
- } else {
|
|
|
|
- this.$refs.uToast.show({
|
|
|
|
- title: '获取用户信息失败!',
|
|
|
|
- type: 'error',
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- uni.hideLoading()
|
|
|
|
- }).catch((err) => {
|
|
|
|
- this.$refs.uToast.show({
|
|
|
|
- title: '获取用户信息失败!',
|
|
|
|
- type: 'error',
|
|
|
|
- });
|
|
|
|
- })
|
|
|
|
- },
|
|
|
|
/**
|
|
/**
|
|
* 跳转页面
|
|
* 跳转页面
|
|
* */
|
|
* */
|