diff --git a/src/App.vue b/src/App.vue index cd4eee3..d6cf276 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,7 +1,6 @@ diff --git a/src/static/images/almost-lottery__action.png b/src/static/images/almost-lottery__action.png deleted file mode 100644 index 2e221a4..0000000 Binary files a/src/static/images/almost-lottery__action.png and /dev/null differ diff --git a/src/static/images/almost-lottery__bg.png b/src/static/images/almost-lottery__bg.png deleted file mode 100644 index be39367..0000000 Binary files a/src/static/images/almost-lottery__bg.png and /dev/null differ diff --git a/src/utils/login.js b/src/utils/login.js index d021f6b..cca68c2 100644 --- a/src/utils/login.js +++ b/src/utils/login.js @@ -1,6 +1,4 @@ -import { - http -} from '@/utils/request' +import { http } from '@/utils/request' import store from '@/store' @@ -19,28 +17,22 @@ export function getWxCode() { } //小程序静默登录 -export async function wxMnpLogin(invite_code){ - store.commit('user/LOGOUT') - const code = await getWxCode() - invite_code=invite_code?invite_code: uni.getStorageSync('INVITE_CODE') - await silentLogin({code,invite_code}) +export async function wxMnpLogin(invite_code) { + // 判断是否有 auth_token + var token = store.getters.token + if (token) { + // 获取 当前用户信息 + await store.dispatch('user/getUserInfo', false) + return; + } + // 没有 auth_token, 再调用 wx.login 登录 + store.commit('user/LOGOUT') + const code = await getWxCode() + invite_code = invite_code ? invite_code : uni.getStorageSync('INVITE_CODE') + + const resData = await http.post(`/v1/wechat-mini/login`, { code, invite_code }, { custom: { toast: false } }) + uni.setStorageSync("openid", resData.openid) + if (resData.token) { + store.commit('user/LOGIN', resData.token) + } } - - -async function silentLogin(data){ - // const provider = 'wechat-mini' - // const resData = await http.post(`/v1/socialite/code-auth/${provider}`,data,{ - // custom:{ - // toast:false - // } - // }) - const resData = await http.post(`/v1/wechat-mini/login`,data,{ - custom:{ - toast:false - } - }) - uni.setStorageSync("openid", resData.openid) - if (resData.token) { - store.commit('user/LOGIN', resData.token) - } - }