重构项目文件夹目录
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
const orderApi = require('../../api/order')
|
||||
const auth = require('../../utils/auth')
|
||||
const navigation = require('../../utils/navigation')
|
||||
const theme = require('../../utils/theme')
|
||||
const { formatDateTime, formatPrice } = require('../../utils/format')
|
||||
const { runWithLoading } = require('../../utils/loading')
|
||||
|
||||
function safeList(value) {
|
||||
return Array.isArray(value) ? value : []
|
||||
}
|
||||
|
||||
function formatClock(value) {
|
||||
return value ? String(value).replace('T', ' ').slice(11, 16) : '--'
|
||||
}
|
||||
|
||||
function formatAppointment(item) {
|
||||
return {
|
||||
...item,
|
||||
dayText: String(item.appointmentStartTime || '').slice(5, 10),
|
||||
timeText: `${formatClock(item.appointmentStartTime)}-${formatClock(item.appointmentEndTime)}`,
|
||||
amountText: `¥${formatPrice(item.actualAmount || item.totalAmount)}`,
|
||||
dateTimeText: formatDateTime(item.appointmentStartTime)
|
||||
}
|
||||
}
|
||||
|
||||
Page({
|
||||
data: Object.assign(theme.pageThemeData(getApp().globalData.shopTheme), {
|
||||
loading: false,
|
||||
isLoggedIn: false,
|
||||
appointments: []
|
||||
}),
|
||||
|
||||
onShow() {
|
||||
this.loadAppointments()
|
||||
},
|
||||
|
||||
handleBack() {
|
||||
navigation.goBack('/pages/artist-orders/index')
|
||||
},
|
||||
|
||||
async loadAppointments() {
|
||||
const isLoggedIn = auth.isLoggedIn()
|
||||
this.setData({ isLoggedIn })
|
||||
if (!isLoggedIn) {
|
||||
navigation.openAuth(navigation.getCurrentPageUrl())
|
||||
return
|
||||
}
|
||||
this.setData({ loading: true })
|
||||
try {
|
||||
const list = safeList(await orderApi.getArtistCalendarRecent(7))
|
||||
this.setData({
|
||||
appointments: list.map(formatAppointment)
|
||||
})
|
||||
} catch (error) {
|
||||
wx.showToast({ title: error.message || '预约日历加载失败', icon: 'none' })
|
||||
} finally {
|
||||
this.setData({ loading: false })
|
||||
}
|
||||
},
|
||||
|
||||
openArtistOrders() {
|
||||
navigation.navigate('/pages/artist-orders/index')
|
||||
},
|
||||
|
||||
async completeOrder(event) {
|
||||
const orderId = event.currentTarget.dataset.orderId
|
||||
if (!orderId) return
|
||||
try {
|
||||
await runWithLoading(() => orderApi.completeArtistOrder(orderId))
|
||||
wx.showToast({ title: '服务已完成', icon: 'none' })
|
||||
await this.loadAppointments()
|
||||
} catch (error) {
|
||||
wx.showToast({ title: error.message || '完成服务失败', icon: 'none' })
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"navigation-bar": "/components/navigation-bar/navigation-bar"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<navigation-bar title="预约日历" showBack="{{true}}" fallbackPath="/pages/artist-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">未来 7 �?/text>
|
||||
<text class="hero-title">{{appointments.length}} 个预�?/text>
|
||||
<text class="hero-desc">按时间查看即将服务的客户与项目��?/text>
|
||||
<view class="hero-action-row">
|
||||
<view class="hero-action secondary" bindtap="openArtistOrders">订单列表</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{loading}}" class="page-card empty-card">
|
||||
<text class="empty-title">正在加载日历</text>
|
||||
</view>
|
||||
|
||||
<view wx:elif="{{appointments.length}}">
|
||||
<view wx:for="{{appointments}}" wx:key="orderItemId" class="page-card appointment-card">
|
||||
<view class="day-box">
|
||||
<text>{{item.dayText}}</text>
|
||||
<text>{{item.timeText}}</text>
|
||||
</view>
|
||||
<view class="appointment-main">
|
||||
<text class="appointment-title">{{item.customerNickname || '客户'}} · {{item.productTitle}}</text>
|
||||
<text class="appointment-line">{{item.orderStatusText}} · {{item.shopName || '门店'}}</text>
|
||||
<text class="appointment-line">{{item.amountText}}</text>
|
||||
<view wx:if="{{item.orderStatus == 1}}" class="ghost-btn" data-order-id="{{item.orderId}}" bindtap="completeOrder">完成服务</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:else class="page-card empty-card">
|
||||
<text class="empty-title">未来 7 天暂无预�?/text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -0,0 +1,49 @@
|
||||
.appointment-card {
|
||||
display: flex;
|
||||
gap: 18rpx;
|
||||
margin-top: 22rpx;
|
||||
padding: 24rpx;
|
||||
}
|
||||
|
||||
.day-box {
|
||||
width: 136rpx;
|
||||
flex: 0 0 auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
gap: 8rpx;
|
||||
padding: 20rpx 12rpx;
|
||||
border-radius: 24rpx;
|
||||
background: var(--theme-primary-soft);
|
||||
color: var(--theme-primary);
|
||||
text-align: center;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.appointment-main {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.appointment-title,
|
||||
.appointment-line {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.appointment-title {
|
||||
color: var(--text-primary);
|
||||
font-size: 29rpx;
|
||||
font-weight: 800;
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.appointment-line {
|
||||
margin-top: 8rpx;
|
||||
color: #504444;
|
||||
font-size: 24rpx;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.ghost-btn {
|
||||
margin-top: 16rpx;
|
||||
}
|
||||
Reference in New Issue
Block a user