重构项目文件夹目录
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
const orderApi = require('../../api/order')
|
||||
const afterSaleApi = require('../../api/after-sale')
|
||||
const auth = require('../../utils/auth')
|
||||
const navigation = require('../../utils/navigation')
|
||||
const theme = require('../../utils/theme')
|
||||
const { formatDateTime } = require('../../utils/format')
|
||||
|
||||
function safeList(value) {
|
||||
if (Array.isArray(value)) return value
|
||||
if (value && Array.isArray(value.list)) return value.list
|
||||
return []
|
||||
}
|
||||
|
||||
function buildNodes(order, reviews, changes, afterSales) {
|
||||
const items = safeList(order && order.items)
|
||||
const appointment = items.map(item => item && item.appointmentTime).find(Boolean)
|
||||
const status = Number(order && order.status)
|
||||
return [
|
||||
{ key: 'created', title: '订单创建', text: formatDateTime(order && order.createTime) || '已提交', done: true, active: false },
|
||||
{ key: 'appointment', title: '预约确认', text: formatDateTime(appointment) || '待确认', done: Boolean(appointment), active: status === 1 },
|
||||
{ key: 'artist', title: '服务安排', text: changes.length ? `${changes.length} 条改派记录` : '按预约安排服务', done: changes.length > 0 || items.some(item => item.artistName), active: changes.some(item => String(item.status || '').toUpperCase() === 'PENDING') },
|
||||
{ key: 'service', title: status === 3 ? '订单取消' : '服务完成', text: formatDateTime(order && (order.completeTime || order.cancelTime || order.updateTime)) || '等待服务', done: status === 2 || status === 3, active: status === 2 || status === 3 },
|
||||
{ key: 'after-sale', title: '售后/评价', text: afterSales.length ? `${afterSales.length} 条售后` : (reviews.length ? `${reviews.length} 条评价` : '暂无记录'), done: afterSales.length > 0 || reviews.length > 0, active: afterSales.some(item => String(item.status || '').toUpperCase() === 'PENDING') }
|
||||
]
|
||||
}
|
||||
|
||||
Page({
|
||||
data: Object.assign(theme.pageThemeData(getApp().globalData.shopTheme), {
|
||||
orderId: '',
|
||||
loading: false,
|
||||
isLoggedIn: false,
|
||||
order: null,
|
||||
nodes: [],
|
||||
items: [],
|
||||
reviews: [],
|
||||
changes: [],
|
||||
afterSales: []
|
||||
}),
|
||||
|
||||
onLoad(options) {
|
||||
this.setData({
|
||||
orderId: (options && (options.orderId || options.id)) || ''
|
||||
})
|
||||
},
|
||||
|
||||
onShow() {
|
||||
this.loadProgress()
|
||||
},
|
||||
|
||||
handleBack() {
|
||||
navigation.goBack('/pages/orders/index')
|
||||
},
|
||||
|
||||
async loadProgress() {
|
||||
const isLoggedIn = auth.isLoggedIn()
|
||||
this.setData({ isLoggedIn })
|
||||
if (!isLoggedIn) {
|
||||
navigation.openAuth(navigation.getCurrentPageUrl())
|
||||
return
|
||||
}
|
||||
if (!this.data.orderId) return
|
||||
|
||||
this.setData({ loading: true })
|
||||
try {
|
||||
const [order, reviews, changes, afterSalePage] = await Promise.all([
|
||||
orderApi.getOrderDetail(this.data.orderId),
|
||||
orderApi.listOrderReviews(this.data.orderId).catch(() => []),
|
||||
orderApi.listOrderArtistChangeRequests(this.data.orderId).catch(() => []),
|
||||
afterSaleApi.getMyAfterSales({ page: 1, size: 50 }).catch(() => ({ list: [] }))
|
||||
])
|
||||
const afterSales = safeList(afterSalePage).filter(item => String(item.orderId) === String(this.data.orderId))
|
||||
this.setData({
|
||||
order,
|
||||
items: safeList(order && order.items).map(item => ({
|
||||
...item,
|
||||
appointmentText: formatDateTime(item.appointmentTime)
|
||||
})),
|
||||
reviews,
|
||||
changes,
|
||||
afterSales,
|
||||
nodes: buildNodes(order, reviews || [], changes || [], afterSales)
|
||||
})
|
||||
} catch (error) {
|
||||
wx.showToast({
|
||||
title: error.message || '服务进度加载失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.setData({ loading: false })
|
||||
}
|
||||
},
|
||||
|
||||
openOrder() {
|
||||
navigation.navigate('/pages/order-detail/index', { id: this.data.orderId })
|
||||
},
|
||||
|
||||
openAfterSaleApply() {
|
||||
navigation.navigate('/pages/after-sale-apply/index', { orderId: this.data.orderId })
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"navigation-bar": "/components/navigation-bar/navigation-bar"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<navigation-bar title="服务进度" showBack="{{true}}" fallbackPath="/pages/orders/index" color="{{navThemeColor || '#4A443F'}}" background="{{navThemeBackground || '#FDFBF9'}}"></navigation-bar>
|
||||
|
||||
<view class="page-shell" style="{{themeVars}}">
|
||||
<view class="page-content">
|
||||
<view class="page-hero">
|
||||
<text class="hero-kicker">进度追踪</text>
|
||||
<text class="hero-title">{{order && order.orderNo || '订单进度'}}</text>
|
||||
<text class="hero-desc">{{order && order.shopName || '查看预约、服务��评价与售后节点'}}</text>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{loading}}" class="page-card empty-card">
|
||||
<text class="empty-title">正在加载进度</text>
|
||||
</view>
|
||||
|
||||
<block wx:elif="{{order}}">
|
||||
<view class="page-card progress-card">
|
||||
<view wx:for="{{nodes}}" wx:key="key" class="progress-node {{item.done ? 'done' : ''}} {{item.active ? 'active' : ''}}">
|
||||
<view class="node-dot"></view>
|
||||
<view class="node-copy">
|
||||
<text class="node-title">{{item.title}}</text>
|
||||
<text class="node-text">{{item.text}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{items.length}}" class="page-card record-card">
|
||||
<text class="section-title">项目进度</text>
|
||||
<text wx:for="{{items}}" wx:key="id" class="record-line">{{item.productTitle}}:{{item.artistName || '待安�?}} · {{item.appointmentText || '待确�?}}</text>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{changes.length}}" class="page-card record-card">
|
||||
<text class="section-title">改派记录</text>
|
||||
<text wx:for="{{changes}}" wx:key="id" class="record-line">{{item.statusText || item.status || '已记�?}}:{{item.reason || item.timeImpactText || ''}}</text>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{afterSales.length}}" class="page-card record-card">
|
||||
<text class="section-title">售后记录</text>
|
||||
<text wx:for="{{afterSales}}" wx:key="id" class="record-line">{{item.afterSaleNo || item.id}}:{{item.status}}</text>
|
||||
</view>
|
||||
|
||||
<view class="action-row">
|
||||
<view class="secondary-btn" bindtap="openOrder">订单详情</view>
|
||||
<view class="primary-btn" bindtap="openAfterSaleApply">申请售后</view>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<view wx:else class="page-card empty-card">
|
||||
<text class="empty-title">未找到订单进�?/text>
|
||||
<text class="empty-desc">请从订单中心重新进入�?/text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -0,0 +1,61 @@
|
||||
.progress-card,
|
||||
.record-card {
|
||||
margin-top: 22rpx;
|
||||
padding: 26rpx;
|
||||
}
|
||||
|
||||
.progress-node {
|
||||
display: flex;
|
||||
gap: 18rpx;
|
||||
padding: 20rpx 0;
|
||||
border-top: 2rpx solid var(--theme-border);
|
||||
}
|
||||
|
||||
.progress-node:first-child {
|
||||
padding-top: 0;
|
||||
border-top: 0;
|
||||
}
|
||||
|
||||
.node-dot {
|
||||
width: 24rpx;
|
||||
height: 24rpx;
|
||||
margin-top: 6rpx;
|
||||
border-radius: 999rpx;
|
||||
background: var(--theme-border);
|
||||
box-shadow: 0 0 0 10rpx var(--theme-primary-soft);
|
||||
}
|
||||
|
||||
.progress-node.done .node-dot,
|
||||
.progress-node.active .node-dot {
|
||||
background: var(--theme-primary);
|
||||
}
|
||||
|
||||
.node-copy {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.node-title,
|
||||
.node-text,
|
||||
.record-line {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.node-title {
|
||||
color: var(--text-primary);
|
||||
font-size: 29rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.node-text,
|
||||
.record-line {
|
||||
margin-top: 8rpx;
|
||||
color: #504444;
|
||||
font-size: 24rpx;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.action-row {
|
||||
display: grid;
|
||||
gap: 16rpx;
|
||||
margin-top: 24rpx;
|
||||
}
|
||||
Reference in New Issue
Block a user