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