diff --git a/App.vue b/App.vue index 1f54ccc..82f80f9 100644 --- a/App.vue +++ b/App.vue @@ -9,6 +9,9 @@ console.log('App Launch') store.dispatch('fetchConfigList') store.dispatch('getUserInfo') + if(uni.getStorageSync('token')){ + store.dispatch("login") + } }, onShow: function() { console.log('App Show') diff --git a/pages/login/index.vue b/pages/login/index.vue index ad0d663..9a28d62 100644 --- a/pages/login/index.vue +++ b/pages/login/index.vue @@ -82,7 +82,7 @@ icon:'none' }) } - store.dispatch("login") + store.dispatch("login", true) } diff --git a/pages/myOrdersManage/components/timelineService.vue b/pages/myOrdersManage/components/timelineService.vue index 49a867f..dcf4607 100644 --- a/pages/myOrdersManage/components/timelineService.vue +++ b/pages/myOrdersManage/components/timelineService.vue @@ -193,15 +193,15 @@ today.setHours(0, 0, 0, 0); serviceDate.setHours(0, 0, 0, 0); - if (serviceDate > today) { - // 服务日期未到,显示提示 - uni.showToast({ - title: '服务日期未到,无法打卡', - icon: 'none', - duration: 2000 - }); - return; - } + // if (serviceDate > today) { + // // 服务日期未到,显示提示 + // uni.showToast({ + // title: '服务日期未到,无法打卡', + // icon: 'none', + // duration: 2000 + // }); + // return; + // } // 根据订单状态确定跳转路径 const paths = [ diff --git a/store/modules/user.js b/store/modules/user.js index 5b1f890..0e8a1c0 100644 --- a/store/modules/user.js +++ b/store/modules/user.js @@ -42,13 +42,25 @@ const user = { }, actions: { - login(context) { + login(context, loading) { + + let success = function(){} + let error = function(){} + let promise = new Promise((s, e) => { + success = s + error = e + }) + uni.login({ success: (res) => { const code = res.code - uni.showLoading({ - mask : true - }); + + if(loading){ + uni.showLoading({ + mask : true + }); + } + wxLogin({ code }).then(res => { @@ -59,7 +71,7 @@ const user = { context.commit('setUserInfo', res.data.userInfo); setIsLogin(true); uni.hideLoading(); - + success(res) if (!res.data.userInfo.userName || !res.data.userInfo.userImage || ! res.data.userInfo.userTelephone) { uni.navigateTo({ @@ -72,6 +84,8 @@ const user = { }) } }) + + return promise }, // 已登录的情况下调用接口获取用户信息,保证用户信息的实时更新 diff --git a/utils/request.js b/utils/request.js index 985bc50..57e4e1e 100644 --- a/utils/request.js +++ b/utils/request.js @@ -44,7 +44,7 @@ const request = config => { if (code === 401) { showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?').then(res => { if (res.confirm) { - store.dispatch('LogOut').then(res => { + store.dispatch('login').then(res => { uni.reLaunch({ url: '/pages/index' })