From 66f810c643e174536242b16d169fcad3f8789558 Mon Sep 17 00:00:00 2001 From: zpc Date: Mon, 29 Sep 2025 17:26:17 +0800 Subject: [PATCH] 321 --- common/server/config.js | 17 +++ common/server/index.js | 126 ++++++++++++---------- common/server/interface/sq.js | 14 +++ components/com/index/ReservationPopup.vue | 8 +- components/com/page/reservation-item.vue | 32 ++++-- pages/index/index.vue | 38 ++++++- pages/index/loading.vue | 4 + pages/me/appointment-record-page.vue | 14 ++- pages/me/me-page.vue | 14 +++ 9 files changed, 199 insertions(+), 68 deletions(-) diff --git a/common/server/config.js b/common/server/config.js index 4e4101e..56ea5d0 100644 --- a/common/server/config.js +++ b/common/server/config.js @@ -55,4 +55,21 @@ export const getSubscribeMessage = async (depositFee) => { console.error('获取订阅消息配置失败:', error); return null; } +} + +/** + * + * @param {*} path + * @returns + */ +export const getShareConfig = async (path) => { + if (configData.value == null) { + return null; + } + var config = configData.value.config; + return { + title: config.shareTitle, + path: path, + imageUrl: config.shareImage + }; } \ No newline at end of file diff --git a/common/server/index.js b/common/server/index.js index 2e265ce..c3c849c 100644 --- a/common/server/index.js +++ b/common/server/index.js @@ -4,7 +4,7 @@ import { import { ref } from 'vue'; -import { getReservationList } from '@/common/server/interface/sq' +import { getReservationList, getReservationDetail } from '@/common/server/interface/sq' import { parseTimeString, formatTime, calculateTimeRange } from '@/common/system/timeUtile' // 响应式数据定义 // 首页核心数据(banner + 通知) @@ -66,6 +66,65 @@ const shouldUseCache = () => { return homeData.value && Date.now() - lastLoadTime < CACHE_TIMEOUT; }; +/** + * 将后端预约数据映射为首页列表展示项结构 + * @param {*} item 原始预约数据 + * @returns {*} 映射后的展示项 + */ +export const mapReservationItem = (item) => { + console.log(item); + + let start_time = parseTimeString(item.start_time); + let end_time = parseTimeString(item.end_time); + let timeStr = calculateTimeRange(start_time, end_time); + let time = formatTime(start_time, "HH:MM") + " ~ " + formatTime(end_time, "HH:MM") + " 共" + timeStr; + let requirementsList = [item.game_type, item.game_rule]; + if (item.is_smoking == 1) { + requirementsList.push("禁烟"); + } + if (item.gender_limit == 1) { + requirementsList.push("男性"); + } + if (item.gender_limit == 2) { + requirementsList.push("女性"); + } + if (item.credit_limit > 0) { + requirementsList.push("信誉分≧" + item.credit_limit); + } + if (item.min_age > 0) { + requirementsList.push("最小年龄≧" + item.min_age); + } + if (item.max_age > 0) { + requirementsList.push("最大年龄≦" + item.max_age); + } + if (item.deposit_fee > 0) { + requirementsList.push("鸽子费≧" + item.deposit_fee); + } + let requirements = requirementsList.join(","); + return { + id: item.id, + data: item, + status: item.status, + description: item.title, + dateStr: formatTime(start_time, "yyyy-MM-dd"), + time: time, + room: item.room_name, + requirements: requirements, + extra_info: item.extra_info, + personCount: item.player_count, + joinPerson: item.participants.map(participant => { + return { + id: participant.id, + name: participant.userName, + avatar: participant.avatarImage, + userBlackStatus: participant.userBlackStatus, + joinTime: participant.join_time, + role: participant.role, + }; + }), + }; +} + /** * 获取预约记录 * @param {*} index @@ -74,63 +133,20 @@ const shouldUseCache = () => { export const getReservation = async (index = 1, size = 20) => { const res = await getReservationList(index, size); if (res != null && res.length > 0) { - - console.log("记录", res); - var list = res.map(item => { - let start_time = parseTimeString(item.start_time); - let end_time = parseTimeString(item.end_time); - let timeStr = calculateTimeRange(start_time, end_time); - let time = formatTime(start_time, "HH:MM") + " ~ " + formatTime(end_time, "HH:MM") + " 共" + timeStr; - let requirementsList = [item.game_type, item.game_rule]; - if (item.is_smoking == 1) { - requirementsList.push("禁烟"); - } - if (item.gender_limit == 1) { - requirementsList.push("男性"); - } - if (item.gender_limit == 2) { - requirementsList.push("女性"); - } - if (item.credit_limit > 0) { - requirementsList.push("信誉分≧" + item.credit_limit); - } - if (item.min_age > 0) { - requirementsList.push("最小年龄≧" + item.min_age); - } - if (item.max_age > 0) { - requirementsList.push("最大年龄≦" + item.max_age); - } - if (item.deposit_fee > 0) { - requirementsList.push("鸽子费≧" + item.deposit_fee); - } - let requirements = requirementsList.join(","); - return { - id: item.id, - data: item, - status: item.status, - description: item.title, - dateStr: formatTime(start_time, "yyyy-MM-dd"), - time: time, - room: item.room_name, - requirements: requirements, - extra_info: item.extra_info, - personCount: item.player_count, - joinPerson: item.participants.map(participant => { - return { - id: participant.id, - name: participant.userName, - avatar: participant.avatarImage, - userBlackStatus: participant.userBlackStatus, - joinTime: participant.join_time, - role: participant.role, - }; - }), - }; - }); + console.log("记录", res); + var list = res.map(mapReservationItem); return list; - // return []; + } return []; } + +export const getDetail = async (id) => { + const res = await getReservationDetail(id); + if (res != null) { + return mapReservationItem(res); + } + return null; +} \ No newline at end of file diff --git a/common/server/interface/sq.js b/common/server/interface/sq.js index 3c07636..c3db6f8 100644 --- a/common/server/interface/sq.js +++ b/common/server/interface/sq.js @@ -32,6 +32,19 @@ export const getReservationList = async (index = 1, size = 20) => { return null; } +/** + * 根据预约ID获取详情(结构同首页预约列表单项) + * @param {number} id 预约ID + * @returns {Promise} + */ +export const getReservationDetail = async (id) => { + const res = await request.get("sq/GetReservationDetail", { id: id }); + if (res.code == 0) { + return res.data; + } + return null; +} + /** * 获取我的预约记录 * @param {number} type 0 参与者,1发起者 @@ -244,6 +257,7 @@ export const checkInReservation = async (checkInData) => { export const sqInterface = { canCreateSQReservation, getReservationList, + getReservationDetail, getMyReservation, getMyUseReservation, getEvaluateServices, diff --git a/components/com/index/ReservationPopup.vue b/components/com/index/ReservationPopup.vue index 2de3176..9895909 100644 --- a/components/com/index/ReservationPopup.vue +++ b/components/com/index/ReservationPopup.vue @@ -100,17 +100,23 @@ style="height: 80rpx; flex: 1; background-color: #9F9F9F; border-radius: 10rpx;"> 关闭 + 取消组局 + + 分享 + + 关闭 - diff --git a/components/com/page/reservation-item.vue b/components/com/page/reservation-item.vue index 08c021d..5497f4c 100644 --- a/components/com/page/reservation-item.vue +++ b/components/com/page/reservation-item.vue @@ -16,15 +16,25 @@ {{ reservation.room_name || '' }} - - 已约牌友: - - - 牌友评价 + + + 已约牌友: + - - 签到 + + + 牌友评价 + + + 签到 + + + @@ -54,7 +64,11 @@ const onQianDao = () => { emit('qianDao', props.reservation) // TODO: 实现签到逻辑 } - +const onfengxiao = () => { + console.log(" props.onfengxiao", props.reservation); + return false; + // TODO: 实现签到逻辑 +} // 计算属性:判断是否显示签到按钮 const isQianDaoVisible = computed(() => { const item = props.reservation; diff --git a/pages/index/index.vue b/pages/index/index.vue index 4c93516..c75927f 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -96,20 +96,26 @@ import { reactive, onMounted } from 'vue' +import { onShareAppMessage } from '@dcloudio/uni-app'; + import zPaging from '@/uni_modules/z-paging/components/z-paging/z-paging.vue' import MahjongCard from '@/components/index/MahjongCard.vue' import ReservationPopup from '@/components/com/index/ReservationPopup.vue' import { homeData, preloadHomeData, - getReservation + getReservation, + getDetail } from '@/common/server/index' + import { configData, getConfigData, + getShareConfig, preloadConfigData } from '@/common/server/config' import { userInfo, loadUserInfo } from '@/common/server/user' +import { sleep } from '../../uni_modules/uview-plus/libs/function'; const statusBarHeight = ref(uni.getSystemInfoSync().statusBarHeight); const getBackgroundImg = () => { return { @@ -193,6 +199,21 @@ const clearData = () => { pagePaging.value.clear() } + + +onShareAppMessage(({ from, target, webViewUrl }) => { + // console.log('onShareAppMessage', from, target, webViewUrl); + var resid = 0; + if (target != null) { + var item = target.dataset.item; + console.log('item', item); + resid = item.id; + } + var obj = getShareConfig("pages/index/loading?id=" + resid); + return obj +}); + + // 弹窗相关方法 const openPop = (item) => { reservationPopup.value.show(item.data) @@ -231,10 +252,23 @@ onMounted(() => { onShow(async () => { refreshData(); }); -onLoad(async () => { +onLoad(async (option) => { + // console.log('INDEX-option', option); if (!homeData.value) preloadHomeData(); if (!configData.value) preloadConfigData(); await loadUserInfo(); + var share_id = uni.getStorageSync('share_id'); + console.log('share_id', share_id); + if (share_id != null && share_id != "0" && share_id != "") { + uni.removeStorageSync('share_id') + var share_data = await getDetail(share_id); + // console.log("share_data321321", share_data.data); + if (reservationPopup.value != null) { + // await sleep() + openPop(share_data); + } + + } // initMockData(); // initMockData(); }); diff --git a/pages/index/loading.vue b/pages/index/loading.vue index b9204ff..0f73316 100644 --- a/pages/index/loading.vue +++ b/pages/index/loading.vue @@ -41,7 +41,11 @@ onLoad(async (option) => { if (endTimeF > 50) { await sleep(endTimeF); } + if (option != null && option.id != null && option.id != "0") { + uni.setStorageSync('share_id', option.id); + } com.navigateTo("/pages/index/index"); + }); /** * 检查网络状态 diff --git a/pages/me/appointment-record-page.vue b/pages/me/appointment-record-page.vue index 8e563f0..e36e163 100644 --- a/pages/me/appointment-record-page.vue +++ b/pages/me/appointment-record-page.vue @@ -40,6 +40,8 @@ import { sqInterface } from '@/common/server/interface/sq.js' import zPaging from '@/uni_modules/z-paging/components/z-paging/z-paging.vue' import ReservationItem from '@/components/com/page/reservation-item.vue' import ContainerBase from '@/components/com/page/container-base.vue' +import { onShareAppMessage } from '@dcloudio/uni-app'; +import { getShareConfig } from '@/common/server/config' // 响应式数据 const currentIndex = ref(0) const reservationList = ref([]) @@ -80,7 +82,17 @@ const goBack = () => { delta: 1 }) } - +onShareAppMessage(({ from, target, webViewUrl }) => { + // console.log('onShareAppMessage', from, target, webViewUrl); + var resid = 0; + if (target != null) { + var item = target.dataset.item; + console.log('item', item); + resid = item.id; + } + var obj = getShareConfig("pages/index/loading?id=" + resid); + return obj +}); // 页面加载时交由 z-paging 自动触发加载 onMounted(() => { }) diff --git a/pages/me/me-page.vue b/pages/me/me-page.vue index 19f5e84..4070d0f 100644 --- a/pages/me/me-page.vue +++ b/pages/me/me-page.vue @@ -131,7 +131,10 @@ import { reactive, onMounted } from 'vue' +import { onShareAppMessage } from '@dcloudio/uni-app'; +import { getShareConfig } from '@/common/server/config' import ReservationItem from '@/components/com/page/reservation-item.vue' + // 响应式数据 const rateValue = ref(4.5) const loading = ref(false) @@ -280,6 +283,17 @@ const loadCurrentAppointment = async () => { } } +onShareAppMessage(({ from, target, webViewUrl }) => { + // console.log('onShareAppMessage', from, target, webViewUrl); + var resid = 0; + if (target != null) { + var item = target.dataset.item; + console.log('item', item); + resid = item.id; + } + var obj = getShareConfig("pages/index/loading?id=" + resid); + return obj +}); // 页面显示时重新加载数据(用于登录后刷新) onShow(async () => { // 检查是否有登录状态