Merge pull request '功能:优化Salon作品选择与历史补单' (#64) from dev into sit
Reviewed-on: http://wcy111.top:3000/xiaowang/JayuCloud/pulls/64
This commit was merged in pull request #64.
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
<view wx:if="{{visible}}" class="selector-mask" bindtap="close" catchtouchmove="stopEvent">
|
||||
<view class="selector-sheet" catchtap="stopEvent">
|
||||
<view class="selector-handle"></view>
|
||||
<view class="selector-head">
|
||||
<text class="selector-title">{{title}}</text>
|
||||
<button class="selector-close" bindtap="close" aria-label="关闭"></button>
|
||||
<view class="selector-close" bindtap="close" aria-label="关闭"></view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{showSearch}}" class="selector-search-wrap">
|
||||
|
||||
@@ -50,14 +50,6 @@
|
||||
animation: selectorSheetUp 220ms ease both;
|
||||
}
|
||||
|
||||
.selector-handle {
|
||||
width: 72rpx;
|
||||
height: 7rpx;
|
||||
margin: 14rpx auto 2rpx;
|
||||
border-radius: 999rpx;
|
||||
background: #ddd6cd;
|
||||
}
|
||||
|
||||
.selector-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
Component({
|
||||
properties: {
|
||||
visible: { type: Boolean, value: false },
|
||||
mode: { type: String, value: 'list' },
|
||||
title: { type: String, value: '选择作品' },
|
||||
keyword: { type: String, value: '' },
|
||||
placeholder: { type: String, value: '搜索作品名称' },
|
||||
items: { type: Array, value: [] },
|
||||
selectedId: { type: null, value: '' },
|
||||
loading: { type: Boolean, value: false },
|
||||
errorText: { type: String, value: '' },
|
||||
emptyText: { type: String, value: '暂无作品' },
|
||||
manualForm: { type: Object, value: {} },
|
||||
manualMoreExpanded: { type: Boolean, value: false },
|
||||
showManualExtra: { type: Boolean, value: true },
|
||||
manualImageUrl: { type: String, value: '' },
|
||||
manualImageUploading: { type: Boolean, value: false }
|
||||
},
|
||||
methods: {
|
||||
close() { this.triggerEvent('close') },
|
||||
stopEvent() {},
|
||||
onSearch(event) { this.triggerEvent('search', { value: event.detail.value }) },
|
||||
selectItem(event) {
|
||||
const item = this.data.items[Number(event.currentTarget.dataset.index)]
|
||||
if (item) this.triggerEvent('select', { item })
|
||||
},
|
||||
openManual() { this.triggerEvent('openmanual') },
|
||||
backToList() { this.triggerEvent('backtolist') },
|
||||
onManualInput(event) {
|
||||
this.triggerEvent('manualinput', { field: event.currentTarget.dataset.field, value: event.detail.value })
|
||||
},
|
||||
toggleMore() { this.triggerEvent('togglemore') },
|
||||
chooseImage() { this.triggerEvent('chooseimage') },
|
||||
removeImage() { this.triggerEvent('removeimage') },
|
||||
confirmManual() { this.triggerEvent('confirmmanual') },
|
||||
retry() { this.triggerEvent('retry') }
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"component": true
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
const assert = require('assert')
|
||||
|
||||
let definition
|
||||
global.Component = value => { definition = value }
|
||||
require('./index')
|
||||
|
||||
const events = []
|
||||
const component = {
|
||||
data: { items: [{ id: 4, title: '测试作品' }] },
|
||||
triggerEvent(name, detail) { events.push({ name, detail }) }
|
||||
}
|
||||
Object.assign(component, definition.methods)
|
||||
component.selectItem({ currentTarget: { dataset: { index: 0 } } })
|
||||
assert.strictEqual(events[0].name, 'select')
|
||||
assert.strictEqual(events[0].detail.item.id, 4)
|
||||
@@ -0,0 +1,30 @@
|
||||
<view wx:if="{{visible}}" class="product-selector-mask" bindtap="close" catchtouchmove="stopEvent">
|
||||
<view class="product-selector-sheet" catchtap="stopEvent">
|
||||
<view class="product-selector-head">
|
||||
<view><text class="product-selector-title">{{mode === 'manual' ? '手动录入作品' : title}}</text><text wx:if="{{mode === 'manual'}}" class="product-selector-subtitle">名称和价格必填,可补充更多信息</text></view>
|
||||
<view class="product-selector-close" bindtap="close" aria-label="关闭作品选择"></view>
|
||||
</view>
|
||||
<block wx:if="{{mode === 'list'}}">
|
||||
<view class="product-selector-search"><text class="product-selector-search-icon"></text><input value="{{keyword}}" bindinput="onSearch" placeholder="{{placeholder}}" confirm-type="search" /></view>
|
||||
<scroll-view class="product-selector-scroll" scroll-y enhanced show-scrollbar="{{false}}">
|
||||
<view wx:if="{{loading}}" class="product-selector-state">正在加载作品...</view>
|
||||
<view wx:elif="{{errorText}}" class="product-selector-state error">{{errorText}}<button class="product-selector-retry" bindtap="retry">重新加载</button></view>
|
||||
<view wx:elif="{{items.length === 0}}" class="product-selector-state">{{emptyText}}</view>
|
||||
<view wx:else class="product-selector-list">
|
||||
<view wx:for="{{items}}" wx:key="id" class="product-selector-item {{selectedId == item.id ? 'selected' : ''}}" data-index="{{index}}" bindtap="selectItem">
|
||||
<image wx:if="{{item.coverImage}}" class="product-selector-cover" src="{{item.coverImage}}" mode="aspectFill"></image><view wx:else class="product-selector-cover placeholder">图</view>
|
||||
<view class="product-selector-copy"><view class="product-selector-name-row"><text class="product-selector-name">{{item.title}}</text><text class="product-selector-price">{{item.priceText || (item.price == null ? '价格待定' : '¥' + item.price)}}</text></view><text class="product-selector-meta">{{item.durationText || '时长待定'}} · {{item.artistText || '全部员工'}}</text><view class="product-selector-tags"><text wx:for="{{item.tagList}}" wx:for-item="tag" wx:key="*this">{{tag}}</text></view></view><text class="product-selector-check">{{selectedId == item.id ? '✓' : '›'}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<view class="product-selector-footer"><button class="product-selector-action" bindtap="openManual">+ 手动录入作品</button></view>
|
||||
</block>
|
||||
<block wx:else>
|
||||
<scroll-view class="product-selector-scroll manual" scroll-y enhanced show-scrollbar="{{false}}">
|
||||
<view class="manual-product-card"><view class="manual-product-grid"><input value="{{manualForm.title}}" data-field="title" bindinput="onManualInput" placeholder="作品名称" /><input value="{{manualForm.price}}" data-field="price" bindinput="onManualInput" type="digit" placeholder="价格" /></view><view wx:if="{{showManualExtra}}" class="manual-product-more" bindtap="toggleMore">{{manualMoreExpanded ? '⌃ 收起更多信息' : '⌄ 补充更多信息'}}</view></view>
|
||||
<view wx:if="{{showManualExtra && manualMoreExpanded}}" class="manual-product-extra"><textarea value="{{manualForm.description}}" data-field="description" bindinput="onManualInput" placeholder="作品描述(选填)"></textarea><input value="{{manualForm.tags}}" data-field="tags" bindinput="onManualInput" placeholder="标签,多个用逗号分隔(选填)" /><input value="{{manualForm.targetAudience}}" data-field="targetAudience" bindinput="onManualInput" placeholder="适合人群(选填)" /><input value="{{manualForm.precautions}}" data-field="precautions" bindinput="onManualInput" placeholder="注意事项(选填)" /><view class="manual-product-image-row"><image wx:if="{{manualImageUrl}}" src="{{manualImageUrl}}" class="manual-product-image" mode="aspectFill"></image><view wx:else class="manual-product-image placeholder">图</view><button bindtap="chooseImage" loading="{{manualImageUploading}}">上传图片</button><button wx:if="{{manualImageUrl}}" bindtap="removeImage">移除</button></view></view>
|
||||
</scroll-view>
|
||||
<view class="product-selector-footer manual-footer"><button class="product-selector-confirm" bindtap="confirmManual">使用此作品</button><button class="product-selector-back" bindtap="backToList">‹ 返回作品列表</button></view>
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
@@ -0,0 +1 @@
|
||||
.product-selector-mask{position:fixed;inset:0;z-index:130;display:flex;align-items:flex-end;background:rgba(25,22,18,.5)}.product-selector-sheet{display:flex;width:100%;height:88vh;max-height:88vh;flex-direction:column;overflow:hidden;border-radius:34rpx 34rpx 0 0;background:#fffdf8;box-shadow:0 -20rpx 48rpx rgba(44,35,27,.18)}.product-selector-head{display:flex;align-items:center;justify-content:space-between;min-height:92rpx;padding:0 28rpx}.product-selector-title{display:block;color:#29241f;font-size:34rpx;font-weight:900}.product-selector-subtitle{display:block;margin-top:7rpx;color:#8b8177;font-size:22rpx}.product-selector-close{position:relative;display:flex;align-items:center;justify-content:center;box-sizing:border-box;width:52rpx;height:52rpx;min-width:52rpx;flex:0 0 52rpx;margin:0;padding:0;overflow:hidden;border:1rpx solid #e6dfd6;border-radius:50%;background:#f8f4ee;line-height:1}.product-selector-close::before,.product-selector-close::after{content:"";position:absolute;top:24rpx;left:14rpx;width:22rpx;height:3rpx;border-radius:999rpx;background:#665e56}.product-selector-close::before{transform:rotate(45deg)}.product-selector-close::after{transform:rotate(-45deg)}.product-selector-search{display:flex;align-items:center;height:80rpx;margin:0 28rpx 18rpx;padding:0 22rpx;border-radius:22rpx;background:#f7f3ed}.product-selector-search input{height:78rpx;flex:1;color:#29241f;font-size:27rpx}.product-selector-search-icon{width:24rpx;height:24rpx;margin-right:16rpx;border:3rpx solid #8e877f;border-radius:50%}.product-selector-scroll{height:0;min-height:0;flex:1}.product-selector-scroll.manual{padding:0 28rpx}.product-selector-list{padding:0 28rpx 24rpx}.product-selector-item{display:flex;align-items:center;min-height:132rpx;margin-bottom:14rpx;padding:16rpx;border:1rpx solid #ece5dc;border-radius:20rpx;background:#fff}.product-selector-item.selected{border-color:#8eafa3;background:#f0f6f3}.product-selector-cover{width:92rpx;height:92rpx;flex:0 0 auto;border-radius:14rpx;background:#eee9e2}.product-selector-cover.placeholder,.manual-product-image.placeholder{display:flex;align-items:center;justify-content:center;color:#b79b82;font-size:24rpx}.product-selector-copy{min-width:0;flex:1;margin-left:18rpx}.product-selector-name-row{display:flex;align-items:center;gap:12rpx}.product-selector-name{min-width:0;overflow:hidden;color:#2b2621;font-size:28rpx;font-weight:800;text-overflow:ellipsis;white-space:nowrap}.product-selector-price{flex:0 0 auto;color:#b7683d;font-size:27rpx;font-weight:900}.product-selector-meta{display:block;margin-top:7rpx;overflow:hidden;color:#7f7870;font-size:23rpx;text-overflow:ellipsis;white-space:nowrap}.product-selector-tags{display:flex;gap:8rpx;margin-top:7rpx}.product-selector-tags text{padding:3rpx 10rpx;border-radius:999rpx;background:#f3e9df;color:#826c5b;font-size:19rpx}.product-selector-check{width:42rpx;color:#8c857d;font-size:32rpx;text-align:right}.product-selector-item.selected .product-selector-check{color:#2f6f62}.product-selector-state{display:flex;min-height:360rpx;align-items:center;justify-content:center;padding:40rpx;color:#9a9289;font-size:25rpx;text-align:center}.product-selector-state.error{flex-direction:column;color:#a8554e}.product-selector-retry{margin-top:20rpx;padding:0 24rpx;border:1rpx solid #d8d1c8;border-radius:999rpx;background:#fff;color:#514b44;font-size:23rpx}.product-selector-footer{padding:16rpx 28rpx calc(18rpx + env(safe-area-inset-bottom));border-top:1rpx solid #eee7de;background:#fffdf8}.product-selector-action,.product-selector-confirm,.product-selector-back{width:100%;height:76rpx;margin:0;border-radius:20rpx;font-size:26rpx;line-height:76rpx}.product-selector-action{border:1rpx solid #cbdad4;background:#edf4f1;color:#2f6f62}.manual-product-card{margin:18rpx 0;padding:20rpx;border-radius:18rpx;background:#f8f2eb}.manual-product-grid{display:grid;grid-template-columns:minmax(0,1fr) 180rpx;gap:14rpx}.manual-product-grid input,.manual-product-extra input,.manual-product-extra textarea{box-sizing:border-box;width:100%;padding:0 18rpx;border:0;border-radius:14rpx;background:#fff;color:#302923;font-size:26rpx}.manual-product-grid input{height:72rpx}.manual-product-more{margin-top:16rpx;color:#5f897c;font-size:24rpx}.manual-product-extra{display:grid;gap:14rpx;padding-bottom:20rpx}.manual-product-extra textarea{min-height:120rpx;padding-top:16rpx}.manual-product-extra input{height:68rpx}.manual-product-image-row{display:flex;align-items:center;gap:14rpx}.manual-product-image{width:92rpx;height:92rpx;border-radius:14rpx;background:#efe5da}.manual-product-image-row button{flex:1;min-width:0;padding:0;border-radius:12rpx;background:#edf4f1;color:#2f6f62;font-size:23rpx}.manual-footer{display:grid;gap:10rpx}.product-selector-confirm{background:#4f766d;color:#fff}.product-selector-back{height:58rpx;line-height:58rpx;background:transparent;color:#5f897c;font-size:23rpx}
|
||||
@@ -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
|
||||
})
|
||||
@@ -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')
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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,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; } }
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
# Salon 作品选择与手动录入优化
|
||||
|
||||
## 目标
|
||||
|
||||
统一新增预约和历史补单中的作品选择交互。已有作品在底部选择页中显示封面、名称、价格、时长和适用员工;手动作品在同一弹层切换录入,不再占用主表单空间。
|
||||
|
||||
## 交互
|
||||
|
||||
- 选择页高度约 88% 屏高,拥有独立滚动区域、防触摸穿透和明确的圆形关闭按钮。
|
||||
- 已有作品点击整行立即回填。新增预约回填作品、只读参考价格和服务时长;历史补单回填作品和金额初值,金额仍可独立调整。
|
||||
- 手动录入状态默认只显示名称和价格,二者必填;描述、标签、适合人群、注意事项和图片放在默认折叠的更多信息中。
|
||||
- 手动确认后清空已有作品 ID,关闭弹层并回填当前表单;返回列表不会丢失手动草稿。
|
||||
|
||||
## 实现边界
|
||||
|
||||
新增 `product-selector-sheet` 组件承载列表态和手动态,页面负责搜索、数据加载、图片上传和表单回填。继续使用现有作品和预约/补单接口,不修改后端、数据库、ArtList 或 Nacos。
|
||||
|
||||
## 验收
|
||||
|
||||
验证两页的价格展示、作品选择、手动录入互斥、更多信息折叠、关闭/返回、错误重试和滚动防穿透;执行页面脚本语法检查、相关小程序测试和 `git diff --check`。
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
## 展示与流转
|
||||
|
||||
规划页提供独立“补录历史订单”入口。没有具体时间的补单显示在日视图“历史补单”区域,不进入时间轴;有时间的记录可展示但不产生排班容量占用。服务中补单可完成或取消,已完成补单不再进入普通预约流程。
|
||||
规划页不提供独立补录按钮;点击过去日期时直接进入历史补单页,并带入服务日期和已筛选员工。新增预约表单选中历史日期时,先提示历史补单规则,用户可取消并保留原表单,或跳转到预填日期的补单页。没有具体时间的补单显示在日视图“历史补单”区域,不进入时间轴;有时间的记录可展示但不产生排班容量占用。服务中补单可完成或取消,已完成补单不再进入普通预约流程。
|
||||
|
||||
## 兼容与验证
|
||||
|
||||
|
||||
+7
-1
@@ -1,5 +1,10 @@
|
||||
# 项目变更记录
|
||||
|
||||
## 2026-10-13 Salon 作品选择与手动录入优化
|
||||
|
||||
- 新增预约和历史补单统一使用底部作品选择页,作品列表直接展示价格、时长和适用员工。
|
||||
- 手动作品录入迁移到选择页内部,名称和价格必填,描述、标签、图片等信息默认折叠。
|
||||
|
||||
## 2026-10-12 Salon 小程序业务引用字段底部选择页
|
||||
|
||||
- 新增统一的业务引用选择组件,客户、员工和门店使用约 88% 屏高的底部选择页,统一搜索、加载、错误、空状态和滚动防穿透行为。
|
||||
@@ -183,5 +188,6 @@
|
||||
|
||||
- 新增历史补单接口与小程序独立补单页面,补单可直接进入“服务中”或“已完成”。
|
||||
- 新增 `IN_SERVICE(4)` 状态、历史补单来源和服务日期字段;无具体时间的补单仅参与日期统计,不创建预约占用。
|
||||
- 规划页增加补录入口、历史补单展示,后台订单筛选增加服务中状态。
|
||||
- 规划页点击历史日期进入补录页面;新增预约选择历史日期时提示取消或跳转补单,并自动带入日期和已选员工。移除独立补录按钮。
|
||||
- 规划页保留历史补单展示,后台订单筛选增加服务中状态。
|
||||
- 数据库字段与索引已融合到 `docs/scripts/sql/init/jayucloud-salon.sql`,初始化脚本可重复执行。
|
||||
|
||||
@@ -6,6 +6,7 @@ security:
|
||||
username: root
|
||||
password: 122503wcy....
|
||||
redis:
|
||||
username: xiaowang
|
||||
password: 122503wcy
|
||||
rabbitmq:
|
||||
username: rabbitmq
|
||||
|
||||
Reference in New Issue
Block a user