feat(plan): 统一计划书权限检查使用 requireLogin
- 将 checkPlanPermission 改为 requireLogin - 更新导入:usePlanPermission → usePermission - 计划书专属文案:请先登录后制作专属计划书 影响文件: - src/pages/index/index.vue - src/pages/product-center/index.vue - src/pages/product-detail/index.vue - src/pages/search/index.vue Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Showing
4 changed files
with
33 additions
and
23 deletions
| ... | @@ -95,7 +95,10 @@ | ... | @@ -95,7 +95,10 @@ |
| 95 | :tags="product.tags" | 95 | :tags="product.tags" |
| 96 | :class="{ 'mb-[24rpx]': index < hotProducts.length - 1 }" | 96 | :class="{ 'mb-[24rpx]': index < hotProducts.length - 1 }" |
| 97 | @detail="goToProductDetail" | 97 | @detail="goToProductDetail" |
| 98 | - @plan="(productId) => checkPlanPermission(() => openPlanPopup(productId))" | 98 | + @plan="(productId) => requireLogin( |
| 99 | + () => openPlanPopup(productId), | ||
| 100 | + { content: '请先登录后制作专属计划书', confirmText: '立即登录' } | ||
| 101 | + )" | ||
| 99 | /> | 102 | /> |
| 100 | </view> | 103 | </view> |
| 101 | </view> | 104 | </view> |
| ... | @@ -173,15 +176,14 @@ import { listAPI } from '@/api/get_product'; | ... | @@ -173,15 +176,14 @@ import { listAPI } from '@/api/get_product'; |
| 173 | import { weekHotAPI } from '@/api/file'; | 176 | import { weekHotAPI } from '@/api/file'; |
| 174 | import { homeIconAPI } from '@/api/home'; | 177 | import { homeIconAPI } from '@/api/home'; |
| 175 | import { usePlanSubmit } from '@/composables/usePlanSubmit'; | 178 | import { usePlanSubmit } from '@/composables/usePlanSubmit'; |
| 176 | -import { usePlanPermission } from '@/composables/usePlanPermission'; | 179 | +import { usePermission } from '@/composables/usePermission'; |
| 177 | 180 | ||
| 181 | +// 初始化权限检查 | ||
| 182 | +const { requireLogin } = usePermission() | ||
| 178 | 183 | ||
| 179 | // User Store | 184 | // User Store |
| 180 | const userStore = useUserStore(); | 185 | const userStore = useUserStore(); |
| 181 | 186 | ||
| 182 | -// 获取权限检查方法 | ||
| 183 | -const { checkPlanPermission } = usePlanPermission(); | ||
| 184 | - | ||
| 185 | // Header Image Error State | 187 | // Header Image Error State |
| 186 | /** | 188 | /** |
| 187 | * 头部图片加载失败状态 | 189 | * 头部图片加载失败状态 |
| ... | @@ -445,10 +447,10 @@ const handleGridNav = (item) => { | ... | @@ -445,10 +447,10 @@ const handleGridNav = (item) => { |
| 445 | 447 | ||
| 446 | // 特殊处理:计划书页面需要登录权限 | 448 | // 特殊处理:计划书页面需要登录权限 |
| 447 | if (item.route === '/pages/plan/index') { | 449 | if (item.route === '/pages/plan/index') { |
| 448 | - checkPlanPermission(navigate, { | 450 | + requireLogin( |
| 449 | - content: '计划书功能需要登录后才能使用,是否立即登录?', | 451 | + () => navigate(), |
| 450 | - confirmText: '去登录' | 452 | + { content: '请先登录后查看专属计划书', confirmText: '立即登录' } |
| 451 | - }); | 453 | + ); |
| 452 | } else { | 454 | } else { |
| 453 | // 其他页面直接导航 | 455 | // 其他页面直接导航 |
| 454 | navigate(); | 456 | navigate(); | ... | ... |
| ... | @@ -151,7 +151,11 @@ import PlanFormContainer from '@/components/plan/PlanFormContainer.vue' | ... | @@ -151,7 +151,11 @@ import PlanFormContainer from '@/components/plan/PlanFormContainer.vue' |
| 151 | import { listAPI } from '@/api/get_product' | 151 | import { listAPI } from '@/api/get_product' |
| 152 | import { mockProductListAPI } from '@/utils/mockData' | 152 | import { mockProductListAPI } from '@/utils/mockData' |
| 153 | import { usePlanSubmit } from '@/composables/usePlanSubmit' | 153 | import { usePlanSubmit } from '@/composables/usePlanSubmit' |
| 154 | -import { usePlanPermission } from '@/composables/usePlanPermission' | 154 | +import { usePermission } from '@/composables/usePermission' |
| 155 | + | ||
| 156 | +// 初始化权限检查 | ||
| 157 | +const { requireLogin } = usePermission() | ||
| 158 | + | ||
| 155 | import { USE_MOCK_DATA } from '@/config/app' | 159 | import { USE_MOCK_DATA } from '@/config/app' |
| 156 | // ⚠️ MOCK 数据开关 - 统一从 @/config/app 导入 | 160 | // ⚠️ MOCK 数据开关 - 统一从 @/config/app 导入 |
| 157 | 161 | ||
| ... | @@ -160,9 +164,6 @@ const go = useGo() | ... | @@ -160,9 +164,6 @@ const go = useGo() |
| 160 | // User Store | 164 | // User Store |
| 161 | const userStore = useUserStore() | 165 | const userStore = useUserStore() |
| 162 | 166 | ||
| 163 | -// 获取权限检查方法 | ||
| 164 | -const { checkPlanPermission } = usePlanPermission() | ||
| 165 | - | ||
| 166 | /** | 167 | /** |
| 167 | * 当前列表数据 | 168 | * 当前列表数据 |
| 168 | * @type {Ref<Array<any>>} | 169 | * @type {Ref<Array<any>>} |
| ... | @@ -502,11 +503,14 @@ const { handleClick: handleProductClick } = useListItemClick({ | ... | @@ -502,11 +503,14 @@ const { handleClick: handleProductClick } = useListItemClick({ |
| 502 | */ | 503 | */ |
| 503 | const openPlanPopup = (product) => { | 504 | const openPlanPopup = (product) => { |
| 504 | console.log('[Product Center] 点击制作计划书,当前登录状态:', userStore.isLoggedIn) | 505 | console.log('[Product Center] 点击制作计划书,当前登录状态:', userStore.isLoggedIn) |
| 505 | - checkPlanPermission(() => { | 506 | + requireLogin( |
| 507 | + () => { | ||
| 506 | console.log('[Product Center] 权限检查通过,打开计划书弹窗') | 508 | console.log('[Product Center] 权限检查通过,打开计划书弹窗') |
| 507 | selectedProduct.value = product | 509 | selectedProduct.value = product |
| 508 | showPlanPopup.value = true | 510 | showPlanPopup.value = true |
| 509 | - }) | 511 | + }, |
| 512 | + { content: '请先登录后制作专属计划书', confirmText: '立即登录' } | ||
| 513 | + ) | ||
| 510 | } | 514 | } |
| 511 | 515 | ||
| 512 | // 使用 composable 统一处理计划书提交后逻辑 | 516 | // 使用 composable 统一处理计划书提交后逻辑 | ... | ... |
| ... | @@ -104,7 +104,10 @@ | ... | @@ -104,7 +104,10 @@ |
| 104 | <nut-button | 104 | <nut-button |
| 105 | color="#2563EB" | 105 | color="#2563EB" |
| 106 | class="!w-full !h-[88rpx] !rounded-[16rpx] !text-[28rpx] !font-bold" | 106 | class="!w-full !h-[88rpx] !rounded-[16rpx] !text-[28rpx] !font-bold" |
| 107 | - @tap="() => checkPlanPermission(() => openPlanPopup())" | 107 | + @tap="() => requireLogin( |
| 108 | + () => openPlanPopup(), | ||
| 109 | + { content: '请先登录后制作专属计划书', confirmText: '立即登录' } | ||
| 110 | + )" | ||
| 108 | > | 111 | > |
| 109 | 制作计划书 | 112 | 制作计划书 |
| 110 | </nut-button> | 113 | </nut-button> |
| ... | @@ -134,7 +137,10 @@ import Taro, { useLoad } from '@tarojs/taro' | ... | @@ -134,7 +137,10 @@ import Taro, { useLoad } from '@tarojs/taro' |
| 134 | import { getDocumentIcon, getDocumentLabel } from '@/utils/documentIcons' | 137 | import { getDocumentIcon, getDocumentLabel } from '@/utils/documentIcons' |
| 135 | import { detailAPI } from '@/api/get_product' | 138 | import { detailAPI } from '@/api/get_product' |
| 136 | import { usePlanSubmit } from '@/composables/usePlanSubmit' | 139 | import { usePlanSubmit } from '@/composables/usePlanSubmit' |
| 137 | -import { usePlanPermission } from '@/composables/usePlanPermission' | 140 | +import { usePermission } from '@/composables/usePermission' |
| 141 | + | ||
| 142 | +// 初始化权限检查 | ||
| 143 | +const { requireLogin } = usePermission() | ||
| 138 | 144 | ||
| 139 | const { viewFile } = useFileOperation() | 145 | const { viewFile } = useFileOperation() |
| 140 | 146 | ||
| ... | @@ -214,7 +220,6 @@ const viewDocument = (doc) => { | ... | @@ -214,7 +220,6 @@ const viewDocument = (doc) => { |
| 214 | * | 220 | * |
| 215 | * @description 检查登录权限后,打开当前产品的计划书表单 | 221 | * @description 检查登录权限后,打开当前产品的计划书表单 |
| 216 | */ | 222 | */ |
| 217 | -const { checkPlanPermission } = usePlanPermission() | ||
| 218 | 223 | ||
| 219 | const openPlanPopup = () => { | 224 | const openPlanPopup = () => { |
| 220 | showPlanPopup.value = true | 225 | showPlanPopup.value = true | ... | ... |
| ... | @@ -74,7 +74,10 @@ | ... | @@ -74,7 +74,10 @@ |
| 74 | :tags="item.tags || []" | 74 | :tags="item.tags || []" |
| 75 | class="search-result-item" | 75 | class="search-result-item" |
| 76 | @detail="goToProductDetail" | 76 | @detail="goToProductDetail" |
| 77 | - @plan="(productId) => checkPlanPermission(() => openPlanPopup(productId))" | 77 | + @plan="(productId) => requireLogin( |
| 78 | + () => openPlanPopup(productId), | ||
| 79 | + { content: '请先登录后制作专属计划书', confirmText: '立即登录' } | ||
| 80 | + )" | ||
| 78 | /> | 81 | /> |
| 79 | 82 | ||
| 80 | <!-- File Results --> | 83 | <!-- File Results --> |
| ... | @@ -140,7 +143,6 @@ import { mockSearchAPI } from '@/utils/mockData' | ... | @@ -140,7 +143,6 @@ import { mockSearchAPI } from '@/utils/mockData' |
| 140 | import { USE_MOCK_DATA } from '@/config/app' | 143 | import { USE_MOCK_DATA } from '@/config/app' |
| 141 | import { usePlanSubmit } from '@/composables/usePlanSubmit' | 144 | import { usePlanSubmit } from '@/composables/usePlanSubmit' |
| 142 | import { usePermission } from '@/composables/usePermission' | 145 | import { usePermission } from '@/composables/usePermission' |
| 143 | -import { usePlanPermission } from '@/composables/usePlanPermission' | ||
| 144 | 146 | ||
| 145 | // ⚠️ MOCK 数据开关 - 统一从 @/config/app 导入 | 147 | // ⚠️ MOCK 数据开关 - 统一从 @/config/app 导入 |
| 146 | 148 | ||
| ... | @@ -165,9 +167,6 @@ onMounted(() => { | ... | @@ -165,9 +167,6 @@ onMounted(() => { |
| 165 | ) | 167 | ) |
| 166 | }) | 168 | }) |
| 167 | 169 | ||
| 168 | -// 获取权限检查方法 | ||
| 169 | -const { checkPlanPermission } = usePlanPermission() | ||
| 170 | - | ||
| 171 | /** | 170 | /** |
| 172 | * 搜索页面状态管理 | 171 | * 搜索页面状态管理 |
| 173 | * @description 支持双类型(产品/资料)搜索,自动切换分类 | 172 | * @description 支持双类型(产品/资料)搜索,自动切换分类 | ... | ... |
-
Please register or login to post a comment