This commit is contained in:
zpc 2025-09-16 03:50:27 +08:00
parent 2c7a7940a0
commit d91eac13d1
4 changed files with 201 additions and 11 deletions

View File

@ -9,7 +9,7 @@ import request from '@/common/system/request';
export const getReservationList = async (index = 1, size = 20) => {
console.log('getReservationList', index, size);
const res = await request.getOrCache("sq/GetReservationList", { pageIndex: index, pageSize: size }, 5);
const res = await request.getOrCache("sq/GetReservationList", { pageIndex: index, pageSize: size }, 1);
if (res.code == 0) {
return res.data;
}
@ -149,7 +149,8 @@ export const joinReservation = async (joinData) => {
if (res.code == 0) {
return {
success: true,
message: res.msg || '加入预约成功'
message: res.msg || '加入预约成功',
data: res.data.reservation_id
};
}
return {

View File

@ -119,8 +119,11 @@
<script setup>
import { ref, computed } from 'vue'
import { userInfo } from '@/common/server/user'
import { showModalConfirm } from '@/common/utils'
import { userInfo, isLogin } from '@/common/server/user'
import { showModalConfirm, requestSubscribeMessage, requestPayment } from '@/common/utils'
import { getSubscribeMessage } from '@/common/server/config'
import { usePay } from '@/common/server/interface/user'
import { joinReservation, cancelReservation } from '@/common/server/interface/sq'
//
const popup = ref(null)
@ -208,21 +211,185 @@ const getGenderText = (genderLimit) => {
}
//
const handleJoin = () => {
// reservationData.value
console.log("reservationData.value", reservationData.value);
const handleJoin = async () => {
//
var isLoginSuccess = await isLogin();
if (!isLoginSuccess) {
close();
uni.navigateTo({
url: '/pages/me/login'
});
return;
}
try {
//
var messageId = await getSubscribeMessage(reservationData.value.deposit_fee);
console.log("messageId", messageId);
var subscribeMessage = await requestSubscribeMessage(messageId);
console.log("message", subscribeMessage);
//
uni.showLoading({
title: '加入中...'
});
//
const joinData = {
ReservationsId: reservationData.value.id,
important_data: {}
};
var resPay = null;
//
if (reservationData.value.deposit_fee > 0) {
resPay = await usePay(reservationData.value.deposit_fee);
if (resPay == null) {
uni.hideLoading();
uni.showToast({
title: '鸽子费订单创建失败,请重新尝试!',
icon: 'none'
});
return;
}
subscribeMessage.result.paymentId = resPay.paymentId;
}
//
var important_data = "";
if (subscribeMessage.result != null) {
important_data = JSON.stringify(subscribeMessage.result);
}
joinData.important_data = important_data;
//
const result = await joinReservation(joinData);
uni.hideLoading();
console.log("join result", result);
if (!result.success) {
uni.showToast({
title: result.message,
icon: 'none'
});
return;
}
//
if (reservationData.value.deposit_fee > 0 && resPay != null) {
var payRes = await requestPayment(resPay);
if (payRes.success) {
uni.showToast({
title: '鸽子费支付成功,加入组局成功!',
icon: 'success'
});
} else {
uni.showToast({
title: '鸽子费支付失败,请重新加入!',
icon: 'none'
});
await cancelReservation(result.data, "鸽子费支付失败,请重新加入!");
return;
}
} else {
uni.showToast({
title: '加入组局成功!',
icon: 'success'
});
}
//
close();
//
emit('refreshList');
} catch (error) {
uni.hideLoading();
console.error('加入组局失败:', error);
uni.showToast({
title: '加入失败,请重试',
icon: 'none'
});
}
}
//
const cancelJoin = async () => {
var res = await showModalConfirm('提示', '确定要取消组局吗?')
if (res) {
console.log("reservationData.value", reservationData.value);
try {
//
uni.showLoading({
title: '取消中...'
});
//
const result = await cancelReservation(reservationData.value.id, "发起者取消组局");
uni.hideLoading();
console.log("cancel result", result);
if (result.success) {
uni.showToast({
title: '取消组局成功!',
icon: 'success'
});
//
close();
//
emit('refreshList');
} else {
uni.showToast({
title: result.message,
icon: 'none'
});
}
} catch (error) {
uni.hideLoading();
console.error('取消组局失败:', error);
uni.showToast({
title: '取消失败,请重试',
icon: 'none'
});
}
}
}
//退
const exitJoin = async () => {
var res = await showModalConfirm('提示', '确定要退出组局吗?')
if (res) {
console.log("reservationData.value", reservationData.value);
try {
//
uni.showLoading({
title: '退出中...'
});
// 退
const result = await cancelReservation(reservationData.value.id, "参与者退出组局");
uni.hideLoading();
console.log("exit result", result);
if (result.success) {
uni.showToast({
title: '退出组局成功!',
icon: 'success'
});
//
close();
//
emit('refreshList');
} else {
uni.showToast({
title: result.message,
icon: 'none'
});
}
} catch (error) {
uni.hideLoading();
console.error('退出组局失败:', error);
uni.showToast({
title: '退出失败,请重试',
icon: 'none'
});
}
}
}
//
@ -232,7 +399,7 @@ const openUserPop = (user) => {
}
//
const emit = defineEmits(['openUserPop'])
const emit = defineEmits(['openUserPop', 'refreshList'])
//
defineExpose({

View File

@ -318,6 +318,24 @@ const gameRuleRangeChange = (e) => {
console.log('gameRuleRangeChange:', e)
}
//
const getGameTypeText = (gameTypeValue) => {
if (!gameTypeValue || gameTypeValue === 0) {
return '';
}
const gameType = gameTypeRange.value.find(item => item.value === gameTypeValue);
return gameType ? gameType.text : '';
}
//
const getGameRuleText = (gameRuleValue) => {
if (!gameRuleValue || gameRuleValue === 0) {
return '';
}
const gameRule = gameRuleRange.value.find(item => item.value === gameRuleValue);
return gameRule ? gameRule.text : '';
}
const smokingOptions = ref([
{ value: 2, text: '不禁烟' },
{ value: 1, text: '禁烟' },
@ -476,6 +494,10 @@ const submitReservation = async () => {
important_data: {}
}
//
submitData.game_type = getGameTypeText(submitData.game_type);
submitData.game_rule = getGameRuleText(submitData.game_rule);
var resPay = null;
if (submitData.deposit_fee > 0) {
resPay = await usePay(submitData.deposit_fee);

View File

@ -38,7 +38,7 @@
<!-- 预约信息弹窗组件 -->
<ReservationPopup ref="reservationPopup" @openUserPop="openUserPop" />
<ReservationPopup ref="reservationPopup" @openUserPop="openUserPop" @refreshList="refreshData" />