合并代码

This commit is contained in:
zpc 2025-12-29 22:42:26 +08:00
commit d0f4f93e16
9 changed files with 1066 additions and 704 deletions

View File

@ -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;
}
/**

View File

@ -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>
@ -97,7 +97,13 @@ const playerPositions = computed(() => {
const joinedCount = joinPerson.length
//
if (personCount === 2) {
if (personCount === 1) {
// 1
return {
positions: [null, joinPerson[0] || null, null, null],
joinPositions: [false, false, false, false]
}
} else if (personCount === 2) {
// 2
return {
positions: [null, joinPerson[0] || null, joinPerson[1] || null, null],
@ -169,7 +175,10 @@ const getPlayerAtPosition = (position) => {
const getJoinPlayerAtPosition = (index) => {
const personCount = props.item.personCount
if (personCount === 2) {
if (personCount === 1) {
// 12
return index === 2
} else if (personCount === 2) {
// 2
return [2, 3].includes(index)
} else if (personCount === 3) {
@ -320,7 +329,7 @@ const handleJoin = () => {
.info-text {
font-family: PingFang SC, PingFang SC;
font-weight: 400;
font-size:18rpx;
font-size:24rpx;
color: #575757;
text-align: left;
display: block;

View File

@ -124,18 +124,19 @@
<card-container marginTop="30rpx">
<label-slect-field label="鸽子费">
<com-appointment-radio-select :options="depositOptions" v-model="reservationInfo.deposit_fee" />
</label-slect-field>
<view v-if="reservationInfo.deposit_fee === -1" :style="{ height: lineHeight }"></view>
<label-slect-field v-if="reservationInfo.deposit_fee === -1" label="金额">
<view class="input-wrapper">
<up-input type="number" placeholder="请输入0-50" v-model="customDeposit" @input="onCustomDepositInput"></up-input>
</view>
</label-slect-field>
<view :style="{ height: lineHeight }"></view>
<text class="note-text">鸽子费保证金参与人需缴纳鸽子费若有参与者在预约后没有赴约其鸽子费由在场的所有人平分组局成功或失败后鸽子费将全额返还</text>
</card-container>
<label-slect-field label="鸽子费">
<com-appointment-radio-select :options="depositOptions" v-model="reservationInfo.deposit_fee" />
</label-slect-field>
<view v-if="reservationInfo.deposit_fee === -1" :style="{ height: lineHeight }"></view>
<label-slect-field v-if="reservationInfo.deposit_fee === -1" label="金额">
<view class="input-wrapper">
<up-input type="number" placeholder="请输入0-50" v-model="customDeposit"
@input="onCustomDepositInput"></up-input>
</view>
</label-slect-field>
<view :style="{ height: lineHeight }"></view>
<text class="note-text">鸽子费保证金参与人需缴纳鸽子费若有参与者在预约后没有赴约其鸽子费由在场的所有人平分组局成功或失败后鸽子费将全额返还</text>
</card-container>
<view class="action-row">
<view class="center reset-button" @click="resetForm">
@ -161,23 +162,23 @@
: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 style="width: 90vw; background-color: #fff; border-radius: 20rpx; padding: 20rpx;">
<view>
<view style="height: 80rpx;"></view>
<view style="font-size: 32rpx;font-weight: 500;color: #000;text-align: center;">发起预约成功</view>
<view style="height:100rpx;"></view>
<view style="display: flex;width: 100%;height:100rpx;">
<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">
style="background-color:#00AC4E; color: #fff;width: 45%;height: 100%; margin-left: 0;" class="center"
: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();">
style="width: 45%; height: 100%;background-color: #f7f7f7;display: flex;align-items: center;justify-content: center; border-radius: 10rpx;"
@click="handleClosePopup">
<text>关闭</text>
</view>
</view>
@ -198,8 +199,12 @@
} from 'vue';
import {
getConfigData,
getSubscribeMessage
getSubscribeMessage,
configData
} from '@/common/server/config'
import {
onShareAppMessage
} from '@dcloudio/uni-app';
import {
usePay
} from '@/common/server/interface/user'
@ -285,7 +290,7 @@
tomorrow.setDate(tomorrow.getDate() + 1);
const dayAfterTomorrow = new Date(today);
dayAfterTomorrow.setDate(dayAfterTomorrow.getDate() + 2);
let dateText = '';
if (targetDate.getTime() === today.getTime()) {
dateText = '今天';
@ -298,11 +303,11 @@
const day = date.getDate();
dateText = `${month}${day}`;
}
//
const weekdays = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];
const weekday = weekdays[date.getDay()];
return `${dateText} ${weekday}`;
}
/**
@ -322,11 +327,11 @@
const onDatePickerConfirm = async (e) => {
console.log('日期选择器确认事件:', e);
console.log('datePickerValue.value:', datePickerValue.value);
// up-datetime-picker confirm { value: , mode: 'date' }
// 使 v-model datePickerValue.value
let timestampMs = datePickerValue.value;
// v-model
if (!timestampMs || isNaN(timestampMs) || timestampMs <= 0) {
if (e && typeof e === 'object' && e.value !== undefined) {
@ -335,9 +340,9 @@
timestampMs = e;
}
}
console.log('提取的时间戳(毫秒):', timestampMs);
//
if (typeof timestampMs !== 'number' || isNaN(timestampMs) || timestampMs <= 0) {
console.error('日期选择器返回的时间戳无效:', e, 'datePickerValue:', datePickerValue.value);
@ -348,7 +353,7 @@
datePickerVisible.value = false;
return;
}
// 0
const date = new Date(timestampMs);
if (isNaN(date.getTime())) {
@ -360,17 +365,17 @@
datePickerVisible.value = false;
return;
}
const year = date.getFullYear();
const month = date.getMonth();
const day = date.getDate();
const dateAtMidnight = new Date(year, month, day, 0, 0, 0);
//
const selectedTimestamp = Math.floor(dateAtMidnight.getTime() / 1000);
console.log('转换后的秒级时间戳:', selectedTimestamp);
//
if (isNaN(selectedTimestamp) || selectedTimestamp <= 0) {
console.error('时间戳转换失败:', dateAtMidnight, selectedTimestamp);
@ -381,13 +386,13 @@
datePickerVisible.value = false;
return;
}
//
if (selectedDate.value && selectedDate.value === selectedTimestamp) {
datePickerVisible.value = false;
return;
}
//
selectedDate.value = selectedTimestamp;
@ -404,7 +409,7 @@
console.log('重新加载房间详情, roomId:', reservationInfo.value.room_id, 'date:', selectedTimestamp);
await loadRoomDetailForReservation(reservationInfo.value.room_id, selectedTimestamp);
}
datePickerVisible.value = false;
}
@ -608,6 +613,28 @@
const tipsShow = () => {
submitPopupRef.value.open()
}
//
const handleClosePopup = () => {
submitPopupRef.value.close()
refreshPrevPageRoomList()
goBack()
}
//
const refreshPrevPageRoomList = () => {
const pages = getCurrentPages()
if (!pages || pages.length < 2) return
const prevPage = pages[pages.length - 2]
const vm = prevPage?.$vm || prevPage
if (vm && typeof vm.loadRoomList === 'function') {
vm.loadRoomList()
return
}
if (vm && typeof vm.loadDates === 'function') {
vm.loadDates()
}
}
const maxPlayerCount = ref(0)
const peopleRange = ref([])
@ -663,34 +690,58 @@
return gameRule ? gameRule.text : '';
}
const smokingOptions = ref([
{ value: 2, text: '不禁烟' },
{ value: 1, text: '禁烟' },
])
const genderOptions = ref([
{ value: 0, text: '不限' },
{ value: 1, text: '男' },
{ value: 2, text: '女' },
])
const depositOptions = ref([
{ value: 0, text: '0元' },
{ value: 5, text: '5元' },
{ value: 10, text: '10元' },
{ value: -1, text: '自定义' },
])
const smokingOptions = ref([{
value: 2,
text: '不禁烟'
},
{
value: 1,
text: '禁烟'
},
])
const genderOptions = ref([{
value: 0,
text: '不限'
},
{
value: 1,
text: '男'
},
{
value: 2,
text: '女'
},
])
const depositOptions = ref([{
value: 0,
text: '0元'
},
{
value: 5,
text: '5元'
},
{
value: 10,
text: '10元'
},
{
value: -1,
text: '自定义'
},
])
const currentValue = ref(0)
const customDeposit = ref('')
const currentValue = ref(0)
const customDeposit = ref('')
const onCustomDepositInput = (val) => {
//
let v = String(val).replace(/[^0-9]/g, '')
if (v === '') v = '0'
let n = Number(v)
if (n > 50) n = 50
if (n < 0) n = 0
customDeposit.value = String(n)
}
const onCustomDepositInput = (val) => {
//
let v = String(val).replace(/[^0-9]/g, '')
if (v === '') v = '0'
let n = Number(v)
if (n > 50) n = 50
if (n < 0) n = 0
customDeposit.value = String(n)
}
const increment = () => {
if (currentValue.value < 5) {
@ -752,6 +803,7 @@ const onCustomDepositInput = (val) => {
return false
}
if (!info.start_time || info.start_time === 0) {
uni.showToast({
title: '请选择开始时间',
@ -835,27 +887,30 @@ const onCustomDepositInput = (val) => {
}
try {
var messageId = await getSubscribeMessage(reservationInfo.value.deposit_fee);
console.log("messageId", messageId);
var subscribeMessage = await requestSubscribeMessage(messageId);
console.log("message", subscribeMessage);
try {
var messageId = await getSubscribeMessage(reservationInfo.value.deposit_fee);
console.log("messageId", messageId);
var subscribeMessage = await requestSubscribeMessage(messageId);
console.log("message", subscribeMessage);
//
uni.showLoading({
title: '提交中...'
})
//
uni.showLoading({
title: '提交中...'
})
//
let finalDeposit = reservationInfo.value.deposit_fee
if (finalDeposit === -1) {
const n = Number(customDeposit.value || 0)
if (isNaN(n) || n < 0 || n > 50) {
uni.showToast({ title: '自定义金额需在0-50之间', icon: 'none' })
return
}
finalDeposit = n
}
//
let finalDeposit = reservationInfo.value.deposit_fee
if (finalDeposit === -1) {
const n = Number(customDeposit.value || 0)
if (isNaN(n) || n < 0 || n > 50) {
uni.showToast({
title: '自定义金额需在0-50之间',
icon: 'none'
})
return
}
finalDeposit = n
}
//
const submitData = {
@ -885,22 +940,22 @@ const onCustomDepositInput = (val) => {
return
}
var resPay = null;
if (submitData.deposit_fee > 0) {
resPay = await usePay(submitData.deposit_fee);
if (resPay == null) {
uni.showToast({
title: '鸽子费订单创建失败,请重新提交预约数据!',
icon: 'none'
})
return;
var resPay = null;
if (submitData.deposit_fee > 0) {
resPay = await usePay(submitData.deposit_fee);
if (resPay == null) {
uni.showToast({
title: '鸽子费订单创建失败,请重新提交预约数据!',
icon: 'none'
})
return;
}
subscribeMessage.result.paymentId = resPay.paymentId;
if (subscribeMessage.result != null) {
important_data = JSON.stringify(subscribeMessage.result);
}
submitData.important_data = important_data;
}
subscribeMessage.result.paymentId = resPay.paymentId;
if (subscribeMessage.result != null) {
important_data = JSON.stringify(subscribeMessage.result);
}
submitData.important_data = important_data;
}
// TODO: API
// API
@ -967,7 +1022,7 @@ const onCustomDepositInput = (val) => {
const savedMaxPlayerCount = maxPlayerCount.value;
const savedPeopleRange = [...peopleRange.value];
const savedPeopleText = peopleText.value;
reservationInfo.value = {
room_id: savedRoomId,
room_name: savedRoomName,
@ -988,7 +1043,7 @@ const onCustomDepositInput = (val) => {
currentValue.value = 0
gameRuleRange.value = []
customDeposit.value = '' //
//
maxPlayerCount.value = savedMaxPlayerCount;
peopleRange.value = savedPeopleRange;
@ -1009,11 +1064,18 @@ const onCustomDepositInput = (val) => {
* 加载房间详情用于预约页面
*/
const loadRoomDetailForReservation = async (roomId, date) => {
console.log('loadRoomDetailForReservation 调用参数:', { roomId, date, dateType: typeof date });
console.log('loadRoomDetailForReservation 调用参数:', {
roomId,
date,
dateType: typeof date
});
//
if (!roomId || !date) {
console.error('loadRoomDetailForReservation 参数无效:', { roomId, date });
console.error('loadRoomDetailForReservation 参数无效:', {
roomId,
date
});
uni.showToast({
title: '参数错误',
icon: 'none'
@ -1021,7 +1083,7 @@ const onCustomDepositInput = (val) => {
roomDetailLoading.value = false;
return;
}
// date
const dateTimestamp = Number(date);
if (isNaN(dateTimestamp) || dateTimestamp <= 0) {
@ -1033,14 +1095,14 @@ const onCustomDepositInput = (val) => {
roomDetailLoading.value = false;
return;
}
roomDetailLoading.value = true;
try {
console.log('调用 getRoomDetail, roomId:', roomId, 'date:', dateTimestamp);
const detail = await getRoomDetail(roomId, dateTimestamp);
if (detail) {
roomDetail.value = detail;
//
if (detail.capacity && detail.capacity > 0) {
maxPlayerCount.value = detail.capacity;
@ -1048,7 +1110,7 @@ const onCustomDepositInput = (val) => {
peopleText.value = "请选择游玩人数";
t.push({
value: 1,
text:'无需组局'
text: '无需组局'
});
for (let i = 2; i <= detail.capacity; i++) {
t.push({
@ -1083,7 +1145,7 @@ const onCustomDepositInput = (val) => {
if (config != null && config.config != null) {
gameTypeRange.value = [...config.config.playingMethodOptions];
}
//
if (!options || !options.roomId) {
uni.showToast({
@ -1095,12 +1157,12 @@ const onCustomDepositInput = (val) => {
}, 1500);
return;
}
//
const roomId = Number(options.roomId);
const roomName = decodeURIComponent(options.roomName || '未知房间');
const date = Number(options.date);
if (!roomId || !date) {
uni.showToast({
title: '房间信息不完整',
@ -1111,12 +1173,12 @@ const onCustomDepositInput = (val) => {
}, 1500);
return;
}
//
reservationInfo.value.room_id = roomId;
reservationInfo.value.room_name = roomName;
selectedDate.value = date;
//
await loadRoomDetailForReservation(roomId, date);
})
@ -1188,6 +1250,53 @@ 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">

File diff suppressed because it is too large Load Diff

View File

@ -55,7 +55,7 @@
<uni-popup ref="userInfo_popup" type="center">
<!-- <uni-popup ref="userInfo_popup" type="center">
<view class="column" style="width: 500rpx; background-color: white; padding: 20rpx;">
@ -97,7 +97,7 @@
</view>
</uni-popup>
</uni-popup> -->
</view>

View File

@ -1,6 +1,6 @@
<template>
<view class="loading-container">
<image class="logo" src="/static/Logo.jpg" mode="widthFix"></image>
<image class="logo" src="/static/logo.png" mode="widthFix"></image>
<view class="spinner"></view>
<text class="tip">{{ tips_text }}</text>
</view>

View File

@ -100,10 +100,10 @@
<text style="font-size: 30rpx; margin-top: 26rpx; margin-left: 36rpx;">常用功能</text>
<view class="row" style="flex-wrap: wrap; justify-content: flex-start; margin: 40rpx;">
<view class="column" v-for="item in commonActions" :key="item.label"
@click="handleCommonAction(item)"
style="width: 25%; align-items: center; margin-bottom: 30rpx;">
<view class="column common-action-item" v-for="item in commonActions" :key="item.label"
@click="handleCommonAction(item)">
<image :src="item.icon" style="width: 50rpx; height: 50rpx;" mode=""></image>
<view v-if="item.action === 'message' && unreadCount > 0" class="red-dot"></view>
<text style="font-size: 24rpx; margin-top: 20rpx;">{{ item.label }}</text>
</view>
</view>
@ -124,6 +124,7 @@ import {
} from '@/common/server/user'
import { navigateToAgreement } from '@/common/system/router'
import { sqInterface } from '@/common/server/interface/sq'
import { getUnreadCount } from '@/common/server/interface/message'
import ReservationEvaluate from '@/components/com/page/reservation-evaluate.vue'
import ContainerBase from '@/components/com/page/container-base.vue'
import {
@ -139,6 +140,7 @@ import ReservationItem from '@/components/com/page/reservation-item.vue'
const rateValue = ref(4.5)
const loading = ref(false)
const _containerBase = ref(null)
const unreadCount = ref(0)
//
@ -146,16 +148,15 @@ const currentAppointment = ref(null)
// -
const commonActions = [
{ label: '预约记录', icon: '@@:app/static/me/wodd.png', action: 'appointment' },
{ label: '预约记录', icon: '@@:app/static/me/wdyy.png', action: 'appointment' },
{ label: '订单记录', icon: '@@:app/static/me/wodd.png', action: 'payment' },
{ label: '常见问题', icon: '@@:app/static/me/cjwt.png', action: 'faq' },
{ label: '黑名单', icon: '@@:app/static/me/hmd.png', action: 'blacklist' },
{ label: '联系我们', icon: '@@:app/static/me/lxwm.png', action: 'contact' },
{ label: '我的消息', icon: '@@:app/static/me/lxwm.png', action: 'message' },
{ label: '我的收益', icon: '@@:app/static/me/lxwm.png', action: 'revenue' },
{ label: '我的消息', icon: '@@:app/static/me/wdxx.png', action: 'message' },
{ label: '我的收益', icon: '@@:app/static/me/wdsy.png', action: 'revenue' },
]
const handleCommonAction = (item) => {
@ -294,6 +295,28 @@ const loadCurrentAppointment = async () => {
}
}
//
const loadUnreadCount = async () => {
const _isLogin = await isLogin();
if (!_isLogin) {
unreadCount.value = 0;
uni.hideTabBarRedDot({ index: 2 });
return;
}
try {
const count = await getUnreadCount();
unreadCount.value = count;
if (count > 0) {
uni.showTabBarRedDot({ index: 2 });
} else {
uni.hideTabBarRedDot({ index: 2 });
}
} catch (error) {
console.error('加载未读消息失败:', error);
uni.hideTabBarRedDot({ index: 2 });
}
}
onShareAppMessage(({ from, target, webViewUrl }) => {
// console.log('onShareAppMessage', from, target, webViewUrl);
var resid = 0;
@ -311,6 +334,7 @@ onShow(async () => {
// getUserInfoData();
loadCurrentAppointment();
await loadUserInfo();
await loadUnreadCount();
})
onLoad(async () => {
@ -336,4 +360,21 @@ onLoad(async () => {
border-radius: 10rpx;
z-index: 9999;
}
.common-action-item {
position: relative;
width: 25%;
align-items: center;
margin-bottom: 30rpx;
}
.red-dot {
position: absolute;
top: 0;
right: 35rpx;
width: 14rpx;
height: 14rpx;
border-radius: 50%;
background-color: #ff3b30;
}
</style>

View File

@ -114,7 +114,7 @@
</view>
<view class="center"
style="width: 304rpx; height: 90rpx; background-color: #00AC4E; color: #FFFFFF; margin: 30rpx auto 0; font-size: 32rpx;"
style="width: 304rpx; height: 90rpx; background-color: #00AC4E; color: #FFFFFF; margin: 30rpx auto 30rpx; border-radius: 20rpx; font-size: 32rpx;"
@click="submitWithdraw">
申请提现
</view>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB