feat(活动页面): 添加活动状态检查并更新分享配置
- 在ShareButton组件中移除默认的活动banner图片,仅使用shareConfig中的imageUrl - 在map.js中添加获取活动状态和保存海报背景的API接口 - 在ActivitiesCover页面中添加活动状态检查逻辑,根据活动状态禁用按钮并更新分享配置 - 更新分享标题和路径配置,移除硬编码的分享标题
Showing
3 changed files
with
80 additions
and
7 deletions
| 1 | /* | 1 | /* |
| 2 | * @Date: 2025-09-04 17:23:17 | 2 | * @Date: 2025-09-04 17:23:17 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-09-17 11:35:23 | 4 | + * @LastEditTime: 2025-09-17 14:36:35 |
| 5 | * @FilePath: /lls_program/src/api/map.js | 5 | * @FilePath: /lls_program/src/api/map.js |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | */ | 7 | */ |
| ... | @@ -10,6 +10,8 @@ import { fn, fetch } from './fn'; | ... | @@ -10,6 +10,8 @@ import { fn, fetch } from './fn'; |
| 10 | const Api = { | 10 | const Api = { |
| 11 | GET_MAP_URL: '/srv/?a=map&t=get_map_url', | 11 | GET_MAP_URL: '/srv/?a=map&t=get_map_url', |
| 12 | GET_POSTER_DETAIL: '/srv/?a=map&t=poster', | 12 | GET_POSTER_DETAIL: '/srv/?a=map&t=poster', |
| 13 | + GET_ACTIVITY_STATUS: '/srv/?a=map&t=get_map_url', | ||
| 14 | + SAVE_POSTER_BACKGROUND: '/srv/?a=map&t=save_poster_background', | ||
| 13 | } | 15 | } |
| 14 | 16 | ||
| 15 | /** | 17 | /** |
| ... | @@ -33,6 +35,7 @@ export const getMapUrlAPI = (params) => fn(fetch.get(Api.GET_MAP_URL, params)); | ... | @@ -33,6 +35,7 @@ export const getMapUrlAPI = (params) => fn(fetch.get(Api.GET_MAP_URL, params)); |
| 33 | * @returns {Array} response.data.details - 关卡列表 | 35 | * @returns {Array} response.data.details - 关卡列表 |
| 34 | * @returns {Object} response.data.details[].id - 关卡ID | 36 | * @returns {Object} response.data.details[].id - 关卡ID |
| 35 | * @returns {string} response.data.details[].name - 关卡名称 | 37 | * @returns {string} response.data.details[].name - 关卡名称 |
| 38 | + * @returns {string} response.data.details[].is_checked - 关卡是否已完成, 1 已完成, 0 未完成 | ||
| 36 | * @returns {string} response.data.details[].background_url - 关卡背景图URL | 39 | * @returns {string} response.data.details[].background_url - 关卡背景图URL |
| 37 | * @returns {string} response.data.details[].main_slogan - 关卡主 slogan | 40 | * @returns {string} response.data.details[].main_slogan - 关卡主 slogan |
| 38 | * @returns {string} response.data.details[].sub_slogan - 关卡子 slogan | 41 | * @returns {string} response.data.details[].sub_slogan - 关卡子 slogan |
| ... | @@ -44,3 +47,24 @@ export const getMapUrlAPI = (params) => fn(fetch.get(Api.GET_MAP_URL, params)); | ... | @@ -44,3 +47,24 @@ export const getMapUrlAPI = (params) => fn(fetch.get(Api.GET_MAP_URL, params)); |
| 44 | * @returns {string} response.data.qrcode_url - 小程序码 | 47 | * @returns {string} response.data.qrcode_url - 小程序码 |
| 45 | */ | 48 | */ |
| 46 | export const getPosterDetailAPI = (params) => fn(fetch.get(Api.GET_POSTER_DETAIL, params)); | 49 | export const getPosterDetailAPI = (params) => fn(fetch.get(Api.GET_POSTER_DETAIL, params)); |
| 50 | + | ||
| 51 | +/** | ||
| 52 | + * @description: 获取活动状态 | ||
| 53 | + * @param {Object} params - 请求参数 | ||
| 54 | + * @returns {number} response.code - 响应状态码 | ||
| 55 | + * @returns {string} response.msg - 响应消息 | ||
| 56 | + * @returns {Object} response.data - 响应数据 | ||
| 57 | + * @returns {boolean} response.data.is_ended - 活动是否已经结束, 1 已结束, 0 未结束 | ||
| 58 | + */ | ||
| 59 | +export const getActivityStatusAPI = (params) => fn(fetch.get(Api.GET_ACTIVITY_STATUS, params)); | ||
| 60 | + | ||
| 61 | +/** | ||
| 62 | + * @description: 保存海报背景 | ||
| 63 | + * @param {Object} params - 请求参数 | ||
| 64 | + * @param {string} params.detail_id - 海报详情ID | ||
| 65 | + * @param {string} params.poster_background_url - 海报背景图URL | ||
| 66 | + * @returns {number} response.code - 响应状态码 | ||
| 67 | + * @returns {string} response.msg - 响应消息 | ||
| 68 | + * @returns {Object} response.data - 响应数据 | ||
| 69 | + */ | ||
| 70 | +export const savePosterBackgroundAPI = (params) => fn(fetch.post(Api.SAVE_POSTER_BACKGROUND, params)); | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2025-09-03 14:34:58 | 2 | * @Date: 2025-09-03 14:34:58 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-09-15 12:52:03 | 4 | + * @LastEditTime: 2025-09-17 17:35:27 |
| 5 | * @FilePath: /lls_program/src/components/ShareButton/index.vue | 5 | * @FilePath: /lls_program/src/components/ShareButton/index.vue |
| 6 | * @Description: 分享按钮组件 - 点击后弹出分享选项 | 6 | * @Description: 分享按钮组件 - 点击后弹出分享选项 |
| 7 | --> | 7 | --> |
| ... | @@ -62,7 +62,7 @@ const onShareAppMessage = (res) => { | ... | @@ -62,7 +62,7 @@ const onShareAppMessage = (res) => { |
| 62 | const shareData = { | 62 | const shareData = { |
| 63 | title: props.shareConfig.title || '精彩活动等你参与', | 63 | title: props.shareConfig.title || '精彩活动等你参与', |
| 64 | path: addShareFlag(props.shareConfig.path || '/pages/ActivitiesCover/index'), | 64 | path: addShareFlag(props.shareConfig.path || '/pages/ActivitiesCover/index'), |
| 65 | - imageUrl: props.shareConfig.imageUrl || props.activityData.banner || '' | 65 | + imageUrl: props.shareConfig.imageUrl || '' |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | // 触发分享事件 | 68 | // 触发分享事件 | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2022-09-19 14:11:06 | 2 | * @Date: 2022-09-19 14:11:06 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-09-16 20:11:36 | 4 | + * @LastEditTime: 2025-09-17 17:34:36 |
| 5 | * @FilePath: /lls_program/src/pages/ActivitiesCover/index.vue | 5 | * @FilePath: /lls_program/src/pages/ActivitiesCover/index.vue |
| 6 | * @Description: 活动海报页面 - 展示活动信息并处理定位授权 | 6 | * @Description: 活动海报页面 - 展示活动信息并处理定位授权 |
| 7 | --> | 7 | --> |
| ... | @@ -17,6 +17,7 @@ | ... | @@ -17,6 +17,7 @@ |
| 17 | <!-- 分享按钮组件 --> | 17 | <!-- 分享按钮组件 --> |
| 18 | <ShareButton | 18 | <ShareButton |
| 19 | :activity-data="activityData" | 19 | :activity-data="activityData" |
| 20 | + :share-config="shareConfig" | ||
| 20 | @share-activity="onShareActivity" | 21 | @share-activity="onShareActivity" |
| 21 | @share-poster="onSharePoster" | 22 | @share-poster="onSharePoster" |
| 22 | class="share-button-wrapper" | 23 | class="share-button-wrapper" |
| ... | @@ -46,8 +47,9 @@ | ... | @@ -46,8 +47,9 @@ |
| 46 | type="primary" | 47 | type="primary" |
| 47 | size="large" | 48 | size="large" |
| 48 | class="join-button" | 49 | class="join-button" |
| 49 | - :color="THEME_COLORS.PRIMARY" | 50 | + :color="activityStatus.is_ended ? '#cccccc' : THEME_COLORS.PRIMARY" |
| 50 | - :loading="isJoining" | 51 | + :loading="isJoining || activityStatus.loading" |
| 52 | + :disabled="activityStatus.is_ended" | ||
| 51 | @click="checkFamilyStatusAndJoinActivity" | 53 | @click="checkFamilyStatusAndJoinActivity" |
| 52 | > | 54 | > |
| 53 | {{ getButtonText() }} | 55 | {{ getButtonText() }} |
| ... | @@ -138,6 +140,7 @@ import PosterBuilder from '../../components/PosterBuilder/index.vue' | ... | @@ -138,6 +140,7 @@ import PosterBuilder from '../../components/PosterBuilder/index.vue' |
| 138 | import ShareButton from '../../components/ShareButton/index.vue' | 140 | import ShareButton from '../../components/ShareButton/index.vue' |
| 139 | // 接口信息 | 141 | // 接口信息 |
| 140 | import { getMyFamiliesAPI } from '@/api/family' | 142 | import { getMyFamiliesAPI } from '@/api/family' |
| 143 | +import { getActivityStatusAPI } from '@/api/map' | ||
| 141 | import { handleSharePageAuth, addShareFlag } from '@/utils/authRedirect' | 144 | import { handleSharePageAuth, addShareFlag } from '@/utils/authRedirect' |
| 142 | // 导入主题颜色 | 145 | // 导入主题颜色 |
| 143 | import { THEME_COLORS } from '@/utils/config'; | 146 | import { THEME_COLORS } from '@/utils/config'; |
| ... | @@ -157,6 +160,12 @@ const userLocation = ref({ lng: null, lat: null }) // 用户位置信息 | ... | @@ -157,6 +160,12 @@ const userLocation = ref({ lng: null, lat: null }) // 用户位置信息 |
| 157 | const hasJoinedFamily = ref(false); | 160 | const hasJoinedFamily = ref(false); |
| 158 | const showLocationPrompt = ref(false) // 是否显示定位权限提示 | 161 | const showLocationPrompt = ref(false) // 是否显示定位权限提示 |
| 159 | 162 | ||
| 163 | +// 活动状态相关 | ||
| 164 | +const activityStatus = ref({ | ||
| 165 | + is_ended: false, // 活动是否已结束 | ||
| 166 | + loading: false // 是否正在加载活动状态 | ||
| 167 | +}) | ||
| 168 | + | ||
| 160 | // Dialog 相关状态 | 169 | // Dialog 相关状态 |
| 161 | const showLocationDialog = ref(false) // 是否显示位置权限申请弹窗 | 170 | const showLocationDialog = ref(false) // 是否显示位置权限申请弹窗 |
| 162 | const pendingLocationCallback = ref(null) // 待执行的位置获取回调 | 171 | const pendingLocationCallback = ref(null) // 待执行的位置获取回调 |
| ... | @@ -202,6 +211,13 @@ const activityData = ref({ | ... | @@ -202,6 +211,13 @@ const activityData = ref({ |
| 202 | ] | 211 | ] |
| 203 | }) | 212 | }) |
| 204 | 213 | ||
| 214 | +// 分享配置 | ||
| 215 | +const shareConfig = ref({ | ||
| 216 | + title: '主题路线打卡活动等你参与', | ||
| 217 | + path: '/pages/ActivitiesCover/index', | ||
| 218 | + imageUrl: '', | ||
| 219 | +}) | ||
| 220 | + | ||
| 205 | /** | 221 | /** |
| 206 | * 检查定位授权状态 | 222 | * 检查定位授权状态 |
| 207 | */ | 223 | */ |
| ... | @@ -306,6 +322,11 @@ const getUserLocation = async (skipAuthCheck = false) => { | ... | @@ -306,6 +322,11 @@ const getUserLocation = async (skipAuthCheck = false) => { |
| 306 | * 获取按钮显示文本 | 322 | * 获取按钮显示文本 |
| 307 | */ | 323 | */ |
| 308 | const getButtonText = () => { | 324 | const getButtonText = () => { |
| 325 | + // 如果活动已结束,显示"活动已结束" | ||
| 326 | + if (activityStatus.value.is_ended) { | ||
| 327 | + return '活动已结束' | ||
| 328 | + } | ||
| 329 | + | ||
| 309 | // 如果没有加入家庭,显示"加入家庭" | 330 | // 如果没有加入家庭,显示"加入家庭" |
| 310 | if (!hasJoinedFamily.value) { | 331 | if (!hasJoinedFamily.value) { |
| 311 | return '参加活动' | 332 | return '参加活动' |
| ... | @@ -508,7 +529,7 @@ const onShareActivity = () => { | ... | @@ -508,7 +529,7 @@ const onShareActivity = () => { |
| 508 | */ | 529 | */ |
| 509 | const onShareAppMessage = () => { | 530 | const onShareAppMessage = () => { |
| 510 | return { | 531 | return { |
| 511 | - title: '分享活动海报', | 532 | + title: '主题路线打卡活动等你参与', |
| 512 | path: addShareFlag('/pages/ActivitiesCover/index'), | 533 | path: addShareFlag('/pages/ActivitiesCover/index'), |
| 513 | success: (res) => { | 534 | success: (res) => { |
| 514 | // 分享成功 | 535 | // 分享成功 |
| ... | @@ -845,10 +866,38 @@ const initPageData = async () => { | ... | @@ -845,10 +866,38 @@ const initPageData = async () => { |
| 845 | } | 866 | } |
| 846 | } | 867 | } |
| 847 | 868 | ||
| 869 | + // 获取活动状态 | ||
| 870 | + await fetchActivityStatus() | ||
| 871 | + | ||
| 848 | // 检查定位授权状态(不获取位置,只检查权限) | 872 | // 检查定位授权状态(不获取位置,只检查权限) |
| 849 | await checkLocationAuth() | 873 | await checkLocationAuth() |
| 850 | } | 874 | } |
| 851 | 875 | ||
| 876 | +/** | ||
| 877 | + * 获取活动状态 | ||
| 878 | + */ | ||
| 879 | +const fetchActivityStatus = async () => { | ||
| 880 | + try { | ||
| 881 | + activityStatus.value.loading = true | ||
| 882 | + const { code, data } = await getActivityStatusAPI() | ||
| 883 | + | ||
| 884 | + if (code === 1 && data) { | ||
| 885 | + activityStatus.value.is_ended = Boolean(data.is_ended) | ||
| 886 | + console.log('活动状态:', activityStatus.value.is_ended ? '已结束' : '进行中') | ||
| 887 | + } else { | ||
| 888 | + console.warn('获取活动状态失败:', data) | ||
| 889 | + // 默认认为活动未结束,避免影响用户体验 | ||
| 890 | + activityStatus.value.is_ended = false | ||
| 891 | + } | ||
| 892 | + } catch (error) { | ||
| 893 | + console.error('获取活动状态异常:', error) | ||
| 894 | + // 默认认为活动未结束,避免影响用户体验 | ||
| 895 | + activityStatus.value.is_ended = false | ||
| 896 | + } finally { | ||
| 897 | + activityStatus.value.loading = false | ||
| 898 | + } | ||
| 899 | +} | ||
| 900 | + | ||
| 852 | // 处理页面加载时的授权检查 | 901 | // 处理页面加载时的授权检查 |
| 853 | useLoad((options) => { | 902 | useLoad((options) => { |
| 854 | // 处理分享页面的授权逻辑 | 903 | // 处理分享页面的授权逻辑 | ... | ... |
-
Please register or login to post a comment