是否登录判别工具,当用户未登录时,让用户去登录,应用于申请代理,我的订单,设置,申请租赁支付

This commit is contained in:
WindowBird 2025-09-01 13:46:43 +08:00
parent 49eeab90e2
commit cd09d15379
3 changed files with 42 additions and 0 deletions

View File

@ -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({

View File

@ -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',
})

22
utils/checkLogin.js Normal file
View File

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