是否登录判别工具,当用户未登录时,让用户去登录,应用于申请代理,我的订单,设置,申请租赁支付
This commit is contained in:
parent
49eeab90e2
commit
cd09d15379
|
|
@ -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({
|
||||
|
|
|
|||
|
|
@ -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
22
utils/checkLogin.js
Normal 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
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user