对接订单相关接口

This commit is contained in:
wangxiaowei
2025-12-19 01:39:09 +08:00
parent 10aae8ea46
commit eee48dd9aa
13 changed files with 379 additions and 810 deletions

View File

@ -17,7 +17,7 @@
<wd-search v-model="keywords" hide-cancel placeholder-left light placeholder="搜索订单信息"></wd-search>
</view> -->
<view class="search-box flex items-center ml-26rpx" @click="Order.handleToSearch">
<wd-search placeholder="搜索茶址名称" hide-cancel disabled :placeholder-left="true"
<wd-search placeholder="搜索订单信息" hide-cancel disabled :placeholder-left="true"
placeholderStyle="text-align:left;padding-left: 24rpx;line-heigt: 44rpx;color: #C9C9C9; font-size: 32rpx;font-weight: normal;">
</wd-search>
</view>
@ -36,10 +36,13 @@
<view class="tabs mt-18rpx mx-30rpx">
<mescroll-body ref="mescrollItem0" @init="mescrollInit" @down="downCallback" @up="Order.upCallback" :down="downOption" :up="upOption">
<view class="mb-20rpx" v-for="(item, index) in list" :key="index">
<combo-card :type="OrderSource.Admin" :order="item"></combo-card>
<combo-card :type="OrderSource.Admin" :order="item" @refresh="Order.handleResetSearch"></combo-card>
</view>
</mescroll-body>
</view>
<!-- 弹出框 -->
<wd-message-box></wd-message-box>
</view>
</template>
@ -50,6 +53,10 @@
import useMescroll from "@/uni_modules/mescroll-uni/hooks/useMescroll.js"
import { OrderSource, AdminOrderStatusText, TeaSpecialistOrderStatusText, TeaSpecialistOrderStatusValue } from '@/utils/order'
import { router } from '@/utils/tools'
import { getStoreOrderList} from '@/api/order'
import { useStoreStore } from '@/store'
const useStore = useStoreStore()
/* mescroll */
const { mescrollInit, downCallback, getMescroll } = useMescroll(onPageScroll, onReachBottom) // 调用mescroll的hook
@ -87,21 +94,22 @@
const Order = {
// 上拉加载的回调: 其中num:当前页 从1开始, size:每页数据条数,默认10
upCallback: (mescroll) => {
// const filter = {
// page: mescroll.num,
// size: mescroll.size,
// order_status: orderStatus.value,
// search: keywords.value
// }
const filter = {
page: mescroll.num,
size: mescroll.size,
store_id: useStore.defaultStore.id,
order_status: '',
search: keywords.value,
}
// getTeaSpecialistOrderList(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(() => {
getStoreOrderList(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() // 请求失败, 结束加载
// })
})
},
/**
@ -122,8 +130,6 @@
* 重置搜索
*/
handleResetSearch: () => {
console.log("🚀 ~ location:", 456)
list.value = []
getMescroll().resetUpScroll()
},

View File

@ -1,6 +1,5 @@
<!-- 使用 type="home" 属性设置首页其他页面不需要设置默认为page -->
<route lang="jsonc" type="page">{
"needLogin": true,
"layout": "tabbar",
"style": {
// 'custom' 表示开启自定义导航栏,默认 'default'
@ -24,7 +23,7 @@
hide-cancel
placeholder-left
light
placeholder="搜索茶址名称"
placeholder="搜索订单信息"
placeholderStyle="text-align:left;line-heigt: 44rpx;color: #C9C9C9; font-size: 32rpx;font-weight: normal;"
@search="Search.handleSearch">
</wd-search>
@ -42,7 +41,7 @@
</view>
<view class="mt-40rpx flex flex-wrap items-center">
<view class="bg-[#F8F9FA] rounded-28rpx w-112rpx h-56rpx text-center text-[#606266] text-26rpx leading-56rpx mr-20rpx mb-24rpx" v-for="(item, index) in searchHistory" :key="index">
<view class="bg-[#F8F9FA] rounded-28rpx w-112rpx h-56rpx text-center text-[#606266] text-26rpx leading-56rpx mr-20rpx mb-24rpx line-1 px-10rpx" v-for="(item, index) in searchHistory" :key="index">
{{ item.content }}
</view>
</view>
@ -55,7 +54,7 @@
<script lang="ts" setup>
import { getNavBarHeight } from '@/utils/index'
import { getTeaRoomSearchHistory, clearTeaRoomSearchHistory } from '@/api/tea-room'
import { getOrderSearchHistory, deleteOrderSearchHistory } from '@/api/order'
import { router } from '@/utils/tools'
import { useMessage } from 'wot-design-uni'
@ -83,7 +82,7 @@
// 初始化
handleInit: () => {
console.log("🚀 ~ Search.handleInit:")
getTeaRoomSearchHistory().then( res => {
getOrderSearchHistory().then( res => {
searchHistory.value = res.list
console.log('搜索历史123', res.list)
})
@ -119,7 +118,7 @@
title: '删除中...',
mask: true
})
clearTeaRoomSearchHistory().then(() => {
deleteOrderSearchHistory().then(() => {
searchHistory.value = []
uni.hideLoading()
})

View File

@ -13,20 +13,20 @@
<view class="mt-38rpx">
<mescroll-body ref="mescrollItem0" @init="mescrollInit" @down="downCallback" @up="Renew.upCallback" :down="downOption" :up="upOption">
<view class="bg-white rounded-16rpx p-30rpx mx-32rpx relative">
<view class="absolute top-0 right-0 bg-[#4C9F44] text-[#fff] w-160rpx h-64rpx leading-64rpx text-center xd" @click="showRenewTimePopup = true">
<view class="bg-white rounded-16rpx p-30rpx mx-32rpx relative mb-20rpx" v-for="item in list" :key="item.id">
<view class="absolute top-0 right-0 bg-[#4C9F44] text-[#fff] w-160rpx h-64rpx leading-64rpx text-center xd" @click="selectRenewOrderId = item.id; showRenewTimePopup = true">
续单
</view>
<view class="flex items-center">
<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="item.img"></wd-img>
</view>
<view class="flex-1">
<view @click="ComboCard.handleToOrderDetail">
<view class="font-bold text-28rpx text-[#303133] leading-40rpx line-2 w-260rpx">这是茶室包间名称换行效果这是茶室包间名称换行效果</view>
<view class="font-bold text-28rpx text-[#303133] leading-40rpx line-2 w-260rpx">{{ item.room_name }}</view>
<view class="font-400 leading-36rpx text-26rpx text-[#606266] mt-10rpx">
<view>预约时间03/18 08:00-12:00</view>
<view class="mt-18rpx">预约时长2小时</view>
<view>预约时间{{ item.day_time }} {{ item.start_time }}-{{ item.end_time }}</view>
<view class="mt-18rpx">预约时长{{ item.hours }}小时</view>
</view>
</view>
</view>
@ -35,7 +35,7 @@
</mescroll-body>
</view>
<view class="bg-[#4C9F44] w-630rpx h-90rpx text-[#fff] text-center leading-90rpx rounded-8rpx mx-auto mt-50rpx">确定</view>
<!-- <view class="bg-[#4C9F44] w-630rpx h-90rpx text-[#fff] text-center leading-90rpx rounded-8rpx mx-auto mt-50rpx">确定</view> -->
<!-- 选择续订时间 -->
<renew-time v-model="showRenewTimePopup" @selectedTime="Renew.handleChooseRenewTime"></renew-time>
@ -44,18 +44,16 @@
<script lang="ts" setup>
import { OrderSource, OrderStatus, TeaRoomOrderStatusText, TeaRoomOrderStatusValue } from '@/utils/order'
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 { getTeaRoomOrderList } from '@/api/tea-room'
import { router } from '@/utils/tools'
import type { ITeaSpecialistFuture7DaysResult } from '@/api/types/tea'
import { getNext7Days, renewTeaRoomOrder } from '@/api/tea-room'
// 续单
const showRenewTimePopup = ref<boolean>(false)
import { getStoreOrderList, renewOrder} from '@/api/order'
import { useStoreStore } from '@/store'
import { toast } from '@/utils/toast'
const OSS = inject('OSS')
const useStore = useStoreStore()
// mescroll
const { mescrollInit, downCallback, getMescroll } = useMescroll(onPageScroll, onReachBottom) // 调用mescroll的hook
@ -66,40 +64,12 @@
auto: true,
textNoMore: '~ 已经到底啦 ~', //无更多数据的提示
}
const orderStatus = ref<string>('')
const list = ref<Array<any>>([]) // 茶室列表
const keywords = ref<string>('') // 搜索关键词
const OSS = inject('OSS')
const checked = ref<boolean>(false)
const columns = ref<Array<{label: string, id: number}>>([
{ label: '包厢A', id: 1 },
{ label: '包厢B', id: 2 },
{ label: '包厢C', id: 3 },
])
// tab
const tab = ref<string>('list')
const tabList = ref<Array<{title: string, num: number, name: string}>>([
{ title: '已上架', num: 10, name: 'list'},
{ title: '已下架', num: 11, name: 'delist' },
// { title: '草稿箱', num: 0, name: 'draft' }
])
// 选择预定时间
const showBookTimePopup = ref<boolean>(false)
const sevenDay = reactive<ITeaSpecialistFuture7DaysResult>({
minimum_time: 0,
time: []
})
// 续单
const reserveTime = ref<Array<any>>([])
const form = ref({
name: '',
price: '',
})
const showRenewTimePopup = ref<boolean>(false)
const selectRenewOrderId = ref<number>(0)
onLoad(async (args) => {
@ -118,46 +88,49 @@
*/
upCallback: (mescroll) => {
// 需要留一下数据为空的时候显示的空数据图标内容
// const filter = {
// page: mescroll.num,
// size: mescroll.size,
// order_status: orderStatus.value,
// search: keywords.value
// }
const filter = {
page: mescroll.num,
size: mescroll.size,
store_id: useStore.defaultStore.id,
order_status: '',
}
// getTeaRoomOrderList(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(() => {
getStoreOrderList(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() // 请求失败, 结束加载
// })
})
},
/**
* 开锁
*/
handleOpenLock: () => {
},
/**
* 选中预定时间
*/
handleChooseReserveTime: (params: any) => {
reserveTime.value = params
console.log("🚀 ~ reserveTime:", reserveTime)
// 一键续订的金额
// totalReserveMoney.value = Number(toTimes(params[3], order.value.room_price))
},
/**
* 一键续订时间
*/
handleChooseRenewTime: (item) => {
handleChooseRenewTime: async (item) => {
uni.showLoading({
title: '操作中...',
mask: true
})
try {
uni.hideLoading()
await renewOrder({
id: selectRenewOrderId.value,
renew_hour: item.value
})
list.value = []
getMescroll().resetUpScroll()
toast.success('续订成功')
} catch (error) {
uni.hideLoading()
toast.info('续订失败,请稍后重试')
return
}
console.log("🚀 ~ item:", item)
}
}

View File

@ -15,7 +15,7 @@
<view class="">
<view class="text-26rpx leading-32rpx text-[#606266] mb-20rpx">包厢选择</view>
<view class="">
<wd-picker :columns="columns" value-key="label" value-name="id" v-model="form.name" use-default-slot>
<wd-picker :columns="columns" value-key="label" value-name="id" v-model="form.name" use-default-slot @confirm="Reserve.handleConfirmRoom">
<wd-input type="text" v-model="form.name" placeholder="请选择包厢" readonly>
<template #suffix>
<wd-icon name="arrow-down" size="32rpx" color="#D8D8D8"></wd-icon>
@ -28,9 +28,9 @@
<view class="mt-22rpx">
<view class="text-26rpx leading-32rpx text-[#606266] mb-20rpx">包厢价格</view>
<view class="">
<wd-input type="text" v-model="form.price" placeholder="请选择包厢" readonly>
<template #suffix>
<wd-icon name="arrow-down" size="32rpx" color="#D8D8D8"></wd-icon>
<wd-input type="text" v-model="form.price" placeholder="请输入包厢价格">
<template #prefix>
<text class=""></text>
</template>
</wd-input>
</view>
@ -39,7 +39,7 @@
<view class="mt-22rpx">
<view class="text-26rpx leading-32rpx text-[#606266] mb-20rpx">预定时间</view>
<view class="" @click="showBookTimePopup = true">
<wd-input type="text" v-model="form.name" placeholder="请选择预定时间" readonly no-border>
<wd-input type="text" v-model="displayTime" placeholder="请选择预定时间" readonly no-border>
<template #suffix>
<wd-icon name="arrow-down" size="32rpx" color="#D8D8D8"></wd-icon>
</template>
@ -48,41 +48,25 @@
</view>
</view>
<view class="bg-[#4C9F44] w-630rpx h-90rpx text-[#fff] text-center leading-90rpx rounded-8rpx mx-auto mt-50rpx">确定</view>
<view class="bg-[#4C9F44] w-630rpx h-90rpx text-[#fff] text-center leading-90rpx rounded-8rpx mx-auto mt-50rpx" @click="Reserve.handleConfirm">确定</view>
<!-- 选择预定时间 -->
<!-- <booking-time v-model="showBookTimePopup" :day="sevenDay" @selectedTime="Reserve.handleChooseReserveTime"></booking-time> -->
<booking-time v-model="showBookTimePopup" :day="sevenDay" @selectedTime="Reserve.handleChooseReserveTime"></booking-time>
</view>
</template>
<script lang="ts" setup>
import { OrderSource, OrderStatus, TeaRoomOrderStatusText, TeaRoomOrderStatusValue } from '@/utils/order'
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 { getTeaRoomOrderList } from '@/api/tea-room'
import { router } from '@/utils/tools'
import type { ITeaSpecialistFuture7DaysResult } from '@/api/types/tea'
import { getNext7Days, renewTeaRoomOrder } from '@/api/tea-room'
import { getNext7Days } from '@/api/tea-room'
import { getAllRoomList, reserveRoom } from '@/api/store'
import { useStoreStore } from '@/store'
import { toast } from '@/utils/toast'
const OSS = inject('OSS')
const useStore = useStoreStore()
const checked = ref<boolean>(false)
const columns = ref<Array<{label: string, id: number}>>([
{ label: '包厢A', id: 1 },
{ label: '包厢B', id: 2 },
{ label: '包厢C', id: 3 },
])
// tab
const tab = ref<string>('list')
const tabList = ref<Array<{title: string, num: number, name: string}>>([
{ title: '已上架', num: 10, name: 'list'},
{ title: '已下架', num: 11, name: 'delist' },
// { title: '草稿箱', num: 0, name: 'draft' }
])
const columns = ref<Array<{label: string, id: number}>>([])
// 选择预定时间
const showBookTimePopup = ref<boolean>(false)
@ -93,15 +77,28 @@
const reserveTime = ref<Array<any>>([])
const form = ref({
name: '',
price: '',
id: 0, // 包间ID
name: '', // 包间名称
price: '', // 包间价格
day_time: '', // 预定日期
start_time: '', // 开始时间
end_time: '', // 结束时间
hours: 0, // 预定小时数
})
const displayTime = ref<string>('')
onLoad(async (args) => {
// 预定时间
// const next7 = await getNext7Days()
// Object.assign(sevenDay, next7)
const next7 = await getNext7Days()
Object.assign(sevenDay, next7)
// 获取包厢列表
const res = await getAllRoomList(useStore.defaultStore.id)
columns.value = res.list.map((item: any) => ({
label: item.title,
id: item.id
}))
})
onUnload(() => {
@ -109,24 +106,65 @@
const Reserve = {
/**
* 开锁
* 选中包厢
* @param params
*/
handleOpenLock: () => {
},
handleConfirmRoom: (item) => {
form.value.id = item.selectedItems.id
},
/**
* 选中预定时间
*/
handleChooseReserveTime: (params: any) => {
reserveTime.value = params
console.log("🚀 ~ reserveTime:", reserveTime)
displayTime.value = reserveTime.value[0] + ' ' + reserveTime.value[1].join(',')
// 一键续订的金额
// totalReserveMoney.value = Number(toTimes(params[3], order.value.room_price))
},
/**
* 确认预定
*/
handleConfirm: async () => {
if (!form.value.name) {
toast.info('请选择包厢')
return
}
if (!form.value.price) {
toast.info('请输入包厢价格')
return
}
if (reserveTime.value.length === 0) {
toast.info('请选择预定时间')
return
}
const time = reserveTime.value
form.value.day_time = time[0]
form.value.start_time = time[1][0]
form.value.end_time = time[1][time[2].length - 1]
form.value.hours = time[3]
delete form.value.name
uni.showLoading({
title: '操作中...',
mask: true
})
try {
await reserveRoom(form.value)
uni.hideLoading()
toast.info('预定成功')
router.navigateBack(1, 500)
} catch (error) {
uni.hideLoading()
toast.info('预定失败,请重试')
return
}
}
}
</script>

View File

@ -110,12 +110,12 @@
</wd-upload>
</view> -->
<!-- 团购图片 -->
<!-- 包间图片 -->
<view class="mt-28rpx">
<view class="mb-28rpx flex items-center justify-between">
<view class="flex items-center">
<view class="mr-10rpx text-32rpx text-[#303133] font-bold leading-44rpx">
团购图片
包间图片
</view>
<view class="flex items-center">
<wd-img width="16rpx" height="16rpx" :src="`${OSS}icon/icon_validate.png`" />
@ -484,7 +484,6 @@
index: tagIndex
}
})
console.log("🚀 ~ form.tags:", tags.value)
// 设置已选择的标签
selectedTags.value = []