From cc9887e4ec80cf93ed19aede5147ed9245522607 Mon Sep 17 00:00:00 2001 From: liutong <836164388@qq.com> Date: Thu, 20 Mar 2025 18:30:26 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat(common):=20=E6=B7=BB=E5=8A=A0=E8=B7=B3?= =?UTF-8?q?=E8=BD=AC=E9=A6=96=E9=A1=B5=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 openHomeView函数,用于跳转到不同用户类型的首页 - 根据用户类型缓存,判断跳转路径 - 支持教练、销售、学员三种用户类型的首页跳转 - 添加错误处理,当用户类型错误时显示提示信息并跳转到登录页面 --- common/util.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/common/util.js b/common/util.js index cc67c08..ff6531a 100644 --- a/common/util.js +++ b/common/util.js @@ -141,7 +141,37 @@ function getDefaultImage() { } +//跳转首页 +function openHomeView() { + //获取用户类型缓存 + let userType = uni.getStorageSync('userType') + let url_path = '' + switch (String(userType)) { + case '1': //教练 + url_path = '/pages/coach/home/index' + break; + case '2': //销售 + url_path = '/pages/market/index/index' + break; + case '3': //学员 + url_path = '/pages/student/index/index' + break; + default: + uni.showToast({ + title: '用户类型错误', + icon: 'none' + }) + url_path = '/pages/student/login/login' + return; + } + uni.navigateTo({ + url: url_path + }) +} + + module.exports = { + openHomeView, formatTime, formatDateTime, formatLocation, From 538ea229c327375b94a73a10ffd34562cb6e9510 Mon Sep 17 00:00:00 2001 From: liutong <836164388@qq.com> Date: Thu, 20 Mar 2025 18:36:24 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat(util):=20=E6=B7=BB=E5=8A=A0=E9=80=80?= =?UTF-8?q?=E5=87=BA=E7=99=BB=E5=BD=95=E5=8A=9F=E8=83=BD=E5=B9=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E5=8F=8D=E9=A6=88=E6=8F=90=E4=BA=A4=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 util.js 中添加 logout 函数,用于清除用户信息并跳转到登录页 - 在 feedback.vue 中增加提交成功后返回首页的功能 --- common/util.js | 15 +++++++++++++++ pages/common/feedback.vue | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/common/util.js b/common/util.js index ff6531a..b5c59e3 100644 --- a/common/util.js +++ b/common/util.js @@ -169,8 +169,23 @@ function openHomeView() { }) } +//退出登陆 +function logout() { + //清除token + uni.removeStorageSync('token') + //清除用户信息 + uni.removeStorageSync('userInfo') + //清除用户类型 + uni.removeStorageSync('userType') + + uni.navigateTo({ + url: '/pages/student/login/login' + }) +} + module.exports = { + logout, openHomeView, formatTime, formatDateTime, diff --git a/pages/common/feedback.vue b/pages/common/feedback.vue index 03a39e8..7b07849 100644 --- a/pages/common/feedback.vue +++ b/pages/common/feedback.vue @@ -92,6 +92,10 @@ title:'提交成功', icon:'none' }) + //延迟1s执行 + setTimeout(() => { + this.$util.openHomeView(); + }, 1000); } },