|
@@ -41,6 +41,7 @@ import { getWxInfo, getMiniMobile } from "@/api/mini"
|
|
|
import { create } from "@/api/user"
|
|
import { create } from "@/api/user"
|
|
|
import store from '@/store'
|
|
import store from '@/store'
|
|
|
import { TOKEN_STORAGE_KEY } from "@/constant/storageKeys";
|
|
import { TOKEN_STORAGE_KEY } from "@/constant/storageKeys";
|
|
|
|
|
+import { refreshShopInfoAfterLogin } from "@/api/shop"
|
|
|
|
|
|
|
|
export default {
|
|
export default {
|
|
|
name: "index",
|
|
name: "index",
|
|
@@ -63,10 +64,21 @@ export default {
|
|
|
if (this.option && this.option.needBack) {
|
|
if (this.option && this.option.needBack) {
|
|
|
this.needBack = this.option.needBack
|
|
this.needBack = this.option.needBack
|
|
|
}
|
|
}
|
|
|
|
|
+ // 登录页带 account 时写回,保证邀请缓存 key 与门店一致
|
|
|
|
|
+ if (this.option && this.option.account) {
|
|
|
|
|
+ uni.setStorageSync('account', this.option.account)
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
accountLogin() {
|
|
accountLogin() {
|
|
|
this.$util.pageTo({ url: "/pages/login/account", type: 2 })
|
|
this.$util.pageTo({ url: "/pages/login/account", type: 2 })
|
|
|
},
|
|
},
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 登录成功后重拉 shop/info:新建客户并绑定分享 inviterCustomId(读本地 shareInviter_{account})
|
|
|
|
|
+ */
|
|
|
|
|
+ afterLoginSuccess() {
|
|
|
|
|
+ const account = (this.option && this.option.account) || uni.getStorageSync('account') || ''
|
|
|
|
|
+ return refreshShopInfoAfterLogin(account)
|
|
|
|
|
+ },
|
|
|
confirmFn() {
|
|
confirmFn() {
|
|
|
let currentMiniOpenId = uni.getStorageSync('miniOpenId')
|
|
let currentMiniOpenId = uni.getStorageSync('miniOpenId')
|
|
|
let that = this
|
|
let that = this
|
|
@@ -75,18 +87,22 @@ export default {
|
|
|
uni.setStorageSync(TOKEN_STORAGE_KEY, res.data.token)
|
|
uni.setStorageSync(TOKEN_STORAGE_KEY, res.data.token)
|
|
|
if (res.data.user && !that.$util.isEmpty(res.data.user)) {
|
|
if (res.data.user && !that.$util.isEmpty(res.data.user)) {
|
|
|
store.commit('setLoginInfo', res.data.user)
|
|
store.commit('setLoginInfo', res.data.user)
|
|
|
- if (this.needBack == 1) {
|
|
|
|
|
- that.$msg('登录成功')
|
|
|
|
|
- setTimeout(function () {
|
|
|
|
|
- let pages = getCurrentPages();
|
|
|
|
|
- let prevPage = pages[pages.length - 2];
|
|
|
|
|
- prevPage.$vm.loginComeBack = 1
|
|
|
|
|
- prevPage.$vm.pageAction = { refresh: 1 }
|
|
|
|
|
- uni.navigateBack({})
|
|
|
|
|
- }, 1100)
|
|
|
|
|
- } else {
|
|
|
|
|
- that.$util.pageTo({ url: "/pages/login/result", type: 2 })
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ that.afterLoginSuccess().finally(() => {
|
|
|
|
|
+ if (that.needBack == 1) {
|
|
|
|
|
+ that.$msg('登录成功')
|
|
|
|
|
+ setTimeout(function () {
|
|
|
|
|
+ let pages = getCurrentPages();
|
|
|
|
|
+ let prevPage = pages[pages.length - 2];
|
|
|
|
|
+ if (prevPage && prevPage.$vm) {
|
|
|
|
|
+ prevPage.$vm.loginComeBack = 1
|
|
|
|
|
+ prevPage.$vm.pageAction = { refresh: 1 }
|
|
|
|
|
+ }
|
|
|
|
|
+ uni.navigateBack({})
|
|
|
|
|
+ }, 1100)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ that.$util.pageTo({ url: "/pages/login/result", type: 2 })
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|