Browse Source

feat(login): 优化用户登录流程和缓存处理

- 清除用户类型和底部菜单选中状态
- 修复教练登录后跳转至学生首页的问题
- 优化退出账号功能
-调整 AQTabber 组件初始化逻辑
master
liutong 1 year ago
parent
commit
dc47758f3b
  1. 3
      common/util.js
  2. 4
      components/AQ/AQTabber.vue
  3. 12
      pages/coach/my/set_up.vue
  4. 11
      pages/student/login/login.vue

3
common/util.js

@ -178,6 +178,9 @@ function loginOut() {
//清除用户类型
uni.removeStorageSync('userType')
//底部菜单选中
uni.removeStorageSync('tabBerIndex')
uni.navigateTo({
url: '/pages/student/login/login'
})

4
components/AQ/AQTabber.vue

@ -50,12 +50,10 @@
methods: {
async init() {
uni.setStorageSync('userType', '3')
let userType = uni.getStorageSync('userType')
this.userType = userType
let tabBerIndex = uni.getStorageSync('tabBerIndex')// tabBerIndex=0|1
let tabBerIndex = uni.getStorageSync('tabBerIndex')
if (tabBerIndex) {
this.tabBerIndex = String(tabBerIndex)
} else {

12
pages/coach/my/set_up.vue

@ -8,7 +8,7 @@
<view class="option">清空缓存</view>
<view style="width:90%;margin: 60rpx auto;">
<fui-button background="#29d3b4">退出账号</fui-button>
<fui-button background="#29d3b4" @click="logOut()">退出账号</fui-button>
</view>
</view>
</template>
@ -21,6 +21,16 @@
}
},
methods: {
//退
logOut(){
//
uni.removeStorageSync('userInfo');
//
uni.navigateTo({
url: '/pages/student/login/login'
})
},
privacy_agreement(type){
uni.navigateTo({
url: '/pages/common/privacy_agreement?type='+type

11
pages/student/login/login.vue

@ -71,9 +71,16 @@
memberApi.login(item).then(res => {
if (res.code == 1) {
uni.setStorageSync('token', res.data.token);
uni.setStorageSync('userType', res.data.userType);
let userType = res.data.userType
userType = 1
uni.setStorageSync('userType', userType);
uni.setStorageSync('tabBerIndex', 0);
// uni.setStorageSync('userType', res.data.userType);
let url_path = ''
switch (String(res.data.userType)) {
switch (String(userType)) {
case '1': //
url_path = '/pages/coach/home/index'
break;

Loading…
Cancel
Save