功能:优化Salon作品选择与历史补单
This commit is contained in:
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user