feat: 订单的处理,ordertype 等于0的处理
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
<view class="border-box bg-white p-12 rounded-12 mb-12">
|
||||
<!-- 酒店类型入住离店日期部分 -->
|
||||
<DateRangeSection
|
||||
v-if="orderData.orderType === 0"
|
||||
v-if="orderData.orderType == 0"
|
||||
:selectedDate="selectedDate"
|
||||
:showBtn="true"
|
||||
@click="navigateToDetail(orderData)"
|
||||
@@ -64,7 +64,7 @@
|
||||
|
||||
<!-- 非酒店类型 -->
|
||||
<ContactSection
|
||||
v-if="orderData.orderType !== 0"
|
||||
v-if="orderData.orderType != 0"
|
||||
v-model="quantity"
|
||||
:userFormList="userFormList"
|
||||
v-model:reservationDate="selectedReservationDate"
|
||||
@@ -72,7 +72,7 @@
|
||||
|
||||
<!-- 酒店类型 -->
|
||||
<UserSection
|
||||
v-if="orderData.orderType === 0"
|
||||
v-if="orderData.orderType == 0"
|
||||
v-model="quantity"
|
||||
:userFormList="userFormList"
|
||||
/>
|
||||
@@ -244,12 +244,12 @@ const handlePayClick = ThrottleUtils.createThrottle(async (goodsData) => {
|
||||
};
|
||||
|
||||
// 预约日期,酒店类型不需要
|
||||
if (orderData.value.orderType !== 0) {
|
||||
if (orderData.value.orderType != 0) {
|
||||
params.reservationDate = selectedReservationDate.value;
|
||||
}
|
||||
|
||||
//酒店类型添加入住时间、离店时间
|
||||
if (goodsData.orderType === 0 && selectedDate.value) {
|
||||
if (goodsData.orderType == 0 && selectedDate.value) {
|
||||
const { startDate, endDate } = selectedDate.value;
|
||||
// 入住时间
|
||||
params.checkInData = startDate;
|
||||
|
||||
@@ -90,7 +90,7 @@ const handleButtonClick = DebounceUtils.createDebounce(async (orderData) => {
|
||||
// 检查接口返回数据
|
||||
if (!res || !res.data) {
|
||||
uni.hideLoading();
|
||||
uni.showToast({ title: "订单创建失败,请重试", icon: "none" });
|
||||
uni.showToast({ title: res.msg || "订单创建失败,请重试", icon: "none" });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -119,7 +119,10 @@ const handleButtonClick = DebounceUtils.createDebounce(async (orderData) => {
|
||||
uni.showToast({
|
||||
title: "支付成功",
|
||||
icon: "success",
|
||||
success: () => emit("refresh"),
|
||||
success: () => {
|
||||
console.log("支付成功,刷新订单详情");
|
||||
emit("refresh", { orderId: orderId });
|
||||
},
|
||||
});
|
||||
},
|
||||
fail: () => {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<template>
|
||||
<view
|
||||
v-if="orderType === '0'"
|
||||
v-if="orderType == 0"
|
||||
class="border-box bg-white p-12 rounded-12 mb-12"
|
||||
>
|
||||
<!-- 酒店类型入住离店日期部分 -->
|
||||
<DateRangeSection
|
||||
v-if="orderData.orderType === 0"
|
||||
v-if="orderData.orderType == 0"
|
||||
:selectedDate="selectedDate"
|
||||
/>
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
</view>
|
||||
|
||||
<view
|
||||
v-if="orderType !== '0'"
|
||||
v-if="orderType != 0"
|
||||
class="border-box bg-white p-12 rounded-12 mb-12"
|
||||
>
|
||||
<view
|
||||
@@ -85,7 +85,7 @@ const orderType = computed(() => props.orderData.orderType);
|
||||
const commodityAmount = computed(() => {
|
||||
// 门票单位:张、餐饮单位:份
|
||||
const { commodityAmount } = props.orderData;
|
||||
return orderType.value === "2"
|
||||
return orderType.value == 2
|
||||
? `${parseInt(commodityAmount)}张`
|
||||
: `${parseInt(commodityAmount)}份`;
|
||||
});
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
<text
|
||||
:class="[
|
||||
{
|
||||
'color-FF3D60': statusCode === '0',
|
||||
'color-21B466': ['1', '2', '3', '4', '5', '6'].includes(statusCode),
|
||||
'color-FF3D60': statusCode === '0' || statusCode === '3',
|
||||
'color-21B466': ['1', '2', '4', '5', '6'].includes(statusCode),
|
||||
},
|
||||
]"
|
||||
>
|
||||
@@ -45,7 +45,7 @@ const statusCode = computed(() => props.orderData.orderStatus);
|
||||
|
||||
// 使用计算属性缓存支付方式文本
|
||||
const statusText = computed(() =>
|
||||
statusCode.value === "0" ? "未支付" : "已支付"
|
||||
statusCode.value === "0" || statusCode.value === "3" ? "未支付" : "已支付"
|
||||
);
|
||||
</script>
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
<GoodsInfo :orderData="orderData" />
|
||||
|
||||
<UserInfo v-if="orderData.orderType === 0" :orderData="orderData" />
|
||||
<UserInfo v-if="orderData.orderType == 0" :orderData="orderData" />
|
||||
|
||||
<OrderInfo :orderData="orderData" />
|
||||
</view>
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
<!-- 核销凭证 二维码 -->
|
||||
<OrderQrcode
|
||||
v-if="orderData.orderStatus === '2'"
|
||||
v-show="visbleQrcode"
|
||||
v-model="visbleQrcode"
|
||||
:orderData="orderData"
|
||||
@@ -34,8 +35,8 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
import { onLoad } from "@dcloudio/uni-app";
|
||||
import { ref, getCurrentInstance } from "vue";
|
||||
import { onLoad, onUnload } from "@dcloudio/uni-app";
|
||||
import { userOrderDetail, orderRefund } from "@/request/api/OrderApi";
|
||||
import TopNavBar from "@/components/TopNavBar/index.vue";
|
||||
import OrderQrcode from "./components/OrderQrcode/index.vue";
|
||||
@@ -48,6 +49,9 @@ import OrderInfo from "./components/OrderInfo/index.vue";
|
||||
import FooterSection from "./components/FooterSection/index.vue";
|
||||
import RefundPopup from "@/components/RefundPopup/index.vue";
|
||||
|
||||
// 获取事件通道对象
|
||||
let eventChannel = null
|
||||
|
||||
const refundVisible = ref(false);
|
||||
const orderData = ref({});
|
||||
|
||||
@@ -55,7 +59,14 @@ const visbleQrcode = ref(false);
|
||||
const selectedVoucher = ref(null);
|
||||
const selectedVoucherIndex = ref(0);
|
||||
|
||||
onLoad(({ orderId }) => getOrderDetail(orderId));
|
||||
onLoad(({ orderId }) => {
|
||||
getOrderDetail(orderId);
|
||||
|
||||
// 获取当前页面的事件通道(由 navigateTo 打开时可用)
|
||||
const pages = getCurrentPages()
|
||||
const currentPage = pages[pages.length - 1]
|
||||
eventChannel = currentPage.getOpenerEventChannel()
|
||||
});
|
||||
|
||||
// 处理选中核销凭证事件
|
||||
const handleSelectedVoucher = (voucher) => {
|
||||
@@ -96,8 +107,18 @@ const handleRefundConfirm = async ({ orderId }) => {
|
||||
|
||||
// 再次预定
|
||||
const handlePaySuccess = ({ orderId }) => {
|
||||
console.log("支付成功,刷新订单详情", orderId);
|
||||
getOrderDetail(orderId);
|
||||
// 支付成功后通知上一个页面
|
||||
setTimeout(() => {
|
||||
eventChannel.emit('refreshOrderList', { success: true });
|
||||
}, 1000);
|
||||
};
|
||||
|
||||
onUnload(() => {
|
||||
eventChannel.on('refreshOrderList');
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@@ -51,6 +51,14 @@ const handleOrderClick = ({ orderId }) => {
|
||||
// 这里可以添加订单详情跳转逻辑
|
||||
uni.navigateTo({
|
||||
url: `/pages-order/order/detail?orderId=${orderId}`,
|
||||
events: {
|
||||
refreshOrderList: (event) => {
|
||||
console.log("订单详情页面请求刷新订单列表", event);
|
||||
if (event.success) {
|
||||
queryList(1, 10);
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<Tabs @change="handleTabChange"/>
|
||||
|
||||
<!-- 选择入住、离店日期 0:是酒店 -->
|
||||
<view v-if="didSelectedTabItem && didSelectedTabItem.orderType === 0" class="bg-white border-box flex flex-items-center p-12">
|
||||
<view v-if="didSelectedTabItem && didSelectedTabItem.orderType == 0" class="bg-white border-box flex flex-items-center p-12">
|
||||
<view class="in flex flex-items-center">
|
||||
<text class="font-size-11 font-500 color-99A0AE mr-4">入住</text>
|
||||
<text class="font-size-14 font-500 color-171717">
|
||||
@@ -72,7 +72,7 @@ const queryList = async (pageNum = 1, pageSize = 10) => {
|
||||
current: pageNum,
|
||||
};
|
||||
|
||||
if (didSelectedTabItem.value.orderType === 0) {
|
||||
if (didSelectedTabItem.value.orderType == 0) {
|
||||
params.checkInDate = selectedDate.value.startDate;
|
||||
params.checkOutDate = selectedDate.value.endDate;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
}}</view>
|
||||
<view class="goods-price">
|
||||
<text class="currency">¥</text>
|
||||
<template v-if="goodsData.orderType === 0">
|
||||
<template v-if="goodsData.orderType == 0">
|
||||
<text class="price">
|
||||
{{ goodsData.calculatedTotalPrice || 0 }}
|
||||
</text>
|
||||
@@ -106,7 +106,7 @@
|
||||
<!-- 总价区域 -->
|
||||
<SumCard
|
||||
:referencePrice="
|
||||
goodsData.orderType === 0
|
||||
goodsData.orderType == 0
|
||||
? goodsData.calculatedTotalPrice
|
||||
: goodsData.specificationPrice
|
||||
"
|
||||
@@ -195,14 +195,14 @@ const isDeleting = ref(false); // 标志位,防止删除时watch冲突
|
||||
// 计算属性
|
||||
const totalPrice = computed(() => {
|
||||
const price =
|
||||
props.goodsData?.orderType === 0
|
||||
props.goodsData?.orderType == 0
|
||||
? props.goodsData?.calculatedTotalPrice
|
||||
: props.goodsData?.specificationPrice || 0;
|
||||
return (price * quantity.value).toFixed(0);
|
||||
});
|
||||
|
||||
const isHotelType = computed(() => {
|
||||
return props.goodsData?.orderType === COMMODITY_TYPES.HOTEL;
|
||||
return props.goodsData?.orderType == 0;
|
||||
});
|
||||
|
||||
const sectionTitle = computed(() => {
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
<!-- 日期选择区域 -->
|
||||
<DateSelector
|
||||
v-if="goodsData.orderType === 0"
|
||||
v-if="goodsData.orderType == 0"
|
||||
@showCalendar="showCalendar"
|
||||
:checkInDate="selectedDate.startDate"
|
||||
:checkOutDate="selectedDate.endDate"
|
||||
@@ -35,7 +35,7 @@
|
||||
/>
|
||||
|
||||
<!-- 商品套餐组件 -->
|
||||
<GoodPackage v-if="goodsData.orderType !== 0 && goodsData.commodityPackageConfig && goodsData.commodityPackageConfig.length > 0" :goodsData="goodsData" />
|
||||
<GoodPackage v-if="goodsData.orderType != 0 && goodsData.commodityPackageConfig && goodsData.commodityPackageConfig.length > 0" :goodsData="goodsData" />
|
||||
|
||||
<!-- 商品设施组件 -->
|
||||
<GoodFacility v-if="goodsData.commodityEquipment && goodsData.commodityEquipment.length > 0" :goodsData="goodsData" />
|
||||
@@ -128,7 +128,7 @@ const goodsInfo = async (params) => {
|
||||
calculatedTotalPrice.value = goodsData.value.specificationPrice || 0;
|
||||
|
||||
// 判断是酒店类型订单再获取获取商品日价格及库存
|
||||
if (goodsData.value.orderType === 0) {
|
||||
if (goodsData.value.orderType == 0) {
|
||||
configGoodsData();
|
||||
getGoodsDailyPrice({
|
||||
commodityId: goodsData.value.commodityId,
|
||||
@@ -189,7 +189,7 @@ const handleDateSelect = (data) => {
|
||||
selectedDateStore.setData(selectedDate.value);
|
||||
|
||||
// 根据商品类型计算价格
|
||||
if (goodsData.value.orderType === 0) {
|
||||
if (goodsData.value.orderType == 0) {
|
||||
// 酒店类型:计算dateRange总价格,排除最后一天(同一天除外)
|
||||
if (data.dateRange && Array.isArray(data.dateRange)) {
|
||||
// 获取默认价格作为回退值
|
||||
|
||||
Reference in New Issue
Block a user