|
@@ -22,7 +22,7 @@ import util from './util'
|
|
|
export async function getShopUser(update) {
|
|
export async function getShopUser(update) {
|
|
|
let userInfo = store.getters.getShopUser
|
|
let userInfo = store.getters.getShopUser
|
|
|
if (!util.isEmpty(userInfo) && !update) {
|
|
if (!util.isEmpty(userInfo) && !update) {
|
|
|
- return userInfo
|
|
|
|
|
|
|
+ return userInfo
|
|
|
}
|
|
}
|
|
|
await getShopUserApi().then((res) => {
|
|
await getShopUserApi().then((res) => {
|
|
|
userInfo = res.data
|
|
userInfo = res.data
|
|
@@ -41,7 +41,7 @@ export async function getShopUser(update) {
|
|
|
export async function getUser(update) {
|
|
export async function getUser(update) {
|
|
|
let userInfo = store.getters.getUser
|
|
let userInfo = store.getters.getUser
|
|
|
if (!util.isEmpty(userInfo) && !update) {
|
|
if (!util.isEmpty(userInfo) && !update) {
|
|
|
- return userInfo
|
|
|
|
|
|
|
+ return userInfo
|
|
|
}
|
|
}
|
|
|
await getUserApi().then((res) => {
|
|
await getUserApi().then((res) => {
|
|
|
userInfo = res.data
|
|
userInfo = res.data
|
|
@@ -88,20 +88,45 @@ export async function wxLoginFn(update) {
|
|
|
success: res => {
|
|
success: res => {
|
|
|
uni.setStorageSync('code', res.code)
|
|
uni.setStorageSync('code', res.code)
|
|
|
postWxCode({ code: res.code }).then(subRes => {
|
|
postWxCode({ code: res.code }).then(subRes => {
|
|
|
- if (util.isEmpty(subRes)){
|
|
|
|
|
|
|
+ if (util.isEmpty(subRes)) {
|
|
|
return false
|
|
return false
|
|
|
- }
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// @傅威 明天要发版,我做了个临时解决方案,这块请优化好
|
|
// @傅威 明天要发版,我做了个临时解决方案,这块请优化好
|
|
|
-
|
|
|
|
|
- var pages = getCurrentPages();
|
|
|
|
|
|
|
+
|
|
|
|
|
+ var pages = getCurrentPages();
|
|
|
var page = (pages[pages.length - 1]).route;
|
|
var page = (pages[pages.length - 1]).route;
|
|
|
|
|
|
|
|
- resolve({redirectPage:page,...subRes})
|
|
|
|
|
|
|
+ resolve({ redirectPage: page, ...subRes })
|
|
|
|
|
|
|
|
uni.setStorageSync('token', subRes.data.token)
|
|
uni.setStorageSync('token', subRes.data.token)
|
|
|
uni.setStorageSync('shopId', subRes.data.shopId)
|
|
uni.setStorageSync('shopId', subRes.data.shopId)
|
|
|
store.commit('setLoginInfo', subRes.data.user)
|
|
store.commit('setLoginInfo', subRes.data.user)
|
|
|
|
|
+
|
|
|
|
|
+ if (subRes.data.update == 1) {
|
|
|
|
|
+ const updateManager = wx.getUpdateManager()
|
|
|
|
|
+ console.log('请求完新版本信息的回调')
|
|
|
|
|
+ updateManager.onCheckForUpdate(function (res) {
|
|
|
|
|
+ // 请求完新版本信息的回调
|
|
|
|
|
+ console.log(res.hasUpdate)
|
|
|
|
|
+ })
|
|
|
|
|
+ updateManager.onUpdateReady(function () {
|
|
|
|
|
+ wx.showModal({
|
|
|
|
|
+ title: '更新提示',
|
|
|
|
|
+ content: '新版本已经准备好,是否重启应用?',
|
|
|
|
|
+ success(res) {
|
|
|
|
|
+ if (res.confirm) {
|
|
|
|
|
+ // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
|
|
|
|
|
+ updateManager.applyUpdate()
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+ updateManager.onUpdateFailed(function () {
|
|
|
|
|
+ // 新版本下载失败
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|