From 83668500dfd8677faf73cd30ab87a5acfef69613 Mon Sep 17 00:00:00 2001 From: 18631081161 <2088094923@qq.com> Date: Mon, 8 Dec 2025 03:44:05 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E6=88=BF=E9=97=B4=E6=97=B6?= =?UTF-8?q?=E9=97=B4,=E9=A2=84=E7=BA=A6=E9=A1=B5=E9=9D=A2=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=E5=88=86=E4=BA=AB,?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/system/timeUtile.js | 32 ++++++++++---- components/index/MahjongCard.vue | 8 ++-- pages/appointment/appointment-page.vue | 59 +++++++++++++++++++++++-- static/Logo.jpg | Bin 54955 -> 0 bytes 4 files changed, 83 insertions(+), 16 deletions(-) delete mode 100644 static/Logo.jpg diff --git a/common/system/timeUtile.js b/common/system/timeUtile.js index 6667bc3..c301cbf 100644 --- a/common/system/timeUtile.js +++ b/common/system/timeUtile.js @@ -14,7 +14,8 @@ function parseTimeString(timeStr) { /** * 将时间对象格式化为指定格式的字符串 * @param {Date} date - 时间对象 - * @param {string} format - 格式字符串,如:yyyy-mm-dd HH:MM:ss + * @param {string} format - 格式字符串,如:yyyy-MM-dd HH:MM:ss + * 注意:MM 在日期部分(yyyy-MM-dd)表示月份,在时间部分(HH:MM)表示分钟 * @returns {string} 格式化后的时间字符串 */ function formatTime(date, format) { @@ -25,13 +26,28 @@ function formatTime(date, format) { const minutes = String(date.getMinutes()).padStart(2, '0'); const seconds = String(date.getSeconds()).padStart(2, '0'); - return format - .replace('yyyy', year) - .replace('mm', month) - .replace('dd', day) - .replace('HH', hours) - .replace('MM', minutes) - .replace('ss', seconds); + // 使用临时占位符避免 MM 冲突 + // 先处理日期部分的 MM(在 yyyy 和 dd 之间的 MM 表示月份) + let result = format.replace(/(yyyy-)(MM)(-dd)/g, '$1__MONTH__$3'); + + // 再处理时间部分的 MM(在 HH 之后的 MM 表示分钟) + result = result.replace(/(HH:)(MM)/g, '$1__MINUTE__'); + + // 替换所有其他标记 + result = result.replace(/yyyy/g, year); + result = result.replace(/dd/g, day); + result = result.replace(/HH/g, hours); + result = result.replace(/mm/g, month); // 小写 mm 始终表示月份 + result = result.replace(/ss/g, seconds); + + // 最后替换临时占位符 + result = result.replace(/__MONTH__/g, month); + result = result.replace(/__MINUTE__/g, minutes); + + // 处理剩余的 MM(如果还有,默认表示月份) + result = result.replace(/MM/g, month); + + return result; } /** diff --git a/components/index/MahjongCard.vue b/components/index/MahjongCard.vue index 607a903..23106f1 100644 --- a/components/index/MahjongCard.vue +++ b/components/index/MahjongCard.vue @@ -12,28 +12,28 @@ - + - + - + - + diff --git a/pages/appointment/appointment-page.vue b/pages/appointment/appointment-page.vue index b6aeb8a..1bbb79a 100644 --- a/pages/appointment/appointment-page.vue +++ b/pages/appointment/appointment-page.vue @@ -149,7 +149,7 @@ :defaultIndex="agePickerDefaultIndex" @confirm="onAgePickerConfirm" @cancel="() => agePickerVisible = false" @close="() => agePickerVisible = false"> - + @@ -159,13 +159,13 @@ + @click="handleClosePopup"> 关闭 @@ -186,8 +186,10 @@ } from 'vue'; import { getConfigData, - getSubscribeMessage + getSubscribeMessage, + configData } from '@/common/server/config' + import { onShareAppMessage } from '@dcloudio/uni-app'; import { usePay } from '@/common/server/interface/user' @@ -681,6 +683,12 @@ const tipsShow = () => { submitPopupRef.value.open() } + + // 处理关闭弹窗,返回上一页 + const handleClosePopup = () => { + submitPopupRef.value.close() + goBack() + } const maxPlayerCount = ref(0) const peopleRange = ref([]) @@ -1372,6 +1380,49 @@ const onCustomDepositInput = (val) => { reservationInfo.value.max_age = maxAge agePickerVisible.value = false } + + // 分享处理函数 + onShareAppMessage(({ from, target, webViewUrl }) => { + console.log('onShareAppMessage', from, target, webViewUrl); + var resid = 0; + if (target != null && target.dataset && target.dataset.item) { + var item = target.dataset.item; + console.log('item', item); + // reservationData 的结构包含 id 字段 + if (item && item.id) { + resid = item.id; + } else if (item && item.data && item.data.id) { + // 兼容数据结构 + resid = item.data.id; + } + } + // 如果从 reservationData 获取不到,尝试从当前值获取 + if (resid === 0 && reservationData.value) { + if (reservationData.value.id) { + resid = reservationData.value.id; + } else if (reservationData.value.data && reservationData.value.data.id) { + resid = reservationData.value.data.id; + } + } + console.log('分享的预约ID:', resid); + + // 同步获取分享配置(因为 onShareAppMessage 需要同步返回) + const path = "pages/index/loading?id=" + resid; + // 直接访问 configData.value,避免异步调用 + if (configData.value && configData.value.config) { + return { + title: configData.value.config.shareTitle || '山雀搭子 - 麻将组局', + path: path, + imageUrl: configData.value.config.shareImage || '' + }; + } + // 默认配置 + return { + title: '山雀搭子 - 麻将组局', + path: path, + imageUrl: '' + }; + });