是否登录判别工具,当用户未登录时,让用户去登录,应用于申请代理,我的订单,设置,申请租赁支付
This commit is contained in:
parent
49eeab90e2
commit
cd09d15379
|
|
@ -138,6 +138,7 @@ import {
|
||||||
getPeriodPackages as fetchPeriodPackages,
|
getPeriodPackages as fetchPeriodPackages,
|
||||||
createLeaseOrder,
|
createLeaseOrder,
|
||||||
} from '@/api/lease/lease.js'
|
} from '@/api/lease/lease.js'
|
||||||
|
import { checkLoginStatus } from '../../utils/checkLogin'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'LeasePage',
|
name: 'LeasePage',
|
||||||
|
|
@ -318,6 +319,10 @@ export default {
|
||||||
this.showDetails = !this.showDetails
|
this.showDetails = !this.showDetails
|
||||||
},
|
},
|
||||||
handlePayment() {
|
handlePayment() {
|
||||||
|
if (checkLoginStatus()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// 表单验证
|
// 表单验证
|
||||||
if (!this.formData.name.trim()) {
|
if (!this.formData.name.trim()) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
|
|
|
||||||
|
|
@ -125,6 +125,7 @@
|
||||||
import { commonEnum } from '@/enum/commonEnum.js'
|
import { commonEnum } from '@/enum/commonEnum.js'
|
||||||
import { getUserInfo, getUserFinancialData, getAgentCount } from '@/api/user/user.js'
|
import { getUserInfo, getUserFinancialData, getAgentCount } from '@/api/user/user.js'
|
||||||
import { isAgent } from '@/api/agents.js'
|
import { isAgent } from '@/api/agents.js'
|
||||||
|
import { checkLoginStatus } from '../../utils/checkLogin'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'ProfilePage',
|
name: 'ProfilePage',
|
||||||
|
|
@ -154,6 +155,7 @@ export default {
|
||||||
isAgent: false,
|
isAgent: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onLoad() {
|
onLoad() {
|
||||||
this.fetchUserData()
|
this.fetchUserData()
|
||||||
},
|
},
|
||||||
|
|
@ -275,6 +277,11 @@ export default {
|
||||||
|
|
||||||
// 跳转到设置页面,传递用户信息
|
// 跳转到设置页面,传递用户信息
|
||||||
goToSettings() {
|
goToSettings() {
|
||||||
|
// 检查登录状态
|
||||||
|
if (checkLoginStatus()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
console.log('准备跳转到设置页面,当前用户信息:', this.userInfo)
|
console.log('准备跳转到设置页面,当前用户信息:', this.userInfo)
|
||||||
|
|
||||||
// 将当前用户信息存储到本地,供设置页面使用
|
// 将当前用户信息存储到本地,供设置页面使用
|
||||||
|
|
@ -296,12 +303,20 @@ export default {
|
||||||
url: '/pages/set/set',
|
url: '/pages/set/set',
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
goToAgentApply() {
|
goToAgentApply() {
|
||||||
|
if (checkLoginStatus()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/pages/agents/agents',
|
url: '/pages/agents/agents',
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
goToMyOrderList() {
|
goToMyOrderList() {
|
||||||
|
if (checkLoginStatus()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/pages/myOrder/myOrder',
|
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