10.25午夜修改
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
const res_form = ref(null)
|
||||
const is_login = ref(null)
|
||||
const userinfo = ref(null)
|
||||
const newUser = ref(null)
|
||||
// const avatarUrl = ref(null)
|
||||
const nickname = ref('')
|
||||
// 函数
|
||||
@@ -26,9 +27,9 @@
|
||||
userinfo.value = JSON.parse(uni.getStorageSync('userInfo'))
|
||||
}
|
||||
}
|
||||
function toLogin() {
|
||||
function toLogin(token_info) {
|
||||
uni.navigateTo({
|
||||
url:"/pages/login/login"
|
||||
url:"/pages/login/login?token_info="+token_info
|
||||
})
|
||||
}
|
||||
function toDetail(type) {
|
||||
@@ -83,8 +84,24 @@
|
||||
// console.log('登录参数:',data);return;
|
||||
const res = await api.getToken(data)
|
||||
if(res.code === 200) {
|
||||
if(res.data.newUser) { // 新用户,跳转登录页
|
||||
toLogin()
|
||||
// newUser.value = res.data.newUser
|
||||
if(res.data.newUser) { // 新用户,不做任何缓存动作,跳转登录页
|
||||
let userId = res.data.userId
|
||||
let res_p=await new Promise(resolve=>{
|
||||
uni.login({
|
||||
provider: 'weixin', //使用微信登录
|
||||
success: function (loginRes) {
|
||||
resolve(loginRes);
|
||||
console.log(loginRes,'微信登录返回信息');
|
||||
}
|
||||
});
|
||||
});
|
||||
uni.setStorageSync('access_token','Bearer '+res.data.access_token);// token单独缓存一次
|
||||
let res2=await api.wx_login({code:res_p.code},userId);
|
||||
if(res2.code === 0) {
|
||||
|
||||
toLogin(encodeURIComponent(JSON.stringify(res.data)))
|
||||
}
|
||||
}
|
||||
else{
|
||||
uni.setStorageSync('avatarUrl', res.data.avatar);//avatarUrl
|
||||
@@ -111,6 +128,9 @@
|
||||
uni.setStorageSync('userInfo',JSON.stringify(res_form.value))
|
||||
// is_login.value = custom.checkLogin()
|
||||
getInfo()
|
||||
// if(newUser.value) {
|
||||
// toLogin()
|
||||
// }
|
||||
}
|
||||
else{
|
||||
uni.clearStorage();
|
||||
|
Reference in New Issue
Block a user