feat(order): 新增订单 tab,支持未分配与我的订单分栏

This commit is contained in:
lik
2026-11-10 15:51:22 +08:00
parent 541611eaad
commit 5848d181a6
9 changed files with 149 additions and 76 deletions
+6
View File
@@ -36,6 +36,12 @@
"iconPath": "images/home.png", "iconPath": "images/home.png",
"selectedIconPath": "images/home-warm.png" "selectedIconPath": "images/home-warm.png"
}, },
{
"pagePath": "pages/order/index",
"text": "订单",
"iconPath": "images/order.png",
"selectedIconPath": "images/order-warm.png"
},
{ {
"pagePath": "pages/ai/index", "pagePath": "pages/ai/index",
"text": "AI", "text": "AI",
+2 -2
View File
@@ -125,8 +125,8 @@
| 选中文字色 | `#C26A2E` | | 选中文字色 | `#C26A2E` |
| 未选中文字色 | `#8A8078` | | 未选中文字色 | `#8A8078` |
| 背景色 | `#ffffff` | | 背景色 | `#ffffff` |
| 选中图标 | `images/home-warm.png`、`images/chat-warm.png`、`images/set-warm.png` | | 选中图标 | `images/home-warm.png`、`images/order-warm.png`、`images/chat-warm.png`、`images/set-warm.png` |
| 未选中图标 | `images/home.png`、`images/chat.png`、`images/set.png`(暖灰 `#8A8078`) | | 未选中图标 | `images/home.png`、`images/order.png`、`images/chat.png`、`images/set.png`(暖灰 `#8A8078`) |
图标为 128×128 PNG,选中态像素色 `rgb(194, 106, 46)`。 图标为 128×128 PNG,选中态像素色 `rgb(194, 106, 46)`。
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

+3 -3
View File
@@ -16,7 +16,7 @@ const ADMIN_ENTRIES = [
{ type: 'quick', icon: 'add-circle', name: '增加预约', url: '/pages/order/orderEdit', color: '#E8A96B' }, { type: 'quick', icon: 'add-circle', name: '增加预约', url: '/pages/order/orderEdit', color: '#E8A96B' },
{ type: 'quick', icon: 'file-add', name: '增加档案', url: '/pages/healthprofile/profileInfo', color: '#E8A96B' }, { type: 'quick', icon: 'file-add', name: '增加档案', url: '/pages/healthprofile/profileInfo', color: '#E8A96B' },
{ type: 'quick', icon: 'lightbulb-circle-filled', name: 'AI办公', url: '/pages/ai/index', isTab: true, color: '#E8A96B' }, { type: 'quick', icon: 'lightbulb-circle-filled', name: 'AI办公', url: '/pages/ai/index', isTab: true, color: '#E8A96B' },
{ type: 'function', icon: 'bill', name: '预约订单', url: '/pages/order/index', color: '#C26A2E' }, { type: 'function', icon: 'bill', name: '预约订单', url: '/pages/order/index', isTab: true, color: '#C26A2E' },
{ type: 'function', icon: 'heart', name: '健康档案', url: '/pages/healthprofile/index', color: '#C26A2E' }, { type: 'function', icon: 'heart', name: '健康档案', url: '/pages/healthprofile/index', color: '#C26A2E' },
{ type: 'function', icon: 'user', name: '注册用户', url: '/pages/customer/index', color: '#C26A2E' }, { type: 'function', icon: 'user', name: '注册用户', url: '/pages/customer/index', color: '#C26A2E' },
{ type: 'function', icon: 'user-circle', name: '个人信息', url: '/pages/me/index', color: '#C26A2E' } { type: 'function', icon: 'user-circle', name: '个人信息', url: '/pages/me/index', color: '#C26A2E' }
@@ -24,7 +24,7 @@ const ADMIN_ENTRIES = [
const ATTENDANT_ENTRIES = [ const ATTENDANT_ENTRIES = [
{ type: 'quick', icon: 'lightbulb-circle-filled', name: 'AI办公', url: '/pages/ai/index', isTab: true, color: '#E8A96B' }, { type: 'quick', icon: 'lightbulb-circle-filled', name: 'AI办公', url: '/pages/ai/index', isTab: true, color: '#E8A96B' },
{ type: 'function', icon: 'bill', name: '预约订单', url: '/pages/order/index', color: '#C26A2E' }, { type: 'function', icon: 'bill', name: '预约订单', url: '/pages/order/index', isTab: true, color: '#C26A2E' },
{ type: 'function', icon: 'user-circle', name: '个人信息', url: '/pages/me/index', color: '#C26A2E' } { type: 'function', icon: 'user-circle', name: '个人信息', url: '/pages/me/index', color: '#C26A2E' }
] ]
@@ -217,7 +217,7 @@ Page({
}, },
viewAllOrders() { viewAllOrders() {
wx.navigateTo({ wx.switchTab({
url: '/pages/order/index' url: '/pages/order/index'
}) })
}, },
+65 -13
View File
@@ -65,6 +65,8 @@ Page({
isAdmin: false, isAdmin: false,
// 实习陪诊师:能看到未分配订单,但不能接单 // 实习陪诊师:能看到未分配订单,但不能接单
isIntern: false, isIntern: false,
// 订单分栏:pool=未分配订单,mine=我的订单
currentScope: 'pool',
// 统计 // 统计
stats: { stats: {
total: 0, total: 0,
@@ -77,6 +79,9 @@ Page({
}, },
// 状态筛选 // 状态筛选
statusFilters: STATUS_FILTERS, statusFilters: STATUS_FILTERS,
// 状态下拉:picker 只认索引,文案与 statusFilters 保持同序
statusFilterLabels: STATUS_FILTERS.map(filter => filter.label),
statusIndex: 0,
currentStatus: 'pending', currentStatus: 'pending',
// 订单列表 // 订单列表
orderList: [], orderList: [],
@@ -96,10 +101,20 @@ Page({
onLoad(options) { onLoad(options) {
// 先解析角色:陪诊员走订单池接口,管理员走全量接口 // 先解析角色:陪诊员走订单池接口,管理员走全量接口
role.ensureRoleSafe().then(({ role: r, attendant }) => { role.ensureRoleSafe().then(({ role: r, attendant }) => {
const isAdmin = r === 'admin'
// 管理员与陪诊员统一从「未分配订单」进入,两个分栏都可见
const currentStatus = isAdmin ? this.data.currentStatus : ''
const statusIndex = Math.max(
0,
STATUS_FILTERS.findIndex(filter => filter.value === currentStatus)
)
this.setData({ this.setData({
role: r, role: r,
isAdmin: r === 'admin', isAdmin,
isIntern: Boolean(attendant && attendant.stage === 'intern') isIntern: Boolean(attendant && attendant.stage === 'intern'),
currentScope: 'pool',
currentStatus,
statusIndex
}) })
this.loadOrderList(); this.loadOrderList();
}) })
@@ -115,7 +130,7 @@ Page({
}, },
/** /**
* 更新筛选标签计数(口径由后端聚合,避免按当前页统计) * 更新状态下拉的计数(口径由后端聚合,避免按当前页统计)
*/ */
updateFilterCounts(counts) { updateFilterCounts(counts) {
const c = counts || {}; const c = counts || {};
@@ -132,7 +147,11 @@ Page({
...filter, ...filter,
count: Number(countMap[filter.value]) || 0 count: Number(countMap[filter.value]) || 0
})); }));
this.setData({ statusFilters }); // 下拉项直接带计数,替代原筛选条上的数字
const statusFilterLabels = statusFilters.map(filter =>
filter.count > 0 ? `${filter.label}(${filter.count})` : filter.label
);
this.setData({ statusFilters, statusFilterLabels });
}, },
/** /**
@@ -184,14 +203,17 @@ Page({
loadOrderList(isRefresh = false) { loadOrderList(isRefresh = false) {
if (this.data.isLoading || this.data.isLoadingMore) return; if (this.data.isLoading || this.data.isLoadingMore) return;
const { currentStatus, page, pageSize } = this.data; const { currentStatus, currentScope, page, pageSize } = this.data;
this.setData({ isLoading: !isRefresh, isLoadingMore: isRefresh && page > 1 }); this.setData({ isLoading: !isRefresh, isLoadingMore: isRefresh && page > 1 });
const params = { const params = {
page, page,
pageSize, pageSize,
...buildTabFilter(currentStatus) // 陪诊员:pool=未分配,mine=我的;管理员不传,保持全量口径
...(currentScope ? { scope: currentScope } : {}),
// 未分配订单不做状态筛选,所有可接订单都要能刷到
...(currentScope === 'pool' ? {} : buildTabFilter(currentStatus))
}; };
role.queryOrders(params) role.queryOrders(params)
@@ -215,8 +237,11 @@ Page({
this.setData({ this.setData({
orderList, orderList,
// 头部总数用后端「全部」口径,页签内条数仍由 currentStatus 决定 // 头部总数用后端「全部」口径;未分配池与当前筛选完全一致,直接用 total
stats: { ...this.data.stats, total: Number((data.counts || {}).all) || total }, stats: {
...this.data.stats,
total: currentScope === 'pool' ? total : Number((data.counts || {}).all) || total
},
isLoading: false, isLoading: false,
isLoadingMore: false, isLoadingMore: false,
isRefreshing: false, isRefreshing: false,
@@ -259,14 +284,41 @@ Page({
}, },
/** /**
* 状态筛选切换 * 状态筛选下拉切换
*/ */
onStatusChange(e) { onStatusPick(e) {
const status = e.currentTarget.dataset.status; const index = Number(e.detail.value) || 0;
if (status === this.data.currentStatus) return; const filter = this.data.statusFilters[index];
if (!filter || filter.value === this.data.currentStatus) return;
this.setData({ this.setData({
currentStatus: status, currentStatus: filter.value,
statusIndex: index,
page: 1,
hasMore: true,
orderList: []
}, () => {
this.loadOrderList();
});
},
/**
* 未分配订单 / 我的订单切换:范围、分页、计数都由服务端按 scope 重算
*/
onScopeChange(e) {
const scope = e.currentTarget.dataset.scope;
if (!scope || scope === this.data.currentScope) return;
const statusFilters = this.data.statusFilters.map(filter => ({ ...filter, count: 0 }));
this.setData({
currentScope: scope,
// 我的订单默认展示全部状态;未分配订单不参与状态筛选
currentStatus: scope === 'mine' ? '' : this.data.currentStatus,
statusIndex: scope === 'mine' ? 0 : this.data.statusIndex,
statusFilters,
// 清空上一分栏的状态计数,等本次请求返回后再写入
statusFilterLabels: statusFilters.map(filter => filter.label),
stats: { ...this.data.stats, total: 0 },
page: 1, page: 1,
hasMore: true, hasMore: true,
orderList: [] orderList: []
+39 -39
View File
@@ -92,59 +92,59 @@ page {
border-radius: 32rpx; border-radius: 32rpx;
} }
/* === 筛选栏 === */ /* === 接单分栏(未分配 / 我的) === */
.filter-bar { .scope-bar {
padding: 24rpx 0 0; display: flex;
} gap: 8rpx;
margin-top: 24rpx;
.filter-scroll { padding: 8rpx;
white-space: nowrap; background: @card;
} border-radius: 32rpx;
.filter-list {
display: inline-flex;
padding: 0 24rpx;
gap: 16rpx;
}
.filter-tag {
display: inline-flex;
align-items: center;
padding: 12rpx 28rpx;
background: #ffffff;
border-radius: 28rpx;
font-size: 24rpx;
color: @muted;
border: 1rpx solid rgba(90, 62, 42, 0.06); border: 1rpx solid rgba(90, 62, 42, 0.06);
box-shadow: 0 4rpx 12rpx rgba(90, 62, 42, 0.05); box-shadow: 0 4rpx 12rpx rgba(90, 62, 42, 0.05);
}
.scope-tab {
flex: 1;
padding: 16rpx 0;
text-align: center;
border-radius: 26rpx;
font-size: 26rpx;
color: @muted;
transition: all 0.25s; transition: all 0.25s;
&.active { &.active {
background: @accent; background: @accent;
color: #fff; color: #fff;
border-color: transparent; font-weight: 600;
box-shadow: 0 4rpx 16rpx rgba(180, 85, 42, 0.3); box-shadow: 0 4rpx 16rpx rgba(180, 85, 42, 0.3);
.filter-count {
background: rgba(255, 255, 255, 0.25);
color: #fff;
}
} }
} }
.filter-count { /* === 状态筛选下拉 === */
min-width: 32rpx; .filter-bar {
height: 32rpx; display: flex;
padding: 0 8rpx; align-items: center;
margin-left: 8rpx; justify-content: space-between;
background: rgba(0, 0, 0, 0.06); padding: 24rpx 0 0;
border-radius: 16rpx; }
font-size: 20rpx;
.filter-label {
font-size: 24rpx;
color: @muted; color: @muted;
}
.status-pill {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
justify-content: center; gap: 8rpx;
font-weight: 600; padding: 12rpx 24rpx;
background: @card;
border-radius: 28rpx;
font-size: 24rpx;
color: @text;
border: 1rpx solid rgba(90, 62, 42, 0.06);
box-shadow: 0 4rpx 12rpx rgba(90, 62, 42, 0.05);
} }
/* === 列表区域 === */ /* === 列表区域 === */
+30 -18
View File
@@ -3,28 +3,40 @@
<!-- 顶部标题 --> <!-- 顶部标题 -->
<view class="header"> <view class="header">
<view class="header-content"> <view class="header-content">
<text class="header-title">订单管理</text> <text class="header-title">{{currentScope === 'pool' ? '接单大厅' : '我的订单'}}</text>
<text class="header-sub">共 {{stats.total}} 个订单</text> <text class="header-sub">共 {{stats.total}} {{currentScope === 'pool' ? '个未分配订单' : '个订单'}}</text>
</view> </view>
<view class="header-add" wx:if="{{isAdmin}}" bindtap="onAddOrder">新增预约</view> <view class="header-add" wx:if="{{isAdmin}}" bindtap="onAddOrder">新增预约</view>
</view> </view>
<!-- 状态筛选 --> <!-- 订单分栏:未分配订单 / 我的订单 -->
<view class="filter-bar"> <view class="scope-bar">
<scroll-view class="filter-scroll" scroll-x enhanced show-scrollbar="{{false}}"> <view
<view class="filter-list"> class="scope-tab {{currentScope === 'pool' ? 'active' : ''}}"
<view data-scope="pool"
class="filter-tag {{currentStatus === item.value ? 'active' : ''}}" bindtap="onScopeChange"
wx:for="{{statusFilters}}" >未分配订单</view>
wx:key="value" <view
data-status="{{item.value}}" class="scope-tab {{currentScope === 'mine' ? 'active' : ''}}"
bindtap="onStatusChange" data-scope="mine"
> bindtap="onScopeChange"
<text>{{item.label}}</text> >我的订单</view>
<text class="filter-count" wx:if="{{item.count > 0}}">{{item.count}}</text> </view>
</view>
<!-- 状态筛选:仅「我的订单」可用,通过下拉选择,不再占用页面 tab -->
<view class="filter-bar" wx:if="{{currentScope === 'mine'}}">
<text class="filter-label">订单状态</text>
<picker
mode="selector"
range="{{statusFilterLabels}}"
value="{{statusIndex}}"
bindchange="onStatusPick"
>
<view class="status-pill">
<text>{{statusFilterLabels[statusIndex]}}</text>
<t-icon name="chevron-down" size="24rpx" color="#A3988B" />
</view> </view>
</scroll-view> </picker>
</view> </view>
<!-- 订单列表 --> <!-- 订单列表 -->
@@ -44,7 +56,7 @@
<!-- 空状态 --> <!-- 空状态 -->
<view class="empty-box" wx:elif="{{!isLoading && orderList.length === 0}}"> <view class="empty-box" wx:elif="{{!isLoading && orderList.length === 0}}">
<t-empty icon="file" description="暂无订单" t-class-description="empty-text"> <t-empty icon="file" description="{{currentScope === 'pool' ? '暂无可接订单' : '暂无订单'}}" t-class-description="empty-text">
<view slot="action"> <view slot="action">
<view class="empty-btn" bindtap="onReload">刷新</view> <view class="empty-btn" bindtap="onReload">刷新</view>
</view> </view>
+4 -1
View File
@@ -49,7 +49,10 @@
"compileWorklet": false, "compileWorklet": false,
"localPlugins": false, "localPlugins": false,
"swc": false, "swc": false,
"disableSWC": true "disableSWC": true,
"lessSetting": {
"commonUseFilePath": "app.less"
}
}, },
"compileType": "miniprogram", "compileType": "miniprogram",
"libVersion": "3.16.1", "libVersion": "3.16.1",