重构项目文件夹目录
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
const afterSaleApi = require('../../api/after-sale')
|
||||
const auth = require('../../utils/auth')
|
||||
const navigation = require('../../utils/navigation')
|
||||
const theme = require('../../utils/theme')
|
||||
const { formatDateTime, formatPrice } = require('../../utils/format')
|
||||
|
||||
function safeList(value) {
|
||||
if (Array.isArray(value)) return value
|
||||
if (value && Array.isArray(value.list)) return value.list
|
||||
if (value && Array.isArray(value.records)) return value.records
|
||||
return []
|
||||
}
|
||||
|
||||
function statusText(status) {
|
||||
const value = String(status || '').toUpperCase()
|
||||
if (value === 'PENDING') return '审核中'
|
||||
if (value === 'APPROVED') return '已通过'
|
||||
if (value === 'REJECTED') return '已拒绝'
|
||||
return status || '处理中'
|
||||
}
|
||||
|
||||
function typeText(type) {
|
||||
return type === 'REFUND' ? '退款' : (type || '售后')
|
||||
}
|
||||
|
||||
function formatRecord(item) {
|
||||
return {
|
||||
...item,
|
||||
typeText: typeText(item.type),
|
||||
statusText: statusText(item.status),
|
||||
amountText: item.refundAmount === undefined || item.refundAmount === null ? '--' : `¥${formatPrice(item.refundAmount)}`,
|
||||
createdText: formatDateTime(item.createTime)
|
||||
}
|
||||
}
|
||||
|
||||
Page({
|
||||
data: Object.assign(theme.pageThemeData(getApp().globalData.shopTheme), {
|
||||
orderId: '',
|
||||
loading: false,
|
||||
isLoggedIn: false,
|
||||
records: []
|
||||
}),
|
||||
|
||||
onLoad(options) {
|
||||
this.setData({
|
||||
orderId: (options && options.orderId) || ''
|
||||
})
|
||||
},
|
||||
|
||||
onShow() {
|
||||
this.loadRecords()
|
||||
},
|
||||
|
||||
handleBack() {
|
||||
navigation.goBack('/pages/profile/index')
|
||||
},
|
||||
|
||||
async loadRecords() {
|
||||
const isLoggedIn = auth.isLoggedIn()
|
||||
this.setData({ isLoggedIn })
|
||||
if (!isLoggedIn) {
|
||||
navigation.openAuth(navigation.getCurrentPageUrl())
|
||||
return
|
||||
}
|
||||
this.setData({ loading: true })
|
||||
try {
|
||||
const payload = await afterSaleApi.getMyAfterSales({ page: 1, size: 50 })
|
||||
let records = safeList(payload)
|
||||
if (this.data.orderId) {
|
||||
records = records.filter(item => String(item.orderId) === String(this.data.orderId))
|
||||
}
|
||||
this.setData({
|
||||
records: records.map(formatRecord)
|
||||
})
|
||||
} catch (error) {
|
||||
wx.showToast({
|
||||
title: error.message || '售后记录加载失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.setData({ loading: false })
|
||||
}
|
||||
},
|
||||
|
||||
openOrder(event) {
|
||||
navigation.navigate('/pages/order-detail/index', {
|
||||
id: event.currentTarget.dataset.orderId
|
||||
})
|
||||
},
|
||||
|
||||
openProgress(event) {
|
||||
navigation.navigate('/pages/service-progress/index', {
|
||||
orderId: event.currentTarget.dataset.orderId
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"navigation-bar": "/components/navigation-bar/navigation-bar"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<navigation-bar title="售后记录" showBack="{{true}}" fallbackPath="/pages/profile/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">{{records.length}} 条记�?/text>
|
||||
<text class="hero-desc">{{orderId ? '当前订单的售后进�? : '逢�款��售后和审核记录集中查看'}}</text>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{loading}}" class="page-card empty-card">
|
||||
<text class="empty-title">正在加载售后记录</text>
|
||||
</view>
|
||||
|
||||
<view wx:elif="{{records.length}}">
|
||||
<view wx:for="{{records}}" wx:key="id" class="page-card record-card">
|
||||
<view class="record-head">
|
||||
<view>
|
||||
<text class="record-label">{{item.typeText}}</text>
|
||||
<text class="record-title">{{item.afterSaleNo || item.id}}</text>
|
||||
</view>
|
||||
<text class="chip">{{item.statusText}}</text>
|
||||
</view>
|
||||
<view class="record-grid">
|
||||
<view>
|
||||
<text class="summary-label">订单</text>
|
||||
<text class="summary-value">{{item.orderId}}</text>
|
||||
</view>
|
||||
<view>
|
||||
<text class="summary-label">金额</text>
|
||||
<text class="summary-value">{{item.amountText}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<text wx:if="{{item.reason}}" class="record-line">原因:{{item.reason}}</text>
|
||||
<text wx:if="{{item.auditReason}}" class="record-line">处理说明:{{item.auditReason}}</text>
|
||||
<text class="record-line">提交时间:{{item.createdText}}</text>
|
||||
<view class="record-actions">
|
||||
<view class="ghost-btn" data-order-id="{{item.orderId}}" bindtap="openOrder">订单详情</view>
|
||||
<view class="ghost-btn" data-order-id="{{item.orderId}}" bindtap="openProgress">服务进度</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:else class="page-card empty-card">
|
||||
<text class="empty-title">暂无售后记录</text>
|
||||
<text class="empty-desc">订单完成或支付后可以发起售后申请�?/text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -0,0 +1,57 @@
|
||||
.record-card {
|
||||
margin-top: 22rpx;
|
||||
padding: 26rpx;
|
||||
}
|
||||
|
||||
.record-head {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 18rpx;
|
||||
}
|
||||
|
||||
.record-label,
|
||||
.record-title,
|
||||
.record-line {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.record-label {
|
||||
color: var(--theme-primary);
|
||||
font-size: 22rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.record-title {
|
||||
margin-top: 8rpx;
|
||||
color: var(--text-primary);
|
||||
font-size: 30rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.record-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 14rpx;
|
||||
margin-top: 22rpx;
|
||||
}
|
||||
|
||||
.record-grid view {
|
||||
padding: 18rpx;
|
||||
border-radius: 22rpx;
|
||||
background: var(--theme-primary-soft);
|
||||
}
|
||||
|
||||
.record-line {
|
||||
margin-top: 14rpx;
|
||||
color: #504444;
|
||||
font-size: 24rpx;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.record-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 14rpx;
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
Reference in New Issue
Block a user