对接订单管理接口

This commit is contained in:
wangxiaowei
2025-12-19 16:41:32 +08:00
parent eee48dd9aa
commit 09c86fa8ca
13 changed files with 710 additions and 917 deletions

View File

@ -15,24 +15,24 @@
<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="搜索套餐名称" @search="OrderList.handleSearch()"></wd-search>
<wd-search v-model="keywords" hide-cancel placeholder-left light placeholder="搜索套餐名称" @search="Setmeal.handleSearch()"></wd-search>
</view>
</view>
</template>
</wd-navbar>
<view class="tabs">
<wd-tabs v-model="tab" swipeable slidable="always" :lazy="false" @click="OrderList.handleChangeTabs">
<wd-tabs v-model="tab" swipeable slidable="always" :lazy="false" @click="Setmeal.handleChangeTabs">
<wd-tab :title="item.title + `(${item.num})`" :name="item.name" v-for="(item, index) in tabList" :key="index"></wd-tab>
</wd-tabs>
</view>
</view>
<view class="tabs mt-18rpx mx-30rpx">
<!-- <mescroll-body ref="mescrollItem0" @init="mescrollInit" @down="downCallback" @up="OrderList.upCallback" :down="downOption" :up="upOption"> -->
<view class="mb-20rpx" v-for="(item, index) in 10" :key="index">
<combo-card :type="OrderSource.SetMeal" :order="item"></combo-card>
<mescroll-body ref="mescrollItem0" @init="mescrollInit" @down="downCallback" @up="Setmeal.upCallback" :down="downOption" :up="upOption">
<view class="mb-20rpx" v-for="(item, index) in list" :key="index">
<combo-card :type="OrderSource.SetMeal" :order="item" @refresh="Setmeal.handleSearch"></combo-card>
</view>
<!-- </mescroll-body> -->
</mescroll-body>
</view>
<view class="w-full fixed bottom-0 left-0 right-0 bg-white h-152rpx">
@ -45,11 +45,11 @@
<script lang="ts" setup>
import { OrderSource, OrderStatus, TeaRoomOrderStatusText, TeaRoomOrderStatusValue } from '@/utils/order'
import { OrderSource } 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 { getTeaSpecialistOrderPackageList } from '@/api/order'
import { router } from '@/utils/tools'
// mescroll
@ -61,16 +61,15 @@
auto: true,
textNoMore: '~ 已经到底啦 ~', //无更多数据的提示
}
const orderStatus = ref<string>('')
const list = ref<Array<any>>([]) // 茶室列表
const keywords = ref<string>('') // 搜索关键词
// 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 tab = ref<number>(1)
const tabList = ref<Array<{title: string, num: number, name: number}>>([
{ title: '已上架', num: 0, name: 1},
{ title: '已下架', num: 0, name: 0},
// { title: '草稿箱', num: 0, name: 2 }
])
onLoad((args) => {
@ -78,64 +77,60 @@
list.value = []
getMescroll().resetUpScroll()
})
// 根据传过来的参数决定显示哪个tab
if (args.orderStatus) {
tab.value = args.orderStatus
}
})
onUnload(() => {
uni.$off('refreshOrderList')
})
const OrderList = {
const Setmeal = {
/**
* 分页加载
* @param mescroll
*/
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,
status: tab.value,
search: keywords.value,
}
// 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(() => {
getTeaSpecialistOrderPackageList(filter).then((res) => {
tabList.value[0].num = res.online || 0
tabList.value[1].num = res.offline || 0
// tabList.value[2].num = res.draft || 0
const curPageData = res.list || [] // 当前页数据
console.log("🚀 ~ curPageData:", curPageData)
if(mescroll.num == 1) list.value = [] // 第一页需手动制空列表
list.value = list.value.concat(curPageData) //追加新数据
mescroll.endSuccess(curPageData.length, Boolean(res.more))
console.log("🚀 ~ res.more:", res.more)
}).catch(() => {
mescroll.endErr() // 请求失败, 结束加载
// })
})
},
/**
* 切换订单状态
* @param e
*/
handleChangeTabs: (e: {index: number, name: string}) => {
// tab.value = e.name
// if (e.name === TeaRoomOrderStatusText.Pending) {
// orderStatus.value = '0'
// } else {
// orderStatus.value = TeaRoomOrderStatusValue[e.name] || ''
// }
handleChangeTabs: (e: {index: number, name: number}) => {
tab.value = e.name
// // 切换tab时,重置当前的mescroll
// list.value = []
// getMescroll().resetUpScroll();
// 切换tab时,重置当前的mescroll
list.value = []
getMescroll().resetUpScroll();
},
/**
* 内容搜索
*/
handleSearch: () => {
// list.value = []
// getMescroll().resetUpScroll();
list.value = []
getMescroll().resetUpScroll();
}
}
</script>