|
|
@@ -39,50 +39,44 @@ export default {
|
|
|
let openid = res.authResult.openid
|
|
|
let access_token = res.authResult.access_token
|
|
|
phoneLogin({openid,access_token}).then(subRes=>{
|
|
|
- let currentShopId = subRes.data.admin.currentShopId || 0
|
|
|
- if(Number(currentShopId) > 0){
|
|
|
- //有几个地方涉及登陆,需要统一方法,请搜索关键词 uni_login
|
|
|
- if(subRes.code == 1){
|
|
|
- if (that.$util.isEmpty(subRes)) {
|
|
|
+ let token = subRes.data.token || ''
|
|
|
+ uni.hideLoading()
|
|
|
+ if (that.$util.isEmpty(token)) {
|
|
|
+ that.$msg('请先注册')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ //有几个地方涉及登陆,需要统一方法,请搜索关键词 uni_login
|
|
|
+ if(subRes.code == 1){
|
|
|
+ if (that.$util.isEmpty(subRes)) {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ uni.setStorageSync('token', subRes.data.token)
|
|
|
+ uni.setStorageSync('shopId', subRes.data.admin.currentShopId)
|
|
|
+ getDictionaries({ token: subRes.data.token }).then(res => {
|
|
|
+ if (that.$util.isEmpty(res)) {
|
|
|
return false
|
|
|
}
|
|
|
- uni.setStorageSync('token', subRes.data.token)
|
|
|
- uni.setStorageSync('shopId', subRes.data.admin.currentShopId)
|
|
|
- getDictionaries({ token: subRes.data.token }).then(res => {
|
|
|
- if (that.$util.isEmpty(res)) {
|
|
|
- return false
|
|
|
- }
|
|
|
- that.$store.commit('setDictionariesInfo', { ...res.data.dict, ...res.data })
|
|
|
- that.$store.commit('setMyShopInfo', { ...res.data.shop, ...res.data })
|
|
|
- })
|
|
|
- that.$store.commit('setLoginInfo', { ...subRes.data.admin, ...subRes.data })
|
|
|
-
|
|
|
- that.show_login_model = false
|
|
|
-
|
|
|
- getUser(true).then(res => { uni.setNavigationBarTitle({ title: res.name }) })
|
|
|
+ that.$store.commit('setDictionariesInfo', { ...res.data.dict, ...res.data })
|
|
|
+ that.$store.commit('setMyShopInfo', { ...res.data.shop, ...res.data })
|
|
|
+ })
|
|
|
+ that.$store.commit('setLoginInfo', { ...subRes.data.admin, ...subRes.data })
|
|
|
|
|
|
- //#ifdef APP-PLUS
|
|
|
- that.skCustomId = subRes.data.skCustomId
|
|
|
- that.listenPDAkd()
|
|
|
- // #endif
|
|
|
+ getUser(true).then(res => { uni.setNavigationBarTitle({ title: res.name }) })
|
|
|
|
|
|
- that.setUserShopAll()
|
|
|
- that.init()
|
|
|
+ that.setUserShopAll()
|
|
|
+ that.init()
|
|
|
|
|
|
- // #ifdef APP-PLUS
|
|
|
- //保存安卓的clientId
|
|
|
- let hasClientId = !that.$util.isEmpty(subRes.data.admin.clientId) ? subRes.data.admin.clientId : ''
|
|
|
- const clientInfo = plus.push.getClientInfo()
|
|
|
- let currentClientId = !that.$util.isEmpty(clientInfo.clientid) ? clientInfo.clientid : ''
|
|
|
- if(hasClientId == '' || hasClientId != currentClientId){
|
|
|
- replaceClientId({id:currentClientId}).then(res=>{ })
|
|
|
- }
|
|
|
- // #endif
|
|
|
+ // #ifdef APP-PLUS
|
|
|
+ //保存安卓的clientId
|
|
|
+ let hasClientId = !that.$util.isEmpty(subRes.data.admin.clientId) ? subRes.data.admin.clientId : ''
|
|
|
+ const clientInfo = plus.push.getClientInfo()
|
|
|
+ let currentClientId = !that.$util.isEmpty(clientInfo.clientid) ? clientInfo.clientid : ''
|
|
|
+ if(hasClientId == '' || hasClientId != currentClientId){
|
|
|
+ replaceClientId({id:currentClientId}).then(res=>{ })
|
|
|
}
|
|
|
- uni.hideLoading()
|
|
|
- }else{
|
|
|
- that.$msg('您还没有注册')
|
|
|
+ // #endif
|
|
|
}
|
|
|
+
|
|
|
})
|
|
|
},
|
|
|
fail(res){
|
|
|
@@ -126,15 +120,8 @@ export default {
|
|
|
})
|
|
|
that.$store.commit('setLoginInfo', { ...subRes.data.admin, ...subRes.data })
|
|
|
|
|
|
- that.show_login_model = false
|
|
|
-
|
|
|
getUser(true).then(res => { uni.setNavigationBarTitle({ title: res.name }) })
|
|
|
|
|
|
- //#ifdef APP-PLUS
|
|
|
- that.skCustomId = subRes.data.skCustomId
|
|
|
- that.listenPDAkd()
|
|
|
- // #endif
|
|
|
-
|
|
|
that.setUserShopAll()
|
|
|
that.init()
|
|
|
uni.hideLoading()
|