修复管理师端预约与登录体验

This commit is contained in:
2026-06-26 11:07:54 +08:00
parent f1fdf6e5d3
commit 078a2b32cd
48 changed files with 1044 additions and 276 deletions
@@ -86,6 +86,7 @@ Page({
selectedArtist: {},
productModalVisible: false,
productKeyword: '',
productError: '',
conflictTip: '',
conflictLevel: 'free',
canCreateAppointment: true,
@@ -96,6 +97,8 @@ Page({
const creatable = canCreateAppointment()
this.setData({
canCreateAppointment: creatable,
'form.customerName': options.customerName ? decodeURIComponent(options.customerName) : '',
'form.phone': options.phone ? decodeURIComponent(options.phone) : '',
'form.appointmentDate': options.date || dateUtil.formatDate(new Date()),
'form.artistId': options.artistId || ''
})
@@ -107,17 +110,16 @@ Page({
},
async loadOptions() {
const fallbackProducts = [
{ id: 1, title: '纯色美甲', approximateDuration: '90分钟' },
{ id: 2, title: '猫眼延长', approximateDuration: '120分钟' },
{ id: 3, title: '手部护理', approximateDuration: '60分钟' }
]
try {
const productsData = await productsApi.list({ page: 1, size: 100 })
const products = productsData.list || productsData || fallbackProducts
this.setData({ products })
const products = productsData.list || productsData || []
this.setData({ products, productError: '' })
} catch (error) {
this.setData({ products: fallbackProducts })
this.setData({
products: [],
filteredProducts: [],
productError: error.message || '作品列表加载失败'
})
}
await this.loadArtists()
this.refreshProductCards()
@@ -125,14 +127,24 @@ Page({
},
async loadArtists() {
const calendar = await planningApi.calendar({
startDate: this.data.form.appointmentDate,
endDate: this.data.form.appointmentDate
})
const artists = getCalendarArtists(calendar)
const selectedArtist = this.data.form.artistId ? findArtist(artists, this.data.form.artistId) : {}
this.setData({ artists, selectedArtist })
this.refreshProductCards()
try {
const calendar = await planningApi.calendar({
startDate: this.data.form.appointmentDate,
endDate: this.data.form.appointmentDate
})
const artists = getCalendarArtists(calendar)
const selectedArtist = this.data.form.artistId ? findArtist(artists, this.data.form.artistId) : {}
this.setData({ artists, selectedArtist })
this.refreshProductCards()
} catch (error) {
this.setData({
artists: [],
selectedArtist: {},
'form.artistId': '',
conflictTip: error.message || '美甲师列表加载失败',
conflictLevel: 'danger'
})
}
},
onInput(event) {
@@ -198,7 +210,7 @@ Page({
const title = String(this.data.form.manualProductTitle || '').trim()
const price = Number(this.data.form.manualProductPrice)
if (!title || Number.isNaN(price) || price < 0) {
wx.showToast({ title: '请填写手动项目名称和价格', icon: 'none' })
wx.showToast({ title: '请填写手动预约作品名称和价格', icon: 'none' })
return
}
this.setData({
@@ -265,9 +277,9 @@ Page({
this.setData({ conflictTip: tip, conflictLevel: 'free' })
return { ok: true, tip }
} catch (error) {
const tip = '暂未获取到排班,请保存时以系统校验为准'
this.setData({ conflictTip: tip, conflictLevel: 'warn' })
return { ok: true, tip }
const tip = error.message || '排班校验失败,请稍后重试'
this.setData({ conflictTip: tip, conflictLevel: 'danger' })
return { ok: false, tip }
}
},
@@ -1,39 +1,39 @@
<view class="page no-tab">
<view class="card form-card">
<view class="field">
<text class="field-label">客户姓名</text>
<text class="field-label required">客户姓名</text>
<input value="{{form.customerName}}" data-field="customerName" bindinput="onInput" placeholder="请输入客户姓名" />
</view>
<view class="field">
<text class="field-label">手机号</text>
<text class="field-label required">手机号</text>
<input value="{{form.phone}}" data-field="phone" bindinput="onInput" placeholder="请输入手机号" />
</view>
<view class="field">
<text class="field-label">预约日期</text>
<text class="field-label required">预约日期</text>
<picker mode="date" value="{{form.appointmentDate}}" bindchange="onDateChange">
<view class="field-value">{{form.appointmentDate}}</view>
</picker>
</view>
<view class="field">
<text class="field-label">预约时间</text>
<text class="field-label required">预约时间</text>
<picker mode="time" value="{{form.appointmentTime}}" start="10:00" end="22:00" bindchange="onTimeChange">
<view class="field-value">{{form.appointmentTime}}</view>
</picker>
</view>
<view class="field">
<text class="field-label">项目内容</text>
<text class="field-label required">预约作品</text>
<view class="field-value product-value" bindtap="openProductModal">
<text>{{selectedProduct.title || form.manualProductTitle || '请选择项目'}}</text>
<text>{{selectedProduct.title || form.manualProductTitle || '请选择预约作品'}}</text>
<text wx:if="{{form.manualProductTitle && !form.productId}}" class="manual-badge">手动</text>
</view>
</view>
<view class="field">
<text class="field-label">预计时长</text>
<input value="{{form.durationMinutes}}" data-field="durationMinutes" bindinput="onInput" type="number" placeholder="默认读取项目时长" />
<input value="{{form.durationMinutes}}" data-field="durationMinutes" bindinput="onInput" type="number" placeholder="默认读取作品时长" />
<text class="unit">分钟</text>
</view>
<view class="field">
<text class="field-label">指定员工</text>
<text class="field-label required">指定员工</text>
<picker range="{{artists}}" range-key="name" bindchange="onArtistChange">
<view class="field-value">{{selectedArtist.name || '请选择美甲师'}}</view>
</picker>
@@ -58,12 +58,13 @@
<view class="product-modal" catchtap="stopTap">
<view class="modal-head">
<view>
<text class="modal-title">选择项目内容</text>
<text class="modal-title">选择预约作品</text>
</view>
<view class="modal-close" bindtap="closeProductModal">×</view>
</view>
<input class="product-search" value="{{productKeyword}}" bindinput="onProductSearch" placeholder="搜索作品、标签、美甲师" />
<scroll-view class="product-list" scroll-y>
<view wx:if="{{productError}}" class="product-empty">{{productError}}</view>
<view wx:for="{{filteredProducts}}" wx:key="id" class="product-option {{form.productId == item.id ? 'active' : ''}}" data-id="{{item.id}}" bindtap="selectProduct">
<image wx:if="{{item.coverImage}}" class="product-cover" src="{{item.coverImage}}" mode="aspectFill"></image>
<view wx:else class="product-cover placeholder">图</view>
@@ -78,15 +79,15 @@
</view>
</view>
</view>
<view wx:if="{{filteredProducts.length === 0}}" class="product-empty">暂无匹配作品</view>
<view wx:if="{{!productError && filteredProducts.length === 0}}" class="product-empty">暂无匹配作品</view>
</scroll-view>
<view class="manual-panel">
<text class="manual-title">手动新增项目</text>
<text class="manual-title required-label">手动新增预约作品</text>
<view class="manual-grid">
<input value="{{form.manualProductTitle}}" data-field="manualProductTitle" bindinput="onInput" placeholder="项目名称" />
<input value="{{form.manualProductTitle}}" data-field="manualProductTitle" bindinput="onInput" placeholder="作品名称" />
<input value="{{form.manualProductPrice}}" data-field="manualProductPrice" bindinput="onInput" type="digit" placeholder="价格" />
</view>
<button class="secondary-btn manual-btn" bindtap="useManualProduct">使用手动项目</button>
<button class="secondary-btn manual-btn" bindtap="useManualProduct">使用手动预约作品</button>
</view>
</view>
</view>
@@ -114,18 +114,37 @@
}
.modal-close {
position: relative;
display: flex;
align-items: center;
justify-content: center;
width: 56rpx;
min-width: 56rpx;
height: 56rpx;
width: 48rpx;
min-width: 48rpx;
height: 48rpx;
border-radius: 50%;
background: #f2e7da;
color: #61554c;
font-size: 32rpx;
font-weight: 800;
line-height: 1;
border: 1rpx solid #e4d8ca;
background: #fffaf4;
color: transparent;
font-size: 0;
line-height: 0;
}
.modal-close::before,
.modal-close::after {
content: "";
position: absolute;
width: 22rpx;
height: 3rpx;
border-radius: 999rpx;
background: #61554c;
}
.modal-close::before {
transform: rotate(45deg);
}
.modal-close::after {
transform: rotate(-45deg);
}
.product-search {