Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
jgdl
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
hookehuyr
2025-07-29 14:18:50 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d225a225a32c772f9ffa08affa4518dd4a6fac52
d225a225
1 parent
d75ebfff
refactor(权限): 移除页面权限检查并优化权限提示交互
重构权限检查逻辑,移除多个页面的硬编码权限验证 在商品详情页添加更友好的权限提示弹窗,引导用户完善信息
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
73 additions
and
25 deletions
src/components/TabBar.vue
src/pages/productDetail/index.vue
src/pages/profile/index.vue
src/components/TabBar.vue
View file @
d225a22
...
...
@@ -102,18 +102,18 @@ const getCurrentPage = () => {
*/
const navigateTo = async (url) => {
// 定义需要权限验证的页面(移除个人中心和sell页面的权限检查)
const permissionPages = {
'/pages/messages/index': PERMISSION_TYPES.MESSAGE
}
//
const permissionPages = {
//
'/pages/messages/index': PERMISSION_TYPES.MESSAGE
//
}
// 检查是否需要权限验证
const permissionType = permissionPages[url]
if (permissionType) {
const hasPermission = await checkPermission(permissionType)
if (!hasPermission) {
return
}
}
//
const permissionType = permissionPages[url]
//
if (permissionType) {
//
const hasPermission = await checkPermission(permissionType)
//
if (!hasPermission) {
//
return
//
}
//
}
Taro.reLaunch({
url
...
...
src/pages/productDetail/index.vue
View file @
d225a22
<!--
* @Date: 2022-09-19 14:11:06
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-07-2
2 16:05:59
* @LastEditTime: 2025-07-2
9 13:45:56
* @FilePath: /jgdl/src/pages/productDetail/index.vue
* @Description: 商品详情页
-->
...
...
@@ -354,8 +354,32 @@ const copyWechat = () => {
*/
const conversation_id = ref('')
const handleContactSeller = async () => {
const hasPermission = await checkPermission(PERMISSION_TYPES.CONTACT_SELLER)
if (hasPermission) {
const hasPermission = await checkPermission(PERMISSION_TYPES.CONTACT_SELLER, {
showToast: false,
autoRedirect: false
})
// 如果没有权限,显示确认弹窗
if (!hasPermission) {
Taro.showModal({
title: '提示',
content: '联系卖家需要先完善个人信息',
cancelText: '关闭',
confirmText: '前往完善',
success: (res) => {
if (res.confirm) {
// 用户点击前往完善,跳转到注册页面
Taro.navigateTo({
url: '/pages/register/index'
})
} else {
// 用户点击关闭,返回上一页
// Taro.navigateBack()
}
}
})
return
} else {
// 获取聊天室ID
const { code, data } = await getChatConversationAPI({
buyer_id: userStore.userInfo.id,
...
...
@@ -414,8 +438,32 @@ const sendMessageToSeller = async () => {
* 购买商品
*/
const handlePurchase = async () => {
const hasPermission = await checkPermission(PERMISSION_TYPES.BUY_CAR)
if (hasPermission) {
const hasPermission = await checkPermission(PERMISSION_TYPES.BUY_CAR, {
showToast: false,
autoRedirect: false
})
// 如果没有权限,显示确认弹窗
if (!hasPermission) {
Taro.showModal({
title: '提示',
content: '购买车辆需要先完善个人信息',
cancelText: '关闭',
confirmText: '前往完善',
success: (res) => {
if (res.confirm) {
// 用户点击前往完善,跳转到注册页面
Taro.navigateTo({
url: '/pages/register/index'
})
} else {
// 用户点击关闭,返回上一页
// Taro.navigateBack()
}
}
})
return
} else {
onPay({
id: product.value.id,
remain_time: 1800, // 30分钟
...
...
src/pages/profile/index.vue
View file @
d225a22
...
...
@@ -83,7 +83,7 @@ import { Heart, Clock, Notice, Cart, Message, Tips, Right, StarN } from '@nutui/
import Taro, { useDidShow } from '@tarojs/taro'
import TabBar from '@/components/TabBar.vue'
import { useUserStore } from '@/stores/user'
import { checkPermission, PERMISSION_TYPES } from '@/utils/permission'
//
import { checkPermission, PERMISSION_TYPES } from '@/utils/permission'
// 默认头像
const defaultAvatar = 'https://cdn.ipadbiz.cn/mlaj/images/icon_1.jpeg'
...
...
@@ -111,36 +111,36 @@ const onEditProfile = () => {
* 我的关注
*/
const onMyFavorites = async () => {
const hasPermission = await checkPermission(PERMISSION_TYPES.BASIC_INFO)
if (hasPermission) {
// const hasPermission = await checkPermission(PERMISSION_TYPES.BASIC_INFO)
// if (hasPermission) {
// }
Taro.navigateTo({
url: '/pages/myFavorites/index'
})
}
}
/**
* 订单管理
*/
const onOrderManagement = async () => {
const hasPermission = await checkPermission(PERMISSION_TYPES.ORDER_MANAGEMENT)
if (hasPermission) {
// const hasPermission = await checkPermission(PERMISSION_TYPES.ORDER_MANAGEMENT)
// if (hasPermission) {
// }
Taro.navigateTo({
url: '/pages/myOrders/index'
})
}
}
/**
* 我的消息
*/
const onMessages = async () => {
const hasPermission = await checkPermission(PERMISSION_TYPES.MESSAGE)
if (hasPermission) {
// const hasPermission = await checkPermission(PERMISSION_TYPES.MESSAGE)
// if (hasPermission) {
// }
Taro.navigateTo({
url: '/pages/messages/index'
})
}
}
/**
...
...
Please
register
or
login
to post a comment