From cd09d15379f08c29e82110ad6de6a09b476668ad Mon Sep 17 00:00:00 2001 From: WindowBird <13870814+windows-bird@user.noreply.gitee.com> Date: Mon, 1 Sep 2025 13:46:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=98=AF=E5=90=A6=E7=99=BB=E5=BD=95=E5=88=A4?= =?UTF-8?q?=E5=88=AB=E5=B7=A5=E5=85=B7=EF=BC=8C=E5=BD=93=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=9C=AA=E7=99=BB=E5=BD=95=E6=97=B6=EF=BC=8C=E8=AE=A9=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=8E=BB=E7=99=BB=E5=BD=95=EF=BC=8C=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E4=BA=8E=E7=94=B3=E8=AF=B7=E4=BB=A3=E7=90=86=EF=BC=8C=E6=88=91?= =?UTF-8?q?=E7=9A=84=E8=AE=A2=E5=8D=95=EF=BC=8C=E8=AE=BE=E7=BD=AE=EF=BC=8C?= =?UTF-8?q?=E7=94=B3=E8=AF=B7=E7=A7=9F=E8=B5=81=E6=94=AF=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/lease/lease.vue | 5 +++++ pages/profile/profile.vue | 15 +++++++++++++++ utils/checkLogin.js | 22 ++++++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 utils/checkLogin.js diff --git a/pages/lease/lease.vue b/pages/lease/lease.vue index 183a6e5..06bede3 100644 --- a/pages/lease/lease.vue +++ b/pages/lease/lease.vue @@ -138,6 +138,7 @@ import { getPeriodPackages as fetchPeriodPackages, createLeaseOrder, } from '@/api/lease/lease.js' +import { checkLoginStatus } from '../../utils/checkLogin' export default { name: 'LeasePage', @@ -318,6 +319,10 @@ export default { this.showDetails = !this.showDetails }, handlePayment() { + if (checkLoginStatus()) { + return + } + // 表单验证 if (!this.formData.name.trim()) { uni.showToast({ diff --git a/pages/profile/profile.vue b/pages/profile/profile.vue index 5e03c81..5679de3 100644 --- a/pages/profile/profile.vue +++ b/pages/profile/profile.vue @@ -125,6 +125,7 @@ import { commonEnum } from '@/enum/commonEnum.js' import { getUserInfo, getUserFinancialData, getAgentCount } from '@/api/user/user.js' import { isAgent } from '@/api/agents.js' +import { checkLoginStatus } from '../../utils/checkLogin' export default { name: 'ProfilePage', @@ -154,6 +155,7 @@ export default { isAgent: false, } }, + onLoad() { this.fetchUserData() }, @@ -275,6 +277,11 @@ export default { // 跳转到设置页面,传递用户信息 goToSettings() { + // 检查登录状态 + if (checkLoginStatus()) { + return + } + console.log('准备跳转到设置页面,当前用户信息:', this.userInfo) // 将当前用户信息存储到本地,供设置页面使用 @@ -296,12 +303,20 @@ export default { url: '/pages/set/set', }) }, + goToAgentApply() { + if (checkLoginStatus()) { + return + } + uni.navigateTo({ url: '/pages/agents/agents', }) }, goToMyOrderList() { + if (checkLoginStatus()) { + return + } uni.navigateTo({ url: '/pages/myOrder/myOrder', }) diff --git a/utils/checkLogin.js b/utils/checkLogin.js new file mode 100644 index 0000000..02d79f5 --- /dev/null +++ b/utils/checkLogin.js @@ -0,0 +1,22 @@ +export const checkLoginStatus = () => { + // 检查登录状态 + const token = uni.getStorageSync('token') + if (!token) { + console.log('用户未登录,显示登录提示') + uni.showModal({ + title: '提示', + content: '请先登录后再进行操作', + confirmText: '去登录', + cancelText: '取消', + success: res => { + if (res.confirm) { + // 用户点击确认,跳转到登录页面 + uni.navigateTo({ + url: '/pages/login/login', + }) + } + }, + }) + return true + } +}