完善页面

This commit is contained in:
wangxiaowei
2025-11-28 19:19:54 +08:00
parent 58211f2430
commit 67c8e8e016
43 changed files with 2722 additions and 1018 deletions

View File

@ -21,7 +21,7 @@
<view class="mx-30rpx">
<view class="mx30rpx">
<text class="text-[#303133] font-bold text-30rpx leading-42rpx">可用优惠券</text>
<text class="text-[#606266] font-400 text-28rpx leading-40rpx ml-24rpx">{{ couponList.no_use.length }}</text>
<text class="text-[#606266] font-400 text-28rpx leading-40rpx ml-24rpx">{{ couponList.use.length }}</text>
</view>
<view class="mt-28rpx radio">
<wd-radio-group v-model="checkedId" size="large" checked-color="#4C9F44">
@ -70,18 +70,18 @@
<view class="mt-28rpx radio">
<wd-radio-group v-model="checkedId" size="large" checked-color="#4C9F44">
<group-coupon
v-for="(item, index) in couponList"
v-for="(item, index) in groupCouponList"
:key="item.id"
:coupon="item"
canUse
:checked="item.id === checkedId"
:onCheck="Coupons.handleCheck"
:class="index !== couponList.length - 1 ? 'mb-20rpx' : ''"
:class="index !== groupCouponList.length - 1 ? 'mb-20rpx' : ''"
></group-coupon>
</wd-radio-group>
</view>
</view>
<view class="mx-30rpx">
<!-- <view class="mx-30rpx">
<view class="mx30rpx">
<text class="text-[#303133] font-bold text-30rpx leading-42rpx">不可用团购券</text>
<text class="text-[#606266] font-400 text-28rpx leading-40rpx ml-24rpx">2</text>
@ -99,7 +99,7 @@
></group-coupon>
</wd-radio-group>
</view>
</view>
</view> -->
</view>
</view>
</view>
@ -117,8 +117,10 @@
import Coupon from '@/components/coupon/Coupon.vue'
import GroupCoupon from '@/components/coupon/GroupCoupon.vue'
import { getCoupons } from '@/api/user'
import { getTeaRoomGroupCouponList } from '@/api/tea-room'
import type { IUserCouponListResult } from '@/api/types/user'
import { router } from '@/utils/tools'
import { CouponType } from '@/utils/coupon'
const couponType = ref<number>(2) // couponType 1:优惠券 2:团购券
@ -126,6 +128,7 @@
no_use: [],
use: []
})
const groupCouponList = ref<any>()
const checkedId = ref<number>(0)
const unCouponList = ref([
@ -133,17 +136,20 @@
{ id: 2, amount: 10, limit: 50, expire: '2024.08.25' }
])
const storeId = ref<number>(0) // 门店ID
const teaRoomId = ref<number>(0) // 包间ID
onLoad((args) => {
teaRoomId.value = args.id
storeId.value = args.storeId || 0
couponType.value = args.type // 1:优惠券 2:团购券
// 初始化优惠券数据
if (args.id && args.numbers && args.type == 1) {
// 获取到包间ID和预定了几个小时
Coupons.handleInitCoupon(args.id, args.numbers)
} else if (args.id && args.type == 2) {
Coupons.handleInitGroupCoupon(args.id, args.numbers)
}
})
@ -158,6 +164,14 @@
couponList.value = res
},
/**
* 初始化团购券列表
*/
handleInitGroupCoupon: async (id: number, numbers: number) => {
const res = await getTeaRoomGroupCouponList({store_id: storeId.value})
groupCouponList.value = res.list
},
/**
* 选择优惠券
* @param id 优惠券ID
@ -170,7 +184,12 @@
* 确认选择优惠券
*/
handleConfirmCoupon: () => {
const coupon = couponList.value.use.find(item => item.user_coupon_id === checkedId.value)
let coupon = null
if (couponType.value == CouponType.Discount) {
coupon = couponList.value.use.find(item => item.user_coupon_id === checkedId.value)
} else {
coupon = groupCouponList.value.find(item => item.id === checkedId.value)
}
uni.$emit('chooseCoupon', { coupon })
router.navigateBack()
}

View File

@ -177,7 +177,6 @@
<view class="text-[#909399] text-26rpx leading-36rpx mx-102rpx mb-40rpx">
<view v-if="orderStatus === OrderStatus.AfterSaleApply || orderStatus === OrderStatus.AfterSaleProcessing">请耐心等待我们会尽快处理您的请求</view>
<view v-if="orderStatus === OrderStatus.Refunded" class="text-center mt-14rpx">
<view class="text-40rpx text-[#303133] leading-56rpx">
<view v-if="orderType !== OrderSource.TeaSpecialist">退款成功128.00</view>
<!-- 茶艺师退款需要有退款详情 -->
@ -333,8 +332,8 @@
const orderStatus = ref<string>('') // 订单状态:待使用、退款等
onLoad((args) => {
// 这里暂时使用 OrderSource.Direct 这个,因为平台团购类型下面都是有共同的售后
title.value = OrderStatusTitle[OrderSource.Direct][args.orderStatus] || '订单详情'
// 这里暂时使用 OrderSource.Combo 这个,因为平台团购类型下面都是有共同的售后
title.value = OrderStatusTitle[OrderSource.Combo][args.orderStatus] || '订单详情'
orderType.value = args.orderType
orderStatus.value = args.orderStatus

View File

@ -15,7 +15,7 @@
</view>
<view class="text-[#909399] text-26rpx leading-36rpx mx-102rpx mb-40rpx">
<text v-if="orderStatus === OrderStatus.ToUse">请在2025.12.31()前使用</text>
<!-- <text v-if="orderStatus === OrderStatus.ToUse">请在2025.12.31()前使用</text> -->
<text v-if="orderStatus === OrderStatus.Used">感谢购买期待再次光临</text>
</view>
@ -162,7 +162,7 @@
<script lang="ts" setup>
import { OrderSource, OrderStatus, OrderStatusTitle } from '@/utils/order'
import { getTeaRoomPackageOrderDetail } from '@/api/tea-room'
import {toast} from '@/utils/toast'
const OSS = inject('OSS')
@ -172,7 +172,7 @@
const orderStatus = ref<string>('') // 订单状态:待使用、退款等
onLoad((args) => {
title.value = OrderStatusTitle[OrderSource.Direct][args.orderStatus] || '订单详情'
title.value = OrderStatusTitle[OrderSource.Combo][args.orderStatus] || '订单详情'
type.value = args.type
orderStatus.value = args.orderStatus

View File

@ -188,7 +188,7 @@
const orderStatus = ref<string>('') // 订单状态:待使用、退款等
onLoad((args) => {
title.value = OrderStatusTitle[OrderSource.Franchise][args.orderStatus] || '订单详情'
title.value = OrderStatusTitle[OrderSource.Combo][args.orderStatus] || '订单详情'
type.value = args.type
orderStatus.value = args.orderStatus

View File

@ -0,0 +1,285 @@
<route lang="jsonc" type="page">
{
"layout": "default",
"style": {
"navigationStyle": "custom"
}
}
</route>
<template>
<view class="pb-254rpx">
<view>
<navbar :title="title" custom-class='!bg-[#F6F7F8]'></navbar>
</view>
<view class="text-[#909399] text-26rpx leading-36rpx mx-102rpx mb-40rpx">
<!-- <text v-if="orderStatus === OrderStatus.ToUse">请在2025.12.31()前使用</text> -->
<text v-if="orderStatus === TeaRoomPackageOrderStatus.Used">感谢购买期待再次光临</text>
</view>
<view class="">
<!-- 待使用下显示 -->
<view class="mx-30rpx" v-if="orderStatus === TeaRoomPackageOrderStatus.ToUse">
<view class="bg-white rounded-16rpx p-30rpx">
<view class="flex items-center">
<view class="mr-30rpx">
<wd-img width="190rpx" height="190rpx" :src="order.group.img" mode="scaleToFill"></wd-img>
</view>
<view class="flex-1">
<view class="flex justify-between items-center" @click="OrderDetail.handleToCombo">
<view class="font-bold text-30rpx leading-42rpx text-[#303133] mr-10rpx w-362rpx line-1">{{ order.group.title }}</view>
<wd-icon name="chevron-right" size="32rpx"></wd-icon>
</view>
<view class="flex justify-between items-center text-26rpx leading-36rpx text-[#909399] mt-18rpx">
<view>{{ order.group.hour }}小时</view>
<view>x1</view>
</view>
<view class="text-[#606266] text-right mt-26rpx">
<text class="text-24rpx leading-34rpx mr-12rpx">实付</text>
<text class="tetx-32rpx leading-36rpx">{{ order.order_amount }}</text>
<wd-icon name="chevron-right" size="32rpx"></wd-icon>
</view>
</view>
</view>
<!-- 平台团购直营店待使用 -->
<view class="mt-30rpx font-500 leading-48rpx">
<!-- <view class="text-26rpx text-[#606266]">有效期2025.04.04-2025.12.31</view> -->
<view class="text-28rpx text-[#303133] mt-18rpx">
<text class="mr-20rpx">券码 1052 4258 5654 125</text>
<text class="text-[#4C9F44]">复制</text>
</view>
</view>
</view>
</view>
<!-- 已使用下显示 -->
<view class="mx-30rpx coupon-bg" v-if="orderStatus === TeaRoomPackageOrderStatus.Used">
<view class="flex items-center px-30rpx pt-30rpx pb-40rpx">
<view class="mr-30rpx">
<wd-img width="190rpx" height="190rpx" :src="`${OSS}images/home/home_image5.png`" mode="scaleToFill"></wd-img>
</view>
<view class="flex-1">
<view class="flex justify-between items-center" @click="OrderDetail.handleToRoom">
<view class="font-bold text-30rpx leading-42rpx text-[#303133] mr-10rpx line-1 w-300rpx">这个是包间的名称</view>
<wd-icon name="chevron-right" size="32rpx"></wd-icon>
<view class="text-26rpx leading-36rpx text-[#909399]">324</view>
</view>
<view class="flex justify-between items-center text-26rpx leading-36rpx text-[#909399] mt-18rpx">
<view>3小时</view>
<view>x1</view>
</view>
<view class="text-[#606266] text-right mt-26rpx">
<text class="text-24rpx leading-34rpx mr-12rpx">实付</text>
<text class="tetx-32rpx leading-36rpx">29.32</text>
<wd-icon name="chevron-right" size="32rpx"></wd-icon>
</view>
</view>
</view>
<view class="px-30rpx mt-28rpx pb-48rpx">
<view class="text-30rpx leading-42rpx text-[#303133]">预约信息</view>
<view class="font-500 text-26rpx leading-48rpx text-[#606266] mt-20rpx">
<view class="mb-20rpx">预约时间2025-03-18 09:00-12:00</view>
<view>预约时长3小时</view>
</view>
</view>
</view>
</view>
<!-- 适用门店 -->
<view class="">
<use-store :store="order.store"></use-store>
</view>
<!-- 订单信息 -->
<view class="bg-white rounded-16rpx px-30rpx py-34rpx mx-30rpx mt-20rpx">
<view class="text-[#303133] text-32rpx leading-44rpx">订单信息</view>
<view class="text-28rpx leading-40rpx text-[#606266] flex items-center justify-between mt-22rpx">
<view>订单编号</view>
<view>
<text>{{ order.order_sn }}</text>
<wd-divider vertical />
<text class="text-[#4C9F44]" @click="copy(order.order_sn)">复制</text>
</view>
</view>
<view class="text-28rpx leading-40rpx text-[#606266] flex items-center justify-between mt-22rpx">
<view>交易方式</view>
<view>{{ order.pay_way_title }}</view>
</view>
<view class="text-28rpx leading-40rpx text-[#606266] flex items-center justify-between mt-22rpx">
<view>创建时间</view>
<view>{{ order.dtime }}</view>
</view>
<view class="text-28rpx leading-40rpx text-[#606266] flex items-center justify-between mt-22rpx">
<view>付款时间</view>
<view>{{ order.pay_dtime }}</view>
</view>
</view>
<!-- 操作按钮 -->
<view class="w-full fixed bottom-0 left-0 right-0 bg-white h-152rpx">
<view class="mt-34rpx">
<!-- 待使用 -->
<view class="text-32rpx leading-44rpx flex items-center justify-center leading-90rpx text-center" v-if="orderStatus === TeaRoomPackageOrderStatus.ToUse">
<view class="w-330rpx h-90rpx bg-[#F6F7F8] rounded-8rpx text-[#303133] mr-30rpx" @click="OrderDetail.handleToRefund">申请退款</view>
<view class="w-330rpx h-90rpx bg-[#4C9F44] rounded-8rpx text-[#fff]" @click="OrderDetail.handleUsePackage">立即预定</view>
</view>
<!-- 已使用 -->
<view class="text-32rpx leading-44rpx flex items-center justify-center leading-90rpx text-center" v-if="orderStatus === TeaRoomPackageOrderStatus.Used">
<view class="w-630rpx h-90rpx bg-[#4C9F44] rounded-8rpx text-[#fff]">再次预定</view>
</view>
</view>
</view>
</view>
</template>
<script lang="ts" setup>
import { OrderSource, OrderStatus, OrderStatusTitle, TeaRoomPackageOrderStatusTextValue, TeaRoomPackageOrderStatus } from '@/utils/order'
import { getTeaRoomPackageOrderDetail } from '@/api/tea-room'
import type { ITeaRoomPackageOrderDetailsResult } from '@/api/types/tea-room'
import { toast } from '@/utils/toast'
import { handleToTeaRoomStoreHooks } from '@/hooks/useOrder'
import { router, copy } from '@/utils/tools'
import { ReserveServiceCategory } from '@/utils/order'
import UseStore from '@/components/UseStore.vue'
const OSS = inject('OSS')
const title = ref<string>('')
const type = ref<string>('') // 订单类型:团购、抖音等
// 订单
const orderId = ref<number>(0)
const orderStatus = ref<number>(0) // 订单状态:待使用、退款等
const order = ref<ITeaRoomPackageOrderDetailsResult>({
pay: 0,
pay_way_title: '',
order_amount: '',
order_sn: '',
order_status: 0,
dtime: '',
pay_dtime: '',
group: {
id: 0,
title: '',
img: '',
hour: '',
},
store: {
id: 0,
address: '',
latitude: '',
longitude: '',
name: '',
image: '',
contact_phone: '',
store_id: 0,
distance: '',
operation_type: 1
}
})
onLoad((args) => {
title.value = OrderStatusTitle[OrderSource.Combo][args.orderStatus] || '订单详情'
orderId.value = args.orderId
// 获取订单详情
OrderDetail.handleInit()
type.value = args.type
orderStatus.value = args.orderStatus
})
const OrderDetail = {
/**
* 获取订单详情
*/
handleInit: async () => {
const res = await getTeaRoomPackageOrderDetail({
id: orderId.value,
latitude: uni.getStorageSync('latitude'),
longitude: uni.getStorageSync('longitude')
})
order.value = res.details
// order.value = res.details
// console.log("🚀 ~ order.value :", order.value )
title.value = TeaRoomPackageOrderStatusTextValue[order.value.order_status].title || '订单详情'
orderStatus.value = order.value.order_status
},
/**
* 跳转到套餐详情
*/
handleToCombo: () => {
router.navigateTo(`/bundle/tea-room/detail?teaRoomId=${order.value.store.id}&id=${order.value.group.id}&type=${ReserveServiceCategory.GroupBuying}`)
},
/**
* 跳转到包间详情
*/
handleToRoom: () => {
handleToTeaRoomStoreHooks(order.value.store.id, order.value.store.store_id)
},
/**
* 处理导航逻辑
*/
handleLocation: () => {
uni.openLocation({
latitude: Number(order.value.store.latitude),
longitude: Number(order.value.store.longitude),
name: order.value.store.name,
address: order.value.store.address,
scale: 18
})
},
/**
* 处理拨打电话逻辑
*/
handleCallPhone: () => {
uni.makePhoneCall({
phoneNumber: order.value.store.contact_phone
})
},
/**
* 跳转到申请退款页面
*/
handleToRefund: () => {
router.navigateTo(`/bundle/order/after-sales/after-sales?orderId=${orderId.value}&type=${OrderSource.Combo}&orderStatus=${OrderStatus.AfterSaleApply}`)
},
/**
* 跳转到立即预定页面(选择茶室)
*/
handleToChooseTeaRoom: () => {
router.navigateTo(`/bundle/tea-room/choose-room`)
},
/**
* 使用套餐
*/
handleUsePackage: () => {
router.navigateTo(`/bundle/tea-room/choose-room?groupCouponId=${order.value.group.id}&teaRoomId=${order.value.store.id}`)
},
}
</script>
<style lang="scss">
page {
background-color: $cz-page-background;
}
.coupon-bg {
background-image: url(#{$OSS}images/order/order_image2.png);
background-repeat: no-repeat;
background-size: 100% 100%;
}
</style>

View File

@ -12,42 +12,32 @@
<navbar layoutLeft>
<template #left>
<view class="flex items-center ml-24rpx">
<view @click.stop="orderList.handleChangeMenu(item.type)" class="mr-28rpx" :class="item.type == currentType ? 'text-36rpx text-[#303133] leading-50rpx' : 'text-32rpx text-[#606266] leading-44rpx font-400'" v-for="(item, index) in menuList" :key="index">
<view @click.stop="OrderList.handleChangeMenu(item.type)" class="mr-28rpx" :class="item.type == currentType ? 'text-36rpx text-[#303133] leading-50rpx' : 'text-32rpx text-[#606266] leading-44rpx font-400'" v-for="(item, index) in menuList" :key="index">
{{ item.title }}
</view>
</view>
</template>
</navbar>
<view class="bg-white pb-20rpx">
<wd-search v-model="keywords" placeholder="搜索订单信息" hide-cancel placeholder-left custom-class="!h-72rpx"/>
<wd-search v-model="keywords" placeholder="搜索订单信息" hide-cancel placeholder-left custom-class="!h-72rpx" @search="OrderList.handleResetSearch()"/>
</view>
</view>
<view class="tabs">
<wd-tabs v-model="tab" swipeable slidable="always" @change="orderList.handleChangeTab" :lazy="false">
<wd-tab title="全部">
<view class="content mx-30rpx mt-34rpx">
<mescroll-body @init="mescrollInit" @down="downCallback" @up="orderList.upCallback">
<view class="mb-20rpx" v-for="(item, index) in 10" :key="index">
<combo-card></combo-card>
</view>
</mescroll-body>
</view>
</wd-tab>
<wd-tab title="待使用">
<view class="content mx-30rpx mt-34rpx">
<mescroll-body @init="mescrollInit" @down="downCallback" @up="orderList.upCallback">
</mescroll-body>
</view>
</wd-tab>
<wd-tab title="已使用">
<view class="content mx-30rpx mt-34rpx">
<mescroll-body @init="mescrollInit" @down="downCallback" @up="orderList.upCallback">
</mescroll-body>
</view>
</wd-tab>
<wd-tabs v-model="tab" swipeable slidable="always" @change="OrderList.handleChangeTabs" :lazy="false">
<wd-tab title="全部" :name="TeaRoomPackageOrderStatusText.All"></wd-tab>
<wd-tab title="待使用" :name="TeaRoomPackageOrderStatusText.ToUse"></wd-tab>
<wd-tab title="已使用" :name="TeaRoomPackageOrderStatusText.Used"></wd-tab>
</wd-tabs>
</view>
<view class="content mx-30rpx mt-34rpx">
<mescroll-body ref="mescrollItem" @init="mescrollInit" @down="downCallback" @up="OrderList.upCallback" :down="downOption" :up="upOption">
<view class="mb-20rpx" v-for="(item, index) in list" :key="index">
<combo-card :type="OrderSource.Combo" :order="item"></combo-card>
</view>
</mescroll-body>
</view>
</view>
</template>
@ -56,9 +46,22 @@
import ComboCard from '@/components/order/ComboCard.vue'
import { onPageScroll, onReachBottom } from '@dcloudio/uni-app'
import useMescroll from "@/uni_modules/mescroll-uni/hooks/useMescroll.js"
import { OrderSource } from '@/utils/order'
import { getTeaRoomPackageOrderList } from '@/api/tea-room'
import { TeaRoomPackageOrderStatusText, TeaRoomPackageOrderStatusValue } from '@/utils/order'
/* mescroll */
const { mescrollInit, downCallback } = useMescroll(onPageScroll, onReachBottom) // 调用mescroll的hook
// mescroll
const { mescrollInit, downCallback, getMescroll } = useMescroll(onPageScroll, onReachBottom) // 调用mescroll的hook
const downOption = {
auto: true
}
const upOption = {
auto: true,
textNoMore: '~ 已经到底啦 ~', //无更多数据的提示
}
const orderStatus = ref<string>('')
const list = ref<Array<any>>([]) // 茶室列表
const keywords = ref<string>('') // 搜索关键词
// 菜单
const currentType = ref<number>(1)
@ -73,65 +76,69 @@
}
])
// 店铺类型
// 搜索
const keywords = ref<string>('')
// tab
const tab = ref<number>(0)
const tab = ref<string>('all')
const orderList = {
// 上拉加载的回调: 其中num:当前页 从1开始, size:每页数据条数,默认10
onLoad(() => {
uni.$on('refreshPackageOrderList', () => {
list.value = []
getMescroll().resetUpScroll()
})
})
onUnload(() => {
uni.$off('refreshPackageOrderList')
})
const OrderList = {
upCallback: (mescroll) => {
// 需要留一下数据为空的时候显示的空数据图标内容
// list({
// page: mescroll.num,
// size: mescroll.size
// }).then((res: { list: Array<any>, totalPages: Number }) => {
// const curPageData = res.list || [] // 当前页数据
// if(mescroll.num == 1) goods.value = []; // 第一页需手动制空列表
// goods.value = goods.value.concat(curPageData); //追加新数据
// console.log("🚀 ~ goods:", goods)
// mescroll.endByPage(curPageData.length, res.totalPages); //必传参数(当前页的数据个数, 总页数)
// }).catch(() => {
// mescroll.endErr(); // 请求失败, 结束加载
// })
// apiGoods(mescroll.num, mescroll.size).then(res=>{
// const curPageData = res.list || [] // 当前页数据
// if(mescroll.num == 1) goods.value = []; // 第一页需手动制空列表
// goods.value = goods.value.concat(curPageData); //追加新数据
// //联网成功的回调,隐藏下拉刷新和上拉加载的状态;
// //mescroll会根据传的参数,自动判断列表如果无任何数据,则提示空;列表无下一页数据,则提示无更多数据;
// //方法一(推荐): 后台接口有返回列表的总页数 totalPage
// //mescroll.endByPage(curPageData.length, totalPage); //必传参数(当前页的数据个数, 总页数)
// //方法二(推荐): 后台接口有返回列表的总数据量 totalSize
// //mescroll.endBySize(curPageData.length, totalSize); //必传参数(当前页的数据个数, 总数据量)
// //方法三(推荐): 您有其他方式知道是否有下一页 hasNext
// //mescroll.endSuccess(curPageData.length, hasNext); //必传参数(当前页的数据个数, 是否有下一页true/false)
// //方法四 (不推荐),会存在一个小问题:比如列表共有20条数据,每页加载10条,共2页.如果只根据当前页的数据个数判断,则需翻到第三页才会知道无更多数据.
// mescroll.endSuccess(curPageData.length); // 请求成功, 结束加载
// }).catch(()=>{
mescroll.endErr(); // 请求失败, 结束加载
// })
const filter = {
page: mescroll.num,
size: mescroll.size,
operation_type: currentType.value,
use_status: orderStatus.value,
search: keywords.value
}
getTeaRoomPackageOrderList(filter).then((res) => {
const curPageData = res.list || [] // 当前页数据
if(mescroll.num == 1) list.value = [] // 第一页需手动制空列表
list.value = list.value.concat(curPageData) //追加新数据
mescroll.endSuccess(curPageData.length, Boolean(res.more))
}).catch(() => {
mescroll.endErr() // 请求失败, 结束加载
})
},
// 切换菜单
/**
* 切换菜单
*/
handleChangeMenu: (type: number) => {
currentType.value = type
console.log("🚀 ~ currentType.value:", currentType.value)
OrderList.handleResetSearch()
},
// 切换tab
handleChangeTab: (e: any) => {
tab.value = e.index
/**
* 切换订单状态
* @param e
*/
handleChangeTabs: (e: {index: number, name: string}) => {
tab.value = e.name
if (e.name === TeaRoomPackageOrderStatusText.ToUse) {
orderStatus.value = '0'
} else {
orderStatus.value = TeaRoomPackageOrderStatusValue[e.name] || ''
}
// 切换tab时,重置当前的mescroll
OrderList.handleResetSearch()
},
/**
* 内容搜索
*/
handleResetSearch: () => {
list.value = []
getMescroll().resetUpScroll();
}
}
</script>

View File

@ -1,5 +1,6 @@
<route lang="jsonc" type="page">
{
"needLogin": true,
"layout": "default",
"style": {
"navigationStyle": "custom"
@ -10,7 +11,7 @@
<template>
<view class="pb-254rpx">
<!-- 一键续订 -->
<wd-popup v-model="showRenewPopup" lock-scroll custom-style="border-radius: 32rpx 32rpx 0rpx 0rpx;" position="bottom">
<!-- <wd-popup v-model="showRenewPopup" lock-scroll custom-style="border-radius: 32rpx 32rpx 0rpx 0rpx;" position="bottom">
<view class="relative pb-26rpx">
<view class="absolute top-18rpx right-30rpx" @click="showRenewPopup = false">
<wd-img width="60rpx" height='60rpx' :src="`${OSS}icon/icon_close.png`"></wd-img>
@ -68,6 +69,53 @@
</view>
</view>
</view>
</wd-popup> -->
<wd-popup v-model="showRenewPopup" lock-scroll custom-style="border-radius: 32rpx 32rpx 0rpx 0rpx;" position="bottom">
<view class="relative pb-26rpx">
<view class="absolute top-18rpx right-30rpx" @click="showRenewPopup = false; ">
<wd-img width="60rpx" height='60rpx' :src="`${OSS}icon/icon_close.png`"></wd-img>
</view>
<view class="text-36rpx text-[#121212] leading-50rpx text-center pt-50rpx pb-40rpx">续订包间</view>
<!-- 预定时间 -->
<view class="bg-white rounded-16rpx py-26rpx px-30rpx mt-24rpx mx-30rpx" @click="showBookTimePopup = true;">
<view class="text-[#303133] text-32rpx leading-44rpx font-bold mb-24rpx">预定时间</view>
<view class="flex items-center justify-between">
<view class="text-[26rpx] text-[#606266] leading-36rpx">{{ sevenDay.minimum_time }}小时起订</view>
<view class="flex items-center">
<view class="text-[28rpx] text-[#909399] leading-40rpx w-430rpx line-1 text-right">
<template v-if="reserveTime.length > 0">
{{ reserveTime[0] }} {{ reserveTime[1].join(',') }}
</template>
<template v-else>
请选择
</template>
</view>
<view>
<wd-icon name="chevron-right" size="32rpx" color="#909399"></wd-icon>
</view>
</view>
</view>
</view>
<view class="mt-102rpx">
<wd-gap height="2rpx" bg-color="#EFF0F2"></wd-gap>
</view>
<view class="flex justify-between items-center mt-50rpx mx-60rpx">
<view class="flex items-center">
<view class="text-24rpx text-[#303133] leading-34rpx">合计:</view>
<view class="flex items-center h-56rpx mr-16rpx">
<price-format color="#FF5951" :first-size="40" :second-size="40" :subscript-size="28" :price="totalReserveMoney"></price-format>
<!-- <view class="ml-20rpx">
<price-format color="#909399" :first-size="26" :second-size="26" :subscript-size="26" :price="23.02" lineThrough></price-format>
</view> -->
</view>
</view>
<view>
<wd-button custom-class='!bg-[#4C9F44] !rounded-8rpx !h-70rpx' @click="OrderDetail.handleRenewReserve">立即预定</wd-button>
</view>
</view>
</view>
</wd-popup>
<!-- 续订成功 -->
@ -80,7 +128,7 @@
</view>
<view class="text-[#303133] text-36rpx leading-46rpx text-center mt-48rpx">包间续订成功</view>
<view class="text-[#9CA3AF] text-28rpx leading-44rpx mt-16rpx text-center">可以刷新页面查看预约时间</view>
<view class="w-630rpx h-90rpx leading-90rpx text-center bg-[#4C9F44] rounded-8rpx text-[#fff] mt-174rpx mx-auto">好的</view>
<view class="w-630rpx h-90rpx leading-90rpx text-center bg-[#4C9F44] rounded-8rpx text-[#fff] mt-174rpx mx-auto" @click="showRenewSuccessPopup = false">好的</view>
</view>
</wd-popup>
@ -142,49 +190,53 @@
</view>
</wd-popup>
<!-- 选择预定时间 -->
<booking-time v-model="showBookTimePopup" :day="sevenDay" @selectedTime="OrderDetail.handleChooseReserveTime"></booking-time>
<view>
<navbar :title="title" custom-class='!bg-[#F6F7F8]'></navbar>
</view>
<!-- 描述信息 -->
<view class="text-[#909399] text-26rpx leading-36rpx mb-40rpx mt-20rpx">
<view class="ml-80rpx" v-if="orderStatus === OrderStatus.Consuming || orderStatus === OrderStatus.Reserved">使用过程中有任何问题,请联系客服</view>
<view class="flex items-center justify-center" v-if="orderStatus === OrderStatus.Pending">
<view class="ml-80rpx" v-if="orderStatus === TeaRoomOrderStatus.Pay || orderStatus === TeaRoomOrderStatus.Consumption">使用过程中有任何问题请联系客服</view>
<view class="flex items-center justify-center" v-if="orderStatus === TeaRoomOrderStatus.Pending">
<view class="flex items-center mr-6rpx">
<wd-img width="36rpx" height="36rpx" :src="`${OSS}icon/icon_time.png`"/>
</view>
<view class="flex items-center text-26rpx leading-36rpx text-[#909399]">
<view>还剩</view>
<view class="mx-6rpx">
<wd-count-down :time="time" custom-class="!text-[#FF5951]" />
<wd-count-down :time="order.time1" custom-class="!text-[#FF5951]" />
</view>
<view>订单自动取消</view>
</view>
</view>
<view class="ml-80rpx" v-if="orderStatus === OrderStatus.Finished">品一口香茗,让生活慢下来从一杯好茶开始</view>
<view class="ml-80rpx" v-if="orderStatus === TeaRoomOrderStatus.Finished">品一口香茗让生活慢下来从一杯好茶开始</view>
</view>
<view class="mx-30rpx coupon-bg" >
<view class="flex items-center px-30rpx pt-30rpx pb-40rpx">
<view class="mr-30rpx">
<wd-img width="190rpx" height="190rpx" :src="`${OSS}images/home/home_image5.png`" mode="scaleToFill"></wd-img>
<wd-img width="190rpx" height="190rpx" :src="order.room_msg.img" mode="scaleToFill"></wd-img>
</view>
<view class="flex-1">
<view class="flex justify-between items-center">
<view class="font-bold text-30rpx leading-42rpx text-[#303133] mr-10rpx line-1 w-300rpx">
这个是包间的名称
<view class="flex justify-between items-center" @click="OrderDetail.handleToStore">
<view class="flex items-center font-bold text-30rpx leading-42rpx text-[#303133] mr-10rpx">
<view class="line-1 w-300rpx">
{{ order.room_msg.title }}
</view>
<wd-icon name="chevron-right" size="32rpx"></wd-icon>
</view>
<view class="text-26rpx leading-36rpx text-[#909399]">¥324</view>
<view class="text-26rpx leading-36rpx text-[#909399]">{{ order.room_all_price }}</view>
</view>
<view class="flex justify-between items-center text-26rpx leading-36rpx text-[#909399] mt-18rpx">
<view>3小时</view>
<view>x1</view>
{{ order.room_price }}/小时
</view>
<!-- 等待付款不显示实付金额 -->
<view class="text-[#606266] text-right mt-26rpx" v-if="orderStatus !== OrderStatus.Pending">
<view class="text-[#606266] text-right mt-26rpx" v-if="orderStatus !== TeaRoomOrderStatus.Pending">
<text class="text-24rpx leading-34rpx mr-12rpx">实付</text>
<text class="tetx-32rpx leading-36rpx">¥29.32</text>
<text class="tetx-32rpx leading-36rpx">{{ order.order_amount }}</text>
<wd-icon name="chevron-right" size="32rpx"></wd-icon>
</view>
</view>
@ -193,13 +245,13 @@
<view class="mt-28rpx pb-36rpx">
<view class="text-30rpx leading-42rpx text-[#303133] px-30rpx">预约信息</view>
<view class="font-500 text-26rpx leading-48rpx text-[#606266] mt-20rpx">
<view class="mb-20rpx px-30rpx">预约时间2025-03-18 09:00-12:00</view>
<view class="mb-20rpx px-30rpx">预约时间{{ order.day_time }} {{ order.renew_dtime.start_time || order.start_time }}-{{ order.renew_dtime.end_time || order.end_time }}</view>
<view class="flex justify-between items-center pl-30rpx" >
<view>预约时长3小时</view>
<view>预约时长{{ order.hours }}小时</view>
<!-- 已预约和消费中显示一键续订 -->
<view v-if="orderStatus === OrderStatus.Reserved || orderStatus === OrderStatus.Consuming"
<view v-if="orderStatus === TeaRoomOrderStatus.Pay || orderStatus === TeaRoomOrderStatus.Consumption"
class="bg-[#4C9F44] rounded-[100rpx_0rpx_0rpx_100rpx] font-bold text-28rpx leading-40rpx text-[#fff] w-170rpx h-56rpx flex justify-center items-center"
@click="showRenewPopup = true">
@click="showRenewPopup = true; showBookTimePopup = true">
一键续订
</view>
</view>
@ -208,7 +260,7 @@
</view>
<!-- 已预约和消费中显示开门锁 -->
<view class="bg-white rounded-16rpx mx-30rpx mt-20rpx" v-if="orderStatus === OrderStatus.Reserved || orderStatus === OrderStatus.Consuming">
<view class="bg-white rounded-16rpx mx-30rpx mt-20rpx" v-if="orderStatus === TeaRoomOrderStatus.Pay || orderStatus === TeaRoomOrderStatus.Consumption">
<view class="pt-32rpx text-[#303133] text-32rpx leading-44rpx px-30rpx">开门锁</view>
<view class="mt-20rpx">
<wd-gap height="2rpx" bg-color="#F6F7F9"></wd-gap>
@ -241,24 +293,24 @@
<view class="pt-32rpx text-[#303133] text-32rpx leading-44rpx">适用门店</view>
<view class="mt-26rpx flex items-center">
<view class="mr-24rpx">
<wd-img width="170rpx" height="170rpx" :src="`${OSS}images/home/home_image5.png`"></wd-img>
<wd-img width="170rpx" height="170rpx" :src="order.store_msg.image"></wd-img>
</view>
<view class="flex-1 flex justify-between items-center relative">
<view class="">
<view class="text-[#303133] text-30rpx leading-40rpx line-2">这是商家的名称这是</view>
<view class="mt-26rpx text-[#909399] text-24rpx leading-34rpx">距您9km</view>
<view class="text-[#303133] text-30rpx leading-40rpx line-2" @click="handleToTeaRoomStoreHooks(order.store_msg.id, order.store_msg.operation_type)">{{ order.store_msg.name }}</view>
<view class="mt-26rpx text-[#909399] text-24rpx leading-34rpx">距您{{ order.distance }}km</view>
<view class="flex items-center mt-14rpx">
<view class="mr-8rpx">
<wd-img width="28rpx" height="28rpx" :src="`${OSS}icon/icon_location.png`"/>
</view>
<view class="ml-2rpx text-26rpx text-[#606266] line-1 w-300rpx">青浦区仓路478号青浦区仓路478号青浦区仓路478号青浦区仓路478号青浦区仓路478号青浦区仓路478号</view>
<view class="ml-2rpx text-26rpx text-[#606266] line-1 w-300rpx">{{ order.store_msg.address }}</view>
</view>
</view>
<view class="flex absolute top-1/2 right-0 -translate-y-1/2">
<view class="text-center mr-20rpx" >
<view class="text-center mr-20rpx" @click="OrderDetail.handleLocation">
<wd-img width="64rpx" height="64rpx" :src="`${OSS}icon/icon_nav.png`"/>
</view>
<view class="text-center" >
<view class="text-center" @click="OrderDetail.handleCallPhone">
<wd-img width="64rpx" height="64rpx" :src="`${OSS}icon/icon_phone.png`"/>
</view>
</view>
@ -266,64 +318,46 @@
</view>
</view>
<!-- 支付方式 -->
<view class="bg-white rounded-16rpx px-30rpx py-34rpx mx-30rpx mt-20rpx" v-if="orderStatus === OrderStatus.Pending">
<wd-radio-group v-model="pay" shape="dot" checked-color="#4C9F44">
<block v-for="(item, index) in PayList" :key="index">
<view
class="flex justify-between items-center"
:class="index !== PayList.length - 1 ? 'mb-40rpx' : ''"
>
<view class="flex items-center">
<wd-img width="50rpx" height="50rpx" :src="`${OSS}${item.icon}`"></wd-img>
<view class="ml-20rpx text-30rpx text-[#303133] leading-42rpx">{{ item.name }}</view>
</view>
<view class="flex items-center">
<wd-radio :value="item.value">
<view class="text-[#303133] text-26rpx leading-36rpx mr-20rpx" v-if="item.type !== PayCategory.WeChatPay">可用202.22</view>
</wd-radio>
</view>
</view>
</block>
</wd-radio-group>
</view>
<!-- 订单信息 -->
<view class="bg-white rounded-16rpx px-30rpx py-34rpx mx-30rpx mt-20rpx">
<view class="text-[#303133] text-32rpx leading-44rpx">订单信息</view>
<view class="text-28rpx leading-40rpx text-[#606266] flex items-center justify-between mt-22rpx">
<view>订单编号</view>
<view>
<text>7327328627526903</text>
<text>{{ order.order_sn }}</text>
<wd-divider vertical />
<text class="text-[#4C9F44]">复制</text>
<text class="text-[#4C9F44]" @click="copy(order.order_sn)">复制</text>
</view>
</view>
<view class="text-28rpx leading-40rpx text-[#606266] flex items-center justify-between mt-22rpx" v-if="orderStatus !== OrderStatus.Pending">
<view class="text-28rpx leading-40rpx text-[#606266] flex items-center justify-between mt-22rpx" v-if="orderStatus != TeaRoomOrderStatus.Pending && order.pay_way">
<view>交易方式</view>
<view>微信支付</view>
<view>{{ order.pay_way_title }}</view>
</view>
<view class="text-28rpx leading-40rpx text-[#606266] flex items-center justify-between mt-22rpx">
<view>创建时间</view>
<view>2019-05-16 12:20:26</view>
<view>{{ order.dtime }}</view>
</view>
<view class="text-28rpx leading-40rpx text-[#606266] flex items-center justify-between mt-22rpx" v-if="orderStatus !== OrderStatus.Pending">
<view class="text-28rpx leading-40rpx text-[#606266] flex items-center justify-between mt-22rpx" v-if="orderStatus != TeaRoomOrderStatus.Pending && orderStatus != TeaRoomOrderStatus.Cancelled && order.pay_way_title">
<view>付款时间</view>
<view>2019-05-16 13:20:26</view>
<view>{{ order.update_dtime }}</view>
</view>
</view>
<!-- 操作按钮 -->
<view class="w-full fixed bottom-0 left-0 right-0 bg-white h-152rpx">
<!-- 已预约 -->
<view
class="text-32rpx leading-44rpx flex items-center justify-center leading-90rpx text-center mt-34rpx"
v-if="orderStatus === OrderStatus.Reserved || orderStatus === OrderStatus.Consuming">
<view class="w-630rpx h-90rpx bg-[#4C9F44] rounded-8rpx text-[#fff]">分享房间给朋友</view>
<view class="flex items-center justify-center text-32rpx leading-44rpx leading-90rpx text-center !mt-34rpx" v-if="orderStatus == TeaRoomOrderStatus.Pay || orderStatus == TeaRoomOrderStatus.Consumption">
<wd-button custom-class="!text-32rpx !w-630rpx !h-90rpx !bg-[#4C9F44] !rounded-8rpx !text-[#fff]" open-type="share">分享房间给朋友</wd-button>
</view>
<!-- 待付款 -->
<view class="flex items-center justify-between mx-58rpx mt-34rpx" v-if="orderStatus === OrderStatus.Pending">
<view class="flex items-center justify-between mx-58rpx mt-34rpx" v-if="orderStatus == TeaRoomOrderStatus.Pending">
<view class="flex items-center">
<view class="text-28rpx leading-40rpx text-[#606266] mr-16rpx" @click="OrderDetail.handleCancelOrder">取消订单</view>
</view>
<view class="w-360rpx h-90rpx leading-90rpx text-center bg-[#4C9F44] rounded-8rpx text-[#fff]" @click="OrderDetail.handleToPay">立即支付{{ order.order_amount }}</view>
</view>
<!-- <view class="flex items-center justify-between mx-58rpx mt-34rpx" v-if="orderStatus === TeaRoomOrderStatus.Pending">
<view class="flex items-center">
<view class="text-28rpx leading-40rpx text-[#606266] mr-16rpx" @click="OrderDetail.handleCancelOrder">取消</view>
<view class="flex items-center">
@ -337,11 +371,11 @@
</view>
</view>
<view class="w-178rpx h-90rpx leading-90rpx text-center bg-[#4C9F44] rounded-8rpx text-[#fff]">立即预定</view>
</view>
</view> -->
<!-- 交易完成 -->
<view class="text-32rpx leading-44rpx flex items-center justify-center leading-90rpx text-center mt-34rpx"
v-if="orderStatus === OrderStatus.Finished || orderStatus === OrderStatus.Cancelled">
<view @click="OrderDetail.handleAgainReserve" class="text-32rpx leading-44rpx flex items-center justify-center leading-90rpx text-center mt-34rpx"
v-if="orderStatus === TeaRoomOrderStatus.Finished || orderStatus === TeaRoomOrderStatus.Cancelled">
<view class="w-630rpx h-90rpx bg-[#4C9F44] rounded-8rpx text-[#fff]">再次预定</view>
</view>
</view>
@ -349,14 +383,21 @@
</template>
<script lang="ts" setup>
import { OrderStatus, OrderSource, OrderStatusTitle } from '@/utils/order'
import { TeaRoomOrderStatusTextValue, TeaRoomOrderStatus } from '@/utils/order'
import { useMessage } from 'wot-design-uni'
import {toast} from '@/utils/toast'
import { PayList, PayCategory, PayValue } from '@/utils/pay'
import { getTeaRoomOrderDetail } from '@/api/tea-room'
import { handleTRCancelOrderHooks, handleTRToPayHooks } from '@/hooks/useOrder'
import type { ITeaSpecialistOrderDetailsResult } from '@/api/types/tea'
import { router } from '@/utils/tools'
import { ReserveServiceCategory, OrderType } from '@/utils/order'
import type { ITeaSpecialistFuture7DaysResult } from '@/api/types/tea'
import { getNext7Days, renewTeaRoomOrder } from '@/api/tea-room'
import { toTimes, copy } from '@/utils/tools'
const OSS = inject('OSS')
const title = ref<string>('')
const orderStatus = ref<string>('') // 订单状态:待使用、退款等
const orderStatus = ref<number>(0) // 订单状态:待使用、退款等
// 续订包间
const showRenewPopup = ref<boolean>(false)
@ -389,6 +430,14 @@
const showRenewSuccessPopup = ref<boolean>(false)
// 选择预定时间
const showBookTimePopup = ref<boolean>(false)
const sevenDay = reactive<ITeaSpecialistFuture7DaysResult>({
minimum_time: 0,
time: []
})
const reserveTime = ref<Array<any>>([])
// 订单倒计时取消
const time = ref<number>(30 * 60 * 60 * 1000)
@ -398,15 +447,106 @@
// 费用明细
const showCostPopup = ref<boolean>(false) // 是否显示退款详情弹出框
onLoad((args) => {
title.value = OrderStatusTitle[OrderSource.TeaRoom][args.orderStatus] || '订单详情'
console.log("🚀 ~ title.value :", title.value )
// 订单
const orderId = ref<number>(0)
const order = ref<ITeaSpecialistOrderDetailsResult>({
order_amount: '',
order_sn: '',
store_id: 0,
room_msg: {
id: 0,
price: 0,
img: '',
title: '',
},
store_msg: {
id: 0,
address: '',
name: '',
operation_type: 1,
image: '',
latitude: '',
longitude: '',
contact_phone: ''
},
time1: 0,
order_status: 0,
room_all_price: 0,
room_price: 0,
day_time: '',
start_time: '',
end_time: '',
hours: 0,
distance: 0,
pay_way: 0,
pay_way_title: '',
dtime: '',
update_dtime: '',
renew_price: 0,
renew_dtime: {
start_time: '',
end_time: '',
renew_price: 0
}
})
orderStatus.value = args.orderStatus
// 一键续订的金额
const totalReserveMoney = ref<number>(0)
onLoad(async (args) => {
orderId.value = args.orderId
// 获取订单详情
OrderDetail.handleInit()
// 预定时间
const next7 = await getNext7Days()
Object.assign(sevenDay, next7)
})
onUnload(() => {
uni.$off('refreshOrderDetail')
})
onShareAppMessage(async (e) => {
if (e.from === 'button') {
return {
title: `我在${order.value.store_msg.name}预定了${order.value.room_msg.title},一起来吧!`,
path: `/pages/share/tea-room/share-order-detail?orderId=${orderId.value}`,
}
}
})
const OrderDetail = {
// 取消订单
/**
* 获取订单详情
*/
handleInit: async () => {
const res = await getTeaRoomOrderDetail({
id: orderId.value,
latitude: uni.getStorageSync('latitude'),
longitude: uni.getStorageSync('longitude')
})
order.value = res.details
console.log("🚀 ~ order.value :", order.value )
title.value = TeaRoomOrderStatusTextValue[order.value.order_status].title || '订单详情'
orderStatus.value = order.value.order_status
},
/**
* 支付订单
*/
handleToPay: () => {
uni.$on('refreshOrderDetail', () => {
OrderDetail.handleInit()
uni.$off('refreshOrderDetail')
})
handleTRToPayHooks(orderId.value, order.value.store_msg.name, order.value.store_msg.id)
},
/**
* 获取订单详情
*/
handleCancelOrder: () => {
message.confirm({
title: '确定取消订单?',
@ -420,12 +560,113 @@
customClass: '!bg-[#4C9F44] !text-[#fff] !text-32rpx !leading-44rpx !rounded-8rpx',
}
}).then((res) => {
// 点击确认按钮回调事件
if (res.action == 'confirm') {
// 点击确认按钮回调事件
uni.$on('refreshOrderDetail', () => {
OrderDetail.handleInit()
uni.$off('refreshOrderDetail')
})
handleTRCancelOrderHooks(orderId.value)
}
toast.info('订单取消成功')
}).catch(() => {
// 点击取消按钮回调事件
})
}
},
/**
* 再次预定
*/
handleAgainReserve: () => {
router.navigateTo(
`/bundle/tea-room/detail?storeId=${order.value.store_msg.id}&roomId=${order.value.room_msg.id}&type=${ReserveServiceCategory.ReserveRoom}&price=${order.value.room_msg.price}`
)
},
/**
* 选中预定时间
*/
handleChooseReserveTime: (params: any) => {
reserveTime.value = params
// 一键续订的金额
totalReserveMoney.value = Number(toTimes(params[3], order.value.room_price))
},
/**
* 确认一键续订
*/
handleRenewReserve: async () => {
uni.showLoading({ title: '加载中...' })
try {
await renewTeaRoomOrder({
id: orderId.value,
start_time: reserveTime.value[2][0],
end_time: reserveTime.value[2][reserveTime.value[2].length - 1],
renew_hour: reserveTime.value[3],
})
uni.$on('payment', params => {
uni.$off("payment")
if (params.result) {
OrderDetail.handleInit()
showRenewSuccessPopup.value = true
} else {
message.alert({
title: '提示',
msg: '您已取消续订',
confirmButtonText: '确定',
confirmButtonProps: {
customClass: '!bg-[#4C9F44] !text-[#fff] !text-32rpx !leading-44rpx !rounded-8rpx',
}
})
}
})
uni.hideLoading()
showRenewPopup.value = false
router.navigateTo(
`/pages/cashier/cashier?from=${OrderType.TeaRoomOrder}&renew=renewTeaRoomOrder&orderId=${orderId.value}&teaRoomName=${order.value.store_msg.name}&storeId=${order.value.store_msg.id}`
)
} catch (err) {
uni.hideLoading()
toast.info('续订失败')
return false
}
},
/**
* 跳转到对对应室的详情页
*/
handleToStore: () => {
handleToTeaRoomStoreHooks(order.value.store_id, order.value.store_msg.operation_type)
},
/**
* 处理导航逻辑
*/
handleLocation: () => {
uni.openLocation({
latitude: Number(order.value.store_msg.latitude),
longitude: Number(order.value.store_msg.longitude),
name: order.value.store_msg.name,
address: order.value.store_msg.address,
scale: 18
})
},
/**
* 处理拨打电话逻辑
*/
handleCallPhone: () => {
uni.makePhoneCall({
phoneNumber: order.value.store_msg.contact_phone
})
},
}
</script>

View File

@ -9,14 +9,14 @@
<template>
<view class="">
<view class="order-list sticky top-0 left-0 z-50 bg-[#F6F7F8] pb-10rpx">
<wd-navbar safeAreaInsetTop custom-class='!bg-[#F6F7F8]' :bordered="false" placeholder @click-left="router.navigateBack">
<wd-navbar safeAreaInsetTop custom-class='!bg-[#F6F7F8]' :bordered="false" placeholder>
<template #left>
<view class="h-48rpx flex items-center">
<view class="mt-4rpx">
<view class="mt-4rpx" @click="router.navigateBack()">
<wd-icon name="thin-arrow-left" size="30rpx"></wd-icon>
</view>
<view class="search-box">
<wd-search v-model="keywords" hide-cancel placeholder-left light placeholder="搜索茶室订单"></wd-search>
<wd-search v-model="keywords" hide-cancel placeholder-left light placeholder="搜索茶室订单" @search="OrderList.handleSearch()"></wd-search>
</view>
</view>
</template>
@ -106,7 +106,7 @@
})
},
/**
/**
* 切换订单状态
* @param e
*/
@ -121,6 +121,14 @@
// 切换tab时,重置当前的mescroll
list.value = []
getMescroll().resetUpScroll();
},
/**
* 内容搜索
*/
handleSearch: () => {
list.value = []
getMescroll().resetUpScroll();
}
}
</script>

View File

@ -431,7 +431,7 @@
const selectedRenewTea = ref<Array<any>>([]) // 选择的续订时间
const showRenewSuccessPopup = ref<boolean>(false)
// 订单ID
// 订单
const orderId = ref<number>(0)
const order = ref<any>({})
@ -440,6 +440,10 @@
// 获取订单详情
OrderDetail.handleInit()
})
onUnload(() => {
uni.$off('refreshOrderDetail')
})
const OrderDetail = {
// 获取订单详情

View File

@ -37,7 +37,7 @@
<!-- 全部 -->
<mescroll-body ref="mescrollItem0" @init="mescrollInit" @down="downCallback" @up="OrderList.upCallback" :down="downOption" :up="upOption">
<view class="mb-20rpx" v-for="(item, index) in list" :key="index">
<combo-card :type="OrderSource.TeaSpecialist" :order="item"></combo-card>
<combo-card :type="OrderSource.TeaRoom" :order="item"></combo-card>
</view>
</mescroll-body>

View File

@ -1,5 +1,6 @@
<route lang="jsonc" type="page">
{
"needLogin": true,
"layout": "default",
"style": {
"navigationStyle": "custom"
@ -9,65 +10,6 @@
<template>
<view class="">
<view class="">
<navbar title="个人信息" custom-class='!bg-[#F6F7F8]'></navbar>
</view>
<view class="bg-white rounded-16rpx mt-20rpx mx-30rpx px-30rpx py-32rpx">
<!-- 头像 -->
<view class="flex justify-between items-center mb-54rpx">
<view class="font-400 text-[#303133] text-30rpx leading-42rpx">头像</view>
<view class="flex justify-end">
<view class="flex items-center">
<view class="mr-10rpx">
<wd-upload
:file-list="fileList"
:limit="1"
image-mode="scaleToFill"
:action="action">
<wd-img width="64rpx" height="64rpx" :src="`${OSS}icon/icon_avatar.png`" mode="aspectFill" round />
</wd-upload>
</view>
<wd-icon name="arrow-right" size="32rpx" color="#C0C4CC" />
</view>
</view>
</view>
<!-- 昵称 -->
<view class="flex justify-between items-center mb-54rpx" @click="showEditNicknamePopup = true">
<view class="font-400 text-[#303133] text-30rpx leading-42rpx">昵称</view>
<view class="flex justify-end">
<view class="flex items-center">
<view class="font-400 text-[#303133] text-30rpx leading-42rpx">
王小伟
</view>
<view>
<wd-icon name="arrow-right" size="32rpx" color="#C0C4CC" />
</view>
</view>
</view>
</view>
<!-- 修改手机号 -->
<view class="flex justify-between items-center" @click="profile.handleToEditMobile">
<view class="font-400 text-[#303133] text-30rpx leading-42rpx">修改手机号</view>
<view class="flex justify-end">
<view class="flex items-center">
<view class="font-400 text-[#303133] text-30rpx leading-42rpx">
+86 155****5456
</view>
<view>
<wd-icon name="arrow-right" size="32rpx" color="#C0C4CC" />
</view>
</view>
</view>
</view>
</view>
<view class="bg-white rounded-16rpx mt-144rpx mx-30rpx px-30rpx py-32rpx text-center font-400 text-[#303133] text-30rpx leading-42rpx" @click="showLogoutPopup = true">
退出登录
</view>
<!-- 修改昵称 -->
<wd-popup v-model="showEditNicknamePopup" lock-scroll custom-style="border-radius: 32rpx 32rpx 0rpx 0rpx;" position="bottom">
<view class="relative pb-56rpx">
@ -96,7 +38,7 @@
<view class="mt-22rpx text-26rpx leading-36rpx text-[#909399] mx-48rpx">昵称限制1-10字符一个汉字为一个字符</view>
<view class="mx-48rpx h-90rpx leading-90rpx rounded-8rpx text-center mt-112rpx text-[#fff]" :class="nickname ? 'bg-[#4C9F44]' : 'bg-[#A5CFA1]'" @click="profile.handleSaveNickname">保存</view>
<view class="mx-48rpx h-90rpx leading-90rpx rounded-8rpx text-center mt-112rpx text-[#fff]" :class="nickname ? 'bg-[#4C9F44]' : 'bg-[#A5CFA1]'" @click="Profile.handleSaveNickname">保存</view>
</view>
</wd-popup>
@ -105,7 +47,7 @@
<view class="relative pt-54rpx pb-74rpx">
<view class="text-[#303133] text-36rpx leading-46rpx text-center">您确定要退出该账号吗?</view>
<view class="mt-76rpx">
<view class="bg-[#4C9F44] h-90rpx leading-90rpx mx-60rpx rounded-8rpx text-center text-[#fff]" @click="profile.handleLogout">
<view class="bg-[#4C9F44] h-90rpx leading-90rpx mx-60rpx rounded-8rpx text-center text-[#fff]" @click="Profile.handleLogout">
退出登录
</view>
@ -116,12 +58,75 @@
</view>
</view>
</wd-popup>
<view>
<navbar title="个人信息" custom-class='!bg-[#F6F7F8]'></navbar>
</view>
<view class="bg-white rounded-16rpx mt-20rpx mx-30rpx px-30rpx py-32rpx">
<!-- 头像 -->
<view class="flex justify-between items-center mb-54rpx">
<view class="font-400 text-[#303133] text-30rpx leading-42rpx">头像</view>
<view class="flex justify-end">
<view class="flex items-center">
<view class="mr-10rpx">
<wd-upload
:file-list="fileList"
:limit="1"
image-mode="scaleToFill"
:action="action">
<wd-img width="64rpx" height="64rpx" :src="user.avatar" mode="aspectFill" round />
</wd-upload>
</view>
<wd-icon name="arrow-right" size="32rpx" color="#C0C4CC" />
</view>
</view>
</view>
<!-- 昵称 -->
<view class="flex justify-between items-center mb-54rpx" @click="showEditNicknamePopup = true">
<view class="font-400 text-[#303133] text-30rpx leading-42rpx">昵称</view>
<view class="flex justify-end">
<view class="flex items-center">
<view class="font-400 text-[#303133] text-30rpx leading-42rpx">
{{ user.nickname }}
</view>
<view>
<wd-icon name="arrow-right" size="32rpx" color="#C0C4CC" />
</view>
</view>
</view>
</view>
<!-- 修改手机号 -->
<view class="flex justify-between items-center" @click="Profile.handleToEditMobile">
<view class="font-400 text-[#303133] text-30rpx leading-42rpx">修改手机号</view>
<view class="flex justify-end">
<view class="flex items-center">
<view class="font-400 text-[#303133] text-30rpx leading-42rpx">
+86 {{ maskedMobile }}
</view>
<view>
<wd-icon name="arrow-right" size="32rpx" color="#C0C4CC" />
</view>
</view>
</view>
</view>
</view>
<view class="bg-white rounded-16rpx mt-144rpx mx-30rpx px-30rpx py-32rpx text-center font-400 text-[#303133] text-30rpx leading-42rpx" @click="showLogoutPopup = true">
退出登录
</view>
</view>
</template>
<script lang="ts" setup>
import {toast} from '@/utils/toast'
import { getUserInfo } from '@/api/user'
import type { IUserResult } from '@/api/types/user'
import { useUserStore } from '@/store'
import { router } from '@/utils/tools'
const OSS = inject('OSS')
const showLogoutPopup = ref<boolean>(false) // 是否显示退出登录弹出框
@ -133,14 +138,52 @@
// 修改昵称
const showEditNicknamePopup = ref<boolean>(false) // 是否显示退款详情弹出框
const nickname = ref<string>('') // 昵称
// 用户信息相关
const user = ref<IUserResult>({
id: 0,
sn: 0,
sex: "未知",
account: "",
nickname: "",
real_name: "",
avatar: "",
collect_count: 0,
coupon_count: 0,
create_time: "",
has_auth: false,
has_password: false,
member: 0,
mobile: "",
user_money: "0.00",
version: ""
})
onLoad(() => {
Profile.handleInit()
})
const profile = {
// 图片选择/删除
const Profile = {
/**
* 初始化用户信息
*/
handleInit: () => {
getUserInfo().then(res => {
user.value = res
})
},
/**
* 图片选择/删除
* @param e
*/
handleChange: (e: any) => {
console.log("🚀 ~ e:", e)
},
// 保存昵称
/**
* 保存昵称
*/
handleSaveNickname: () => {
if (!nickname.value) {
toast.info('请输入昵称')
@ -150,18 +193,36 @@
toast.info('昵称修改成功')
},
// 修改手机号
/**
* 修改手机号
*/
handleToEditMobile: () => {
uni.navigateTo({
url: '/pages/login/mobile?type=edit&userId=123' // userId仅做测试使用实际请传真实用户ID
})
},
// 退出
/**
* 退出
*/
handleLogout: () => {
const userStore = useUserStore()
userStore.logout()
if (!userStore.isLoggedIn) {
toast.info('退出成功')
router.reLaunch('/pages/my/my')
}
}
}
/**
* 掩码处理手机号
*/
const maskedMobile = computed(() => {
if (!user.value.mobile) return ''
// 只处理11位手机号
return user.value.mobile.replace(/^(\d{3})\d{4}(\d{4})$/, '$1****$2')
})
</script>
<style lang="scss">

View File

@ -7,6 +7,55 @@
}</route>
<template>
<view class="pb-200rpx">
<!-- 费用明细 -->
<wd-popup v-model="showCostPopup" lock-scroll custom-style="border-radius: 32rpx 32rpx 0rpx 0rpx;" @close="showCostPopup = false" position="bottom">
<view class='bg-[#FBFBFB] py-40rpx realtive'>
<view class="absolute top-18rpx right-30rpx" @click="showCostPopup = false">
<wd-img width="60rpx" height='60rpx' :src="`${OSS}icon/icon_close.png`"></wd-img>
</view>
<view class="text-36rpx text-[#121212] leading-50rpx text-center">费用明细</view>
<view class="mx-30rpx bg-white rounded-16rpx px-30rpx pt-40rpx mt-40rpx pb-30rpx">
<view class="flex justify-between items-center text-30rpx text-[#303133] leading-42rpx">
<view>茶室费</view>
<view>{{ bill.service.total }}</view>
</view>
<view class="flex justify-between items-center text-24rpx text-[#909399] leading-34rpx mt-16rpx">
<view>茶室费{{ teaRoomPrice }}/小时</view>
<view>x{{ bill.service.num }}</view>
</view>
<view class="mt-52rpx">
<view class="flex justify-between items-center text-30rpx text-[#303133] leading-42rpx">
<view>优惠</view>
<view class="text-[#4C9F44]">-{{ bill.totalDiscount }}</view>
</view>
<view class="flex justify-between items-center text-24rpx text-[#909399] leading-34rpx mt-16rpx">
<view>优惠券</view>
<view>-{{ bill.coupon }}</view>
</view>
<view class="flex justify-between items-center text-24rpx text-[#909399] leading-34rpx mt-16rpx">
<view>会员八折</view>
<view>-{{ bill.discount }}</view>
</view>
</view>
<view class="my-30rpx">
<wd-gap height="2rpx" bgColor='#F6F7F9'></wd-gap>
</view>
<view class="flex justify-between items-center text-30rpx text-[#303133] leading-42rpx">
<view>实付金额</view>
<view>{{ bill.total }}</view>
</view>
</view>
</view>
</wd-popup>
<!-- 选择预定时间 -->
<booking-time v-model="showBookTimePopup" :day="sevenDay" @selectedTime="ChooseRoomReserve.handleChooseReserveTime" :hour="Number(groupCoupon.hour)"></booking-time>
<view>
<navbar layoutLeft>
<template #left>
@ -31,15 +80,14 @@
<!-- 轮播图 -->
<view class="mt-32rpx mx-30rpx">
<wd-swiper value-key="image" height="240rpx" indicatorPosition="bottom-left"
:indicator="{ type: 'dots-bar' }" :list="swiperList" v-model:current="current"
@click="chooseRoomReserve.handleClick" @change="chooseRoomReserve.onChange" mode="aspectFit"></wd-swiper>
:indicator="{ type: 'dots-bar' }" :list="swiperList" v-model:current="current" mode="aspectFit"></wd-swiper>
</view>
<!-- 使用说明 -->
<view class="bg-white rounded-16rpx py-26rpx px-30rpx mt-24rpx mx-30rpx">
<view class="text-[#303133] text-32rpx leading-44rpx font-bold mb-24rpx">使用说明</view>
<view class="">
<rich-text :nodes="html"></rich-text>
<rich-text :nodes="teaRoom.textarea1"></rich-text>
</view>
</view>
@ -47,10 +95,36 @@
<view class="bg-white rounded-16rpx py-26rpx px-30rpx mt-24rpx mx-30rpx" @click="showBookTimePopup = true">
<view class="text-[#303133] text-32rpx leading-44rpx font-bold mb-24rpx">预定时间</view>
<view class="flex items-center justify-between">
<view class="text-[26rpx] text-[#606266] leading-36rpx">3小时起订</view>
<view class="text-[26rpx] text-[#606266] leading-36rpx">{{ sevenDay.minimum_time }}小时起订</view>
<view class="flex items-center">
<view class="text-[28rpx] text-[#909399] leading-40rpx w-430rpx line-1 text-right">
<template v-if="reserveTime.length > 0">
{{ reserveTime[0] }} {{ reserveTime[1].join(',') }}
</template>
<template v-else>
请选择
</template>
</view>
<view>
<wd-icon name="chevron-right" size="32rpx" color="#909399"></wd-icon>
</view>
</view>
</view>
</view>
<!-- 优惠券 -->
<view class="bg-white rounded-16rpx py-26rpx px-30rpx mt-24rpx mx-30rpx" @click="ChooseRoomReserve.handleToCoupon(CouponType.Discount)">
<view class="text-[#303133] text-32rpx leading-44rpx font-bold mb-24rpx">优惠券</view>
<view class="flex items-center justify-between">
<view class="text-[26rpx] text-[#606266] leading-36rpx">优惠券</view>
<view class="flex items-center">
<view class="text-[28rpx] text-[#909399] leading-40rpx">
3小时起订
<template v-if="selectedCoupon?.id > 0">
{{ selectedCoupon.name }}
</template>
<template v-else>
请选择
</template>
</view>
<view class="mt-4rpx">
<wd-icon name="chevron-right" size="22px" color="#909399"></wd-icon>
@ -58,74 +132,50 @@
</view>
</view>
</view>
<!-- 适用门店 -->
<view class="bg-white rounded-16rpx px-30rpx pb-32rpx mx-30rpx mt-20rpx">
<view class="pt-32rpx text-[#303133] text-32rpx leading-44rpx">适用门店</view>
<view class="mt-26rpx flex items-center">
<view class="mr-24rpx">
<wd-img width="170rpx" height="170rpx" :src="`${OSS}images/home/home_image5.png`"></wd-img>
</view>
<view class="flex-1 flex justify-between items-center relative">
<view class="">
<view class="text-[#303133] text-30rpx leading-40rpx line-2">这是商家的名称这是</view>
<view class="mt-26rpx text-[#909399] text-24rpx leading-34rpx">距您9km</view>
<view class="flex items-center mt-14rpx">
<view class="mr-8rpx">
<wd-img width="28rpx" height="28rpx" :src="`${OSS}icon/icon_location.png`"/>
</view>
<view class="ml-2rpx text-26rpx text-[#606266] line-2 w-300rpx">青浦区仓路478号青浦区仓路478号青浦区仓路478号青浦区仓路478号青浦区仓路478号青浦区仓路478号</view>
</view>
<view class="fixed left-0 right-0 bottom-0 z-2 bg-[#fff]" :style="{ height: '140rpx' }">
<view class="mt-12rpx w-full" >
<wd-gap height="2rpx" bgColor="#ECECEC"></wd-gap>
</view>
<view class="mt-22rpx flex justify-between items-center">
<view class="flex items-center ml-60rpx">
<view class="text-24rpx text-[#303133] leading-34rpx w-72rpx">合计</view>
<view class="flex items-center h-56rpx mr-16rpx">
<price-format color="#FF5951" :first-size="40" :second-size="40" :subscript-size="28" :price="bill.total"></price-format>
</view>
<view class="flex absolute top-1/2 right-0 -translate-y-1/2">
<view class="text-center mr-20rpx" @click="chooseRoomReserve.handleLocation">
<wd-img width="64rpx" height="64rpx" :src="`${OSS}icon/icon_nav.png`"/>
</view>
<view class="text-center" @click="chooseRoomReserve.handleCallPhone">
<wd-img width="64rpx" height="64rpx" :src="`${OSS}icon/icon_phone.png`"/>
</view>
<view class="flex items-center text-[#4C9F44]" @click="showCostPopup = true">
<view class="text-24rpx mr-10rpx">费用明细</view>
<wd-icon :name="showCostPopup ? 'arrow-up' : 'arrow-down'" size="24rpx" color="#4C9F44"></wd-icon>
</view>
</view>
</view>
</view>
<!-- 选择茶室包间 -->
<view class="bg-white mx-30rpx rounded-16rpx px-30rpx pb-32rpx mx-30rpx mt-20rpx">
<view class="text-32rpx text-[#303133] leading-44rpx pt-32rpx">选择茶室包间</view>
<view class="mt-26rpx">
<mescroll-body @init="mescrollInit" @down="downCallback" @up="chooseRoomReserve.upCallback">
<room-list :is-reserve="true" :store-type="storeType"></room-list>
</mescroll-body>
</view>
</view>
<!-- 操作按钮 -->
<view class="w-full fixed bottom-0 left-0 right-0 bg-white h-152rpx flex items-center justify-center">
<view class="text-32rpx leading-44rpx flex items-center justify-center leading-90rpx text-center">
<view class="w-630rpx h-90rpx bg-[#4C9F44] rounded-8rpx text-[#fff]">下一步</view>
<view class="mr-30rpx">
<wd-button custom-class='!bg-[#4C9F44] !rounded-8rpx !h-70rpx' @click="ChooseRoomReserve.handleReserve">立即预定</wd-button>
</view>
</view>
</view>
</view>
<booking-time v-model="showBookTimePopup"></booking-time>
</view>
</template>
<script lang="ts" setup>
import useMescroll from "@/uni_modules/mescroll-uni/hooks/useMescroll.js"
import RoomList from '@/components/reserve/RoomList.vue'
import BookingTime from '@/components/BookingTime.vue'
import {toast} from '@/utils/toast'
import { useUserStore } from '@/store'
import type { IUserInfoVo } from '@/api/types/login'
import { getTeaRoomDetail } from '@/api/tea-room'
import { getNext7Days, getTeaRoomBalance, createTeaRoomOrder, getTeaRoomPackageDetail, calculateTeaRoomPrice } from '@/api/tea-room'
import type { ITeaSpecialistFuture7DaysResult } from '@/api/types/tea'
import { router, toTimes, toPlus, toMinus } from '@/utils/tools'
import { getUserInfo } from '@/api/user'
import { CouponType } from '@/utils/coupon'
import { ReserveServiceCategory, OrderType } from '@/utils/order'
const OSS = inject('OSS')
// 轮播图
const swiperList = ref<string[]>([
`${OSS}images/banner1.png`,
`${OSS}images/banner1.png`,
`${OSS}images/banner1.png`
])
const swiperList = ref<string[]>([])
const current = ref<number>(0)
const showBookTimePopup = ref<boolean>(false)
const html: string = '<p>这里是富文本内容,需要后台传递</p>'
@ -135,131 +185,220 @@
const storeType = ref<number>(1) // 1直营 2加盟
/* mescroll */
const { mescrollInit, downCallback } = useMescroll(onPageScroll, onReachBottom) // 调用mescroll的hook
// 费用明细相关
const showCostPopup = ref<boolean>(false) // 费用明细popup
const showPayPopup = ref<boolean>(false) // 支付popup
onLoad(() => {
// 用户信息
const userInfo = ref<IUserInfoVo>(null)
// 包间内容
const storeId = ref<number>(0) // 门店ID
const id = ref<number>(0) // id
const teaRoom = ref<any>({})
const teaRoomPrice = ref<number>(0)
// 团购优惠券ID
const groupCouponId = ref<number>(0)
const groupCoupon = ref<any>({})
const groupCouponHour = ref<number>(0) // 团购券可以抵消几个小时的时间
// 选择预定时间
const showBookTimePopup = ref<boolean>(false)
const sevenDay = reactive<ITeaSpecialistFuture7DaysResult>({
minimum_time: 0,
time: []
})
const reserveTime = ref<Array<any>>([])
// 选择的优惠券
const selectedCoupon = ref<{id: number, name: string}>({id: 0, name: ''})
// 计算费用明细 service(服务费) groupCoupon(团购优惠券)
const bill = ref<{service: any, groupCoupon: any, discount: number, totalDiscount: number, coupon: number, total: number}>({
service: {
total: 0,
unitPrice: 0,
num: 0,
startTime: 0,
endTime: 0,
dayTime: '',
startHour: '',
endHour: ''
},
groupCoupon: {
hour: 0,
total: 0
},
discount: 0,
totalDiscount: 0,
coupon: 0,
total: 0
})
// 门店余额
const storeMoney = ref<number>(0)
// 用户信息
const user = ref<any>(null)
onLoad((args) => {
storeId.value = Number(args.storeId)
id.value = Number(args.id)
teaRoomPrice.value = Number(args.price) || 0
groupCouponId.value = Number(args.groupCouponId) || 0
ChooseRoomReserve.handleInitReserveRoom()
// 获取用户需求详
getUserInfo().then(res => {
user.value = res
})
})
const chooseRoomReserve = {
upCallback: (mescroll) => {
// 需要留一下数据为空的时候显示的空数据图标内容
// list({
// page: mescroll.num,
// size: mescroll.size
// }).then((res: { list: Array<any>, totalPages: Number }) => {
// const curPageData = res.list || [] // 当前页数据
// if(mescroll.num == 1) goods.value = []; // 第一页需手动制空列表
// goods.value = goods.value.concat(curPageData); //追加新数据
const ChooseRoomReserve = {
/**
* 初始包间详情
*/
handleInitReserveRoom: async () => {
// 包间详情
const userStore = useUserStore()
userInfo.value = userStore.userInfo
const res = await getTeaRoomDetail({
id: storeId.value,
latitude: uni.getStorageSync('latitude'),
longitude: uni.getStorageSync('longitude'),
user_id: userInfo.value.id || 0
})
teaRoom.value = res.details
swiperList.value = teaRoom.value.img_arr
// console.log("🚀 ~ goods:", goods)
// 预定时间
const next7 = await getNext7Days()
Object.assign(sevenDay, next7)
// mescroll.endByPage(curPageData.length, res.totalPages); //必传参数(当前页的数据个数, 总页数)
// 获取门店余额
const balance = await getTeaRoomBalance({ store_id: storeId.value })
storeMoney.value = balance.data.money || 0
// }).catch(() => {
// mescroll.endErr(); // 请求失败, 结束加载
// })
// apiGoods(mescroll.num, mescroll.size).then(res=>{
// const curPageData = res.list || [] // 当前页数据
// if(mescroll.num == 1) goods.value = []; // 第一页需手动制空列表
// goods.value = goods.value.concat(curPageData); //追加新数据
// //联网成功的回调,隐藏下拉刷新和上拉加载的状态;
// //mescroll会根据传的参数,自动判断列表如果无任何数据,则提示空;列表无下一页数据,则提示无更多数据;
// //方法一(推荐): 后台接口有返回列表的总页数 totalPage
// //mescroll.endByPage(curPageData.length, totalPage); //必传参数(当前页的数据个数, 总页数)
// //方法二(推荐): 后台接口有返回列表的总数据量 totalSize
// //mescroll.endBySize(curPageData.length, totalSize); //必传参数(当前页的数据个数, 总数据量)
// //方法三(推荐): 您有其他方式知道是否有下一页 hasNext
// //mescroll.endSuccess(curPageData.length, hasNext); //必传参数(当前页的数据个数, 是否有下一页true/false)
// //方法四 (不推荐),会存在一个小问题:比如列表共有20条数据,每页加载10条,共2页.如果只根据当前页的数据个数判断,则需翻到第三页才会知道无更多数据.
// mescroll.endSuccess(curPageData.length); // 请求成功, 结束加载
// }).catch(()=>{
mescroll.endErr(); // 请求失败, 结束加载
// })
},
// 收藏和取消收藏
handleCollect: () => {
// 处理收藏逻辑
toast.info('收藏成功')
// 获取团购优惠券
const coupon = await getTeaRoomPackageDetail({ id: groupCouponId.value })
groupCoupon.value = coupon.details
},
// 打开客服弹窗
handleService: () => {
showServicePopup.value = true
},
/**
* 选中预定时间
*/
handleChooseReserveTime: (params: any) => {
reserveTime.value = params
// 处理菜单选择
handleSelectMenu: (item: any) => {
console.log("🚀 ~ item:", item)
if (chooseRoomReserve.sheetMenuType == 'service') {
// 处理客服相关的菜单项
if (item.value === 'saveImage') {
// 处理保存图片逻辑
toast.success('图片已保存')
} else if (item.value === 'addWeChat') {
// 处理添加微信逻辑
toast.success('已添加门店微信')
}
} else if (chooseRoom.sheetMenuType == 'call' && item.index == 1) {
uni.makePhoneCall({
phoneNumber: item.value // 替换为实际电话号码
})
const roomPrice = toTimes(teaRoomPrice.value, params[3])
const useGroupCouponPrice = toTimes(teaRoomPrice.value, groupCoupon.value.hour)
bill.value.service = {
total: roomPrice,
unitPrice: teaRoomPrice.value,
num: params[3],
startTime: params[2][0],
endTime: params[2][params[2].length - 1],
dayTime: params[0],
startHour: params[1][0],
endHour: params[1][params[1].length - 1]
}
showAction.value = false // 关闭菜单
ChooseRoomReserve.handleCalculateTeaRoomPrice()
},
// 处理导航逻辑
handleLocation: () => {
toast.info('正在导航...')
// 可以使用uni.navigateTo或其他方式打开地图应用
uni.navigateTo({
url: '/pages/map/map' // 假设有一个地图页面
/**
* 跳转优惠券页面
*/
handleToCoupon(type) {
if (reserveTime.value.length == 0) {
toast.info('请选择预定时间')
return
}
uni.$on('chooseCoupon', params => {
console.log("🚀 ~ params:", params)
uni.$off('chooseCoupon')
selectedCoupon.value = {id: params.coupon.user_coupon_id, name: `${params.coupon.name}${params.coupon.coupon_price}` }
bill.value.coupon = params.coupon.coupon_price
ChooseRoomReserve.handleCalculateTeaRoomPrice()
})
// 获取预定了几个小时
const count = bill.value.service.num
router.navigateTo(`/bundle/coupon/coupon?id=${id.value}&numbers=${count}&type=${type}&storeId=${storeId.value}`)
},
// 处理拨打电话逻辑
handleCallPhone: () => {
chooseRoom.sheetMenuType = 'call'
showAction.value = true
sheetMenu.value = [
{
name: 15005837859,
value: ''
},
{
name: '呼叫',
value: 15005837859
}
]
},
/**
* 提交订单
*/
handleSubmitOrder: async () => {
// 只有预定茶室才会选择时间
if (bill.value.service.num == 0) {
toast.info('请选择预定时间')
return
}
// tab切换获取index
handleChangeTab: (item: { index: number }) => {
// tabIndexs.value = item.index
// scrollToLastY()
},
handleClick: (item: any) => {
// 处理点击事件
console.log('Clicked item:', item)
},
onChange: (e: any) => {
// 设置 current.value 为当前轮播索引
current.value = e.current
},
handleToRecharge: () => {
uni.navigateTo({
url: '/bundle/store-recharge/store-recharge'
uni.showLoading({
title: '提交中...'
})
try {
let res = await createTeaRoomOrder({
store_id: storeId.value,
room_id: id.value,
day_time: bill.value.service.dayTime,
start_time: bill.value.service.startHour,
end_time: bill.value.service.endHour,
user_coupon_id: selectedCoupon.value.id || 0,
hours: bill.value.service.num,
group_coupon_id: groupCouponId.value
})
uni.hideLoading()
// 支付后的处理
uni.$on('payment', params => {
setTimeout(() => {
uni.$off("payment")
if (params.result) {
router.redirectTo(`/pages/notice/reserve?type=${OrderType.TeaRoomOrder}&orderId=${params.orderId}&isGroupBuying=0`)
} else {
router.redirectTo( `/bundle/order/tea-room/order-list?isGroupBuying=0`)
}
}, 1000)
})
setTimeout(() => {
router.navigateTo(
`/pages/cashier/cashier?from=${OrderType.TeaRoomOrder}&orderId=${res.id}&name=${teaRoom.value.name}&storeId=${storeId.value}&isGroupBuying=0`
)
}, 800)
} catch (error) {
uni.hideLoading()
toast.info('订单提交失败,请稍后重试')
return
}
},
/**
* 计算茶室价格
*/
handleCalculateTeaRoomPrice: async () => {
const res = await calculateTeaRoomPrice({
room_id: id.value,
coupon_id: selectedCoupon.value.id || 0,
group_id: bill.value.service.num > 0 ? groupCouponId.value : 0,
nums: bill.value.service.num,
})
bill.value.service.total = res.details.room_price // 茶室价格
bill.value.discount = res.details.discount_room_price // 茶室总价
bill.value.totalDiscount = res.details.discount_all_price // 总优惠
bill.value.total = res.details.order_amount // 订单金额
}
}
</script>

View File

@ -28,48 +28,23 @@
</view>
<!-- 适用门店 -->
<view class="bg-white rounded-16rpx px-30rpx pb-32rpx mx-30rpx mt-20rpx">
<view class="pt-32rpx text-[#303133] text-32rpx leading-44rpx">适用门店</view>
<view class="mt-26rpx flex items-center">
<view class="mr-24rpx">
<wd-img width="170rpx" height="170rpx" :src="`${OSS}images/home/home_image5.png`"></wd-img>
</view>
<view class="flex-1 flex justify-between items-center relative">
<view class="">
<view class="text-[#303133] text-30rpx leading-40rpx line-2">这是商家的名称这是</view>
<view class="mt-26rpx text-[#909399] text-24rpx leading-34rpx">距您9km</view>
<view class="flex items-center mt-14rpx">
<view class="mr-8rpx">
<wd-img width="28rpx" height="28rpx" :src="`${OSS}icon/icon_location.png`"/>
</view>
<view class="ml-2rpx text-26rpx text-[#606266] line-2 w-300rpx">青浦区仓路478号青浦区仓路478号青浦区仓路478号青浦区仓路478号青浦区仓路478号青浦区仓路478号</view>
</view>
</view>
<view class="flex absolute top-1/2 right-0 -translate-y-1/2">
<view class="text-center mr-20rpx" @click="chooseRoom.handleLocation">
<wd-img width="64rpx" height="64rpx" :src="`${OSS}icon/icon_nav.png`"/>
</view>
<view class="text-center" @click="chooseRoom.handleCallPhone">
<wd-img width="64rpx" height="64rpx" :src="`${OSS}icon/icon_phone.png`"/>
</view>
</view>
</view>
</view>
<view>
<use-store :store="order.store"></use-store>
</view>
<!-- 选择茶室包间 -->
<view class="bg-white mx-30rpx rounded-16rpx px-30rpx pb-32rpx mx-30rpx mt-20rpx">
<view class="text-32rpx text-[#303133] leading-44rpx pt-32rpx">选择茶室包间</view>
<view class="mt-26rpx">
<mescroll-body @init="mescrollInit" @down="downCallback" @up="chooseRoom.upCallback">
<room-list :is-reserve="true" :store-type="storeType"></room-list>
<mescroll-body @init="mescrollInit" @down="downCallback" :down="downOption" :up="upOption" @up="ChooseRoom.upCallback">
<room-list :is-reserve="true" :list="list" is-use-coupon @chooseCouponRoom="ChooseRoom.handleChooseCouponRoom"></room-list>
</mescroll-body>
</view>
</view>
<!-- 操作按钮 -->
<view class="w-full fixed bottom-0 left-0 right-0 bg-white h-152rpx flex items-center justify-center">
<view class="text-32rpx leading-44rpx flex items-center justify-center leading-90rpx text-center">
<view class="text-32rpx leading-44rpx flex items-center justify-center leading-90rpx text-center" @click="ChooseRoom.handleToReserveCouponRoom">
<view class="w-630rpx h-90rpx bg-[#4C9F44] rounded-8rpx text-[#fff]">下一步</view>
</view>
</view>
@ -81,6 +56,12 @@
import useMescroll from "@/uni_modules/mescroll-uni/hooks/useMescroll.js"
import RoomList from '@/components/reserve/RoomList.vue'
import {toast} from '@/utils/toast'
import type { ITeaRoomPackageOrderDetailsResult } from '@/api/types/tea-room'
import { getTeaRoomPackageOrderDetail, getStoreTeaRoomList } from '@/api/tea-room'
import { TeaRoomPackageOrderStatusTextValue } from '@/utils/order'
import UseStore from '@/components/UseStore.vue'
import { router } from '@/utils/tools'
import { ReserveServiceCategory } from '@/utils/order'
const OSS = inject('OSS')
@ -94,54 +75,96 @@
const storeType = ref<number>(1) // 1直营 2加盟
/* mescroll */
const { mescrollInit, downCallback } = useMescroll(onPageScroll, onReachBottom) // 调用mescroll的hook
// 分页
const { mescrollInit, downCallback, getMescroll } = useMescroll(onPageScroll, onReachBottom) // 调用mescroll的hook
const downOption = {
auto: true
}
const upOption = {
auto: true,
textNoMore: '~ 已经到底啦 ~', //无更多数据的提示
}
const list = ref<Array<any>>([])
onLoad(() => {
// 订单
const teaRoomId = ref<number>(0)
const groupCouponId = ref<number>(0)
const orderStatus = ref<number>(0) // 订单状态:待使用、退款等
const order = ref<ITeaRoomPackageOrderDetailsResult>({
pay: 0,
pay_way_title: '',
order_amount: '',
order_sn: '',
order_status: 0,
dtime: '',
pay_dtime: '',
group: {
id: 0,
title: '',
img: '',
hour: '',
},
store: {
id: 0,
address: '',
latitude: '',
longitude: '',
name: '',
image: '',
contact_phone: '',
store_id: 0,
distance: '',
operation_type: 1
}
})
// 选择的包间
const couponRoomId = ref<number>(0)
const couponRoomPrice = ref<number>(0)
onLoad((args) => {
groupCouponId.value = args.groupCouponId
teaRoomId.value = Number(args.teaRoomId)
// 获取订单详情
ChooseRoom.handleInit()
})
const chooseRoom = {
const ChooseRoom = {
sheetMenuType: '', // 记录菜单类型
/**
* 获取订单详情
*/
handleInit: async () => {
const res = await getTeaRoomPackageOrderDetail({
id: groupCouponId.value,
latitude: uni.getStorageSync('latitude'),
longitude: uni.getStorageSync('longitude')
})
order.value = res.details
console.log("🚀 ~ order.value:", order.value)
orderStatus.value = order.value.order_status
},
// 上拉加载的回调: 其中num:当前页 从1开始, size:每页数据条数,默认10
upCallback: (mescroll) => {
// 需要留一下数据为空的时候显示的空数据图标内容
// list({
// page: mescroll.num,
// size: mescroll.size
// }).then((res: { list: Array<any>, totalPages: Number }) => {
// const curPageData = res.list || [] // 当前页数据
// if(mescroll.num == 1) goods.value = []; // 第一页需手动制空列表
// goods.value = goods.value.concat(curPageData); //追加新数据
const filter = {
page: mescroll.num,
size: mescroll.size,
id: teaRoomId.value
}
// console.log("🚀 ~ goods:", goods)
// mescroll.endByPage(curPageData.length, res.totalPages); //必传参数(当前页数据个数, 总页数)
// }).catch(() => {
// mescroll.endErr(); // 请求失败, 结束加载
// })
// apiGoods(mescroll.num, mescroll.size).then(res=>{
// const curPageData = res.list || [] // 当前页数据
// if(mescroll.num == 1) goods.value = []; // 第一页需手动制空列表
// goods.value = goods.value.concat(curPageData); //追加新数据
// //联网成功的回调,隐藏下拉刷新和上拉加载的状态;
// //mescroll会根据传的参数,自动判断列表如果无任何数据,则提示空;列表无下一页数据,则提示无更多数据;
// //方法一(推荐): 后台接口有返回列表的总页数 totalPage
// //mescroll.endByPage(curPageData.length, totalPage); //必传参数(当前页的数据个数, 总页数)
// //方法二(推荐): 后台接口有返回列表的总数据量 totalSize
// //mescroll.endBySize(curPageData.length, totalSize); //必传参数(当前页的数据个数, 总数据量)
// //方法三(推荐): 您有其他方式知道是否有下一页 hasNext
// //mescroll.endSuccess(curPageData.length, hasNext); //必传参数(当前页的数据个数, 是否有下一页true/false)
// //方法四 (不推荐),会存在一个小问题:比如列表共有20条数据,每页加载10条,共2页.如果只根据当前页的数据个数判断,则需翻到第三页才会知道无更多数据.
// mescroll.endSuccess(curPageData.length); // 请求成功, 结束加载
// }).catch(()=>{
mescroll.endErr(); // 请求失败, 结束加载
// })
getStoreTeaRoomList(filter).then( res => {
console.log("🚀 ~ res:", res)
const curPageData = res.list || [] // 当前页数据
if(mescroll.num == 1) list.value = [] // 第一页需手动制空列表
list.value = list.value.concat(curPageData) //追加新数据
mescroll.endSuccess(curPageData.length, Boolean(res.more))
}).catch(() => {
mescroll.endErr() // 请求失败, 结束加载
})
},
// 收藏和取消收藏
@ -158,7 +181,7 @@
// 处理菜单选择
handleSelectMenu: (item: any) => {
console.log("🚀 ~ item:", item)
if (chooseRoom.sheetMenuType == 'service') {
if (ChooseRoom.sheetMenuType == 'service') {
// 处理客服相关的菜单项
if (item.value === 'saveImage') {
// 处理保存图片逻辑
@ -167,7 +190,7 @@
// 处理添加微信逻辑
toast.success('已添加门店微信')
}
} else if (chooseRoom.sheetMenuType == 'call' && item.index == 1) {
} else if (ChooseRoom.sheetMenuType == 'call' && item.index == 1) {
uni.makePhoneCall({
phoneNumber: item.value // 替换为实际电话号码
})
@ -187,7 +210,7 @@
// 处理拨打电话逻辑
handleCallPhone: () => {
chooseRoom.sheetMenuType = 'call'
ChooseRoom.sheetMenuType = 'call'
showAction.value = true
sheetMenu.value = [
{
@ -213,9 +236,28 @@
},
handleToRecharge: () => {
uni.navigateTo({
url: '/bundle/store-recharge/store-recharge'
})
router.navigateTo('/bundle/store-recharge/store-recharge')
},
/**
* 选择包间
* @param e 包间ID
*/
handleChooseCouponRoom: (itme: any) => {
couponRoomId.value = itme.id
couponRoomPrice.value = itme.price
},
/**
* 跳转预定使用优惠券包间页面
*/
handleToReserveCouponRoom: () => {
if (couponRoomId.value === 0) {
toast.info('请选择包间')
return
}
router.navigateTo(`/bundle/tea-room/choose-room-reserve?groupCouponId=${groupCouponId.value}&storeId=${teaRoomId.value}&id=${couponRoomId.value}&type=${ReserveServiceCategory.ReserveRoom}&price=${couponRoomPrice.value}`)
}
}
</script>

View File

@ -33,11 +33,15 @@
</view>
<view class="flex justify-between items-center text-24rpx text-[#909399] leading-34rpx mt-16rpx">
<view>优惠券</view>
<view>-¥{{ bill.coupon }}</view>
<view>-¥{{ bill.coupon || 0 }}</view>
</view>
<view class="flex justify-between items-center text-24rpx text-[#909399] leading-34rpx mt-16rpx">
<view>团购券</view>
<view>-¥{{ bill.groupCoupon || 0 }}</view>
</view>
<view class="flex justify-between items-center text-24rpx text-[#909399] leading-34rpx mt-16rpx">
<view>会员八折</view>
<view>-¥{{ bill.discount }}</view>
<view>-¥{{ bill.discount || 0 }}</view>
</view>
</view>
@ -97,7 +101,7 @@
</view>
<view class="bg-white rounded-16rpx py-26rpx px-30rpx mt-24rpx mx-30rpx">
<view class="font-bold text-36rpx text-[#303133] leading-50rpx">{{ teaRoom.name }}</view>
<view class="font-bold text-36rpx text-[#303133] leading-50rpx">{{ isGroupBuying ? teaRoomPackage.title : teaRoom.name }}</view>
<view class="mt-14rpx flex" v-if="!isGroupBuying">
<template v-for="(label, labelIndex) in teaRoom.label" :key="labelIndex">
<view class="mr-20rpx flex items-start" v-if="label.category_id == 1">
@ -109,7 +113,7 @@
</template>
</view>
<view class="flex justify-between items-center" :class="`${ isGroupBuying ? 'mt-24rpx' : ''}`">
<view class="text-[#303133] text-26rpx leading-48rpx font-500" v-if="isGroupBuying">“环境幽静,谈商务放松好场所”</view>
<view class="text-[#303133] text-26rpx leading-48rpx font-500" v-if="isGroupBuying">{{ teaRoomPackage.introduce }}</view>
<!-- <view class="text-[#6A6363] flex-1 text-22rpx leading-32rpx text-right">已售 10+</view> -->
</view>
<view v-if="isGroupBuying">
@ -117,14 +121,15 @@
<wd-gap height="2rpx" bgColor="#F6F7F9"></wd-gap>
</view>
<view class="text-[#303133] text-28rpx leading-48rpx">
<view>
<rich-text :nodes="teaRoomPackage.details"></rich-text>
<!-- <view>
<text class="font-bold mr-26rpx">须知</text>
<text class="font-500">需预约</text>
<text class="font-500">{{ teaRoomPackage.details }}</text>
</view>
<view class="mt-22rpx">
<text class="font-bold mr-26rpx">保障</text>
<text class="font-500">随时退</text>
</view>
</view> -->
</view>
</view>
</view>
@ -142,22 +147,22 @@
<view class="bg-white rounded-16rpx py-26rpx px-30rpx mt-24rpx mx-30rpx" @click="showBookTimePopup = true">
<view class="text-[#303133] text-32rpx leading-44rpx font-bold mb-24rpx">预定时间</view>
<view class="flex items-center justify-between">
<view class="text-[26rpx] text-[#606266] leading-36rpx">{{ sevenDay.minimum_time }}小时起订</view>
<view class="flex items-center">
<view class="text-[28rpx] text-[#909399] leading-40rpx w-430rpx line-1 text-right">
<template v-if="reserveTime.length > 0">
{{ reserveTime[0] }} {{ reserveTime[1].join(',') }}
</template>
<template v-else>
请选择
</template>
</view>
<view>
<wd-icon name="chevron-right" size="32rpx" color="#909399"></wd-icon>
<view class="text-[26rpx] text-[#606266] leading-36rpx">{{ sevenDay.minimum_time }}小时起订</view>
<view class="flex items-center">
<view class="text-[28rpx] text-[#909399] leading-40rpx w-430rpx line-1 text-right">
<template v-if="reserveTime.length > 0">
{{ reserveTime[0] }} {{ reserveTime[1].join(',') }}
</template>
<template v-else>
请选择
</template>
</view>
<view>
<wd-icon name="chevron-right" size="32rpx" color="#909399"></wd-icon>
</view>
</view>
</view>
</view>
</view>
<!-- 优惠券 -->
<view class="bg-white rounded-16rpx py-26rpx px-30rpx mt-24rpx mx-30rpx" @click="Detail.handleToCoupon(CouponType.Discount)">
@ -181,14 +186,14 @@
</view>
<!-- 团购券 -->
<view class="bg-white rounded-16rpx py-26rpx px-30rpx mt-24rpx mx-30rpx" @click="Detail.handleToCoupon(CouponType.Discount)">
<view class="bg-white rounded-16rpx py-26rpx px-30rpx mt-24rpx mx-30rpx" @click="Detail.handleToCoupon(CouponType.GroupBuy)">
<view class="text-[#303133] text-32rpx leading-44rpx font-bold mb-24rpx">团购券</view>
<view class="flex items-center justify-between">
<view class="text-[26rpx] text-[#606266] leading-36rpx">团购券</view>
<view class="flex items-center">
<view class="text-[28rpx] text-[#909399] leading-40rpx">
<template v-if="selectedCoupon?.id > 0">
{{ selectedCoupon.name }}
<template v-if="selectedGroupCoupon?.id > 0">
{{ selectedGroupCoupon.name }}
</template>
<template v-else>
请选择
@ -200,27 +205,6 @@
</view>
</view>
</view>
<!-- 支付方式 -->
<!-- <view class="bg-white rounded-16rpx py-40rpx px-30rpx mt-24rpx mx-30rpx pay">
<view>
<pay @pay="Detail.handleGetPayValue" :storeMoney="storeMoney"></pay>
</view>
<view class="mt-40rpx mb-30rpx">
<wd-gap height="2rpx" bgColor='#F6F7F9'></wd-gap>
</view>
<view class="flex justify-between items-center" @click="Detail.handleToCoupon(CouponType.GroupBuy)">
<view class="text-30rpx text-[#303133] leading-42rpx">更多支付(团购券)</view>
<view class="flex items-center">
<view class="text-[#4C9F44] text-28rpx leading-40rpx mr-32rpx">1张可用</view>
<view class="mt-4rpx">
<wd-icon name="chevron-right" size="22px" color="#909399"></wd-icon>
</view>
</view>
</view>
</view> -->
</view>
<view v-if="isGroupBuying">
@ -228,7 +212,7 @@
<view class="bg-white rounded-16rpx py-26rpx px-30rpx mt-24rpx mx-30rpx">
<view class="text-[#303133] text-32rpx leading-44rpx font-bold mb-24rpx">套餐详情</view>
<view class="">
<rich-text :nodes="html"></rich-text>
<rich-text :nodes="teaRoomPackage.introduce_details"></rich-text>
</view>
</view>
@ -236,7 +220,7 @@
<view class="bg-white rounded-16rpx py-26rpx px-30rpx mt-24rpx mx-30rpx">
<view class="text-[#303133] text-32rpx leading-44rpx font-bold mb-24rpx">购买须知</view>
<view class="">
<rich-text :nodes="html"></rich-text>
<rich-text :nodes="teaRoomPackage.buy_details"></rich-text>
</view>
</view>
</view>
@ -250,9 +234,9 @@
<view class="flex items-center ml-60rpx">
<view class="text-24rpx text-[#303133] leading-34rpx w-72rpx" v-if="!isGroupBuying">合计</view>
<view class="flex items-center h-56rpx mr-16rpx">
<price-format color="#FF5951" :first-size="40" :second-size="40" :subscript-size="28" :price="bill.total"></price-format>
<price-format color="#FF5951" :first-size="40" :second-size="40" :subscript-size="28" :price="isGroupBuying ? teaRoomPackage.discount_price : bill.total"></price-format>
<view class="ml-20rpx" v-if="isGroupBuying">
<price-format color="#909399" :first-size="26" :second-size="26" :subscript-size="26" :price="23.02" lineThrough></price-format>
<price-format color="#909399" :first-size="26" :second-size="26" :subscript-size="26" :price="teaRoomPackage.price" lineThrough></price-format>
</view>
</view>
<view class="flex items-center text-[#4C9F44]" v-if="!isGroupBuying" @click="showCostPopup = true">
@ -272,14 +256,13 @@
<script lang="ts" setup>
import {toast} from '@/utils/toast'
import { ReserveServiceCategory, OrderType } from '@/utils/order'
import type { ITeaSpecialistDetailsFields, ITeaSpecialistFuture7DaysResult, ITeaTypeListResult } from '@/api/types/tea'
import type { ITeaSpecialistFuture7DaysResult } from '@/api/types/tea'
import { getNext7Days, getTeaRoomBalance, createTeaRoomOrder } from '@/api/tea-room'
import { CouponType } from '@/utils/coupon'
import { router, toTimes, toPlus, toMinus } from '@/utils/tools'
import type {IUserInfoVo } from '@/api/types/login'
import type { IUserInfoVo } from '@/api/types/login'
import { useUserStore } from '@/store'
import { getTeaRoomDetail, collectTeaRoom, getStoreTeaRoomList } from '@/api/tea-room'
import Pay from '@/components/Pay.vue'
import { getTeaRoomDetail, createTeaRoomPackageOrder, getTeaRoomPackageDetail, calculateTeaRoomPrice } from '@/api/tea-room'
import PriceFormat from '@/components/PriceFormat.vue'
import BookingTime from '@/components/BookingTime.vue'
import { getUserInfo } from '@/api/user'
@ -292,7 +275,7 @@
const swiperList = ref<string[]>([])
const current = ref<number>(0)
const html: string = '<p>这里是富文本内容,需要后台传递</p>'
const isGroupBuying: boolean = false // 是否是团购套餐
const isGroupBuying = ref<boolean>(false)// 是否是团购套餐
const pay = ref<number>(1) // 支付方式
const payList = ref<Array<any>>([
{
@ -326,8 +309,8 @@
})
const reserveTime = ref<Array<any>>([])
// 计算费用明细 service(服务费) travel(车马费) teaServiceFee(茶艺服务) coupon(优惠券) discount(会员优惠) totalDiscount(总优惠) total(总费用)
const bill = ref<{service: any, travel: any, teaService: any, discount:number, totalDiscount: number, coupon: number, total: number}>({
// 计算费用明细 service(服务费) coupon(优惠券) discount(会员优惠) totalDiscount(总优惠) total(总费用) groupCoupon(团购券)
const bill = ref<{service: any, discount:number, totalDiscount: number, coupon: number, groupCoupon: number, total: number}>({
service: {
total: 0,
unitPrice: 0,
@ -338,35 +321,20 @@
startHour: '',
endHour: ''
},
travel: {
total: 0,
unitPrice: 0,
num: 0
},
teaService: {
total: 0,
tea: '',
teaTotal: 0,
cup: 0,
peopleNum: 0
},
discount: 0,
totalDiscount: 0,
coupon: 0,
groupCoupon: 0,
total: 0
})
// 预定时间相关
const showReservePopup = ref<boolean>(false) // 预定时间popup
const totalHour = ref<number>(0)
// 费用明细相关
const showCostPopup = ref<boolean>(false) // 费用明细popup
const showPayPopup = ref<boolean>(false) // 支付popup
// 包间内容
const storeId = ref<number>(0) // 门店ID
const teaRoomId = ref<number>(0) // 包间ID
const id = ref<number>(0) // id
const teaRoom = ref<any>({})
const teaRoomPrice = ref<number>(0)
@ -375,21 +343,25 @@
// 选择的优惠券
const selectedCoupon = ref<{id: number, name: string}>({id: 0, name: ''})
const selectedGroupCoupon = ref<{id: number, name: string}>({id: 0, name: ''})
// 用户信息
const user = ref<any>(null)
// 套餐
const teaRoomPackage = ref<any>({})
onLoad((args) => {
storeId.value = Number(args.storeId)
teaRoomId.value = Number(args.roomId)
id.value = Number(args.id)
teaRoomPrice.value = Number(args.price) || 0
Detail.handleInit()
if (args.type == ReserveServiceCategory.GroupBuying) {
// TODO 如果是团购套餐则直接微信支付?
isGroupBuying.value = true
pay.value = 3
// console.log("🚀 ~ pay.value:", pay.value)
Detail.handleInitGroupBuying()
}
Detail.handleInitReserveRoom()
// 获取用户需求详
getUserInfo().then(res => {
@ -401,7 +373,7 @@
/**
* 初始包间详情
*/
handleInit: async () => {
handleInitReserveRoom: async () => {
// 包间详情
const userStore = useUserStore()
userInfo.value = userStore.userInfo
@ -424,42 +396,24 @@
storeMoney.value = balance.data.money || 0
},
// 跳转优惠券页面
handleToCoupon(type) {
// 1优惠券 2团购券
if (type === CouponType.Discount) {
if (reserveTime.value.length == 0) {
toast.info('请选择预定时间')
return
}
uni.$on('chooseCoupon', params => {
uni.$off('chooseCoupon')
selectedCoupon.value = {id: params.coupon.user_coupon_id, name: `${params.coupon.name}${params.coupon.coupon_price}` }
bill.value.coupon = params.coupon.coupon_price
bill.value.totalDiscount = Number(toPlus(bill.value.discount, params.coupon.coupon_price))
})
// 获取预定了几个小时
const count = reserveTime.value[1].length
router.navigateTo(`/bundle/coupon/coupon?id=${teaRoomId.value}&numbers=${count}&type=${type}`)
}
/*
* 初始化套餐详情
*/
handleInitGroupBuying: async () => {
const res = await getTeaRoomPackageDetail({ id: id.value })
teaRoomPackage.value = res.details
},
handlePay: () => {
// 这里需要判断下如果是预约的话跳转结果通知是reserve的团购是pay的
// uni.navigateTo({ url: '/bundle/reserve-room/result' })
},
// 选中预定时间
/**
* 选中预定时间
*/
handleChooseReserveTime: (params: any) => {
reserveTime.value = params
bill.value.service = {
total: toTimes(teaRoomPrice.value, params[1].length),
unitPrice: teaRoomPrice.value,
num: params[1].length,
total: 0,
unitPrice: 0,
num: params[3],
startTime: params[2][0],
endTime: params[2][params[2].length - 1],
dayTime: params[0],
@ -467,10 +421,36 @@
endHour: params[1][params[1].length - 1]
}
// TODO 这里需要判断是否开通VIP享受八折
if (user.value.member == 1) {
bill.value.discount = Number(toMinus(bill.value.service.total, (bill.value.service.total * 0.8).toFixed(2)))
Detail.handleCalculateTeaRoomPrice()
},
/**
* 跳转优惠券页面
*/
handleToCoupon(type) {
if (reserveTime.value.length == 0) {
toast.info('请选择预定时间')
return
}
uni.$on('chooseCoupon', params => {
console.log("🚀 ~ params:", params)
uni.$off('chooseCoupon')
if (type === CouponType.Discount) {
selectedCoupon.value = {id: params.coupon.user_coupon_id, name: `${params.coupon.name}${params.coupon.coupon_price}` }
bill.value.coupon = params.coupon.coupon_price
} else {
selectedGroupCoupon.value = {id: params.coupon.group_id, name: `团购券-${params.coupon.tea_store_group.title}` }
console.log("🚀 ~ selectedGroupCoupon.value:", selectedGroupCoupon.value.name)
bill.value.groupCoupon = params.coupon.coupon_price
}
Detail.handleCalculateTeaRoomPrice()
})
// 获取预定了几个小时
const count = bill.value.service.num
router.navigateTo(`/bundle/coupon/coupon?id=${id.value}&numbers=${count}&type=${type}&storeId=${storeId.value}`)
},
// 选择支付方式
@ -482,74 +462,87 @@
* 提交订单
*/
handleSubmitOrder: async () => {
if (reserveTime.value.length == 0) {
// 只有预定茶室才会选择时间
if (!isGroupBuying.value && bill.value.service.num == 0) {
toast.info('请选择预定时间')
return
}
const params = {
store_id: storeId.value,
room_id: teaRoomId.value,
day_time: bill.value.service.dayTime,
start_time: bill.value.service.startHour,
end_time: bill.value.service.endHour,
user_coupon_id: selectedCoupon.value.id || 0,
hours: bill.value.service.num
}
uni.showLoading({
title: '提交中...'
})
try {
const res = await createTeaRoomOrder(params)
let res: any = null
if (isGroupBuying.value) {
res = await createTeaRoomPackageOrder({
group_id: id.value
})
} else {
res = await createTeaRoomOrder({
store_id: storeId.value,
room_id: id.value,
day_time: bill.value.service.dayTime,
start_time: bill.value.service.startHour,
end_time: bill.value.service.endHour,
user_coupon_id: selectedCoupon.value.id || 0,
hours: bill.value.service.num,
group_coupon_id: selectedGroupCoupon.value.id || 0
})
}
uni.hideLoading()
// 支付后的处理
uni.$on('payment', params => {
console.log("🚀 ~ params:", params)
setTimeout(() => {
uni.$off("payment")
if (params.result) {
uni.redirectTo({
url: `/pages/notice/reserve?type=room&orderId=${params.orderId}`
url: `/pages/notice/reserve?type=${OrderType.TeaRoomOrder}&orderId=${params.orderId}&isGroupBuying=${isGroupBuying.value ? 1 : 0}`
})
} else {
uni.redirectTo({
url: '/bundle/order/tea-room/order-list?orderStatus=all'
})
if (isGroupBuying.value) {
router.redirectTo(`/bundle/order/platform/order-list`)
} else {
router.redirectTo(`/bundle/order/tea-room/order-list?isGroupBuying=${isGroupBuying.value ? 1 : 0}`)
}
}
}, 1000)
})
setTimeout(() => {
router.navigateTo(`/pages/cashier/cashier?from=${OrderType.TeaRoomOrder}&orderId=${res.id}&teaRoomName=${teaRoom.value.name}&storeId=${storeId.value}`)
const name = isGroupBuying.value ? teaRoomPackage.value.title : teaRoom.value.name
router.navigateTo(
`/pages/cashier/cashier?from=${OrderType.TeaRoomOrder}&orderId=${res.id}&name=${name}&storeId=${storeId.value}&isGroupBuying=${isGroupBuying.value ? 1 : 0}`
)
}, 800)
} catch (error) {
uni.hideLoading()
toast.info('订单提交失败,请稍后重试')
return
}
},
/**
* 计算茶室价格
*/
handleCalculateTeaRoomPrice: async () => {
const res = await calculateTeaRoomPrice({
room_id: id.value,
coupon_id: selectedCoupon.value.id || 0,
group_id: selectedGroupCoupon.value.id,
nums: bill.value.service.num,
})
bill.value.service.total = res.details.room_price // 茶室价格
bill.value.discount = res.details.discount_room_price // 茶室总价
bill.value.totalDiscount = res.details.discount_all_price // 总优惠
bill.value.groupCoupon = res.details.group_price // 总优惠
bill.value.total = res.details.order_amount // 订单金额
}
}
const billTotal = computed(() => {
const s = Number(bill.value.service.total) || 0
const t = Number(bill.value.travel.total) || 0
const ts = Number(bill.value.teaService.total) || 0
let total = Number(toPlus(s, t, ts))
total = Number(toMinus(total, bill.value.discount))
if (bill.value.coupon > 0 ) {
total + bill.value.coupon
return Number(toMinus(total, bill.value.coupon))
}
return total
})
watch(billTotal, (val) => {
bill.value.total = val
})
</script>
<style lang="scss">

View File

@ -81,25 +81,13 @@
</view>
<view class="tabs">
<wd-tabs v-model="tab" swipeable slidable="always" @change="Room.handleChangeTab" :lazy="false">
<wd-tab title="茶室预定" v-if="storeType != 2">
<!-- <view class="content mx-30rpx mt-34rpx">
<mescroll-body @init="mescrollInit" @down="downCallback" @up="Room.upCallback">
<room-list :is-reserve="true" :store-type="storeType"></room-list>
</mescroll-body>
</view> -->
</wd-tab>
<wd-tab title="团购套餐">
<!-- <view class="content mx-30rpx mt-34rpx">
<mescroll-body @init="mescrollInit" @down="downCallback" @up="Room.upCallback">
<room-list :is-group-buying="true" :store-type="storeType"></room-list>
</mescroll-body>
</view> -->
</wd-tab>
<wd-tab title="茶室预定" v-if="storeType != 2"></wd-tab>
<wd-tab title="团购套餐"></wd-tab>
</wd-tabs>
<view class="mx-30rpx mt-34rpx">
<mescroll-body @init="mescrollInit" @down="downCallback" :down="downOption" :up="upOption" @up="Room.upCallback">
<room-list :is-reserve="tabIndexs === 0" :is-group-buying="tabIndexs === 1" :store-type="storeType" :list="list"></room-list>
<room-list :is-reserve="tabIndexs === 0" :is-group-buying="tabIndexs === 1" :list="list"></room-list>
</mescroll-body>
</view>
</view>
@ -125,11 +113,12 @@
import RechargeBtn from '@/components/RechargeBtn.vue'
import RoomList from '@/components/reserve/RoomList.vue'
import {toast} from '@/utils/toast'
import { getTeaRoomDetail, collectTeaRoom, getStoreTeaRoomList } from '@/api/tea-room'
import { getTeaRoomDetail, collectTeaRoom, getStoreTeaRoomList, getTeaRoomPackage } from '@/api/tea-room'
import type { ITeaRoomDetailResult } from '@/api/types/tea-room'
import type {IUserInfoVo } from '@/api/types/login'
import { useUserStore } from '@/store'
import { router } from '@/utils/tools'
import { StoreType } from '@/utils/tea'
const rightPadding = inject('capsuleOffset')
const OSS = inject('OSS')
@ -156,8 +145,7 @@
const sheetMenu = ref([])
const showServicePopup = ref<boolean>(false)
// 店铺类型 1直营 2加盟
const storeType = ref<number>(1)
const storeType = ref<number>(StoreType.Direct)
// 分页
const { mescrollInit, downCallback, getMescroll } = useMescroll(onPageScroll, onReachBottom) // 调用mescroll的hook
@ -175,6 +163,12 @@
console.log("🚀 ~ args:", uni.getStorageSync('latitude'), uni.getStorageSync('longitude'))
if (args.id) {
teaRoomId.value = Number(args.id)
storeType.value = Number(args.type) || StoreType.Direct
// 如果是加盟店铺则显示团购套餐TAB
if (storeType.value === StoreType.Franchise) {
tabIndexs.value = 1
}
Room.handleInit()
}
})
@ -188,12 +182,13 @@
*/
upCallback: (mescroll) => {
const filter = {
page: mescroll.num,
size: mescroll.size,
page: mescroll.num,
size: mescroll.size,
id: teaRoomId.value
}
if (tabIndexs.value === 0) {
// 如果是直营店铺且是茶室预定
if (tabIndexs.value === 0 && storeType.value === StoreType.Direct) {
getStoreTeaRoomList(filter).then( res => {
console.log("🚀 ~ res:", res)
const curPageData = res.list || [] // 当前页数据
@ -205,8 +200,15 @@
})
} else {
// 处理团购套餐列表
getTeaRoomPackage(filter).then( res => {
const curPageData = res.list || [] // 当前页数据
if(mescroll.num == 1) list.value = [] // 第一页需手动制空列表
list.value = list.value.concat(curPageData) //追加新数据
mescroll.endSuccess(curPageData.length, Boolean(res.more))
}).catch(() => {
mescroll.endErr() // 请求失败, 结束加载
})
}
},
/**