调试茶艺师订单接口

This commit is contained in:
wangxiaowei
2026-01-03 01:40:12 +08:00
parent 66ee35285d
commit 3a31777431
18 changed files with 717 additions and 344 deletions

View File

@ -7,6 +7,63 @@
}</route>
<template>
<view class="pb-180rpx">
<!-- 消息提示框 -->
<wd-message-box selector="wd-message-box-slot" />
<!-- 上门服务-预定时间 -->
<wd-popup v-model="showReservePopup" lock-scroll custom-style="border-radius: 32rpx 32rpx 0rpx 0rpx;" position="bottom">
<view class="relative">
<view class="absolute top-18rpx right-30rpx" @click="showReservePopup = 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="w-[100%] h-100rpx flex justify-between items-center">
<view
class="w-[50%] h-[100%] flex flex-col items-center justify-center rounded-l-[8rpx]"
:class="`${currentTimePicker == 'start' ? 'bg-[#4C9F44] text-[#fff]' : 'bg-[#F6F7F8] text-[#303133]'}`"
@click="currentTimePicker = 'start'">
<view class="text-28rpx leading-40rpx">开始时间</view>
<view class="text-26rpx leading-36rpx mt-2rpx">{{ startTimeLayout }}</view>
</view>
<view
class="w-[50%] h-[100%] flex flex-col items-center justify-center rounded-r-[8rpx]"
:class="`${currentTimePicker == 'end' ? 'bg-[#4C9F44] text-[#fff]' : 'bg-[#F6F7F8] text-[#303133]'}`"
@click="currentTimePicker = 'end'">
<view class="text-28rpx leading-40rpx">结束时间</view>
<view class="text-26rpx leading-36rpx mt-2rpx">{{ endTimeLayout }}</view>
</view>
</view>
<view class="date-picker">
<view class="" v-if="currentTimePicker == 'start'">
<wd-datetime-picker-view
:minDate='minTimestamp'
:maxDate='maxTimestamp'
type="datetime"
v-model="startTimeValue"
:formatter="Door.handleFormatTime"
@change="Door.handleStartTimePicker"
/>
</view>
<view class="" v-if="currentTimePicker == 'end'">
<wd-datetime-picker-view
:minDate='minTimestamp'
:maxDate='maxTimestamp'
type="datetime"
v-model="endTimeValue"
:formatter="Door.handleFormatTime"
@change="Door.handleEndTimePicker"
/>
</view>
</view>
<view class="pb-22rpx mt-40rpx mx-30rpx flex justify-between items-center text-[32rpx] text-center">
<view class='bg-[#F6F7F8] text-[#303133] rounded-8rpx h-90rpx leading-90rpx w-[50%] mr-28rpx' @click="Door.handleResetTime">重置</view>
<view class='bg-[#4C9F44] text-[#fff] rounded-8rpx h-90rpx leading-90rpx w-[50%]' @click="Door.handleConfirmHour">确定({{ totalHour }}小时)</view>
</view>
</view>
</wd-popup>
<!-- 费用明细 -->
<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'>
@ -109,9 +166,9 @@
v-for="(item, index) in teaList" :key="index"
class="text-28rpx leading-40rpx rounded-8rpx text-center py-14rpx"
:class="selectedTea.includes(item.id) ? 'bg-#4C9F44 text-#fff' : 'bg-#F7F7F7 text-#606266'"
@click="TeaRoom.handleToggleTea(item.id, item.name, item.tea_price)">
@click="Reserve.handleToggleTea(item.id, item.name, item.price)">
<view>{{item.name}}</view>
<view>¥{{item.tea_price}}</view>
<view>¥{{item.price}}</view>
</view>
</view>
</view>
@ -148,8 +205,8 @@
</view>
<view class="flex items-center">
<view class="w-178rpx h-70rpx leading-70rpx text-center bg-#F6F7F8 text-#303133 rounded-8rpx mr-20rpx" @click="TeaRoom.handleResetTeaService">重置</view>
<view class="w-178rpx h-70rpx leading-70rpx text-center bg-#4C9F44 text-#fff rounded-8rpx" @click="TeaRoom.handleConfirmTeaService">确定</view>
<view class="w-178rpx h-70rpx leading-70rpx text-center bg-#F6F7F8 text-#303133 rounded-8rpx mr-20rpx" @click="Reserve.handleResetTeaService">重置</view>
<view class="w-178rpx h-70rpx leading-70rpx text-center bg-#4C9F44 text-#fff rounded-8rpx" @click="Reserve.handleConfirmTeaService">确定</view>
</view>
</view>
</view>
@ -158,7 +215,7 @@
</wd-popup>
<!-- 选择预定时间 -->
<booking-time v-model="showBookTimePopup" :day="sevenDay" @selectedTime="TeaRoom.handleChooseReserveTime"></booking-time>
<booking-time v-model="showBookTimePopup" :day="sevenDay" @selectedTime="Reserve.handleChooseReserveTime"></booking-time>
<view>
<navbar title="预约茶艺师" :leftArrow="false"></navbar>
@ -176,11 +233,11 @@
</view>
<view class="flex items-center mt-18rpx">
<view class="mr-12rpx">
<view class="bg-#FEF1F0 text-#FF5951 w-144rpx h-40rpx rounded-6rpx text-center text-22rpx leading-40rpx">90后茶艺师</view>
<view class="bg-#FEF1F0 text-#FF5951 w-144rpx h-40rpx rounded-6rpx text-center text-22rpx leading-40rpx">{{ info.age_range }}后茶艺师</view>
</view>
<tea-specialist-level :level="TeaSpecialistLevelValue[info.teamasterLevel?.[0]?.level_name] || 'junior'"></tea-specialist-level>
<tea-specialist-level :level="info.level"></tea-specialist-level>
</view>
<view class="font-400 text-22rpx leading-32rpx text-#6A6363 mt-30rpx">已预约 {{ info.reservation_num > 10 ? info.reservation_num + '+' : info.reservation_num }}</view>
<view class="font-400 text-22rpx leading-32rpx text-#6A6363 mt-30rpx">已预约 {{ Number(info.sold) > 10 ? Number(info.sold) + '+' : Number(info.sold) }}</view>
</view>
</view>
@ -189,14 +246,14 @@
<view class="flex items-center justify-between">
<view class="font-bold text-32rpx leading-44rpx">服务方式</view>
<view class="bg-[#F0F6EF] h-60rpx rounded-20rpx flex items-center justify-between py-14rpx px-30rpx relative w-304rpx font-400 text-26rpx text-[#333]">
<view class="absolute left-30rpx top-1/2 -translate-y-1/2 z-2" :class="serviceTypeValue == 1 ? 'text-[#fff]' : ''" @click="TeaRoom.handleChooseService(1)">到店服务</view>
<view class="absolute right-30rpx top-1/2 -translate-y-1/2 z-2" :class="serviceTypeValue == 2 ? 'text-[#fff]' : ''" @click="TeaRoom.handleChooseService(2)">上门服务</view>
<view class="absolute left-30rpx top-1/2 -translate-y-1/2 z-2" :class="serviceTypeValue == 1 ? 'text-[#fff]' : ''" @click="Reserve.handleChooseService(1)">到店服务</view>
<view class="absolute right-30rpx top-1/2 -translate-y-1/2 z-2" :class="serviceTypeValue == 2 ? 'text-[#fff]' : ''" @click="Reserve.handleChooseService(2)">上门服务</view>
<view class="swiper-service" :style="{ transform: serviceTypeValue == 1 ? 'translateY(-50%) translateX(0)' : 'translateY(-50%) translateX(76px)' }"></view>
</view>
</view>
<!-- 预定门店 -->
<view class="flex items-center justify-between mt-48rpx" v-if="serviceTypeValue == 1" @click="TeaRoom.handleToSChooseStore">
<view class="flex items-center justify-between mt-48rpx" v-if="serviceTypeValue == 1" @click="Reserve.handleToChooseStore">
<view class="text-28rpx leading-40rpx">预定店</view>
<view class="flex items-center">
<view class="text-28rpx leading-40rpx text-#303133">{{ teaHouse.name || '请选择茶馆' }}</view>
@ -207,7 +264,7 @@
</view>
<!-- 上门服务地址 -->
<view class="flex items-center justify-between mt-48rpx" v-if="serviceTypeValue == 2" @click="TeaRoom.handleToAddress">
<view class="flex items-center justify-between mt-48rpx" v-if="serviceTypeValue == 2" @click="Reserve.handleToAddress">
<view class="text-28rpx leading-40rpx">地址</view>
<view class="flex items-center">
<view class="text-28rpx leading-40rpx text-#303133 w-430rpx line-1 text-right">
@ -225,18 +282,21 @@
</view>
</view>
<!-- 预定时间 -->
<view class="bg-white py-26rpx px-30rpx mt-20rpx" @click="showBookTimePopup = true">
<view class="bg-white py-26rpx px-30rpx mt-20rpx" @click="Reserve.handleChooseTime">
<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 v-if="serviceTypeValue == 1 && dayHours">
{{ dayTime }} {{ dayHours }}
</template>
<template v-else-if="serviceTypeValue == 2 && startTimeLayout && endTimeLayout">
{{ startTimeLayout }} {{ endTimeLayout }}
</template>
<template v-else>
请选择
</template>
</template>
</view>
<view>
<wd-icon name="chevron-right" size="32rpx" color="#909399"></wd-icon>
@ -276,7 +336,7 @@
</view>
<!-- 优惠券 -->
<view class="bg-white py-26rpx px-30rpx mt-20rpx" @click="TeaRoom.handleToCoupon(CouponType.Discount)">
<view class="bg-white py-26rpx px-30rpx mt-20rpx" @click="Reserve.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>
@ -298,7 +358,7 @@
<!-- 支付方式 -->
<!-- <view class="bg-white py-26rpx px-30rpx mt-20rpx">
<pay hide-store-balance @pay="TeaRoom.handleGetPayValue"></pay>
<pay hide-store-balance @pay="Reserve.handleGetPayValue"></pay>
</view> -->
<view class="fixed left-0 right-0 bottom-0 z-2 bg-[#fff]"
@ -315,7 +375,7 @@
</view>
</view>
<view class="mr-30rpx">
<wd-button custom-class='!bg-[#4C9F44] !rounded-8rpx !h-70rpx' @click="TeaRoom.handleSubmitOrder">立即预定</wd-button>
<wd-button custom-class='!bg-[#4C9F44] !rounded-8rpx !h-70rpx' @click="Reserve.handleSubmitOrder">立即预定</wd-button>
</view>
</view>
</view>
@ -324,20 +384,23 @@
</template>
<script lang="ts" setup>
import { toast } from '@/utils/toast'
import { router, toTimes, toPlus } from '@/utils/tools'
import { useMessage, useToast } from 'wot-design-uni'
import { digits } from '@/utils/test'
import { router, toTimes, toPlus, getCurrentDate } from '@/utils/tools'
import PriceFormat from '@/components/PriceFormat.vue'
import { ReserveServiceCategory, OrderType } from '@/utils/order'
import { PayList, PayCategory, PayValue } from '@/utils/pay'
import Pay from '@/components/Pay.vue'
import { getTeaSpecialistDetails, getNext7Days, getTeaTypeList, createTeaSpecialistOrder } from '@/api/tea'
import { getTeaSpecialistDetails, getTeaTypeList, createTeaSpecialistOrder } from '@/api/tea'
import { getNext7Days} from '@/api/tea-room'
import type { ITeaSpecialistDetailsFields, ITeaSpecialistFuture7DaysResult, ITeaTypeListResult } from '@/api/types/tea'
import { TeaSpecialistLevelValue } from '@/utils/teaSpecialist'
import type { IUserAddressListResult } from '@/api/types/user'
import BookingTime from '@/components/BookingTime.vue'
import { CouponType } from '@/utils/coupon'
import { getTeaSpecialistDetail } from '@/api/tea-specialist'
const OSS = inject('OSS')
const toast = useToast()
const message = useMessage('wd-message-box-slot')
// 服务方式
const serviceType = ref<Array<any>>([
@ -350,24 +413,41 @@
const teaHouse = ref<{id: number, name: string}>({id: 0, name: ''})
// 选择预定时间
const MINIMUMTIME = 2 // TODO 暂时写死
const showBookTimePopup = ref<boolean>(false)
const sevenDay = reactive<ITeaSpecialistFuture7DaysResult>({
minimum_time: 0,
minimum_time: MINIMUMTIME,
time: []
})
const reserveTime = ref<Array<any>>([])
const timeSlots = ref<Array<string>>([]) // 连续选择的预约时间
const dayTitle = ref<string>('') // 周三03/18
const dayTime = ref<string>('') // 2024-03-18
const dayHours = ref<string>('') // 预定时长00:00,00:30
const startTime = ref<number>(0) // 开始时间
const endTime = ref<number>(0) // 结束时间
const countHours = ref<number>(0) // 预定了几个小时
// 上门服务-预定时间相关
const showReservePopup = ref<boolean>(false) // 预定时间popup
const currentTimePicker = ref<string>('start') // 当前选择的时间类型
const startTimeValue = ref<string>('') // 开始时间
const endTimeValue = ref<string>('') // 结束时间
const now = new Date()
const minTimestamp = Date.now()
// 允许选择今天及未来六天的日期
const maxTimestamp = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 6, 23, 59, 59, 999).getTime()
const startTimeLayout = ref<string>('')
const endTimeLayout = ref<string>('')
const totalHour = ref<number>(0)
// 上门服务选择的地址
const address = ref<IUserAddressListResult>({
const address = ref({
id: 0,
contact: '',
telephone: '',
province: '',
province_id: 0,
city: '',
city_id: 0,
district: '',
district_id: 0,
longitude: 0,
latitude: 0,
address: '',
is_default: 0,
})
@ -392,35 +472,29 @@
// 订单备注
const orderRemarks = ref<string>('')
// 支付方式
const pay = ref<number>(0)
const html: string = '<p>这里是富文本内容,需要后台传递</p>'
const isGroupBuying: boolean = false // 是否是团购套餐
// 费用明细相关
const showCostPopup = ref<boolean>(false) // 费用明细popup
// 茶艺师
const teaSpecialistId = ref<number>(0)
const info = reactive<ITeaSpecialistDetailsFields>({
const id = ref<number>(0)
const info = ref({
id: 0,
name: '',
star: 0,
image: '',
reservation_num: 0,
distance: 0,
speed: 0,
real: { gender: 1, both: 18, height: 165, weight: 53, interests: '爱好茶艺,喜欢旅游,把爱好当工作' },
teamasterlabel: [],
teamasterLevel: [],
price: 0,
fare_price: 0,
collect: 0,
up_status: 0,
textarea: []
image_arr: [], // 轮播图
name: '', // 茶艺师名字
star: 0, // 茶艺师评分
sold: 0, // 已预约
age_range: '00', // 茶艺师年龄段
level: 1, // 茶艺师等级
distance: 0, // 距离
is_time: '', // 预计到达
sex: 0, // 性别
both: 0, // 年龄
weight: 0, // 体重
height: 0, // 身高
hobby_introduce: '', // 兴趣爱好介绍
price: 0, // 服务费
mileage_price: 0, // 车马费
})
const is90 = ref<boolean>(false)
// 选择的优惠券
const selectedCoupon = ref<{id: number, name: string}>({id: 0, name: ''})
@ -451,43 +525,33 @@
total: 0
})
onLoad(async (args) => {
if (args.id) {
teaSpecialistId.value = Number(args.id)
const res = await getTeaSpecialistDetails({
id: args.id,
longitude: 0,
latitude: 0,
user_id: 0
id.value = Number(args.id)
// 获取茶艺师详情
const res = await getTeaSpecialistDetail({
team_user_id: args.id,
latitude: uni.getStorageSync('latitude'),
longitude: uni.getStorageSync('longitude'),
})
// 将返回的数据合并到 reactive 对象中
Object.assign(info, res.teamaster || {})
if (info.teamasterlabel) {
info.teamasterlabel.map(item => {
if (item.label_name == '90后茶艺师') {
is90.value = true
}
})
info.value = res.teamaster
bill.value.travel = {
total: toTimes(info.fare_price, info.distance),
unitPrice: info.fare_price,
num: info.distance
}
}
// bill.value.travel = {
// total: toTimes(info.fare_price, info.distance),
// unitPrice: info.fare_price,
// num: info.distance
// }
}
// 初始化数据
TeaRoom.handleInit()
Reserve.handleInit()
})
const TeaRoom = {
const Reserve = {
handleInit: async () => {
// 获取未来7天时间段
const next7 = await getNext7Days()
Object.assign(sevenDay, next7)
// 获取茶叶列表
const tea = await getTeaTypeList()
teaList.value = tea as ITeaTypeListResult[]
console.log("🚀 ~ teaList.value:", teaList.value)
@ -495,9 +559,57 @@
/**
* 选择服务方式
* @param type 服务类型 1到店服务 2上门服务
*/
handleChooseService: (type: number) => {
serviceTypeValue.value = type
if (type === 1) {
Door.handleResetTime()
address.value = {
id: 0,
contact: '',
telephone: '',
longitude: 0,
latitude: 0,
address: '',
is_default: 0,
}
}
if (type === 2) {
// 重置事件选择
reserveTime.value = []
dayTitle.value = ''
dayTime.value = ''
dayHours.value = ''
sevenDay.minimum_time = MINIMUMTIME
sevenDay.time = []
teaHouse.value = {id: 0, name: ''}
}
},
/**
* 选择预订时间
*/
handleChooseTime: async () => {
if (serviceTypeValue.value === 1 && teaHouse.value.id === 0) {
// 到店服务必须要选择门店
toast.show('请先选择门店')
return false
}
if (serviceTypeValue.value === 1) {
const storeId = teaHouse.value.id || 0
const next7 = await getNext7Days(storeId, getCurrentDate())
// disabled = 0 可预约 1不可逾越
Object.assign(sevenDay, next7.data)
Object.assign(sevenDay, {minimum_time: MINIMUMTIME})
showBookTimePopup.value = true
} else if (serviceTypeValue.value === 2) {
// 上门服务
showReservePopup.value = true
}
},
/**
@ -524,8 +636,9 @@
/**
* 选择门店
*/
handleToSChooseStore: () => {
handleToChooseStore: () => {
uni.$on('chooseTeaHouse', params => {
console.log("🚀 ~ params:", params)
uni.$off('chooseTeaHouse')
teaHouse.value = params
})
@ -547,17 +660,45 @@
* 选中预定时间
*/
handleChooseReserveTime: (params: any) => {
console.log("🚀 ~ params:", params)
reserveTime.value = params
if (!digits(params.countSelectedTime)) {
message.alert({
title: '提示',
msg: '选择时间段不满一小时按一小时算请合理选择时间',
confirmButtonText: '确定',
cancelButtonProps: {
customClass: '!bg-[#F6F7F8] !text-[#303133] !text-32rpx !leading-44rpx !rounded-8rpx',
},
confirmButtonProps: {
customClass: '!bg-[#4C9F44] !text-[#fff] !text-32rpx !leading-44rpx !rounded-8rpx',
},
})
}
timeSlots.value = params.selectedTimestamps
dayTitle.value = params.dayTitle
dayTime.value = params.dayTime
const times = params.selectedTime.map(item => {
return item.time
}).join(',')
dayHours.value = times
startTime.value = params.selectedTimestamps[0]
console.log("🚀 ~ startTime.value:", startTime.value)
endTime.value = params.selectedTimestamps[params.selectedTimestamps.length - 1]
console.log("🚀 ~ endTime.value:", endTime.value)
countHours.value = params.countSelectedTime
bill.value.service = {
total: toTimes(info.price, params[3]),
unitPrice: info.price,
num: params[3],
startTime: params[2][0],
endTime: params[2][params[2].length - 1],
},
total: 0,
unitPrice: 0,
num: params.countSelectedTime,
startHour: params.selectedTime[0].time,
endHour: params.selectedTime[params.selectedTime.length - 1].time
}
console.log("🚀 ~ bill.value:", bill.value)
// Detail.handleCalculateTeaRoomPrice()
},
/**
@ -572,18 +713,14 @@
uni.$off('chooseCoupon');
uni.$on('chooseCoupon', params => {
uni.$off('chooseCoupon')
// console.log("🚀 ~ params:", params)
// selectedCoupon.value = {id: params.coupon.user_coupon_id, name: `${params.coupon.name}减${params.coupon.coupon_price}` }
// bill.value.coupon = params.coupon.coupon_price
selectedCoupon.value = {id: params.coupon.id, name: `${params.coupon.name}${params.coupon.coupon_price}` }
selectedCoupon.value = {id: params.coupon.id, name: params.coupon.name}
bill.value.coupon = params.coupon.coupon_price
selectCouponId.value = params.coupon.id // 这里的ID是在数据表自增的ID保存下来是为了回显列表的,没有其他作用
})
// 获取预定了几个小时
const count = bill.value.service.num
uni.navigateTo({ url: `/bundle/coupon/coupon?id=${teaSpecialistId.value}&numbers=${count}&type=${type}` })
// router.navigateTo(`/bundle/coupon/coupon?id=${id.value}&numbers=${count}&type=${type}&storeId=${storeId.value}&couponId=${selectCouponId.value}&groupCouponId=${selectGroupCouponId.value}`)
router.navigateTo(`/bundle_b/pages/tea-specialist/coupon?couponId=${selectCouponId.value}`)
},
/**
@ -630,23 +767,23 @@
toast.info('请选择茶艺时服务')
return
}
// 提交的订单数据
const params = {
teamaster_id: info.id,
address_id: address.value.id,
start_time: bill.value.service.startTime,
end_time: bill.value.service.endTime,
nums: servicePeople.value,
tea_id: selectedTea.value.join(','),
service_type: serviceTypeValue.value,
store_id: teaHouse.value.id,
latitude: uni.getStorageSync('latitude') || 0,
longitude: uni.getStorageSync('longitude') || 0,
remark: orderRemarks.value,
coupon_id: selectedCoupon.value.id || 0,
hours: bill.value.service.num
team_user_id: id.value, // 茶艺师ID
server_type: serviceTypeValue.value, // 服务方式 1到店服务 2上门服务
longitude: uni.getStorageSync('longitude'), // 经度
latitude: uni.getStorageSync('latitude'), // 纬度
store_id: serviceTypeValue.value == 1 ? teaHouse.value.id : 0, // 茶室Id如果是上门服务则传0
address: serviceTypeValue.value == 1 ? teaHouse.value.name : address.value.address, // 地址: 到店传茶室名称 上门则传地址
start_time: serviceTypeValue.value == 1 ? startTime.value : Math.floor(Door.startTimeTimestamp / 1000), // 预约开始时间
end_time: serviceTypeValue.value == 1 ? endTime.value : Math.floor(Door.endTimeTimestamp / 1000), // 预约结束时间
hours: serviceTypeValue.value == 1 ? countHours.value : totalHour.value, // 预约小时数
remrk: orderRemarks.value, // 订单备注
is_teacup: teaUsageValue.value, // 是否需要茶具 1客户自备 2茶艺师提供
tea_id: selectedTea.value.join(','), // 茶叶商品ids 多个逗号隔开
user_coupon_id: selectedCoupon.value.id, // 优惠券id默认传0
}
try {
const res = await createTeaSpecialistOrder(params)
@ -676,6 +813,113 @@
}
}
// 上门服务
const Door = {
startTimeTimestamp: 0, // 记录开始时间戳
endTimeTimestamp: 0, // 记录结束时间戳
handleStartTimePicker: (e: {value: number}) => {
Door.startTimeTimestamp = e.value
startTimeLayout.value = Door.handleFormatDate(e.value)
Door.handleTotalTimestamp()
},
handleEndTimePicker: (e: {value: number}) => {
Door.endTimeTimestamp = e.value
endTimeLayout.value = Door.handleFormatDate(e.value)
Door.handleTotalTimestamp()
},
handleFormatTime: (type: string, values: string) => {
const now = new Date();
if (type === 'year') {
return `${values}`
}
if (type === 'month') {
return `${values}`
}
if (type === 'date') {
return `${values}`
}
if (type === 'hour') {
return `${values}`;
}
if (type === 'minute') {
return `${values}`;
}
return values
},
handleTotalTimestamp: () => {
if (Door.startTimeTimestamp && Door.endTimeTimestamp) {
const diffMs = Door.endTimeTimestamp - Door.startTimeTimestamp
// 计算小时,保留一位小数
const hours = (diffMs / 1000 / 60 / 60)
const result = Math.round(hours * 10) / 10 // 保留一位小数
if (result >= 0) {
totalHour.value = result
}
return result
}
totalHour.value = 0
return 0
},
/**
* 格式化时间
*/
handleFormatDate: (timestamp: number) => {
const date = new Date(timestamp)
const year = date.getFullYear()
const month = String(date.getMonth() + 1).padStart(2, '0')
const day = String(date.getDate()).padStart(2, '0')
const hour = String(date.getHours()).padStart(2, '0')
const minute = String(date.getMinutes()).padStart(2, '0')
return `${year}-${month}-${day} ${hour}:${minute}`
},
/**
* 重置预定时间
*/
handleResetTime: () => {
startTimeValue.value = ''
endTimeValue.value = ''
startTimeLayout.value = ''
endTimeLayout.value = ''
Door.startTimeTimestamp = 0
Door.endTimeTimestamp = 0
totalHour.value = 0
currentTimePicker.value = 'start'
},
/**
* 确定时间
*/
handleConfirmHour: () => {
if (totalHour.value <= sevenDay.minimum_time) {
toast.info(`起订时间${sevenDay.minimum_time}小时`)
return
}
if (!digits(totalHour.value)) {
message.alert({
title: '提示',
msg: '选择时间段不满一小时按一小时算请合理选择时间',
confirmButtonText: '确定',
cancelButtonProps: {
customClass: '!bg-[#F6F7F8] !text-[#303133] !text-32rpx !leading-44rpx !rounded-8rpx',
},
confirmButtonProps: {
customClass: '!bg-[#4C9F44] !text-[#fff] !text-32rpx !leading-44rpx !rounded-8rpx',
},
})
}
showReservePopup.value = false
},
}
const billTotal = computed(() => {
const s = Number(bill.value.service.total) || 0
const t = Number(bill.value.travel.total) || 0