|
@ -42,13 +42,25 @@ const user = { |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
actions: { |
|
|
actions: { |
|
|
login(context) { |
|
|
|
|
|
|
|
|
login(context, loading) { |
|
|
|
|
|
|
|
|
|
|
|
let success = function(){} |
|
|
|
|
|
let error = function(){} |
|
|
|
|
|
let promise = new Promise((s, e) => { |
|
|
|
|
|
success = s |
|
|
|
|
|
error = e |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
uni.login({ |
|
|
uni.login({ |
|
|
success: (res) => { |
|
|
success: (res) => { |
|
|
const code = res.code |
|
|
const code = res.code |
|
|
uni.showLoading({ |
|
|
|
|
|
mask : true |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(loading){ |
|
|
|
|
|
uni.showLoading({ |
|
|
|
|
|
mask : true |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
wxLogin({ |
|
|
wxLogin({ |
|
|
code |
|
|
code |
|
|
}).then(res => { |
|
|
}).then(res => { |
|
@ -59,7 +71,7 @@ const user = { |
|
|
context.commit('setUserInfo', res.data.userInfo); |
|
|
context.commit('setUserInfo', res.data.userInfo); |
|
|
setIsLogin(true); |
|
|
setIsLogin(true); |
|
|
uni.hideLoading(); |
|
|
uni.hideLoading(); |
|
|
|
|
|
|
|
|
|
|
|
success(res) |
|
|
if (!res.data.userInfo.userName || !res.data.userInfo.userImage || ! |
|
|
if (!res.data.userInfo.userName || !res.data.userInfo.userImage || ! |
|
|
res.data.userInfo.userTelephone) { |
|
|
res.data.userInfo.userTelephone) { |
|
|
uni.navigateTo({ |
|
|
uni.navigateTo({ |
|
@ -72,6 +84,8 @@ const user = { |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
return promise |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
// 已登录的情况下调用接口获取用户信息,保证用户信息的实时更新
|
|
|
// 已登录的情况下调用接口获取用户信息,保证用户信息的实时更新
|
|
|