调试接口
This commit is contained in:
@ -58,4 +58,13 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.booking-time {
|
||||||
|
:deep() {
|
||||||
|
.wd-tabs__line--inner,
|
||||||
|
.wd-tabs__line {
|
||||||
|
background-color: #4C9F44 !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@ -25,6 +25,6 @@ export function getBankCardList() {
|
|||||||
/**
|
/**
|
||||||
* 提现申请
|
* 提现申请
|
||||||
*/
|
*/
|
||||||
export function withdrawApply(amount: number, bank_id: number) {
|
export function withdrawApply(store_id: number, amount: number, bank_id: number) {
|
||||||
return http.Post('/storeapi/user/submitReflect', { amount, bank_id })
|
return http.Post('/storeapi/user/submitReflect', { store_id, amount, bank_id })
|
||||||
}
|
}
|
||||||
@ -151,8 +151,8 @@ export function getStoreTeaRoomList(data: IStoreTeaRoomListParams) {
|
|||||||
/**
|
/**
|
||||||
* 获取未来7天时间
|
* 获取未来7天时间
|
||||||
*/
|
*/
|
||||||
export function getNext7Days() {
|
export function getNext7Days(room_id: number, date: string) {
|
||||||
return http.Post<ITeaSpecialistFuture7DaysResult>('/api/Common/get7Time')
|
return http.Post<any>('/api/Common/get7Time', {room_id, date})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -4,4 +4,5 @@ export interface IAddBankCardParams {
|
|||||||
mobile: number|string
|
mobile: number|string
|
||||||
code: number|string
|
code: number|string
|
||||||
bank_open_name: string
|
bank_open_name: string
|
||||||
|
name: string
|
||||||
}
|
}
|
||||||
@ -71,4 +71,11 @@ export interface IResetPasswordParams {
|
|||||||
|
|
||||||
export function resetPassword(data: IResetPasswordParams) {
|
export function resetPassword(data: IResetPasswordParams) {
|
||||||
return http.Post('/storeapi/storeLogin/resetPassword', data)
|
return http.Post('/storeapi/storeLogin/resetPassword', data)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询用户余额
|
||||||
|
*/
|
||||||
|
export function getUserBalance(store_id: number) {
|
||||||
|
return http.Post<any>('/storeapi/user/checkMoney', {store_id})
|
||||||
}
|
}
|
||||||
@ -30,7 +30,7 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="flex flex-col items-center justify-start">
|
<view class="flex flex-col items-center justify-start">
|
||||||
<view class="font-400 text-24rpx text-[#606266] text-34rpx">待提现</view>
|
<view class="font-400 text-24rpx text-[#606266] text-34rpx">待提现</view>
|
||||||
<view class="font-bold text-32rpx text-[#303133] leading-34rpx mt-14rpx">{{ userFinance.user_money }}</view>
|
<view class="font-bold text-32rpx text-[#303133] leading-34rpx mt-14rpx">{{ userFinance.balance }}</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@ -81,7 +81,7 @@
|
|||||||
import { router } from '@/utils/tools'
|
import { router } from '@/utils/tools'
|
||||||
import { onPageScroll, onReachBottom } from '@dcloudio/uni-app'
|
import { onPageScroll, onReachBottom } from '@dcloudio/uni-app'
|
||||||
import useMescroll from "@/uni_modules/mescroll-uni/hooks/useMescroll.js"
|
import useMescroll from "@/uni_modules/mescroll-uni/hooks/useMescroll.js"
|
||||||
import { getStoreIncomeList } from '@/api/store'
|
import { getStoreIncomeList, getStoreDetails } from '@/api/store'
|
||||||
import { useStoreStore } from '@/store'
|
import { useStoreStore } from '@/store'
|
||||||
import { getUserInfo } from '@/api/user'
|
import { getUserInfo } from '@/api/user'
|
||||||
|
|
||||||
@ -115,10 +115,10 @@
|
|||||||
*/
|
*/
|
||||||
handleGetFinanceData: async () => {
|
handleGetFinanceData: async () => {
|
||||||
try {
|
try {
|
||||||
const res = await getUserInfo()
|
const res = await getStoreDetails(useStore.defaultStore.id)
|
||||||
userFinance.value = res
|
userFinance.value = res.details
|
||||||
} catch(e) {
|
console.log("🚀 ~ userFinance.value:", userFinance.value)
|
||||||
}
|
} catch(e) { }
|
||||||
},
|
},
|
||||||
|
|
||||||
upCallback: (mescroll) => {
|
upCallback: (mescroll) => {
|
||||||
@ -130,7 +130,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
getStoreIncomeList(filter).then((res) => {
|
getStoreIncomeList(filter).then((res) => {
|
||||||
console.log("🚀 ~ res:", res)
|
|
||||||
const curPageData = res.list || [] // 当前页数据
|
const curPageData = res.list || [] // 当前页数据
|
||||||
if(mescroll.num == 1) list.value = [] // 第一页需手动制空列表
|
if(mescroll.num == 1) list.value = [] // 第一页需手动制空列表
|
||||||
list.value = list.value.concat(curPageData) //追加新数据
|
list.value = list.value.concat(curPageData) //追加新数据
|
||||||
|
|||||||
@ -68,6 +68,21 @@
|
|||||||
<view>
|
<view>
|
||||||
<wd-gap height="2rpx" bg-color="#F2F2F2"></wd-gap>
|
<wd-gap height="2rpx" bg-color="#F2F2F2"></wd-gap>
|
||||||
</view>
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 提现人名称 -->
|
||||||
|
<view>
|
||||||
|
<view class="flex justify-between items-center mx-38rpx">
|
||||||
|
<view class="text-30rpx leading-42rpx text-#303133">提现人名称</view>
|
||||||
|
<view class="flex items-center">
|
||||||
|
<view >
|
||||||
|
<wd-input v-model="form.name" size="large" placeholder="请输入 提现人名称" no-border custom-input-class="!text-right" placeholderStyle="font-size: 30rpx; line-height: 42rpx; color: #c9c9c9;text-align: right;"></wd-input>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view>
|
||||||
|
<wd-gap height="2rpx" bg-color="#F2F2F2"></wd-gap>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 验证码 -->
|
<!-- 验证码 -->
|
||||||
@ -125,6 +140,7 @@
|
|||||||
mobile: '',
|
mobile: '',
|
||||||
code: '',
|
code: '',
|
||||||
bank_open_name: '',
|
bank_open_name: '',
|
||||||
|
name: ''
|
||||||
})
|
})
|
||||||
|
|
||||||
const Add = {
|
const Add = {
|
||||||
|
|||||||
@ -99,7 +99,7 @@
|
|||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { getBankCardList, withdrawApply } from '@/api/bank'
|
import { getBankCardList, withdrawApply } from '@/api/bank'
|
||||||
import { useUserStore } from '@/store'
|
import { useUserStore, useStoreStore } from '@/store'
|
||||||
import { toast } from '@/utils/toast'
|
import { toast } from '@/utils/toast'
|
||||||
import { amount } from '@/utils/test'
|
import { amount } from '@/utils/test'
|
||||||
import { router } from '@/utils/tools'
|
import { router } from '@/utils/tools'
|
||||||
@ -107,6 +107,7 @@
|
|||||||
|
|
||||||
const OSS = inject('OSS')
|
const OSS = inject('OSS')
|
||||||
const useStore = useUserStore()
|
const useStore = useUserStore()
|
||||||
|
const store = useStoreStore()
|
||||||
|
|
||||||
// 选择银行卡
|
// 选择银行卡
|
||||||
const showBankCardPopup = ref<boolean>(false)
|
const showBankCardPopup = ref<boolean>(false)
|
||||||
@ -128,7 +129,7 @@
|
|||||||
height: 'calc(100vh - var(--window-top) - var(--window-bottom))'
|
height: 'calc(100vh - var(--window-top) - var(--window-bottom))'
|
||||||
}))
|
}))
|
||||||
|
|
||||||
onLoad(() => {
|
onShow(() => {
|
||||||
Withdraw.getBankCardList()
|
Withdraw.getBankCardList()
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -203,7 +204,7 @@
|
|||||||
title: '提交中...'
|
title: '提交中...'
|
||||||
})
|
})
|
||||||
try {
|
try {
|
||||||
await withdrawApply(money, selectBank.value.id)
|
await withdrawApply(store.defaultStore.id, money, selectBank.value.id)
|
||||||
// 重新获取用户余额
|
// 重新获取用户余额
|
||||||
const balance = await getUserInfo()
|
const balance = await getUserInfo()
|
||||||
useStore.setUserMoney(Number(balance.user_money))
|
useStore.setUserMoney(Number(balance.user_money))
|
||||||
|
|||||||
@ -9,45 +9,44 @@
|
|||||||
<view class="">
|
<view class="">
|
||||||
<view class="booking-time">
|
<view class="booking-time">
|
||||||
<wd-tabs v-model="selectedDay" color="#4C9F44" @click="BookingTime.handleChangeTimeTab">
|
<wd-tabs v-model="selectedDay" color="#4C9F44" @click="BookingTime.handleChangeTimeTab">
|
||||||
<block v-for="item in day.time" :key="item">
|
<scroll-view scroll-y class="!h-500rpx pb-100rpx">
|
||||||
<scroll-view scroll-y>
|
<block v-for="item in day.time" :key="item">
|
||||||
<wd-tab :title="`${item.display}`" :name="item.display">
|
<wd-tab :title="`${item.display}`" :name="item.display">
|
||||||
<view class="">
|
<view class="">
|
||||||
<view class="!h-500rpx mt-30rpx">
|
<view class=" mt-30rpx">
|
||||||
<view class="grid grid-cols-4 gap-x-20rpx gap-y-20rpx mx-30rpx">
|
<view class="grid grid-cols-4 gap-x-20rpx gap-y-20rpx mx-30rpx">
|
||||||
<view v-for="item2 in item.time_slots" :key="item2.start_time"
|
<view v-for="item2 in item.time_slots" :key="item2.start_time"
|
||||||
class="h-72rpx rounded-16rpx flex items-center justify-center text-28rpx leading-40rpx"
|
class="h-72rpx rounded-16rpx flex items-center justify-center text-28rpx leading-40rpx"
|
||||||
:class="[
|
:class="[
|
||||||
item2.disabled == 0
|
item2.disabled == 1
|
||||||
? 'bg-[#F7F7F7] text-[#C9C9C9]' // 禁用高亮
|
? 'bg-[#F7F7F7] text-[#C9C9C9]' // 禁用高亮
|
||||||
: selectedTime.includes(item2.start_time)
|
: selectedTime.some(t => t.date === item.date && t.time === item2.start_time)
|
||||||
? 'bg-[#F1F8F0] text-[#4C9F44]' // 选中高亮
|
? 'bg-[#F1F8F0] text-[#4C9F44]' // 选中高亮
|
||||||
: 'bg-[#F7F7F7] text-[#303133]', // 可选高亮
|
: 'bg-[#F7F7F7] text-[#303133]', // 可选高亮
|
||||||
]" @click="item2.disabled == 1 && BookingTime.handleSelectTime(item2.start_time, item2.timestamp, item.time_slots)">
|
]" @click="item2.disabled == 0 && BookingTime.handleSelectTime(item2.start_time, item2.timestamp, item.time_slots, item.date, item.display)">
|
||||||
{{ item2.start_time }}
|
{{ item2.start_time }}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="">
|
|
||||||
<view>
|
|
||||||
<wd-gap height="2rpx" bg-color="#E5E5E5"></wd-gap>
|
|
||||||
</view>
|
|
||||||
<view class="">
|
|
||||||
<view class="w-full fixed bottom-0 left-0 right-0 bg-white h-152rpx text-32rpx leading-44rpx flex items-center justify-center leading-90rpx text-center">
|
|
||||||
<view class="w-330rpx h-90rpx bg-[#F6F7F8] rounded-8rpx text-[#303133] mr-30rpx" @click="BookingTime.handleResetSelectedTime">重置</view>
|
|
||||||
<view class="w-330rpx h-90rpx bg-[#4C9F44] rounded-8rpx text-[#fff]" @click="BookingTime.handleConfirmSelectedTime">
|
|
||||||
<text>确定</text>
|
|
||||||
<text v-if="countSelectedTime">({{countSelectedTime}}小时)</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
</wd-tab>
|
</wd-tab>
|
||||||
</scroll-view>
|
</block>
|
||||||
</block>
|
</scroll-view>
|
||||||
</wd-tabs>
|
</wd-tabs>
|
||||||
|
<view class="">
|
||||||
|
<view>
|
||||||
|
<wd-gap height="2rpx" bg-color="#E5E5E5"></wd-gap>
|
||||||
|
</view>
|
||||||
|
<view class="">
|
||||||
|
<view class="w-full fixed bottom-0 left-0 right-0 bg-white h-152rpx text-32rpx leading-44rpx flex items-center justify-center leading-90rpx text-center">
|
||||||
|
<view class="w-330rpx h-90rpx bg-[#F6F7F8] rounded-8rpx text-[#303133] mr-30rpx" @click="BookingTime.handleResetSelectedTime">重置</view>
|
||||||
|
<view class="w-330rpx h-90rpx bg-[#4C9F44] rounded-8rpx text-[#fff]" @click="BookingTime.handleConfirmSelectedTime">
|
||||||
|
<text>确定</text>
|
||||||
|
<text v-if="countSelectedTime">({{countSelectedTime}}小时)</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@ -78,61 +77,61 @@
|
|||||||
|
|
||||||
// 初始化时间
|
// 初始化时间
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
console.log("🚀 ~ day:", props.day)
|
||||||
})
|
})
|
||||||
|
|
||||||
/** 日期相关 **/
|
/** 日期相关 **/
|
||||||
|
|
||||||
const days = ref<string[]>([])
|
const days = ref<string[]>([])
|
||||||
const selectedDay = ref<number>(0)
|
const selectedDay = ref<number>(0)
|
||||||
const selectedTime = ref<string[]>([])
|
// 支持跨天选择,结构为 { date, time, timestamp }
|
||||||
const selectedTimeStamp = ref<number[]>([])
|
const selectedTime = ref<Array<{ date: string, time: string, timestamp: number }>>([])
|
||||||
const countSelectedTime = ref<number>(0)
|
const countSelectedTime = ref<number>(0)
|
||||||
|
const selectTimeIndex = ref<number>(0) // 选择的时间tab索引
|
||||||
|
|
||||||
const BookingTime = {
|
const BookingTime = {
|
||||||
/**
|
/**
|
||||||
* 选择时间段逻辑
|
* 选择时间段逻辑,支持跨天
|
||||||
|
* @param time 选择的时间字符串 "HH:MM"
|
||||||
|
* @param timestamp 选择的时间戳
|
||||||
|
* @param timeSlots 当前日期的所有时间段
|
||||||
|
* @param date 当前选择的日期 "2025-12-20"
|
||||||
|
* @param display 当前选择的日期展示 "12/20周六"
|
||||||
*/
|
*/
|
||||||
handleSelectTime: (time: string, timestamp: number, timeSlots: any[]) => {
|
handleSelectTime: (time: string, timestamp: number, timeSlots: any[], date: string, display: string) => {
|
||||||
// 获取当前tab下所有可选时间段(未禁用)
|
// 获取当前tab的日期
|
||||||
const availableSlots = timeSlots.filter(slot => slot.disabled == 1)
|
const currentDate = props.day.time[selectTimeIndex.value].date
|
||||||
const times = availableSlots.map(slot => slot.start_time)
|
const idx = selectedTime.value.findIndex(t => t.date === currentDate && t.time === time)
|
||||||
const timestamps = availableSlots.map(slot => slot.timestamp)
|
if (selectedTime.value.length === 0 || selectedTime.value.length > 1) {
|
||||||
const idx = times.indexOf(time)
|
// 第一次点击或已选2个及以上,重置为只选当前
|
||||||
|
selectedTime.value = [{ date: currentDate, time, timestamp }]
|
||||||
// 当前已选的索引
|
} else if (selectedTime.value.length === 1) {
|
||||||
const selectedIdxArr = selectedTime.value.map(t => times.indexOf(t)).sort((a, b) => a - b)
|
// 第二次点击,做范围选择
|
||||||
|
const first = selectedTime.value[0]
|
||||||
if (selectedTime.value.length === 0) {
|
const second = { date: currentDate, time, timestamp }
|
||||||
// 没有已选,直接选中
|
// 获取所有可选时间段(含跨天)
|
||||||
selectedTime.value = [time]
|
let allSlots = []
|
||||||
selectedTimeStamp.value = [timestamp]
|
props.day.time.forEach(dayItem => {
|
||||||
} else if (selectedTime.value.includes(time)) {
|
dayItem.time_slots.forEach(slot => {
|
||||||
// 如果点击的是已选的端点,则取消该端及之后/之前的所有时间
|
if (slot.disabled == 0) {
|
||||||
const minIdx = selectedIdxArr[0]
|
allSlots.push({ date: dayItem.date, time: slot.start_time, timestamp: slot.timestamp })
|
||||||
const maxIdx = selectedIdxArr[selectedIdxArr.length - 1]
|
}
|
||||||
if (idx === minIdx) {
|
})
|
||||||
// 取消左端
|
})
|
||||||
selectedTime.value = times.slice(idx + 1, maxIdx + 1)
|
// 按 timestamp 排序
|
||||||
selectedTimeStamp.value = timestamps.slice(idx + 1, maxIdx + 1)
|
allSlots = allSlots.sort((a, b) => a.timestamp - b.timestamp)
|
||||||
} else if (idx === maxIdx) {
|
// 找到 first 和 second 的索引
|
||||||
// 取消右端
|
const idx1 = allSlots.findIndex(t => t.date === first.date && t.time === first.time)
|
||||||
selectedTime.value = times.slice(minIdx, idx)
|
const idx2 = allSlots.findIndex(t => t.date === second.date && t.time === second.time)
|
||||||
selectedTimeStamp.value = timestamps.slice(minIdx, idx)
|
if (idx1 > -1 && idx2 > -1) {
|
||||||
|
const [start, end] = idx1 < idx2 ? [idx1, idx2] : [idx2, idx1]
|
||||||
|
selectedTime.value = allSlots.slice(start, end + 1)
|
||||||
} else {
|
} else {
|
||||||
// 如果点的是中间的,直接只保留左侧
|
// 找不到则只选当前
|
||||||
selectedTime.value = times.slice(minIdx, idx)
|
selectedTime.value = [second]
|
||||||
selectedTimeStamp.value = timestamps.slice(minIdx, idx)
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// 新选,补全区间
|
|
||||||
const allIdx = selectedIdxArr.concat(idx)
|
|
||||||
const minIdx = Math.min(...allIdx)
|
|
||||||
const maxIdx = Math.max(...allIdx)
|
|
||||||
selectedTime.value = times.slice(minIdx, maxIdx + 1)
|
|
||||||
selectedTimeStamp.value = timestamps.slice(minIdx, maxIdx + 1)
|
|
||||||
}
|
}
|
||||||
|
countSelectedTime.value = BookingTime.handleCalcContinuousHours(selectedTime.value.map(t => t.timestamp))
|
||||||
countSelectedTime.value = BookingTime.handleCalcContinuousHours(selectedTime.value)
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// 确认选择的时间
|
// 确认选择的时间
|
||||||
@ -146,45 +145,87 @@
|
|||||||
toast.info(props.day.minimum_time + '小时起订')
|
toast.info(props.day.minimum_time + '小时起订')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 返回所有已选的时间段(含日期、时间、timestamp)及所有timestamp数组
|
||||||
|
const sortedSelected = selectedTime.value.slice().sort((a, b) => a.timestamp - b.timestamp)
|
||||||
|
const timestamps = sortedSelected.map(t => t.timestamp)
|
||||||
|
|
||||||
|
// 格式化时间戳为 2025-12-18 和 周三03/18
|
||||||
|
function formatDate(ts: number) {
|
||||||
|
const d = new Date(ts * 1000)
|
||||||
|
const y = d.getFullYear()
|
||||||
|
const m = (d.getMonth() + 1).toString().padStart(2, '0')
|
||||||
|
const day = d.getDate().toString().padStart(2, '0')
|
||||||
|
return `${y}-${m}-${day}`
|
||||||
|
}
|
||||||
|
function formatWeek(ts: number) {
|
||||||
|
const d = new Date(ts * 1000)
|
||||||
|
const weekArr = ['周日','周一','周二','周三','周四','周五','周六']
|
||||||
|
const week = weekArr[d.getDay()]
|
||||||
|
const m = (d.getMonth() + 1).toString().padStart(2, '0')
|
||||||
|
const day = d.getDate().toString().padStart(2, '0')
|
||||||
|
return `${week}${m}/${day}`
|
||||||
|
}
|
||||||
|
const formattedStartDates = formatDate(timestamps[0])
|
||||||
|
const formattedEndtDates = formatDate(timestamps[timestamps.length - 1])
|
||||||
|
|
||||||
|
let dayTime = '' // 2025-12-18
|
||||||
|
if (formattedStartDates == formattedEndtDates) {
|
||||||
|
dayTime = formattedStartDates
|
||||||
|
} else {
|
||||||
|
dayTime = `${formattedStartDates} 至 ${formattedEndtDates}`
|
||||||
|
}
|
||||||
|
|
||||||
|
let dayTitle = '' // 周三03/18
|
||||||
|
const formattedStartWeeks = formatWeek(timestamps[0])
|
||||||
|
const formattedEndWeeks = formatWeek(timestamps[timestamps.length - 1])
|
||||||
|
if (formattedStartWeeks == formattedEndWeeks) {
|
||||||
|
dayTitle = formattedStartWeeks
|
||||||
|
} else {
|
||||||
|
dayTitle = `${formattedStartWeeks} 至 ${formattedEndWeeks}`
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = {
|
||||||
|
selectedDay: dayTime,
|
||||||
|
selectedTime: sortedSelected,
|
||||||
|
selectedTimestamps: timestamps,
|
||||||
|
dayTitle,
|
||||||
|
dayTime,
|
||||||
|
countSelectedTime: countSelectedTime.value
|
||||||
|
}
|
||||||
|
|
||||||
const data = [
|
|
||||||
selectedDay.value,
|
|
||||||
selectedTime.value.sort(),
|
|
||||||
selectedTimeStamp.value.sort(),
|
|
||||||
countSelectedTime.value
|
|
||||||
]
|
|
||||||
emit('selectedTime', data)
|
emit('selectedTime', data)
|
||||||
showPopup.value = false
|
showPopup.value = false
|
||||||
},
|
},
|
||||||
|
|
||||||
// 切换时间tab的时候把之前选中的时间重置
|
// 切换时间tab的时候不重置已选,实现跨天选择
|
||||||
handleChangeTimeTab: () => {
|
handleChangeTimeTab: (e: any) => {
|
||||||
selectedTime.value = []
|
selectTimeIndex.value = e.index
|
||||||
selectedTimeStamp.value = []
|
// 不重置 selectedTime
|
||||||
countSelectedTime.value = 0
|
|
||||||
},
|
},
|
||||||
|
|
||||||
handleCalcContinuousHours(times: string[]): number {
|
// 计算所有连续区间的小时数总和,timestamps 为时间戳数组
|
||||||
if (times.length < 2) return 0
|
handleCalcContinuousHours(timestamps: number[]): number {
|
||||||
// 排序
|
if (timestamps.length < 1) return 0
|
||||||
const sorted = times.slice().sort()
|
const sorted = timestamps.slice().sort((a, b) => a - b)
|
||||||
let count = 0
|
let count = 0
|
||||||
|
let segment = 1
|
||||||
for (let i = 1; i < sorted.length; i++) {
|
for (let i = 1; i < sorted.length; i++) {
|
||||||
// 取前后时间的小时数
|
if (sorted[i] - sorted[i - 1] === 1800) {
|
||||||
const [h1, m1] = sorted[i - 1].split(':').map(Number)
|
segment++
|
||||||
const [h2, m2] = sorted[i].split(':').map(Number)
|
} else {
|
||||||
// 如果是连续的1小时(分钟相同且小时差1),则+1
|
count += (segment - 1) * 0.5
|
||||||
if (m1 === m2 && h2 - h1 === 1) {
|
segment = 1
|
||||||
count++
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
count += (segment - 1) * 0.5
|
||||||
return count
|
return count
|
||||||
},
|
},
|
||||||
|
|
||||||
// 重置选择的时间
|
// 重置选择的时间
|
||||||
handleResetSelectedTime: () => {
|
handleResetSelectedTime: () => {
|
||||||
selectedTime.value = []
|
selectedTime.value = []
|
||||||
selectedTimeStamp.value = []
|
countSelectedTime.value = 0
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,12 +241,6 @@
|
|||||||
export default {}
|
export default {}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss">
|
||||||
.booking-time {
|
|
||||||
:deep() {
|
</style>
|
||||||
.wd-tabs__line {
|
|
||||||
background-color: #4C9F44 !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@ -147,13 +147,13 @@
|
|||||||
<view class="mt-22rpx">
|
<view class="mt-22rpx">
|
||||||
<view class="flex items-center">
|
<view class="flex items-center">
|
||||||
<view class="mr-28rpx">
|
<view class="mr-28rpx">
|
||||||
<wd-img width="200rpx" height="200rpx" :src="`${OSS}images/home/home_image5.png`"></wd-img>
|
<wd-img width="200rpx" height="200rpx" :src="order.img"></wd-img>
|
||||||
</view>
|
</view>
|
||||||
<view class="flex-1">
|
<view class="flex-1">
|
||||||
<view @click="ComboCard.handleToOrderDetail(order.id)">
|
<view @click="ComboCard.handleToOrderDetail(order.id)">
|
||||||
<view class="font-500 text-30rpx text-[#303133] leading-42rpx line-1 w-400rpx">{{ order.room_name }}</view>
|
<view class="font-500 text-30rpx text-[#303133] leading-42rpx line-1 w-400rpx">{{ order.room_name }}</view>
|
||||||
<view class="font-400 leading-36rpx text-26rpx text-[#606266] mt-34rpx">
|
<view class="font-400 leading-36rpx text-26rpx text-[#606266] mt-34rpx">
|
||||||
<view>预约时间:{{ order.day_time }} {{ order.start_time }}-{{ order.end_time }}</view>
|
<view>预约时间:{{ order.day_title }} {{ order.start_time }}-{{ order.end_time }}</view>
|
||||||
<view class="mt-18rpx">预约时长:{{ order.hours }}小时</view>
|
<view class="mt-18rpx">预约时长:{{ order.hours }}小时</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@ -57,10 +57,10 @@
|
|||||||
|
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { router } from '@/utils/tools'
|
import { router, getCurrentDate } from '@/utils/tools'
|
||||||
import type { ITeaSpecialistFuture7DaysResult } from '@/api/types/tea'
|
import type { ITeaSpecialistFuture7DaysResult } from '@/api/types/tea'
|
||||||
import { getNext7Days } from '@/api/tea-room'
|
import { getNext7Days, getTeaRoomDetail } from '@/api/tea-room'
|
||||||
import { getAllRoomList, reserveRoom } from '@/api/store'
|
import { getAllRoomList, reserveRoom, getRoomDetails } from '@/api/store'
|
||||||
import { useStoreStore } from '@/store'
|
import { useStoreStore } from '@/store'
|
||||||
import { toast } from '@/utils/toast'
|
import { toast } from '@/utils/toast'
|
||||||
|
|
||||||
@ -74,25 +74,25 @@
|
|||||||
minimum_time: 0,
|
minimum_time: 0,
|
||||||
time: []
|
time: []
|
||||||
})
|
})
|
||||||
const reserveTime = ref<Array<any>>([])
|
const reserveTime = ref<any>({})
|
||||||
|
const dayTitle = ref<string>('') // 周三03/18
|
||||||
|
const dayTime = ref<string>('') // 2024-03-18
|
||||||
|
const displayTime = ref<string>('') // 预定时长00:00,00:30
|
||||||
|
|
||||||
const form = ref({
|
const form = ref({
|
||||||
|
store_id: useStore.defaultStore.id,
|
||||||
id: 0, // 包间ID
|
id: 0, // 包间ID
|
||||||
name: '', // 包间名称
|
name: '', // 包间名称
|
||||||
price: '', // 包间价格
|
price: '', // 包间价格
|
||||||
day_time: '', // 预定日期
|
day_time: '', // 预定日期
|
||||||
|
day_title: '', // 预定日期标题
|
||||||
start_time: '', // 开始时间
|
start_time: '', // 开始时间
|
||||||
end_time: '', // 结束时间
|
end_time: '', // 结束时间
|
||||||
hours: 0, // 预定小时数
|
hours: 0, // 预定小时数
|
||||||
|
timeslot: [], // 预定时间段
|
||||||
})
|
})
|
||||||
const displayTime = ref<string>('')
|
|
||||||
|
|
||||||
onLoad(async (args) => {
|
onLoad(async (args) => {
|
||||||
|
|
||||||
// 预定时间
|
|
||||||
const next7 = await getNext7Days()
|
|
||||||
Object.assign(sevenDay, next7)
|
|
||||||
|
|
||||||
// 获取包厢列表
|
// 获取包厢列表
|
||||||
const res = await getAllRoomList(useStore.defaultStore.id)
|
const res = await getAllRoomList(useStore.defaultStore.id)
|
||||||
columns.value = res.list.map((item: any) => ({
|
columns.value = res.list.map((item: any) => ({
|
||||||
@ -109,8 +109,14 @@
|
|||||||
* 选中包厢
|
* 选中包厢
|
||||||
* @param params
|
* @param params
|
||||||
*/
|
*/
|
||||||
handleConfirmRoom: (item) => {
|
handleConfirmRoom: async (item) => {
|
||||||
form.value.id = item.selectedItems.id
|
form.value.id = item.selectedItems.id
|
||||||
|
const res = await getRoomDetails(form.value.id)
|
||||||
|
|
||||||
|
// 预定时间
|
||||||
|
const next7 = await getNext7Days(form.value.id, getCurrentDate())
|
||||||
|
Object.assign(sevenDay, next7.data)
|
||||||
|
Object.assign(sevenDay, {minimum_time: res.details.room.hours})
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -118,10 +124,13 @@
|
|||||||
*/
|
*/
|
||||||
handleChooseReserveTime: (params: any) => {
|
handleChooseReserveTime: (params: any) => {
|
||||||
reserveTime.value = params
|
reserveTime.value = params
|
||||||
displayTime.value = reserveTime.value[0] + ' ' + reserveTime.value[1].join(',')
|
dayTime.value = params.dayTime
|
||||||
|
dayTitle.value = params.dayTitle
|
||||||
|
|
||||||
// 一键续订的金额
|
const times = params.selectedTime.map(item => {
|
||||||
// totalReserveMoney.value = Number(toTimes(params[3], order.value.room_price))
|
return item.time
|
||||||
|
}).join(',')
|
||||||
|
displayTime.value = params.dayTime + ',' + times
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -143,11 +152,12 @@
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const time = reserveTime.value
|
form.value.day_time = reserveTime.value.dayTime
|
||||||
form.value.day_time = time[0]
|
form.value.start_time = reserveTime.value.selectedTime[0].time
|
||||||
form.value.start_time = time[1][0]
|
form.value.end_time = reserveTime.value.selectedTime[ reserveTime.value.selectedTime.length - 1].time
|
||||||
form.value.end_time = time[1][time[2].length - 1]
|
form.value.hours = reserveTime.value.countSelectedTime
|
||||||
form.value.hours = time[3]
|
form.value.timeslot = reserveTime.value.selectedTimestamps
|
||||||
|
form.value.day_title = dayTitle.value,
|
||||||
|
|
||||||
delete form.value.name
|
delete form.value.name
|
||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
|
|||||||
@ -147,3 +147,14 @@ export function randomLabelColor (index: number) {
|
|||||||
return tagColors[index % tagColors.length]
|
return tagColors[index % tagColors.length]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前年月日,格式:YYYY-MM-DD
|
||||||
|
*/
|
||||||
|
export function getCurrentDate() {
|
||||||
|
const now = new Date();
|
||||||
|
const year = now.getFullYear();
|
||||||
|
const month = String(now.getMonth() + 1).padStart(2, '0');
|
||||||
|
const day = String(now.getDate()).padStart(2, '0');
|
||||||
|
return `${year}-${month}-${day}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user