321
This commit is contained in:
parent
e0ba4f5d5b
commit
66f810c643
|
|
@ -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
|
||||
};
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -32,6 +32,19 @@ export const getReservationList = async (index = 1, size = 20) => {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据预约ID获取详情(结构同首页预约列表单项)
|
||||
* @param {number} id 预约ID
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
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,
|
||||
|
|
|
|||
|
|
@ -100,17 +100,23 @@
|
|||
style="height: 80rpx; flex: 1; background-color: #9F9F9F; border-radius: 10rpx;">
|
||||
<text style="font-size: 24rpx; font-weight: 600; color: white;">关闭</text>
|
||||
</view>
|
||||
|
||||
<view class="center" @click="cancelJoin"
|
||||
style="height: 80rpx; flex: 3; background-color: #1989FA; border-radius: 10rpx; margin-left: 20rpx;">
|
||||
<text style="font-size: 24rpx; font-weight: 600; color: white;">取消组局</text>
|
||||
</view>
|
||||
<view class="center"
|
||||
style="height: 80rpx; flex: 1; background-color:#00AC4E; border-radius: 10rpx;margin-left: 20rpx;">
|
||||
<text style="font-size: 24rpx; font-weight: 600; color: white;">分享</text>
|
||||
<button style="width:100%;height:80rpx;position: absolute; background-color: transparent;"
|
||||
open-type="share" :data-item="reservationData" @click.stop></button>
|
||||
</view>
|
||||
</view>
|
||||
<view class="row" v-if="isAddhandleJoin == 3" style="width: 100%; margin-top: 30rpx;">
|
||||
<view class="center" @click="close"
|
||||
style="height: 80rpx; flex: 1; background-color: #9F9F9F; border-radius: 10rpx;">
|
||||
<text style="font-size: 24rpx; font-weight: 600; color: white;">关闭</text>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
</uni-popup>
|
||||
|
|
|
|||
|
|
@ -16,15 +16,25 @@
|
|||
<text class="row-text ml-20">{{ reservation.room_name || '' }}</text>
|
||||
</view>
|
||||
|
||||
<view class="row row-center mt-10">
|
||||
<text class="row-text ml-20">已约牌友:</text>
|
||||
<image v-for="(participant, pIndex) in reservation.participants" :key="pIndex"
|
||||
:src="participant.avatarImage || '/static/default-avatar.png'" class="avatar" mode="aspectFill" />
|
||||
<view class="center evaluate-btn" v-if="reservation.status == 3" @click.stop="onEvaluate()">
|
||||
<text class="evaluate-btn-text">牌友评价</text>
|
||||
<view class="row row-center mt-10" style="display: flex;">
|
||||
<view style="width: 75%;">
|
||||
<text class="row-text ml-20">已约牌友:</text>
|
||||
<image v-for="(participant, pIndex) in reservation.participants" :key="pIndex"
|
||||
:src="participant.avatarImage || '/static/default-avatar.png'" class="avatar"
|
||||
mode="aspectFill" />
|
||||
</view>
|
||||
<view class="center evaluate-btn" v-else-if="isQianDaoVisible" @click.stop="onQianDao()">
|
||||
<text class="evaluate-btn-text">签到</text>
|
||||
<view>
|
||||
<view class="center evaluate-btn" v-if="reservation.status == 3" @click.stop="onEvaluate()">
|
||||
<text class="evaluate-btn-text">牌友评价</text>
|
||||
</view>
|
||||
<view class="center evaluate-btn" v-else-if="isQianDaoVisible" @click.stop="onQianDao()">
|
||||
<text class="evaluate-btn-text">签到</text>
|
||||
</view>
|
||||
|
||||
<button v-else-if="reservation.status == 0" @click.stop open-type="share"
|
||||
style=" background-color:#00AC4E;" class="center evaluate-btn" :data-item="reservation">
|
||||
<text class="evaluate-btn-text">分享</text>
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
<view class="mt-20" style="height: 10rpx;"></view>
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
||||
});
|
||||
/**
|
||||
* 检查网络状态
|
||||
|
|
|
|||
|
|
@ -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(() => { })
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -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 () => {
|
||||
// 检查是否有登录状态
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user