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] =?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,