hookehuyr

feat(页面参数): 添加页面参数处理逻辑

在PosterCheckin和UploadMedia页面中添加页面参数处理逻辑,根据来源设置不同标题和跳转行为
修改auth页面的测试openid配置
移除未使用的NutIcon组件声明
...@@ -15,7 +15,6 @@ declare module 'vue' { ...@@ -15,7 +15,6 @@ declare module 'vue' {
15 NutActionSheet: typeof import('@nutui/nutui-taro')['ActionSheet'] 15 NutActionSheet: typeof import('@nutui/nutui-taro')['ActionSheet']
16 NutButton: typeof import('@nutui/nutui-taro')['Button'] 16 NutButton: typeof import('@nutui/nutui-taro')['Button']
17 NutDatePicker: typeof import('@nutui/nutui-taro')['DatePicker'] 17 NutDatePicker: typeof import('@nutui/nutui-taro')['DatePicker']
18 - NutIcon: typeof import('@nutui/nutui-taro')['Icon']
19 NutImagePreview: typeof import('@nutui/nutui-taro')['ImagePreview'] 18 NutImagePreview: typeof import('@nutui/nutui-taro')['ImagePreview']
20 NutInput: typeof import('@nutui/nutui-taro')['Input'] 19 NutInput: typeof import('@nutui/nutui-taro')['Input']
21 NutPicker: typeof import('@nutui/nutui-taro')['Picker'] 20 NutPicker: typeof import('@nutui/nutui-taro')['Picker']
......
...@@ -139,6 +139,12 @@ const backgroundImage = ref('') // 用户上传的背景图 ...@@ -139,6 +139,12 @@ const backgroundImage = ref('') // 用户上传的背景图
139 const shouldGeneratePoster = ref(false) // 是否应该生成海报 139 const shouldGeneratePoster = ref(false) // 是否应该生成海报
140 const currentPosterIndex = ref(0) // 当前显示的海报索引 140 const currentPosterIndex = ref(0) // 当前显示的海报索引
141 141
142 +// 页面参数
143 +const pageParams = ref({
144 + id: '',
145 + marker_id: ''
146 +})
147 +
142 // 图片预览相关 148 // 图片预览相关
143 const previewVisible = ref(false) 149 const previewVisible = ref(false)
144 const previewImages = ref([]) 150 const previewImages = ref([])
...@@ -336,6 +342,18 @@ const posterConfig = computed(() => { ...@@ -336,6 +342,18 @@ const posterConfig = computed(() => {
336 */ 342 */
337 onMounted(() => { 343 onMounted(() => {
338 Taro.setNavigationBarTitle({ title: '海报打卡' }) 344 Taro.setNavigationBarTitle({ title: '海报打卡' })
345 +
346 + // 获取页面参数
347 + const instance = Taro.getCurrentInstance()
348 + const params = instance.router?.params || {}
349 +
350 + pageParams.value = {
351 + id: params.id || '',
352 + marker_id: params.marker_id || ''
353 + }
354 +
355 + console.log('海报打卡页面接收到的参数:', pageParams.value)
356 +
339 // 页面加载时生成当前海报 357 // 页面加载时生成当前海报
340 generateCurrentPoster() 358 generateCurrentPoster()
341 }) 359 })
......
...@@ -160,11 +160,30 @@ const previewVisible = ref(false); ...@@ -160,11 +160,30 @@ const previewVisible = ref(false);
160 const previewImages = ref([]); 160 const previewImages = ref([]);
161 const previewIndex = ref(0); 161 const previewIndex = ref(0);
162 162
163 +// 页面参数
164 +const pageParams = ref({
165 + from: '',
166 + id: '',
167 + marker_id: ''
168 +});
169 +
163 /** 170 /**
164 - * 页面加载时设置标题 171 + * 页面加载时获取参数并设置标题
165 */ 172 */
166 onMounted(() => { 173 onMounted(() => {
167 - Taro.setNavigationBarTitle({ title: '拍照留念' }); 174 + // 获取页面参数
175 + const instance = Taro.getCurrentInstance();
176 + const params = instance.router?.params || {};
177 +
178 + pageParams.value = {
179 + from: params.from || '',
180 + id: params.id || '',
181 + marker_id: params.marker_id || ''
182 + };
183 +
184 + // 根据来源设置页面标题
185 + const title = pageParams.value.from === 'checkin' ? '上传图片' : '拍照留念';
186 + Taro.setNavigationBarTitle({ title });
168 }); 187 });
169 188
170 /** 189 /**
...@@ -360,7 +379,7 @@ const formatDuration = (seconds) => { ...@@ -360,7 +379,7 @@ const formatDuration = (seconds) => {
360 */ 379 */
361 const uploadFileToServer = (filePath) => { 380 const uploadFileToServer = (filePath) => {
362 return new Promise((resolve, reject) => { 381 return new Promise((resolve, reject) => {
363 - wx.uploadFile({ 382 + Taro.uploadFile({
364 url: BASE_URL + '/admin/?m=srv&a=upload', 383 url: BASE_URL + '/admin/?m=srv&a=upload',
365 filePath, 384 filePath,
366 name: 'file', 385 name: 'file',
...@@ -369,11 +388,11 @@ const uploadFileToServer = (filePath) => { ...@@ -369,11 +388,11 @@ const uploadFileToServer = (filePath) => {
369 }, 388 },
370 success: function (res) { 389 success: function (res) {
371 try { 390 try {
372 - let upload_data = JSON.parse(res.data); 391 + const upload_data = JSON.parse(res.data);
373 - if (data.code == 0 && upload_data.data) { 392 + if (upload_data.code === 0 && upload_data.data) {
374 resolve(upload_data.data.src); 393 resolve(upload_data.data.src);
375 } else { 394 } else {
376 - reject(new Error('服务器错误')); 395 + reject(new Error(upload_data.msg || '服务器错误'));
377 } 396 }
378 } catch (error) { 397 } catch (error) {
379 reject(new Error('解析响应数据失败')); 398 reject(new Error('解析响应数据失败'));
...@@ -434,13 +453,17 @@ const saveMedia = async () => { ...@@ -434,13 +453,17 @@ const saveMedia = async () => {
434 duration: 2000 453 duration: 2000
435 }); 454 });
436 455
437 - // 延迟返回Dashboard页面 456 + // 根据来源进行不同的跳转处理
438 setTimeout(() => { 457 setTimeout(() => {
439 - // Taro.reLaunch({ 458 + if (pageParams.value.from === 'checkin') {
440 - // url: '/pages/Dashboard/index' 459 + // 如果是从打卡页面跳转过来的,带着参数跳转到海报打卡页面
441 - // }); 460 + Taro.redirectTo({
442 - // 返回前一页 461 + url: `/pages/PosterCheckin/index?id=${pageParams.value.id}&marker_id=${pageParams.value.marker_id}`
443 - Taro.navigateBack(); 462 + });
463 + } else {
464 + // 其他情况返回上一页
465 + Taro.navigateBack();
466 + }
444 }, 2000); 467 }, 2000);
445 } catch (error) { 468 } catch (error) {
446 console.error('保存失败:', error); 469 console.error('保存失败:', error);
......
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-02 19:46:17 4 + * @LastEditTime: 2025-09-03 17:02:11
5 * @FilePath: /lls_program/src/pages/auth/index.vue 5 * @FilePath: /lls_program/src/pages/auth/index.vue
6 * @Description: 文件描述 6 * @Description: 文件描述
7 --> 7 -->
...@@ -42,13 +42,13 @@ export default { ...@@ -42,13 +42,13 @@ export default {
42 // 测试环境下传递openid,正式环境不传递 42 // 测试环境下传递openid,正式环境不传递
43 if (process.env.NODE_ENV === 'development') { 43 if (process.env.NODE_ENV === 'development') {
44 // requestData.openid = 'h-008'; 44 // requestData.openid = 'h-008';
45 - requestData.openid = 'h-009'; 45 + // requestData.openid = 'h-009';
46 // requestData.openid = 'h-010'; 46 // requestData.openid = 'h-010';
47 // requestData.openid = 'h-011'; 47 // requestData.openid = 'h-011';
48 // requestData.openid = 'h-012'; 48 // requestData.openid = 'h-012';
49 // requestData.openid = 'h-013'; 49 // requestData.openid = 'h-013';
50 // requestData.openid = 'oWbdFvkD5VtloC50wSNR9IWiU2q8'; 50 // requestData.openid = 'oWbdFvkD5VtloC50wSNR9IWiU2q8';
51 - // requestData.openid = 'oex8h5QZnZJto3ttvO6swSvylAQo'; 51 + requestData.openid = 'oex8h5QZnZJto3ttvO6swSvylAQo';
52 } 52 }
53 53
54 request.post('/srv/?a=openid', requestData) 54 request.post('/srv/?a=openid', requestData)
......