Browse Source

fix: 修复登录逻辑并更新环境配置

- 修改App.vue在onLaunch时自动登录
- 将默认环境从dev改为prod并添加本地环境配置
- 简化http.js中token失效处理,直接跳转登录
- 移除setting.vue中的退出登录按钮
- 注释store.js中登录后的导航逻辑
master
前端-胡立永 1 month ago
parent
commit
e72ff07346
5 changed files with 21 additions and 19 deletions
  1. +1
    -0
      App.vue
  2. +1
    -3
      api/http.js
  3. +4
    -1
      config.js
  4. +1
    -1
      pages_order/mine/setting.vue
  5. +14
    -14
      store/store.js

+ 1
- 0
App.vue View File

@ -1,6 +1,7 @@
<script>
export default {
onLaunch: function() {
this.$store.commit('login')
},
onShow: function() {
this.$store.commit('initConfig')


+ 1
- 3
api/http.js View File

@ -36,9 +36,7 @@ function http(uri, data, callback, method = 'GET', showLoading, title) {
res.data.message == '操作失败,token非法无效!' ||
res.data.message == '操作失败,用户不存在!'){
uni.removeStorageSync('token')
store.commit('logout')
console.error('登录过期');
utils.toLogin()
store.commit('login')
}
if(res.statusCode == 200 && res.data.code != 200


+ 4
- 1
config.js View File

@ -8,11 +8,14 @@ import uvUI from '@/uni_modules/uv-ui-tools'
Vue.use(uvUI);
// 当前环境
const type = 'dev'
const type = 'prod'
// 环境配置
const config = {
local : {
baseUrl : 'http://127.0.0.1:8002/lbx-api',
},
dev : {
baseUrl : 'http://h5.xzaiyp.top/lbx-api',
},


+ 1
- 1
pages_order/mine/setting.vue View File

@ -8,7 +8,7 @@
<uv-icon name="arrow-right" color="#000000" size="28rpx"></uv-icon>
</view>
<button v-if="isLogined" plain class="btn-logout" @click="onLogout">退出登录</button>
<!-- <button v-if="isLogined" plain class="btn-logout" @click="onLogout">退出登录</button> -->
</view>
<configPopup ref="popup"></configPopup>


+ 14
- 14
store/store.js View File

@ -83,20 +83,20 @@ const store = new Vuex.Store({
Vue.set(state, 'userInfo', res.result.userInfo)
uni.setStorageSync('token', res.result.token)
if(!state.userInfo.nickName || !state.userInfo.headImage){
uni.navigateTo({
url: '/pages_order/auth/wxUserInfo?mode=add'
})
}else{
uni.navigateBack({
delta: 1,
fail: () => {
uni.reLaunch({
url: '/pages/index/index'
})
}
});
}
// if(!state.userInfo.nickName || !state.userInfo.headImage){
// uni.navigateTo({
// url: '/pages_order/auth/wxUserInfo?mode=add'
// })
// }else{
// uni.navigateBack({
// delta: 1,
// fail: () => {
// uni.reLaunch({
// url: '/pages/index/index'
// })
// }
// });
// }
})
}
})


Loading…
Cancel
Save