功能:优化Salon作品选择与历史补单
发布 Nacos 配置 / publish (push) Successful in 30s
环境分支晋级检查 / environment-promotion-source (pull_request_target) Successful in 1s

This commit is contained in:
2026-10-14 00:47:10 +08:00
parent 4101ab3408
commit 261723bc6e
29 changed files with 454 additions and 332 deletions
@@ -0,0 +1,73 @@
const assert = require('assert')
let definition
let modalResult = { confirm: false }
let modalOptions
const navigations = []
global.Page = value => { definition = value }
global.wx = {
showModal(options) {
modalOptions = options
options.success(modalResult)
},
navigateTo(options) {
navigations.push(options.url)
}
}
require('./index')
function createPage() {
const page = {
...definition,
data: {
...definition.data,
form: { ...definition.data.form, appointmentDate: '2099-10-10', appointmentTime: '14:00', artistId: '88' }
},
setData(values) {
Object.entries(values).forEach(([key, value]) => {
const parts = key.split('.')
let target = this.data
for (let index = 0; index < parts.length - 1; index += 1) {
target = target[parts[index]]
}
target[parts[parts.length - 1]] = value
})
}
}
return page
}
async function run() {
const page = createPage()
let refreshes = 0
page.loadArtists = async () => { refreshes += 1 }
page.refreshAvailableTimes = async () => { refreshes += 1 }
page.checkAvailability = () => { refreshes += 1 }
modalResult = { confirm: false }
await page.onDateChange({ detail: { value: '2000-01-01' } })
assert.strictEqual(page.data.form.appointmentDate, '2099-10-10')
assert.strictEqual(page.data.form.appointmentTime, '14:00')
assert.strictEqual(navigations.length, 0)
assert.strictEqual(modalOptions.cancelText, '取消')
assert.strictEqual(modalOptions.confirmText, '去补单')
assert.strictEqual(refreshes, 0)
modalResult = { confirm: true }
await page.onDateChange({ detail: { value: '2000-01-01' } })
assert.strictEqual(navigations.pop(), '/pages/backfill-order/index?serviceDate=2000-01-01&artistId=88')
assert.strictEqual(page.data.form.appointmentDate, '2099-10-10')
assert.strictEqual(refreshes, 0)
await page.onDateChange({ detail: { value: '2099-10-11' } })
assert.strictEqual(page.data.form.appointmentDate, '2099-10-11')
assert.strictEqual(page.data.form.appointmentTime, '')
assert.strictEqual(refreshes, 3)
}
run().catch(error => {
console.error(error)
process.exitCode = 1
})
+88 -13
View File
@@ -289,6 +289,7 @@ Page({
artistId: '',
remark: ''
},
manualProductDraft: { title: '', price: '', description: '', tags: '', targetAudience: '', precautions: '', imageFileIds: '', imageUrl: '' },
customerOptions: [],
customerSheetVisible: false,
customerKeyword: '',
@@ -304,10 +305,14 @@ Page({
artistKeyword: '',
artistError: '',
selectedProduct: {},
selectedProductPriceText: '',
selectedArtist: {},
productModalVisible: false,
productSelectorMode: 'list',
manualProductMoreExpanded: false,
productKeyword: '',
productError: '',
loadingProducts: false,
conflictTip: '',
conflictLevel: 'free',
canCreateAppointment: true,
@@ -327,6 +332,16 @@ Page({
const baseForm = draftForm || {}
this.setData({
canCreateAppointment: creatable,
manualProductDraft: {
title: baseForm.manualProductTitle || '',
price: baseForm.manualProductPrice || '',
description: baseForm.manualProductDescription || '',
tags: baseForm.manualProductTags || '',
targetAudience: baseForm.manualProductTargetAudience || '',
precautions: baseForm.manualProductPrecautions || '',
imageFileIds: baseForm.manualProductImageFileIds || '',
imageUrl: baseForm.manualProductImageUrl || ''
},
form: {
...this.data.form,
...baseForm,
@@ -345,6 +360,7 @@ Page({
},
async loadOptions() {
this.setData({ loadingProducts: true })
try {
const productsData = await productsApi.list({ page: 1, size: 100 })
const products = productsData.list || productsData || []
@@ -355,9 +371,16 @@ Page({
filteredProducts: [],
productError: error.message || '作品列表加载失败'
})
} finally {
this.setData({ loadingProducts: false })
}
await this.loadArtists()
this.refreshProductCards()
const selectedProduct = this.data.filteredProducts.find(item => String(item.id) === String(this.data.form.productId)) || {}
this.setData({
selectedProduct,
selectedProductPriceText: selectedProduct.priceText || ''
})
await this.refreshAvailableTimes()
this.checkAvailability()
},
@@ -514,8 +537,30 @@ Page({
},
async onDateChange(event) {
const nextDate = event.detail.value
const today = dateUtil.formatDate(new Date())
if (nextDate < today) {
const result = await new Promise(resolve => {
wx.showModal({
title: '历史日期不能新建预约',
content: '之前的日期只能作为历史补单记录,不会校验员工排班,也不会占用预约时段。',
cancelText: '取消',
confirmText: '去补单',
success: resolve,
fail: () => resolve({ confirm: false })
})
})
if (result.confirm) {
const query = [`serviceDate=${encodeURIComponent(nextDate)}`]
if (this.data.form.artistId) {
query.push(`artistId=${encodeURIComponent(this.data.form.artistId)}`)
}
wx.navigateTo({ url: `/pages/backfill-order/index?${query.join('&')}` })
}
return
}
this.setData({
'form.appointmentDate': event.detail.value,
'form.appointmentDate': nextDate,
'form.appointmentTime': ''
})
await this.loadArtists()
@@ -537,11 +582,29 @@ Page({
openProductModal() {
this.refreshProductCards()
this.setData({ productModalVisible: true })
this.setData({ productModalVisible: true, productSelectorMode: 'list' })
},
closeProductModal() {
this.setData({ productModalVisible: false })
this.setData({ productModalVisible: false, productSelectorMode: 'list' })
},
openManualProduct() {
this.setData({ productSelectorMode: 'manual', manualProductMoreExpanded: false })
},
backToProductList() {
this.setData({ productSelectorMode: 'list' })
this.refreshProductCards()
},
onManualProductInput(event) {
const field = event.detail.field
this.setData({ [`manualProductDraft.${field}`]: event.detail.value })
},
toggleManualProductMore() {
this.setData({ manualProductMoreExpanded: !this.data.manualProductMoreExpanded })
},
stopTap() {
@@ -556,9 +619,12 @@ Page({
},
selectProduct(event) {
const selectedProduct = this.data.filteredProducts.find(item => String(item.id) === String(event.currentTarget.dataset.id)) || {}
const selectedProduct = event.detail.item || this.data.filteredProducts.find(item => String(item.id) === String(event.currentTarget.dataset.id)) || {}
const selectedDuration = parseInt(selectedProduct.serviceDurationMinutes || selectedProduct.approximateDuration, 10)
this.setData({
selectedProduct,
selectedProductPriceText: selectedProduct.priceText || '',
manualProductDraft: { title: '', price: '', description: '', tags: '', targetAudience: '', precautions: '', imageFileIds: '', imageUrl: '' },
'form.productId': selectedProduct.id,
'form.manualProductTitle': '',
'form.manualProductPrice': '',
@@ -568,7 +634,7 @@ Page({
'form.manualProductPrecautions': '',
'form.manualProductImageFileIds': '',
'form.manualProductImageUrl': '',
'form.durationMinutes': String(parseInt(selectedProduct.approximateDuration, 10) || this.data.form.durationMinutes || '')
'form.durationMinutes': String(selectedDuration || this.data.form.durationMinutes || '')
})
this.closeProductModal()
this.refreshAvailableTimes()
@@ -576,17 +642,26 @@ Page({
},
useManualProduct() {
const title = String(this.data.form.manualProductTitle || '').trim()
const price = Number(this.data.form.manualProductPrice)
if (!title || Number.isNaN(price) || price < 0) {
const draft = this.data.manualProductDraft
const title = String(draft.title || '').trim()
const priceText = String(draft.price === undefined ? '' : draft.price).trim()
const price = Number(priceText)
if (!title || !priceText || !Number.isFinite(price) || price < 0) {
wx.showToast({ title: '请填写手动预约作品名称和价格', icon: 'none' })
return
}
this.setData({
selectedProduct: {},
selectedProductPriceText: `¥${price}`,
'form.productId': '',
'form.manualProductTitle': title,
'form.manualProductPrice': String(price)
'form.manualProductPrice': String(price),
'form.manualProductDescription': String(draft.description || '').trim(),
'form.manualProductTags': String(draft.tags || '').trim(),
'form.manualProductTargetAudience': String(draft.targetAudience || '').trim(),
'form.manualProductPrecautions': String(draft.precautions || '').trim(),
'form.manualProductImageFileIds': String(draft.imageFileIds || ''),
'form.manualProductImageUrl': String(draft.imageUrl || '')
})
this.closeProductModal()
this.refreshAvailableTimes()
@@ -610,8 +685,8 @@ Page({
throw new Error('作品图片上传成功但未返回文件ID')
}
this.setData({
'form.manualProductImageFileIds': String(fileId),
'form.manualProductImageUrl': fileUrl
'manualProductDraft.imageFileIds': String(fileId),
'manualProductDraft.imageUrl': fileUrl
})
} catch (error) {
wx.showToast({ title: error.message || '图片上传失败', icon: 'none' })
@@ -622,8 +697,8 @@ Page({
removeManualProductImage() {
this.setData({
'form.manualProductImageFileIds': '',
'form.manualProductImageUrl': ''
'manualProductDraft.imageFileIds': '',
'manualProductDraft.imageUrl': ''
})
},
@@ -1,6 +1,7 @@
{
"navigationBarTitleText": "新建预约",
"usingComponents": {
"entity-selector-sheet": "/components/entity-selector-sheet/index"
"entity-selector-sheet": "/components/entity-selector-sheet/index",
"product-selector-sheet": "/components/product-selector-sheet/index"
}
}
@@ -17,12 +17,12 @@
<view class="field-value">{{form.appointmentDate}}</view>
</picker>
</view>
<view class="field">
<text class="field-label required">预约作品</text>
<view class="field-value product-value" bindtap="openProductModal">
<text>{{selectedProduct.title || form.manualProductTitle || '请选择预约作品'}}</text>
<view class="field product-field" bindtap="openProductModal">
<text class="field-label required" bindtap="openProductModal">预约作品</text>
<button class="field-value product-value product-picker-button" bindtap="openProductModal">
<view><text>{{selectedProduct.title || form.manualProductTitle || '请选择预约作品'}}</text><text wx:if="{{selectedProductPriceText || form.manualProductPrice}}" class="product-selected-price">{{selectedProductPriceText || ('¥' + form.manualProductPrice)}}</text></view>
<text wx:if="{{form.manualProductTitle && !form.productId}}" class="manual-badge">手动</text>
</view>
</button>
</view>
<view class="field">
<text class="field-label required">预计时长</text>
@@ -126,57 +126,7 @@
</view>
</view>
<view wx:if="{{productModalVisible}}" class="modal-mask" bindtap="closeProductModal" catchtouchmove="stopTouchMove">
<view class="product-modal" catchtap="stopTap">
<view class="modal-head">
<view>
<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-modal-scroll" scroll-y enhanced show-scrollbar="{{false}}">
<view class="product-list">
<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>
<view class="product-info">
<view class="product-title-row">
<text class="product-title">{{item.title}}</text>
<text class="product-price">{{item.priceText}}</text>
</view>
<text class="product-meta">{{item.artistText}} · {{item.durationText || '时长待定'}}</text>
<view class="tag-row">
<text wx:for="{{item.tagList}}" wx:for-item="tag" wx:key="*this" class="tag-pill">{{tag}}</text>
</view>
</view>
</view>
<view wx:if="{{!productError && filteredProducts.length === 0}}" class="product-empty">暂无匹配作品</view>
</view>
<view class="manual-panel">
<text class="manual-title required-label">手动新增预约作品</text>
<view class="manual-grid">
<input value="{{form.manualProductTitle}}" data-field="manualProductTitle" bindinput="onInput" placeholder="作品名称" />
<input value="{{form.manualProductPrice}}" data-field="manualProductPrice" bindinput="onInput" type="digit" placeholder="价格" />
</view>
<textarea class="manual-textarea" value="{{form.manualProductDescription}}" data-field="manualProductDescription" bindinput="onInput" placeholder="作品描述(选填)" />
<view class="manual-grid single">
<input value="{{form.manualProductTags}}" data-field="manualProductTags" bindinput="onInput" placeholder="标签,多个用逗号分隔(选填)" />
<input value="{{form.manualProductTargetAudience}}" data-field="manualProductTargetAudience" bindinput="onInput" placeholder="适合人群(选填)" />
<input value="{{form.manualProductPrecautions}}" data-field="manualProductPrecautions" bindinput="onInput" placeholder="注意事项(选填)" />
</view>
<view class="manual-image-row">
<image wx:if="{{form.manualProductImageUrl}}" class="manual-image" src="{{form.manualProductImageUrl}}" mode="aspectFill"></image>
<view wx:else class="manual-image placeholder">图</view>
<button class="secondary-btn image-btn" loading="{{manualImageUploading}}" bindtap="chooseManualProductImage">上传图片</button>
<button wx:if="{{form.manualProductImageUrl}}" class="text-btn image-remove" bindtap="removeManualProductImage">移除</button>
</view>
<button class="secondary-btn manual-btn" bindtap="useManualProduct">使用手动预约作品</button>
</view>
</scroll-view>
</view>
</view>
<product-selector-sheet visible="{{productModalVisible}}" mode="{{productSelectorMode}}" title="选择预约作品" keyword="{{productKeyword}}" placeholder="搜索作品、标签、美甲师" items="{{filteredProducts}}" selected-id="{{form.productId}}" loading="{{loadingProducts}}" error-text="{{productError}}" empty-text="暂无匹配作品" manual-form="{{manualProductDraft}}" manual-more-expanded="{{manualProductMoreExpanded}}" manual-image-url="{{manualProductDraft.imageUrl}}" manual-image-uploading="{{manualImageUploading}}" bind:search="onProductSearch" bind:select="selectProduct" bind:openmanual="openManualProduct" bind:backtolist="backToProductList" bind:manualinput="onManualProductInput" bind:togglemore="toggleManualProductMore" bind:chooseimage="chooseManualProductImage" bind:removeimage="removeManualProductImage" bind:confirmmanual="useManualProduct" bind:retry="loadOptions" bind:close="closeProductModal" />
<view wx:if="{{timeSheetVisible}}" class="modal-mask" bindtap="closeTimeSheet">
<view class="time-modal" catchtap="stopTap">
@@ -87,6 +87,8 @@
gap: 12rpx;
}
.product-selected-price { display:block; margin-top:6rpx; color:#b7683d; font-size:23rpx; font-weight:800; }
.time-value {
display: flex;
align-items: center;
@@ -213,20 +215,6 @@
background: rgba(18, 15, 12, 0.48);
}
.product-modal {
display: flex;
box-sizing: border-box;
height: 88vh;
width: 100%;
max-height: 88vh;
flex-direction: column;
overflow: hidden;
padding: 28rpx 28rpx calc(28rpx + env(safe-area-inset-bottom));
border-radius: 28rpx 28rpx 0 0;
background: #fffaf4;
box-shadow: 0 -18rpx 40rpx rgba(41, 31, 23, 0.16);
}
.manual-customer-sheet {
display: flex;
width: 100%;
@@ -338,129 +326,6 @@
transform: rotate(-45deg);
}
.product-search {
height: 74rpx;
padding: 0 24rpx;
border-radius: 18rpx;
background: #f5eee6;
color: #2a2521;
font-size: 26rpx;
}
.product-modal-scroll {
flex: 1;
height: 0;
min-height: 0;
margin-top: 20rpx;
padding-right: 2rpx;
}
.product-list {
width: 100%;
}
.product-option {
display: flex;
align-items: stretch;
gap: 18rpx;
min-height: 156rpx;
margin-bottom: 16rpx;
padding: 14rpx;
border: 2rpx solid transparent;
border-radius: 18rpx;
background: #fff;
box-shadow: 0 10rpx 24rpx rgba(92, 66, 43, 0.08);
}
.product-option.active {
border-color: #c9874d;
background: #fff8ef;
}
.product-cover {
flex: 0 0 auto;
width: 132rpx;
height: 132rpx;
border-radius: 14rpx;
background: #efe5da;
}
.product-cover.placeholder {
display: flex;
align-items: center;
justify-content: center;
color: #b79b82;
font-size: 28rpx;
font-weight: 900;
}
.product-info {
flex: 1;
min-width: 0;
display: flex;
flex-direction: column;
justify-content: center;
gap: 10rpx;
}
.product-title-row {
display: flex;
align-items: center;
gap: 16rpx;
}
.product-title {
flex: 1;
min-width: 0;
overflow: hidden;
color: #2a2521;
font-size: 28rpx;
font-weight: 900;
text-overflow: ellipsis;
white-space: nowrap;
}
.product-price {
flex: 0 0 auto;
color: #c56f36;
font-size: 28rpx;
font-weight: 900;
}
.product-meta {
overflow: hidden;
color: #8c8177;
font-size: 24rpx;
text-overflow: ellipsis;
white-space: nowrap;
}
.tag-row {
display: flex;
flex-wrap: wrap;
gap: 8rpx;
min-height: 34rpx;
}
.tag-pill {
max-width: 160rpx;
padding: 4rpx 12rpx;
overflow: hidden;
border-radius: 999rpx;
background: #f3e9df;
color: #826c5b;
font-size: 22rpx;
text-overflow: ellipsis;
white-space: nowrap;
}
.product-empty {
padding: 44rpx 0;
color: #9a9288;
font-size: 26rpx;
text-align: center;
}
.time-list {
max-height: 620rpx;
padding-right: 2rpx;
@@ -542,90 +407,6 @@
text-align: center;
}
.manual-panel {
margin-top: 12rpx;
padding: 20rpx;
border-radius: 18rpx;
background: #f7efe7;
}
.manual-title {
display: block;
margin-bottom: 14rpx;
color: #4e4740;
font-size: 26rpx;
font-weight: 900;
}
.manual-grid {
display: grid;
grid-template-columns: minmax(0, 1fr) 180rpx;
gap: 14rpx;
}
.manual-grid.single {
grid-template-columns: minmax(0, 1fr);
margin-top: 14rpx;
}
.manual-grid input {
height: 70rpx;
padding: 0 18rpx;
border-radius: 14rpx;
background: #fffaf4;
color: #302923;
font-size: 26rpx;
}
.manual-textarea {
width: 100%;
min-height: 120rpx;
margin-top: 14rpx;
padding: 18rpx;
border-radius: 14rpx;
background: #fffaf4;
color: #302923;
font-size: 26rpx;
}
.manual-image-row {
display: flex;
align-items: center;
gap: 14rpx;
margin-top: 14rpx;
}
.manual-image {
flex: 0 0 auto;
width: 92rpx;
height: 92rpx;
border-radius: 14rpx;
background: #efe5da;
}
.manual-image.placeholder {
display: flex;
align-items: center;
justify-content: center;
color: #b79b82;
font-size: 26rpx;
font-weight: 900;
}
.image-btn {
flex: 1;
min-width: 0;
max-width: none;
}
.image-remove {
flex: 0 0 auto;
}
.manual-btn {
margin-top: 16rpx;
}
.action-row {
display: flex;
gap: 16rpx;
@@ -6,9 +6,15 @@ const wxml = fs.readFileSync(path.join(__dirname, 'index.wxml'), 'utf8')
const wxss = fs.readFileSync(path.join(__dirname, 'index.wxss'), 'utf8')
const pageScript = fs.readFileSync(path.join(__dirname, 'index.js'), 'utf8')
assert.match(wxml, /class="modal-mask" bindtap="closeProductModal" catchtouchmove="stopTouchMove"/)
assert.match(wxml, /<scroll-view class="product-modal-scroll" scroll-y/)
assert.match(wxml, /<view class="product-list">/)
assert.match(wxss, /\.product-modal\s*\{[^}]*height:\s*88vh;[^}]*flex-direction:\s*column;[^}]*overflow:\s*hidden;/s)
assert.match(wxss, /\.product-modal-scroll\s*\{[^}]*flex:\s*1;[^}]*height:\s*0;[^}]*min-height:\s*0;/s)
assert.match(pageScript, /stopTouchMove\(\)\s*\{\s*\}/)
assert.match(wxml, /<product-selector-sheet[^>]*bind:close="closeProductModal"/)
assert.match(wxml, /manual-form="\{\{manualProductDraft\}\}"/)
assert.match(wxml, /bind:select="selectProduct"/)
const componentWxml = fs.readFileSync(path.join(__dirname, '../../components/product-selector-sheet/index.wxml'), 'utf8')
const componentWxss = fs.readFileSync(path.join(__dirname, '../../components/product-selector-sheet/index.wxss'), 'utf8')
assert.match(componentWxml, /catchtouchmove="stopEvent"/)
assert.match(componentWxml, /bindtap="openManual"/)
assert.match(componentWxml, /bindtap="selectItem"/)
assert.match(componentWxml, /bindtap="confirmManual"/)
assert.match(componentWxss, /\.product-selector-sheet\{[^}]*height:88vh;[^}]*max-height:88vh;/s)
assert.match(componentWxss, /.product-selector-scroll{height:0;min-height:0;flex:1}/)
assert.match(pageScript, /openManualProduct\(\)\s*\{/)
@@ -0,0 +1,43 @@
const assert = require('assert')
let definition
global.Page = value => { definition = value }
global.wx = { showToast: () => {} }
global.getApp = () => ({ globalData: { userInfo: { id: 1, shopId: 2, type: 2 } } })
require('./index')
function createPage() {
return {
...definition,
data: JSON.parse(JSON.stringify(definition.data)),
setData(values) {
Object.entries(values).forEach(([key, value]) => {
const parts = key.split('.')
let target = this.data
for (let index = 0; index < parts.length - 1; index += 1) target = target[parts[index]]
target[parts[parts.length - 1]] = value
})
}
}
}
const page = createPage()
page.openProductModal()
assert.strictEqual(page.data.productModalVisible, true)
assert.strictEqual(page.data.productSelectorMode, 'list')
page.refreshAvailableTimes = () => {}
page.checkAvailability = () => {}
page.selectProduct({ detail: { item: { id: 8, title: '法式', price: 238, priceText: '¥238', approximateDuration: '90' } } })
assert.strictEqual(page.data.form.productId, 8)
assert.strictEqual(page.data.selectedProduct.title, '法式')
assert.strictEqual(page.data.selectedProductPriceText, '¥238')
assert.strictEqual(page.data.form.manualProductTitle, '')
assert.strictEqual(page.data.form.durationMinutes, '90')
page.data.manualProductDraft = { title: '手绘款', price: '299', description: '', tags: '', targetAudience: '', precautions: '', imageFileIds: '', imageUrl: '' }
page.useManualProduct()
assert.strictEqual(page.data.form.productId, '')
assert.strictEqual(page.data.form.manualProductTitle, '手绘款')
assert.strictEqual(page.data.form.manualProductPrice, '299')
assert.strictEqual(page.data.selectedProductPriceText, '¥299')
+49 -10
View File
@@ -5,33 +5,72 @@ const customersApi = require('../../api/customers')
const dateUtil = require('../../utils/date')
Page({
data: { form: { serviceDate: dateUtil.formatDate(new Date()), manualProductTitle: '', amount: '', customerName: '', phone: '', serviceTime: '', status: 4, remark: '', artistId: '', productId: '', customerUserId: '' }, artists: [], artistOptions: [], allProductOptions: [], productOptions: [], customerOptions: [], allCustomerOptions: [], productSelectorVisible: false, artistSelectorVisible: false, customerSelectorVisible: false, loadingProducts: false, loadingArtists: false, loadingCustomers: false, productKeyword: '', artistKeyword: '', customerKeyword: '', productError: '', artistError: '', customerError: '', selectedArtistName: '', selectedProductTitle: '', submitting: false },
onLoad() { this.loadArtists(); this.loadProducts(); this.loadCustomers() },
async loadArtists() {
data: { form: { serviceDate: dateUtil.formatDate(new Date()), manualProductTitle: '', amount: '', customerName: '', phone: '', serviceTime: '', status: 4, remark: '', artistId: '', productId: '', customerUserId: '' }, manualProductDraft: { title: '', price: '' }, manualMoreExpanded: false, productSelectorMode: 'list', artists: [], artistOptions: [], allProductOptions: [], productOptions: [], customerOptions: [], allCustomerOptions: [], productSelectorVisible: false, artistSelectorVisible: false, customerSelectorVisible: false, loadingProducts: false, loadingArtists: false, loadingCustomers: false, productKeyword: '', artistKeyword: '', customerKeyword: '', productError: '', artistError: '', customerError: '', selectedArtistName: '', selectedProductTitle: '', selectedProductPriceText: '', submitting: false },
onLoad(options = {}) {
const serviceDate = options.serviceDate || this.data.form.serviceDate
const artistId = options.artistId || ''
this.setData({ 'form.serviceDate': serviceDate, 'form.artistId': artistId })
this.loadArtists(artistId); this.loadProducts(); this.loadCustomers()
},
async loadArtists(preferredArtistId) {
try {
const result = await employeesApi.list({ page: 1, size: 100 })
const list = result.list || result || []
const normalized = list.map(item => ({ ...item, name: item.name || item.nickname || item.account || `员工${item.id}` }))
this.setData({ artists: normalized, artistOptions: normalized.map(item => ({ id: item.id, title: item.name, subtitle: item.phone || '' })), selectedArtistName: '', 'form.artistId': '' })
const selected = normalized.find(item => String(item.id) === String(preferredArtistId || this.data.form.artistId))
this.setData({ artists: normalized, artistOptions: normalized.map(item => ({ id: item.id, title: item.name, subtitle: item.phone || '' })), selectedArtistName: selected ? selected.name : '', 'form.artistId': selected ? selected.id : '' })
this.refreshProductOptions()
} catch (error) { wx.showToast({ title: error.message || '员工加载失败', icon: 'none' }) }
},
async loadProducts() { this.setData({ loadingProducts: true }); try { const result = await productsApi.list({ page: 1, size: 100 }); const list = result.list || result || []; const options = list.map(item => ({ id: item.id, title: item.title, price: item.price, subtitle: item.price == null ? '' : `¥${item.price}` })); this.setData({ allProductOptions: options, productOptions: options, productError: '' }) } catch (error) { this.setData({ productError: error.message || '项目加载失败' }) } finally { this.setData({ loadingProducts: false }) } },
async loadProducts() { this.setData({ loadingProducts: true }); try { const result = await productsApi.list({ page: 1, size: 100 }); const list = result.list || result || []; this.setData({ products: list, productError: '' }); this.refreshProductOptions() } catch (error) { this.setData({ products: [], allProductOptions: [], productOptions: [], productError: error.message || '项目加载失败' }) } finally { this.setData({ loadingProducts: false }) } },
refreshProductOptions() {
const options = (this.data.products || []).map(item => {
const artistIds = String(item.bookableArtists || '').split(',').map(id => id.trim()).filter(Boolean)
const artistNames = artistIds.map(id => this.data.artists.find(artist => String(artist.id) === id)).filter(Boolean).map(artist => artist.name)
const tagList = Array.isArray(item.tagList) ? item.tagList : Array.isArray(item.tagInfos) ? item.tagInfos.map(tag => tag.tagName).filter(Boolean) : String(item.tags || '').split(/[;,,、]/).map(tag => tag.trim()).filter(Boolean)
return {
id: item.id,
title: item.title,
price: item.price,
priceText: item.price == null ? '价格待定' : `¥${item.price}`,
coverImage: Array.isArray(item.imageUrls) ? item.imageUrls[0] || '' : '',
durationText: item.approximateDuration || (item.serviceDurationMinutes ? `${item.serviceDurationMinutes}分钟` : '时长待定'),
artistText: artistIds.length ? artistNames.join('、') || `${artistIds.length}位员工可做` : '全部员工',
tagList: tagList.slice(0, 3)
}
})
const keyword = String(this.data.productKeyword || '').trim().toLowerCase()
this.setData({ allProductOptions: options, productOptions: options.filter(item => !keyword || `${item.title} ${item.artistText} ${item.tagList.join(' ')}`.toLowerCase().includes(keyword)) })
},
async loadCustomers() { this.setData({ loadingCustomers: true }); try { const result = await customersApi.list({ page: 1, size: 30 }); const list = result.list || result || []; const options = list.map(item => ({ id: item.id, title: item.nickname || item.name || item.account, subtitle: item.phone || item.contactPhone || '' })); this.setData({ allCustomerOptions: options, customerOptions: options, customerError: '' }) } catch (error) { this.setData({ customerError: error.message || '客户加载失败' }) } finally { this.setData({ loadingCustomers: false }) } },
openProductSelector() { this.setData({ productSelectorVisible: true }) },
closeProductSelector() { this.setData({ productSelectorVisible: false }) },
openProductSelector() { this.setData({ productSelectorVisible: true, productSelectorMode: 'list' }) },
closeProductSelector() { this.setData({ productSelectorVisible: false, productSelectorMode: 'list' }) },
openManualProduct() { this.setData({ productSelectorMode: 'manual', manualMoreExpanded: false }) },
backToProductList() { this.setData({ productSelectorMode: 'list' }) },
onManualProductInput(e) { this.setData({ [`manualProductDraft.${e.detail.field}`]: e.detail.value }) },
toggleManualProductMore() { this.setData({ manualMoreExpanded: !this.data.manualMoreExpanded }) },
openArtistSelector() { this.setData({ artistSelectorVisible: true }) },
closeArtistSelector() { this.setData({ artistSelectorVisible: false }) },
openCustomerSelector() { this.setData({ customerSelectorVisible: true }) },
closeCustomerSelector() { this.setData({ customerSelectorVisible: false }) },
searchProducts(e) { const keyword = String(e.detail.value || '').toLowerCase(); this.setData({ productKeyword: keyword, productOptions: this.data.allProductOptions.filter(item => !keyword || String(item.title).toLowerCase().includes(keyword)) }) },
searchProducts(e) { const keyword = String(e.detail.value || '').trim().toLowerCase(); this.setData({ productKeyword: keyword, productOptions: this.data.allProductOptions.filter(item => !keyword || `${item.title} ${item.artistText} ${item.tagList.join(' ')}`.toLowerCase().includes(keyword)) }) },
searchArtists(e) { const keyword = String(e.detail.value || '').toLowerCase(); this.setData({ artistKeyword: keyword, artistOptions: this.data.artists.map(item => ({ id: item.id, title: item.name, subtitle: item.phone || '' })).filter(item => !keyword || item.title.toLowerCase().includes(keyword)) }) },
searchCustomers(e) { const keyword = String(e.detail.value || '').toLowerCase(); this.setData({ customerKeyword: keyword, customerOptions: this.data.allCustomerOptions.filter(item => !keyword || String(item.title).toLowerCase().includes(keyword) || String(item.subtitle).includes(keyword)) }) },
selectProduct(e) { const item = e.detail.item; this.setData({ 'form.productId': item.id, selectedProductTitle: item.title, 'form.manualProductTitle': '', 'form.amount': item.price == null ? this.data.form.amount : String(item.price), productSelectorVisible: false }) },
selectProduct(e) { const item = e.detail.item; this.setData({ 'form.productId': item.id, selectedProductTitle: item.title, selectedProductPriceText: item.priceText || (item.price == null ? '价格待定' : `¥${item.price}`), 'form.manualProductTitle': '', manualProductDraft: { title: '', price: '' }, 'form.amount': item.price == null ? this.data.form.amount : String(item.price), productSelectorVisible: false, productSelectorMode: 'list' }) },
selectArtist(e) { const item = e.detail.item; this.setData({ 'form.artistId': item.id, selectedArtistName: item.title, artistSelectorVisible: false }) },
selectCustomer(e) { const item = e.detail.item; this.setData({ 'form.customerUserId': item.id, 'form.customerName': item.title, 'form.phone': item.subtitle, customerSelectorVisible: false }) },
useWalkIn() { this.setData({ 'form.customerUserId': '', 'form.customerName': '', 'form.phone': '', customerSelectorVisible: false }) },
onCustomerNameInput(e) { this.setData({ 'form.customerName': e.detail.value, 'form.customerUserId': '' }) },
onProductNameInput(e) { this.setData({ 'form.manualProductTitle': e.detail.value, 'form.productId': '', selectedProductTitle: '' }) },
useManualProduct() {
const title = String(this.data.manualProductDraft.title || '').trim()
const priceText = String(this.data.manualProductDraft.price === undefined ? '' : this.data.manualProductDraft.price).trim()
const price = Number(priceText)
if (!title || !priceText || !Number.isFinite(price) || price < 0) {
wx.showToast({ title: '请填写作品名称和价格', icon: 'none' })
return
}
this.setData({ 'form.productId': '', 'form.manualProductTitle': title, selectedProductTitle: '', selectedProductPriceText: `¥${price}`, 'form.amount': String(price), productSelectorVisible: false, productSelectorMode: 'list' })
},
onInput(e) { this.setData({ [`form.${e.currentTarget.dataset.field}`]: e.detail.value }) },
onDateChange(e) { this.setData({ 'form.serviceDate': e.detail.value }) },
onTimeChange(e) { this.setData({ 'form.serviceTime': e.detail.value }) },
@@ -1,4 +1,4 @@
{
"navigationBarTitleText": "补录历史订单",
"usingComponents": { "entity-selector-sheet": "/components/entity-selector-sheet/index" }
"usingComponents": { "entity-selector-sheet": "/components/entity-selector-sheet/index", "product-selector-sheet": "/components/product-selector-sheet/index" }
}
@@ -2,7 +2,7 @@
<view class="card form-card">
<view class="page-hint">历史补单不校验员工排班,也不会占用预约时段。</view>
<view class="field"><text class="field-label required">服务日期</text><picker mode="date" value="{{form.serviceDate}}" bindchange="onDateChange"><view class="field-value">{{form.serviceDate}}</view></picker></view>
<view class="field"><text class="field-label required">项目</text><view class="field-value" bindtap="openProductSelector">{{selectedProductTitle || form.manualProductTitle || '选择已有项目或手动填写'}}</view><input value="{{form.manualProductTitle}}" bindinput="onProductNameInput" placeholder="手动录入项目名称(选填)" /></view>
<view class="field product-field" bindtap="openProductSelector"><text class="field-label required">项目</text><button class="product-picker-button" bindtap="openProductSelector"><text>{{selectedProductTitle || form.manualProductTitle || '选择项目'}}</text><text wx:if="{{selectedProductPriceText}}" class="selected-amount">参考价 {{selectedProductPriceText}}</text><text class="product-picker-arrow">›</text></button></view>
<view class="field"><text class="field-label required">金额</text><input type="digit" value="{{form.amount}}" data-field="amount" bindinput="onInput" placeholder="请输入实际金额" /></view>
<view class="field"><text class="field-label required">员工</text><view class="field-value" bindtap="openArtistSelector">{{selectedArtistName || '请选择员工'}}</view></view>
<view class="field"><text class="field-label">客户</text><view class="field-value" bindtap="openCustomerSelector">{{form.customerName || '请选择客户(可选)'}}</view><input value="{{form.customerName}}" data-field="customerName" bindinput="onCustomerNameInput" placeholder="或填写散客姓名" /></view>
@@ -13,7 +13,7 @@
</view>
<view class="card submit-tip">提交后订单会直接进入所选状态,不创建预约占用。</view>
<button class="primary-btn" loading="{{submitting}}" disabled="{{submitting}}" bindtap="submit">保存历史补单</button>
<entity-selector-sheet visible="{{productSelectorVisible}}" title="选择项目" keyword="{{productKeyword}}" placeholder="搜索项目名称" items="{{productOptions}}" selected-id="{{form.productId}}" loading="{{loadingProducts}}" error-text="{{productError}}" empty-text="暂无项目,可直接手动录入" bind:search="searchProducts" bind:select="selectProduct" bind:retry="loadProducts" bind:close="closeProductSelector" />
<product-selector-sheet visible="{{productSelectorVisible}}" mode="{{productSelectorMode}}" title="选择项目" keyword="{{productKeyword}}" placeholder="搜索项目名称" items="{{productOptions}}" selected-id="{{form.productId}}" loading="{{loadingProducts}}" error-text="{{productError}}" empty-text="暂无项目" manual-form="{{manualProductDraft}}" show-manual-extra="{{false}}" bind:search="searchProducts" bind:select="selectProduct" bind:openmanual="openManualProduct" bind:backtolist="backToProductList" bind:manualinput="onManualProductInput" bind:togglemore="toggleManualProductMore" bind:confirmmanual="useManualProduct" bind:close="closeProductSelector" bind:retry="loadProducts" />
<entity-selector-sheet visible="{{artistSelectorVisible}}" title="选择员工" keyword="{{artistKeyword}}" placeholder="搜索员工姓名" items="{{artistOptions}}" selected-id="{{form.artistId}}" loading="{{loadingArtists}}" error-text="{{artistError}}" empty-text="暂无可选员工" bind:search="searchArtists" bind:select="selectArtist" bind:retry="loadArtists" bind:close="closeArtistSelector" />
<entity-selector-sheet visible="{{customerSelectorVisible}}" title="选择客户" keyword="{{customerKeyword}}" placeholder="搜索客户姓名或手机号" items="{{customerOptions}}" selected-id="{{form.customerUserId}}" loading="{{loadingCustomers}}" error-text="{{customerError}}" empty-text="暂无客户,可留空记为散客" action-text="按散客记录" bind:search="searchCustomers" bind:select="selectCustomer" bind:retry="loadCustomers" bind:action="useWalkIn" bind:close="closeCustomerSelector" />
</view>
@@ -1 +1,2 @@
.page{padding:24rpx;background:#f7f5f1;min-height:100vh;box-sizing:border-box}.form-card{padding:28rpx}.page-hint,.submit-tip{font-size:26rpx;color:#8b8177;line-height:1.6}.field{padding:24rpx 0;border-bottom:1rpx solid #eee7df}.field-label{display:block;color:#4d463f;font-size:28rpx;margin-bottom:14rpx}.required:after{content:' *';color:#c9795d}.field-value,input,textarea{font-size:30rpx;color:#2d2925}.field-value{min-height:42rpx;color:#6f665d}.status-segment{display:flex;gap:16rpx}.status-option{flex:1;text-align:center;padding:18rpx;border:1rpx solid #ddd4ca;border-radius:12rpx;color:#756b61}.status-option.active{background:#4f766d;color:#fff;border-color:#4f766d}.submit-tip{margin:22rpx 0;padding:22rpx}.primary-btn{margin-top:28rpx;background:#4f766d;color:#fff;border-radius:14rpx}
.product-picker-button{display:flex;align-items:center;justify-content:space-between;min-width:0;flex:1;padding:0;background:transparent;color:#6f665d;text-align:left;font-size:30rpx;line-height:1.35}
.product-picker-arrow{flex:0 0 auto;margin-left:12rpx;color:#a99f95;font-size:38rpx}
@@ -0,0 +1,44 @@
const assert = require('assert')
let definition
global.Page = value => { definition = value }
global.wx = { showToast: () => {} }
require('./index')
function createPage() {
return {
...definition,
data: JSON.parse(JSON.stringify(definition.data)),
setData(values) {
Object.entries(values).forEach(([key, value]) => {
const parts = key.split('.')
let target = this.data
for (let index = 0; index < parts.length - 1; index += 1) target = target[parts[index]]
target[parts[parts.length - 1]] = value
})
}
}
}
const page = createPage()
page.openProductSelector()
assert.strictEqual(page.data.productSelectorVisible, true)
assert.strictEqual(page.data.productSelectorMode, 'list')
page.selectProduct({ detail: { item: { id: 12, title: '轻奢款', price: 168, priceText: '¥168' } } })
assert.strictEqual(page.data.form.productId, 12)
assert.strictEqual(page.data.form.amount, '168')
assert.strictEqual(page.data.selectedProductPriceText, '¥168')
assert.strictEqual(page.data.form.manualProductTitle, '')
page.data.manualProductDraft = { title: '临时款', price: '199' }
page.useManualProduct()
assert.strictEqual(page.data.form.productId, '')
assert.strictEqual(page.data.form.manualProductTitle, '临时款')
assert.strictEqual(page.data.form.amount, '199')
assert.strictEqual(page.data.selectedProductPriceText, '¥199')
page.openManualProduct()
assert.strictEqual(page.data.productSelectorMode, 'manual')
page.toggleManualProductMore()
assert.strictEqual(page.data.manualMoreExpanded, true)
+1 -1
View File
@@ -11,6 +11,6 @@
<view class="agreement-line" bindtap="toggleAgreement"><view class="check small {{agreementAccepted ? 'checked' : ''}}">{{agreementAccepted ? '✓' : ''}}</view><view class="agreement-copy"><text>登录即表示已阅读并同意</text><text class="agreement-link" data-type="USER_TERMS" catchtap="openAgreement">《用户协议》</text><text>和</text><text class="agreement-link" data-type="PRIVACY_POLICY" catchtap="openAgreement">《隐私政策》</text></view></view>
<view wx:if="{{agreementError}}" class="agreement-error" bindtap="loadAgreements">{{agreementError}},点击重试</view>
</view>
<view wx:if="{{agreementModalVisible}}" class="modal-mask" catchtouchmove="stopTap"><view class="agreement-sheet"><view class="sheet-handle"></view><text class="modal-title">{{selectedAgreement.title || '隐私保护提示'}}</text><text class="modal-version">版本 {{selectedAgreement.version || '-'}}</text><scroll-view class="modal-body" scroll-y><text>{{selectedAgreement.content || '暂无协议内容'}}</text></scroll-view><view class="sheet-actions"><button class="sheet-btn secondary" bindtap="closeAgreementModal">关闭</button><button class="sheet-btn primary" bindtap="acceptAgreementModal">同意并继续</button></view></view></view>
<view wx:if="{{agreementModalVisible}}" class="modal-mask" catchtouchmove="stopTap"><view class="agreement-sheet"><text class="modal-title">{{selectedAgreement.title || '隐私保护提示'}}</text><text class="modal-version">版本 {{selectedAgreement.version || '-'}}</text><scroll-view class="modal-body" scroll-y><text>{{selectedAgreement.content || '暂无协议内容'}}</text></scroll-view><view class="sheet-actions"><button class="sheet-btn secondary" bindtap="closeAgreementModal">关闭</button><button class="sheet-btn primary" bindtap="acceptAgreementModal">同意并继续</button></view></view></view>
<view wx:if="{{shopSelectVisible}}" class="modal-mask center"><view class="shop-dialog"><text class="modal-title">选择本次登录门店</text><view wx:for="{{shopOptions}}" wx:key="id" class="shop-option" data-id="{{item.id}}" bindtap="selectShop"><view class="shop-icon">店</view><text>{{item.name}}</text><text class="shop-arrow">›</text></view><text wx:if="{{switchingShop}}" class="switching">正在进入门店…</text></view></view>
</view>
+1 -1
View File
@@ -1,3 +1,3 @@
.login-page { box-sizing:border-box; display:flex; min-height:calc(100vh - 88rpx); flex-direction:column; padding:0 56rpx 38rpx; background:#fff; }.login-main { display:flex; flex:1; flex-direction:column; }.brand-area { display:flex; flex-direction:column; align-items:center; padding-top:190rpx; }.login-logo { width:196rpx; height:196rpx; border-radius:46rpx; }.brand-name { margin-top:26rpx; color:#202522; font-size:40rpx; font-weight:800; letter-spacing:3rpx; }.brand-sub { margin-top:10rpx; color:#9a9f9c; font-size:22rpx; letter-spacing:4rpx; }.action-area { margin-top:118rpx; }.quick-btn { display:flex; align-items:center; justify-content:center; height:92rpx; border-radius:999rpx; background:#2f8f78; color:#fff; font-size:30rpx; font-weight:500; line-height:92rpx; box-shadow:0 10rpx 20rpx rgba(47,143,120,.16); }.quick-btn::after { border:0; }.wechat-symbol { display:flex; align-items:center; justify-content:center; width:38rpx; height:38rpx; margin-right:14rpx; border:2rpx solid rgba(255,255,255,.9); border-radius:50%; font-size:18rpx; font-weight:800; line-height:38rpx; }.remember-row { display:flex; align-items:center; justify-content:center; margin-top:30rpx; color:#737a76; font-size:23rpx; }.check { display:flex; align-items:center; justify-content:center; width:32rpx; height:32rpx; margin-right:12rpx; border:2rpx solid #b7bdb9; border-radius:50%; color:#fff; font-size:19rpx; }.check.small { width:28rpx; height:28rpx; flex:none; margin-right:8rpx; border-radius:7rpx; }.check.checked { border-color:#2f8f78; background:#2f8f78; }.state-line { display:flex; flex-direction:column; align-items:center; margin-top:34rpx; }.state-title { color:#765b32; font-size:24rpx; font-weight:700; }.state-message { margin-top:7rpx; color:#9a8260; font-size:20rpx; text-align:center; }.agreement-footer { padding-top:50rpx; }.agreement-line { display:flex; align-items:flex-start; justify-content:center; }.agreement-copy { color:#a0a4a1; font-size:20rpx; line-height:1.55; text-align:center; }.agreement-link { color:#6b7570; }.agreement-error { margin-top:10rpx; color:#ad6954; font-size:19rpx; text-align:center; }
.modal-mask { position:fixed; z-index:20; inset:0; display:flex; align-items:flex-end; background:rgba(0,0,0,.56); }.modal-mask.center { align-items:center; justify-content:center; padding:36rpx; }.agreement-sheet { box-sizing:border-box; width:100%; max-height:74vh; padding:16rpx 42rpx 48rpx; border-radius:28rpx 28rpx 0 0; background:#fff; }.sheet-handle { width:72rpx; height:8rpx; margin:0 auto 34rpx; border-radius:999rpx; background:#e4e5e4; }.modal-title { display:block; color:#222724; font-size:34rpx; font-weight:800; }.modal-version { display:block; margin-top:10rpx; color:#a1a5a2; font-size:21rpx; }.modal-body { height:38vh; margin-top:24rpx; color:#707773; font-size:25rpx; line-height:1.75; white-space:pre-wrap; }.sheet-actions { display:flex; gap:24rpx; margin-top:30rpx; }.sheet-btn { height:88rpx; flex:1; border-radius:14rpx; font-size:29rpx; line-height:88rpx; }.sheet-btn.secondary { background:#f3f3f3; color:#242824; }.sheet-btn.primary { background:#19be72; color:#fff; }.shop-dialog { box-sizing:border-box; width:100%; padding:34rpx; border-radius:24rpx; background:#fff; }.shop-option { display:flex; align-items:center; margin-top:20rpx; padding:22rpx; border-radius:16rpx; background:#f3f8f5; color:#344b40; font-size:26rpx; }.shop-icon { display:flex; align-items:center; justify-content:center; width:52rpx; height:52rpx; margin-right:16rpx; border-radius:14rpx; background:#dbe9df; color:#35634d; font-weight:800; }.shop-arrow { margin-left:auto; color:#82948a; font-size:34rpx; }.switching { display:block; margin-top:20rpx; color:#82948a; text-align:center; }
.modal-mask { position:fixed; z-index:20; inset:0; display:flex; align-items:flex-end; background:rgba(0,0,0,.56); }.modal-mask.center { align-items:center; justify-content:center; padding:36rpx; }.agreement-sheet { box-sizing:border-box; width:100%; max-height:74vh; padding:34rpx 42rpx 48rpx; border-radius:28rpx 28rpx 0 0; background:#fff; }.sheet-handle { width:72rpx; height:8rpx; margin:0 auto 34rpx; border-radius:999rpx; background:#e4e5e4; }.modal-title { display:block; color:#222724; font-size:34rpx; font-weight:800; }.modal-version { display:block; margin-top:10rpx; color:#a1a5a2; font-size:21rpx; }.modal-body { height:38vh; margin-top:24rpx; color:#707773; font-size:25rpx; line-height:1.75; white-space:pre-wrap; }.sheet-actions { display:flex; gap:24rpx; margin-top:30rpx; }.sheet-btn { height:88rpx; flex:1; border-radius:14rpx; font-size:29rpx; line-height:88rpx; }.sheet-btn.secondary { background:#f3f3f3; color:#242824; }.sheet-btn.primary { background:#19be72; color:#fff; }.shop-dialog { box-sizing:border-box; width:100%; padding:34rpx; border-radius:24rpx; background:#fff; }.shop-option { display:flex; align-items:center; margin-top:20rpx; padding:22rpx; border-radius:16rpx; background:#f3f8f5; color:#344b40; font-size:26rpx; }.shop-icon { display:flex; align-items:center; justify-content:center; width:52rpx; height:52rpx; margin-right:16rpx; border-radius:14rpx; background:#dbe9df; color:#35634d; font-weight:800; }.shop-arrow { margin-left:auto; color:#82948a; font-size:34rpx; }.switching { display:block; margin-top:20rpx; color:#82948a; text-align:center; }
@media (max-height:700px) { .brand-area { padding-top:90rpx; }.action-area { margin-top:70rpx; }.login-logo { width:160rpx; height:160rpx; } }
+7 -3
View File
@@ -245,7 +245,7 @@ Page({
}
const appointmentDate = dateUtil.formatDate(event.currentTarget.dataset.date)
if (appointmentDate < dateUtil.formatDate(new Date())) {
wx.showToast({ title: '不能为历史日期新增预约', icon: 'none' })
this.openBackfillOrder(appointmentDate)
return
}
this.openAppointmentForm(appointmentDate)
@@ -630,12 +630,16 @@ Page({
this.openAppointmentForm(this.data.currentDateText)
},
openBackfillOrder() {
openBackfillOrder(serviceDate) {
if (!this.data.canCreateAppointment) {
wx.showToast({ title: '当前账号仅支持查看预约', icon: 'none' })
return
}
wx.navigateTo({ url: '/pages/backfill-order/index' })
const query = [`serviceDate=${encodeURIComponent(serviceDate || this.data.currentDateText)}`]
if (this.data.selectedArtistId) {
query.push(`artistId=${encodeURIComponent(this.data.selectedArtistId)}`)
}
wx.navigateTo({ url: `/pages/backfill-order/index?${query.join('&')}` })
},
openAppointmentForm(appointmentDate) {
+4 -2
View File
@@ -115,13 +115,15 @@ async function run() {
quickCreatePage.quickCreateAppointment({ currentTarget: { dataset: { date: '2099-12-31' } } })
assert.strictEqual(navigations.pop(), '/pages/appointment-form/index?date=2099-12-31&artistId=88')
quickCreatePage.quickCreateAppointment({ currentTarget: { dataset: { date: '2000-01-01' } } })
assert.strictEqual(navigations.pop(), '/pages/backfill-order/index?serviceDate=2000-01-01&artistId=88')
quickCreatePage.data.selectedArtistId = ''
quickCreatePage.quickCreateAppointment({ currentTarget: { dataset: { date: '2099-11-30' } } })
assert.strictEqual(navigations.pop(), '/pages/appointment-form/index?date=2099-11-30')
quickCreatePage.quickCreateAppointment({ currentTarget: { dataset: { date: '2000-01-01' } } })
assert.strictEqual(navigations.length, 0)
assert.strictEqual(toasts.pop(), '不能为历史日期新增预约')
assert.strictEqual(navigations.pop(), '/pages/backfill-order/index?serviceDate=2000-01-01')
const readonlyPage = createPage({ canCreateAppointment: false, selectedArtistId: '88' })
readonlyPage.quickCreateAppointment({ currentTarget: { dataset: { date: '2099-12-31' } } })
@@ -20,7 +20,6 @@
<view class="segmented">
<view wx:for="{{viewModes}}" wx:key="value" class="segment {{viewMode === item.value ? 'active' : ''}}" data-mode="{{item.value}}" bindtap="switchView">{{item.label}}</view>
</view>
<button wx:if="{{canCreateAppointment}}" class="backfill-entry" bindtap="openBackfillOrder">补录历史订单</button>
<scroll-view class="artist-filter" scroll-x enable-flex>
<view class="artist-chip {{!selectedArtistId ? 'active' : ''}}" data-id="" bindtap="selectArtist">全部员工</view>
<view wx:for="{{artists}}" wx:key="id" class="artist-chip {{selectedArtistId == item.id ? 'active' : ''}}" data-id="{{item.id}}" bindtap="selectArtist">
@@ -770,5 +770,4 @@
}
}
.backfill-entry{margin:18rpx 0 0;background:#f1ebe4;color:#4f766d;border:1rpx solid #d9cfc3;font-size:25rpx;line-height:68rpx;height:68rpx;border-radius:12rpx}
.historical-backfill-card{margin:20rpx 0;padding:22rpx}.historical-backfill-row{display:flex;justify-content:space-between;align-items:center;padding:18rpx 0;border-top:1rpx solid #eee7df;font-size:26rpx}.historical-backfill-row .muted{display:block;color:#92887e;font-size:22rpx;margin-top:8rpx}