hookehuyr

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

在PosterCheckin和UploadMedia页面中添加页面参数处理逻辑,根据来源设置不同标题和跳转行为
修改auth页面的测试openid配置
移除未使用的NutIcon组件声明
......@@ -15,7 +15,6 @@ declare module 'vue' {
NutActionSheet: typeof import('@nutui/nutui-taro')['ActionSheet']
NutButton: typeof import('@nutui/nutui-taro')['Button']
NutDatePicker: typeof import('@nutui/nutui-taro')['DatePicker']
NutIcon: typeof import('@nutui/nutui-taro')['Icon']
NutImagePreview: typeof import('@nutui/nutui-taro')['ImagePreview']
NutInput: typeof import('@nutui/nutui-taro')['Input']
NutPicker: typeof import('@nutui/nutui-taro')['Picker']
......
......@@ -139,6 +139,12 @@ const backgroundImage = ref('') // 用户上传的背景图
const shouldGeneratePoster = ref(false) // 是否应该生成海报
const currentPosterIndex = ref(0) // 当前显示的海报索引
// 页面参数
const pageParams = ref({
id: '',
marker_id: ''
})
// 图片预览相关
const previewVisible = ref(false)
const previewImages = ref([])
......@@ -336,6 +342,18 @@ const posterConfig = computed(() => {
*/
onMounted(() => {
Taro.setNavigationBarTitle({ title: '海报打卡' })
// 获取页面参数
const instance = Taro.getCurrentInstance()
const params = instance.router?.params || {}
pageParams.value = {
id: params.id || '',
marker_id: params.marker_id || ''
}
console.log('海报打卡页面接收到的参数:', pageParams.value)
// 页面加载时生成当前海报
generateCurrentPoster()
})
......
......@@ -160,11 +160,30 @@ const previewVisible = ref(false);
const previewImages = ref([]);
const previewIndex = ref(0);
// 页面参数
const pageParams = ref({
from: '',
id: '',
marker_id: ''
});
/**
* 页面加载时设置标题
* 页面加载时获取参数并设置标题
*/
onMounted(() => {
Taro.setNavigationBarTitle({ title: '拍照留念' });
// 获取页面参数
const instance = Taro.getCurrentInstance();
const params = instance.router?.params || {};
pageParams.value = {
from: params.from || '',
id: params.id || '',
marker_id: params.marker_id || ''
};
// 根据来源设置页面标题
const title = pageParams.value.from === 'checkin' ? '上传图片' : '拍照留念';
Taro.setNavigationBarTitle({ title });
});
/**
......@@ -360,7 +379,7 @@ const formatDuration = (seconds) => {
*/
const uploadFileToServer = (filePath) => {
return new Promise((resolve, reject) => {
wx.uploadFile({
Taro.uploadFile({
url: BASE_URL + '/admin/?m=srv&a=upload',
filePath,
name: 'file',
......@@ -369,11 +388,11 @@ const uploadFileToServer = (filePath) => {
},
success: function (res) {
try {
let upload_data = JSON.parse(res.data);
if (data.code == 0 && upload_data.data) {
const upload_data = JSON.parse(res.data);
if (upload_data.code === 0 && upload_data.data) {
resolve(upload_data.data.src);
} else {
reject(new Error('服务器错误'));
reject(new Error(upload_data.msg || '服务器错误'));
}
} catch (error) {
reject(new Error('解析响应数据失败'));
......@@ -434,13 +453,17 @@ const saveMedia = async () => {
duration: 2000
});
// 延迟返回Dashboard页面
// 根据来源进行不同的跳转处理
setTimeout(() => {
// Taro.reLaunch({
// url: '/pages/Dashboard/index'
// });
// 返回前一页
Taro.navigateBack();
if (pageParams.value.from === 'checkin') {
// 如果是从打卡页面跳转过来的,带着参数跳转到海报打卡页面
Taro.redirectTo({
url: `/pages/PosterCheckin/index?id=${pageParams.value.id}&marker_id=${pageParams.value.marker_id}`
});
} else {
// 其他情况返回上一页
Taro.navigateBack();
}
}, 2000);
} catch (error) {
console.error('保存失败:', error);
......
<!--
* @Date: 2022-09-19 14:11:06
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-09-02 19:46:17
* @LastEditTime: 2025-09-03 17:02:11
* @FilePath: /lls_program/src/pages/auth/index.vue
* @Description: 文件描述
-->
......@@ -42,13 +42,13 @@ export default {
// 测试环境下传递openid,正式环境不传递
if (process.env.NODE_ENV === 'development') {
// requestData.openid = 'h-008';
requestData.openid = 'h-009';
// requestData.openid = 'h-009';
// requestData.openid = 'h-010';
// requestData.openid = 'h-011';
// requestData.openid = 'h-012';
// requestData.openid = 'h-013';
// requestData.openid = 'oWbdFvkD5VtloC50wSNR9IWiU2q8';
// requestData.openid = 'oex8h5QZnZJto3ttvO6swSvylAQo';
requestData.openid = 'oex8h5QZnZJto3ttvO6swSvylAQo';
}
request.post('/srv/?a=openid', requestData)
......