| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385 |
- <template>
- <view class="container">
- <!-- 搜索框 -->
- <view class="search-section">
- <u-search v-model="searchKeyword" placeholder="请输入订单编号或用户名称" :show-action="false" shape="square"
- bg-color="#F5F7FA" @search="handleSearch" @clear="handleSearch"></u-search>
- </view>
- <!-- Tab切换 -->
- <!-- <view class="tabs-section"> -->
- <!-- <view class="custom-tabs">
- <view class="tab-item" :class="{ active: currentTab == index }" v-for="(tab, index) in tabList"
- :key="index" @click="switchTab(index)">
- {{ tab.name }}
- </view>
- </view> -->
- <!-- </view> -->
- <!-- 订单列表 -->
- <scroll-view class="order-list" scroll-y="true" @scrolltolower="loadMore">
- <view v-if="ordersList.length > 0" v-for="order in ordersList" :key="order.id">
- <OrderItem :order-detail="order" @success="getOrderList(false)"></OrderItem>
- </view>
- <view class="empty-state" v-else>
- <u-icon class="empty-icon" name="list" size="60" color="#ccc"></u-icon>
- <view class="empty-text">暂无相关订单</view>
- </view>
- <view class="load-more-status" v-if="loadFinished && ordersList.length !== 0">
- <text>没有更多数据了</text>
- </view>
- <!-- 加载状态提示 -->
- <view class="load-more-status" v-if="loadState">
- <text>加载中...</text>
- </view>
- </scroll-view>
- </view>
- </template>
- <script setup>
- import {
- ref,
- computed
- } from 'vue'
- import {
- onShow,
- onLoad
- } from '@dcloudio/uni-app' // 导入 UniApp 的生命周期
- import OrderItem from './components/OrderItem.vue'
- import { getOrderListApi } from '../../api/order'
- // 搜索关键词
- const searchKeyword = ref('')
- const pageNum = ref(1)
- const pageSize = ref(10)
- const recordTotal = ref(0)
- const loadState = ref(false)
- const loadFinished = ref(false)
- // Tab数据
- const tabList = ref([{
- name: '全部订单'
- },
- {
- name: '待确认'
- },
- {
- name: '已完成'
- },
- {
- name: '申请退款'
- }
- ])
- // 1-全部订单, 2-待确认, 4-已完成, 5-申请退款
- //orderType: 订单类型(1-全部订单, 2-待确认, 3-待核销, 4-已完成, 5-申请退款, 6-服务中)
- const orderTypeMap = {
- 0: 1, // 全部订单
- 1: 2, // 待确认
- 2: 4, // 已完成
- 3: 5, // 申请退款
- }
- // 当前选中的Tab
- const currentTab = ref(0)
- // 订单数据
- const ordersList = ref([{},{},{},{},{}])
- // 获取状态类名
- const getStatusClass = (status) => {
- switch (status) {
- case 0:
- return 'status-pending' // 待派单
- case 1:
- return 'status-assigned' // 已派单
- case 2:
- return 'status-completed' // 已完成
- case 3:
- return 'status-market' // 抢单市场
- default:
- return 'status-pending'
- }
- }
- onLoad((option) => {
- if (option.orderStatusType) {
- currentTab.value = option.orderStatusType
- }
- })
- onShow(() => {
- // 可以在这里初始化数据
- getOrderList(false)
- })
- // Tab切换事件
- const switchTab = (index) => {
- currentTab.value = index
- getOrderList(false)
- }
- const loadMore = () => {
- pageNum.value++
- getOrderList(true)
- }
- const handleSearch = () => {
- getOrderList(false)
- }
- // 获取收益明细列表
- const getOrderList = async (isLoadMore = false) => {
- return
- if (loadState.value) return
- if (!isLoadMore) {
- pageNum.value = 1
- loadFinished.value = false
- ordersList.value = []
- }
- loadState.value = true
- //orderType: 订单类型(1-全部订单, 2-待确认, 4-已完成, 5-申请退款)
- try {
- uni.showLoading({
- mask: true
- })
- const orderType = orderTypeMap[currentTab.value]
- const params = {
- pageNum: pageNum.value,
- pageSize: pageSize.value,
- orderType: orderType,
- keyword: searchKeyword.value
- }
- var res = await getOrderListApi(params)
- if (res.code === 200) {
- const list = res.rows || []
- const total = res.total || 0
- if (isLoadMore) {
- ordersList.value = [...ordersList.value, ...list]
- } else {
- ordersList.value = list
- }
- recordTotal.value = total
- // 判断是否还有更多数据
- if (list.length < pageSize.value) {
- loadFinished.value = true
- }
- }
- } catch (error) {
- } finally {
- loadState.value = false
- uni.hideLoading()
- }
- }
- // 查看订单详情
- const viewOrderDetail = (order) => {
- uni.showToast({
- title: `查看订单详情 - ${order.orderNumber}`,
- icon: 'none'
- })
- }
- </script>
- <style lang="scss" scoped>
- .container {
- display: flex;
- flex-direction: column;
- height: 100vh;
- background-color: #F5F7FA;
- }
- .search-section {
- background-color: #fff;
- padding: 16rpx;
- margin-left: 14rpx;
- :deep .u-search__content {
- border-radius: 36rpx !important;
- }
- }
- .page-title {
- font-size: 36rpx;
- font-weight: bold;
- text-align: center;
- margin-bottom: 30rpx;
- color: #333333;
- }
- .tabs-section {
- height: 88rpx;
- background-color: #ffffff;
- }
- .custom-tabs {
- display: flex;
- width: 100%;
- }
- .tab-item {
- flex: 1;
- text-align: center;
- padding: 30rpx 0;
- font-size: 28rpx;
- color: #333333;
- position: relative;
- transition: all 0.3s;
- }
- .tab-item.active {
- color: #0089FF;
- }
- .tab-item.active::after {
- content: '';
- position: absolute;
- bottom: 0;
- left: 50%;
- transform: translateX(-50%);
- width: 40rpx;
- height: 6rpx;
- background-color: #2979ff;
- border-radius: 4rpx;
- }
- .order-list {
- flex: 1;
- padding: 20rpx;
- min-height: 500rpx;
- background-color: #F5F7FA;
- box-sizing: border-box;
- }
- .order-card {
- background-color: #ffffff;
- border-radius: 16rpx;
- padding: 16rpx;
- margin-bottom: 16rpx;
- position: relative;
- }
- .order-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 20rpx;
- }
- .order-title {
- font-size: 32rpx;
- font-weight: bold;
- color: #333333;
- }
- .order-status {
- width: 136rpx;
- height: 54rpx;
- line-height: 54rpx;
- color: #fff;
- font-size: 24rpx;
- border-radius: 0rpx 16rpx 0rpx 16rpx;
- position: absolute;
- right: 0px;
- top: 0px;
- text-align: center;
- }
- .status-pending {
- background: linear-gradient(270deg, #49ABFF 0%, #0089FF 100%);
- }
- .status-assigned {
- background: linear-gradient(134deg, #5ED89B 0%, #36B475 99%);
- }
- .status-completed {
- background: linear-gradient(134deg, #5ED89B 0%, #36B475 99%);
- }
- .status-market {
- background: linear-gradient(90deg, #FF9F23 0%, #FD5F3C 100%);
- }
- .price-section {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 16rpx;
- }
- .order-price {
- font-size: 32rpx;
- font-weight: bold;
- color: #FD5F3C;
- }
- .countdown {
- font-size: 24rpx;
- color: #F52929;
- }
- .order-details {
- margin-bottom: 16rpx;
- padding: 16rpx;
- background: #F5F7FA;
- border-radius: 16rpx;
- .customer-info {
- display: flex;
- align-items: center;
- margin-bottom: 16rpx;
- }
- .customer-photo {
- width: 48rpx;
- height: 48rpx;
- border-radius: 48rpx;
- margin-right: 16rpx;
- }
- .customer-name {
- font-size: 24rpx;
- color: #333333;
- font-weight: bold;
- }
- }
- .load-more-status {
- text-align: center;
- padding: 20rpx;
- font-size: 24rpx;
- color: #999;
- position: fixed;
- width: 100%;
- height: 100%;
- }
- .empty-state {
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- padding: 120rpx 40rpx;
- color: #999999;
- }
- .empty-text {
- margin-top: 20rpx;
- font-size: 28rpx;
- }
- </style>
|