对齐历史补录款式弹窗

This commit is contained in:
2026-10-21 00:55:51 +08:00
parent 8d3f092084
commit 9925c7f83b
6 changed files with 258 additions and 20 deletions
+14 -9
View File
@@ -5,7 +5,7 @@ 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: '' }, 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: '', selectedProduct: {}, selectedProductTitle: '', selectedProductPriceText: '', submitting: false },
data: { form: { serviceDate: dateUtil.formatDate(new Date()), manualProductTitle: '', amount: '', customerName: '', phone: '', serviceTime: '', status: 4, remark: '', artistId: '', productId: '', customerUserId: '' }, manualProductDraft: { title: '', price: '' }, artists: [], artistOptions: [], allProductOptions: [], productOptions: [], customerOptions: [], allCustomerOptions: [], productSelectorVisible: false, manualProductSheetVisible: false, artistSelectorVisible: false, customerSelectorVisible: false, loadingProducts: false, loadingArtists: false, loadingCustomers: false, productKeyword: '', artistKeyword: '', customerKeyword: '', productError: '', artistError: '', customerError: '', selectedArtistName: '', selectedProduct: {}, selectedProductTitle: '', selectedProductPriceText: '', submitting: false },
onLoad(options = {}) {
const serviceDate = options.serviceDate || this.data.form.serviceDate
const artistId = options.artistId || ''
@@ -43,12 +43,17 @@ Page({
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, 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 }) },
openProductSelector() { this.setData({ manualProductSheetVisible: true }) },
openProductLibrary() { this.setData({ manualProductSheetVisible: false, productSelectorVisible: true }) },
closeProductSelector() { this.setData({ productSelectorVisible: false }) },
closeManualProduct() { this.setData({ manualProductSheetVisible: false }) },
openManualProduct() { this.setData({ productSelectorVisible: false, manualProductSheetVisible: true }) },
onManualProductInput(e) {
const field = e.currentTarget && e.currentTarget.dataset.field || e.detail.field
this.setData({ [`manualProductDraft.${field}`]: e.detail.value })
},
stopTap() {},
stopTouchMove() {},
openArtistSelector() { this.setData({ artistSelectorVisible: true }) },
closeArtistSelector() { this.setData({ artistSelectorVisible: false }) },
openCustomerSelector() { this.setData({ customerSelectorVisible: true }) },
@@ -56,7 +61,7 @@ Page({
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, selectedProduct: item, 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' }) },
selectProduct(e) { const item = e.detail.item; this.setData({ 'form.productId': item.id, selectedProduct: item, 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, manualProductSheetVisible: false }) },
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 }) },
@@ -69,7 +74,7 @@ Page({
wx.showToast({ title: '请填写作品名称和价格', icon: 'none' })
return
}
this.setData({ 'form.productId': '', 'form.manualProductTitle': title, selectedProduct: {}, selectedProductTitle: '', selectedProductPriceText: `¥${price}`, 'form.amount': String(price), productSelectorVisible: false, productSelectorMode: 'list' })
this.setData({ 'form.productId': '', 'form.manualProductTitle': title, selectedProduct: {}, selectedProductTitle: '', selectedProductPriceText: `¥${price}`, 'form.amount': String(price), productSelectorVisible: false, manualProductSheetVisible: false })
},
onInput(e) { this.setData({ [`form.${e.currentTarget.dataset.field}`]: e.detail.value }) },
onDateChange(e) { this.setData({ 'form.serviceDate': e.detail.value }) },
@@ -10,16 +10,16 @@
<view class="card form-card backfill-card style-section">
<view class="section-heading">
<view class="section-title-row"><text class="section-title-main">美甲款式</text><text class="required-mark">*</text></view>
<text class="section-caption">选择款式或手动录入</text>
<text class="section-caption">手动录入为主,也可从款式库快速选择</text>
</view>
<button class="field-card backfill-field-card" bindtap="openProductSelector">
<button class="field-card backfill-field-card full" bindtap="openProductSelector">
<image wx:if="{{selectedProduct.coverImage}}" class="field-icon style-entry-image" src="{{selectedProduct.coverImage}}" mode="aspectFill"></image>
<view wx:else class="field-icon">✦</view>
<view class="field-text">
<text class="field-label">项目款式</text>
<text class="field-value {{selectedProductTitle || form.manualProductTitle ? '' : 'placeholder'}}">{{selectedProductTitle || form.manualProductTitle || '请选择美甲款式'}}</text>
<text wx:if="{{selectedProductPriceText}}" class="field-meta">参考价 {{selectedProductPriceText}}</text>
<text wx:else class="field-meta">可从款式库选择,也可手动录入</text>
<text wx:else class="field-meta">点击录入款式,或从款式库选择</text>
</view>
<text class="chevron">›</text>
</button>
@@ -88,7 +88,26 @@
<button class="primary-btn backfill-submit-btn" loading="{{submitting}}" disabled="{{submitting}}" bindtap="submit">保存历史补单</button>
</view>
<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" />
<product-selector-sheet visible="{{productSelectorVisible}}" mode="list" title="选择已有款式" keyword="{{productKeyword}}" placeholder="搜索款式名称" items="{{productOptions}}" selected-id="{{form.productId}}" loading="{{loadingProducts}}" error-text="{{productError}}" empty-text="暂无款式" show-manual-action="{{true}}" bind:search="searchProducts" bind:select="selectProduct" bind:openmanual="openManualProduct" bind:close="closeProductSelector" bind:retry="loadProducts" />
<view wx:if="{{manualProductSheetVisible}}" class="modal-mask backfill-manual-product-mask" bindtap="closeManualProduct" catchtouchmove="stopTouchMove">
<view class="manual-style-sheet backfill-manual-style-sheet" catchtap="stopTap" catchtouchmove="stopTouchMove">
<view class="modal-head">
<view><text class="modal-title">录入本次美甲款式</text><text class="modal-subtitle">款式名称和价格必填</text></view>
<view class="modal-close" bindtap="closeManualProduct" aria-label="关闭款式录入"></view>
</view>
<scroll-view class="manual-style-content" scroll-y enhanced show-scrollbar="{{false}}">
<view class="style-name-row backfill-manual-fields">
<input class="style-name-input backfill-manual-product-name" value="{{manualProductDraft.title}}" data-field="title" bindinput="onManualProductInput" placeholder="请输入款式名称" />
<input class="style-name-input backfill-manual-product-price" value="{{manualProductDraft.price}}" data-field="price" bindinput="onManualProductInput" type="digit" placeholder="参考价格" />
</view>
<text class="manual-style-hint">参考价会自动带入实际成交金额,保存前仍可按本次服务情况调整。</text>
</scroll-view>
<view class="manual-style-footer">
<button class="manual-style-confirm" bindtap="useManualProduct">用于本次补录</button>
<button class="manual-style-library-link" bindtap="openProductLibrary">从款式库中选择</button>
</view>
</view>
</view>
<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>
+173 -1
View File
@@ -101,6 +101,26 @@
font-weight: 800;
}
.field-card {
display: flex;
width: 100%;
min-height: 124rpx;
align-items: center;
gap: 22rpx;
padding: 20rpx 22rpx;
border: 2rpx dashed #cbdcd5;
border-radius: 30rpx;
background: #fbfdfc;
text-align: left;
line-height: 1.35;
box-sizing: border-box;
}
button.full{
width: 100%;
box-sizing: border-box;
margin: 0; /* 清除小程序button自带左右margin */
}
.backfill-field-card {
display: flex;
width: 100%;
@@ -115,7 +135,11 @@
text-align: left;
line-height: 1.35;
}
button.full{
width: 100%;
box-sizing: border-box;
margin: 0; /* 清除小程序button自带左右margin */
}
.backfill-page .field-icon {
display: flex;
width: 76rpx;
@@ -384,6 +408,154 @@
box-shadow: 0 10rpx 22rpx rgba(23, 33, 31, 0.16);
}
.backfill-manual-product-mask {
position: fixed;
inset: 0;
z-index: 140;
display: flex;
align-items: flex-end;
justify-content: center;
background: rgba(16, 29, 25, 0.44);
}
.backfill-manual-style-sheet {
display: flex;
width: 100%;
height: 70vh;
max-height: 82vh;
flex-direction: column;
overflow: hidden;
padding: 28rpx 28rpx calc(24rpx + env(safe-area-inset-bottom));
border-radius: 34rpx 34rpx 0 0;
background: #fff;
box-shadow: 0 -20rpx 48rpx rgba(24, 48, 40, 0.14);
}
.backfill-manual-style-sheet .modal-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 20rpx;
margin-bottom: 20rpx;
}
.backfill-manual-style-sheet .modal-title,
.backfill-manual-style-sheet .modal-subtitle {
display: block;
}
.backfill-manual-style-sheet .modal-title {
color: #17211f;
font-size: 34rpx;
font-weight: 900;
}
.backfill-manual-style-sheet .modal-subtitle {
margin-top: 8rpx;
color: #71807a;
font-size: 24rpx;
}
.backfill-manual-style-sheet .modal-close {
position: relative;
display: flex;
width: 48rpx;
min-width: 48rpx;
height: 48rpx;
align-items: center;
justify-content: center;
border: 1rpx solid #e7ece9;
border-radius: 50%;
background: #fff;
}
.backfill-manual-style-sheet .modal-close::before,
.backfill-manual-style-sheet .modal-close::after {
position: absolute;
width: 22rpx;
height: 3rpx;
border-radius: 999rpx;
background: #247b63;
content: "";
}
.backfill-manual-style-sheet .modal-close::before {
transform: rotate(45deg);
}
.backfill-manual-style-sheet .modal-close::after {
transform: rotate(-45deg);
}
.backfill-manual-style-sheet .manual-style-content {
height: 0;
min-height: 0;
flex: 1;
padding: 8rpx 0 20rpx;
}
.backfill-manual-fields {
display: flex;
align-items: center;
gap: 14rpx;
}
.backfill-manual-fields .style-name-input {
box-sizing: border-box;
width: 100%;
height: 82rpx;
padding: 0 18rpx;
border: 1rpx solid #dce6e1;
border-radius: 24rpx;
background: #fbfdfc;
color: #17211f;
font-size: 24rpx;
}
.backfill-manual-fields .backfill-manual-product-name {
min-width: 0;
flex: 1;
}
.backfill-manual-fields .backfill-manual-product-price {
min-width: 0;
flex: 0 0 220rpx;
}
.backfill-manual-style-sheet .manual-style-hint {
display: block;
margin-top: 18rpx;
color: #71807a;
font-size: 21rpx;
line-height: 1.5;
}
.backfill-manual-style-sheet .manual-style-footer {
flex: 0 0 auto;
padding-top: 16rpx;
border-top: 2rpx solid #e7ece9;
}
.backfill-manual-style-sheet .manual-style-confirm {
width: 100%;
height: 84rpx;
margin: 0;
border-radius: 24rpx;
background: #17211f;
color: #fff;
font-size: 26rpx;
font-weight: 800;
line-height: 84rpx;
}
.backfill-manual-style-sheet .manual-style-library-link {
height: 64rpx;
margin: 10rpx auto 0;
color: #247b63;
font-size: 22rpx;
line-height: 64rpx;
}
@media (max-width: 360px) {
.backfill-title {
font-size: 44rpx;
@@ -1,4 +1,6 @@
const assert = require('assert')
const fs = require('fs')
const path = require('path')
let definition
global.Page = value => { definition = value }
@@ -22,25 +24,38 @@ function createPage() {
const page = createPage()
page.openProductSelector()
assert.strictEqual(page.data.manualProductSheetVisible, true)
assert.strictEqual(page.data.productSelectorVisible, false)
page.openProductLibrary()
assert.strictEqual(page.data.manualProductSheetVisible, false)
assert.strictEqual(page.data.productSelectorVisible, true)
assert.strictEqual(page.data.productSelectorMode, 'list')
page.openManualProduct()
assert.strictEqual(page.data.productSelectorVisible, false)
assert.strictEqual(page.data.manualProductSheetVisible, true)
page.selectProduct({ detail: { item: { id: 12, title: '轻奢款', price: 168, priceText: '¥168', coverImage: '/cover.jpg' } } })
assert.strictEqual(page.data.form.productId, 12)
assert.strictEqual(page.data.form.amount, '168')
assert.strictEqual(page.data.selectedProductPriceText, '¥168')
assert.strictEqual(page.data.selectedProduct.coverImage, '/cover.jpg')
assert.strictEqual(page.data.form.manualProductTitle, '')
assert.strictEqual(page.data.manualProductSheetVisible, false)
page.data.manualProductDraft = { title: '临时款', price: '199' }
page.onManualProductInput({ currentTarget: { dataset: { field: 'title' } }, detail: { value: '临时款' } })
page.onManualProductInput({ currentTarget: { dataset: { field: 'price' } }, detail: { value: '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')
assert.deepStrictEqual(page.data.selectedProduct, {})
assert.strictEqual(page.data.manualProductSheetVisible, false)
page.openManualProduct()
assert.strictEqual(page.data.productSelectorMode, 'manual')
page.toggleManualProductMore()
assert.strictEqual(page.data.manualMoreExpanded, true)
const wxml = fs.readFileSync(path.join(__dirname, 'index.wxml'), 'utf8')
const wxss = fs.readFileSync(path.join(__dirname, 'index.wxss'), 'utf8')
assert.match(wxml, /class="manual-style-sheet backfill-manual-style-sheet"/)
assert.match(wxml, /class="modal-close" bindtap="closeManualProduct"/)
assert.match(wxml, /bindtap="openProductLibrary">从款式库中选择<\/button>/)
assert.match(wxss, /\.backfill-manual-style-sheet\s*\{[^}]*height:\s*70vh/s)
@@ -0,0 +1,20 @@
# Salon 补录款式弹窗与新增页对齐
## 目标
补录页面的款式录入交互和新增预约保持一致,让手动录入作为默认入口,同时保留从已有款式库快速选择的能力。
## 交互
- 点击补录表单中的美甲款式卡片,打开底部款式录入弹层。
- 弹层沿用新增预约的标题区、圆形关闭按钮、独立滚动内容、底部主按钮和款式库入口。
- 补录特有的款式价格与名称并列录入,二者都必填;确认后款式名称回填表单,参考价带入实际成交金额。
- 实际成交金额仍可在补录表单中单独修改。
- 选择款式库入口后显示已有款式列表;选择款式时按既有逻辑回填项目和参考价。
- 从款式库触发手动录入时也打开同一个录入弹层。
## 边界与验证
- 不修改后端接口、数据库和订单协议。
- 不改变普通预约作品选择流程。
- 使用页面状态测试覆盖录入/款式库切换、作品回填和价格回填,并检查小程序 JavaScript 语法及差异格式。
+7
View File
@@ -1,5 +1,12 @@
# 项目变更记录
## 2026-10-21 Salon 补录款式弹窗对齐新增页
- 问题:补录页面打开后直接进入款式列表,手动录入弹层与新增预约页样式和入口不一致。
- 处理:补录款式卡改为直接打开与新增页同结构的底部录入弹层;弹层保留款式名称、必填参考价、圆形关闭、确认按钮和款式库入口。
- 兼容:款式库选择、参考价带入实际成交金额及金额二次调整行为保持不变。
- 验证:补录作品选择状态测试、新增预约弹层及作品测试、JS 语法检查和 `git diff --check` 通过。
## 2026-10-20 Salon 新增预约页面对齐演示稿
- 问题:新增预约页虽然保留了确认的字段和业务规则,但实际呈现与 demo 差异明显。