首页房间时间,预约页面弹窗分享,
This commit is contained in:
parent
05ad1348cf
commit
83668500df
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -12,28 +12,28 @@
|
|||
<view class="nine-grid-container">
|
||||
<view></view>
|
||||
<view class="item">
|
||||
<view v-if="getJoinPlayerAtPosition(1)" class="item-avatar">
|
||||
<view v-if="getJoinPlayerAtPosition(1)" class="item-avatar center">
|
||||
<image :src="getPlayerAtPosition(0)" class="avatar-img" mode="aspectFit"></image>
|
||||
</view>
|
||||
</view>
|
||||
<view></view>
|
||||
|
||||
<view class="item">
|
||||
<view v-if="getJoinPlayerAtPosition(2)" class="item-avatar">
|
||||
<view v-if="getJoinPlayerAtPosition(2)" class="item-avatar center">
|
||||
<image :src="getPlayerAtPosition(1)" class="avatar-img" mode="aspectFit"></image>
|
||||
</view>
|
||||
</view>
|
||||
<view></view>
|
||||
|
||||
<view class="item">
|
||||
<view v-if="getJoinPlayerAtPosition(3)" class="item-avatar">
|
||||
<view v-if="getJoinPlayerAtPosition(3)" class="item-avatar center">
|
||||
<image :src="getPlayerAtPosition(2)" class="avatar-img" mode="aspectFit"></image>
|
||||
</view>
|
||||
</view>
|
||||
<view></view>
|
||||
|
||||
<view class="item">
|
||||
<view v-if="getJoinPlayerAtPosition(4)" class="item-avatar">
|
||||
<view v-if="getJoinPlayerAtPosition(4)" class="item-avatar center">
|
||||
<image :src="getPlayerAtPosition(3)" class="avatar-img" mode="aspectFit"></image>
|
||||
</view>
|
||||
</view>
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@
|
|||
:defaultIndex="agePickerDefaultIndex" @confirm="onAgePickerConfirm" @cancel="() => agePickerVisible = false"
|
||||
@close="() => agePickerVisible = false"></up-picker>
|
||||
|
||||
<uni-popup ref="submitPopupRef" type="center">
|
||||
<uni-popup ref="submitPopupRef" type="center" :isMaskClick="false">
|
||||
|
||||
<view style="width: 90vw;height:300rpx;background-color: #fff;border-radius: 20rpx;">
|
||||
<view>
|
||||
|
|
@ -159,13 +159,13 @@
|
|||
<view style="display: flex;width: 100%;height:100rpx;">
|
||||
<button @click.stop open-type="share"
|
||||
style=" background-color:#00AC4E;color: #fff;width: 50%;height: 100%; background-color:#00AC4E;"
|
||||
class="center evaluate-btn" :data-item="reservation">
|
||||
class="center evaluate-btn" :data-item="reservationData">
|
||||
<text class="evaluate-btn-text">分享给好友</text>
|
||||
</button>
|
||||
|
||||
<view
|
||||
style="width: 50%;height: 100%;background-color: #f7f7f7;display: flex;align-items: center;justify-content: center;"
|
||||
@click="submitPopupRef.close();">
|
||||
@click="handleClosePopup">
|
||||
<text>关闭</text>
|
||||
</view>
|
||||
</view>
|
||||
|
|
@ -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: ''
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
|
|
|||
BIN
static/Logo.jpg
BIN
static/Logo.jpg
Binary file not shown.
|
Before Width: | Height: | Size: 54 KiB |
Loading…
Reference in New Issue
Block a user