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 + } +}