店务小程序支持预约标签设置与展示
This commit is contained in:
@@ -5,5 +5,28 @@ module.exports = {
|
||||
return request({
|
||||
url: '/tag/list/all'
|
||||
})
|
||||
},
|
||||
|
||||
create(data) {
|
||||
return request({
|
||||
url: '/tag/create',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
},
|
||||
|
||||
update(id, data) {
|
||||
return request({
|
||||
url: `/tag/update/${id}`,
|
||||
method: 'PUT',
|
||||
data
|
||||
})
|
||||
},
|
||||
|
||||
delete(id) {
|
||||
return request({
|
||||
url: `/tag/delete/${id}`,
|
||||
method: 'DELETE'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,14 @@ const ARTIST_PRESET_LABELS = {
|
||||
LATE_SHIFT: '晚班',
|
||||
CUSTOM: '自定义'
|
||||
}
|
||||
const DEFAULT_TAG_STYLE = {
|
||||
textColor: '#333333',
|
||||
bgColor: '#FFFFFF',
|
||||
borderColor: '#E5E5E5',
|
||||
sortOrder: 100,
|
||||
frontVisible: 1
|
||||
}
|
||||
const TAG_SPLIT_PATTERN = /[;,,、]/
|
||||
|
||||
function buildClientRequestId(prefix) {
|
||||
return `${prefix}-${Date.now()}-${Math.random().toString(36).slice(2, 10)}`
|
||||
@@ -555,6 +563,7 @@ function normalizeProduct(product, artists) {
|
||||
return {
|
||||
...product,
|
||||
coverImage: imageUrls[0] || '',
|
||||
allTags: parseProductTags(product),
|
||||
tagList: parseProductTags(product).slice(0, 4),
|
||||
artistText: artistNames.length > 0 ? artistNames.join('、') : '全部美甲师',
|
||||
priceText: productPriceText,
|
||||
@@ -569,7 +578,12 @@ function normalizeTagOption(tag) {
|
||||
}
|
||||
return {
|
||||
id: (tag && tag.id) || name,
|
||||
name
|
||||
name,
|
||||
tagName: (tag && tag.tagName) || name,
|
||||
displayName: (tag && tag.displayName) || name,
|
||||
textColor: (tag && tag.textColor) || DEFAULT_TAG_STYLE.textColor,
|
||||
bgColor: (tag && tag.bgColor) || DEFAULT_TAG_STYLE.bgColor,
|
||||
borderColor: (tag && tag.borderColor) || DEFAULT_TAG_STYLE.borderColor
|
||||
}
|
||||
}
|
||||
|
||||
@@ -588,8 +602,52 @@ function normalizeTagOptions(tags) {
|
||||
})
|
||||
}
|
||||
|
||||
function splitTagValues(value) {
|
||||
return String(value || '')
|
||||
.split(TAG_SPLIT_PATTERN)
|
||||
.map(item => item.trim())
|
||||
.filter(Boolean)
|
||||
}
|
||||
|
||||
function encodeTagValues(tags) {
|
||||
const names = new Set()
|
||||
return (Array.isArray(tags) ? tags : [])
|
||||
.map(item => String(item || '').trim())
|
||||
.filter(Boolean)
|
||||
.filter(item => {
|
||||
if (names.has(item)) {
|
||||
return false
|
||||
}
|
||||
names.add(item)
|
||||
return true
|
||||
})
|
||||
.join(';')
|
||||
}
|
||||
|
||||
function buildSelectableTagOptions(tagOptions, value) {
|
||||
const selected = new Set(splitTagValues(value))
|
||||
return (Array.isArray(tagOptions) ? tagOptions : [])
|
||||
.map(normalizeTagOption)
|
||||
.filter(Boolean)
|
||||
.map(item => ({
|
||||
...item,
|
||||
selected: selected.has(item.name)
|
||||
}))
|
||||
}
|
||||
|
||||
function findTagOptionByName(tagOptions, value) {
|
||||
const tagName = String(value || '').trim()
|
||||
if (!tagName) {
|
||||
return null
|
||||
}
|
||||
return (Array.isArray(tagOptions) ? tagOptions : [])
|
||||
.map(normalizeTagOption)
|
||||
.filter(Boolean)
|
||||
.find(item => item.name === tagName) || null
|
||||
}
|
||||
|
||||
function resolveTagPickerIndex(tagOptions, value) {
|
||||
const firstTag = String(value || '').split(/[;,,、]/)[0].trim()
|
||||
const firstTag = splitTagValues(value)[0] || ''
|
||||
if (!firstTag) {
|
||||
return 0
|
||||
}
|
||||
@@ -598,20 +656,41 @@ function resolveTagPickerIndex(tagOptions, value) {
|
||||
}
|
||||
|
||||
function resolveTagValue(tagOptions, value) {
|
||||
const tokens = String(value || '')
|
||||
.split(/[;,,、]/)
|
||||
.map(item => item.trim())
|
||||
.filter(Boolean)
|
||||
if (tokens.length === 0) {
|
||||
return ''
|
||||
return encodeTagValues(splitTagValues(value))
|
||||
}
|
||||
|
||||
function toggleTagValue(value, tagName) {
|
||||
const current = splitTagValues(value)
|
||||
if (current.includes(tagName)) {
|
||||
return encodeTagValues(current.filter(item => item !== tagName))
|
||||
}
|
||||
if (!Array.isArray(tagOptions) || tagOptions.length === 0) {
|
||||
return ''
|
||||
return encodeTagValues(current.concat(tagName))
|
||||
}
|
||||
|
||||
function appendTagValue(value, tagName) {
|
||||
return encodeTagValues(splitTagValues(value).concat(tagName))
|
||||
}
|
||||
|
||||
function resolveCurrentShopId() {
|
||||
const app = getApp()
|
||||
const userInfo = (app && app.globalData && app.globalData.userInfo) || {}
|
||||
return userInfo.shopId || (app && app.globalData && app.globalData.shopId) || ''
|
||||
}
|
||||
|
||||
function buildTagCreatePayload(tagName) {
|
||||
const shopId = resolveCurrentShopId()
|
||||
const payload = {
|
||||
tagName,
|
||||
textColor: DEFAULT_TAG_STYLE.textColor,
|
||||
bgColor: DEFAULT_TAG_STYLE.bgColor,
|
||||
borderColor: DEFAULT_TAG_STYLE.borderColor,
|
||||
sortOrder: DEFAULT_TAG_STYLE.sortOrder,
|
||||
frontVisible: DEFAULT_TAG_STYLE.frontVisible
|
||||
}
|
||||
const matched = tokens
|
||||
.map(token => tagOptions.find(item => item.name === token))
|
||||
.find(Boolean)
|
||||
return matched ? matched.name : ''
|
||||
if (shopId) {
|
||||
payload.shopId = shopId
|
||||
}
|
||||
return payload
|
||||
}
|
||||
|
||||
function splitManualImageValues(value) {
|
||||
@@ -758,6 +837,8 @@ Page({
|
||||
tagsLoading: false,
|
||||
tagPickerIndex: 0,
|
||||
tagError: '',
|
||||
tagCreating: false,
|
||||
manualTagInput: '',
|
||||
conflictTip: '',
|
||||
conflictLevel: 'free',
|
||||
canCreateAppointment: true,
|
||||
@@ -871,7 +952,7 @@ Page({
|
||||
const tagOptions = normalizeTagOptions(tagsData.list || tagsData || [])
|
||||
const selectedTag = resolveTagValue(tagOptions, this.data.form.manualProductTags)
|
||||
this.setData({
|
||||
tagOptions,
|
||||
tagOptions: buildSelectableTagOptions(tagOptions, selectedTag),
|
||||
tagsLoaded: true,
|
||||
tagPickerIndex: resolveTagPickerIndex(tagOptions, selectedTag),
|
||||
'form.manualProductTags': selectedTag,
|
||||
@@ -1105,6 +1186,8 @@ Page({
|
||||
manualProductPanelVisible: true,
|
||||
productModalVisible: false,
|
||||
manualProductImageUrls: imageUrls,
|
||||
manualTagInput: '',
|
||||
tagOptions: buildSelectableTagOptions(this.data.tagOptions, this.data.form.manualProductTags),
|
||||
tagPickerIndex: resolveTagPickerIndex(this.data.tagOptions, this.data.form.manualProductTags)
|
||||
}
|
||||
if (!productTitle) {
|
||||
@@ -1137,7 +1220,7 @@ Page({
|
||||
const selectedProduct = this.data.filteredProducts.find(item => String(item.id) === String(event.currentTarget.dataset.id)) || {}
|
||||
const price = formatProductPrice(selectedProduct.price)
|
||||
const priceUndetermined = price === '' || price === '0'
|
||||
const productTag = resolveTagValue(this.data.tagOptions, parseProductTags(selectedProduct).join(','))
|
||||
const productTag = resolveTagValue(this.data.tagOptions, (selectedProduct.allTags || parseProductTags(selectedProduct)).join(','))
|
||||
const imageUrls = Array.isArray(selectedProduct.imageUrls) ? selectedProduct.imageUrls : []
|
||||
this.setData({
|
||||
selectedProduct,
|
||||
@@ -1152,6 +1235,7 @@ Page({
|
||||
'form.manualProductImageUrl': imageUrls.join(','),
|
||||
manualProductImageUrls: imageUrls,
|
||||
productModalVisible: false,
|
||||
tagOptions: buildSelectableTagOptions(this.data.tagOptions, productTag),
|
||||
tagPickerIndex: resolveTagPickerIndex(this.data.tagOptions, productTag),
|
||||
'form.durationMinutes': String(parseInt(selectedProduct.approximateDuration, 10) || this.data.form.durationMinutes || '')
|
||||
})
|
||||
@@ -1159,14 +1243,80 @@ Page({
|
||||
this.checkAvailability()
|
||||
},
|
||||
|
||||
toggleManualTag(event) {
|
||||
const tagName = String(event.currentTarget.dataset.name || '').trim()
|
||||
if (!tagName) {
|
||||
return
|
||||
}
|
||||
const nextValue = toggleTagValue(this.data.form.manualProductTags, tagName)
|
||||
this.setData({
|
||||
'form.manualProductTags': nextValue,
|
||||
tagOptions: buildSelectableTagOptions(this.data.tagOptions, nextValue),
|
||||
tagPickerIndex: resolveTagPickerIndex(this.data.tagOptions, nextValue)
|
||||
})
|
||||
},
|
||||
|
||||
onManualTagInput(event) {
|
||||
this.setData({ manualTagInput: event.detail.value })
|
||||
},
|
||||
|
||||
async createManualTag() {
|
||||
if (this.data.tagCreating || this.data.tagsLoading) {
|
||||
return
|
||||
}
|
||||
const tagName = String(this.data.manualTagInput || '').trim()
|
||||
if (!tagName) {
|
||||
wx.showToast({ title: '请输入标签名称', icon: 'none' })
|
||||
return
|
||||
}
|
||||
const existingTag = findTagOptionByName(this.data.tagOptions, tagName)
|
||||
if (existingTag) {
|
||||
const nextValue = appendTagValue(this.data.form.manualProductTags, existingTag.name)
|
||||
this.setData({
|
||||
manualTagInput: '',
|
||||
'form.manualProductTags': nextValue,
|
||||
tagOptions: buildSelectableTagOptions(this.data.tagOptions, nextValue),
|
||||
tagPickerIndex: resolveTagPickerIndex(this.data.tagOptions, nextValue),
|
||||
tagError: ''
|
||||
})
|
||||
return
|
||||
}
|
||||
this.setData({ tagCreating: true })
|
||||
try {
|
||||
const createdId = await tagsApi.create(buildTagCreatePayload(tagName))
|
||||
const nextOptions = normalizeTagOptions(this.data.tagOptions.concat({
|
||||
id: createdId || tagName,
|
||||
tagName,
|
||||
displayName: tagName
|
||||
}))
|
||||
const nextValue = appendTagValue(this.data.form.manualProductTags, tagName)
|
||||
this.setData({
|
||||
manualTagInput: '',
|
||||
tagOptions: buildSelectableTagOptions(nextOptions, nextValue),
|
||||
tagPickerIndex: resolveTagPickerIndex(nextOptions, nextValue),
|
||||
'form.manualProductTags': nextValue,
|
||||
tagsLoaded: true,
|
||||
tagError: ''
|
||||
})
|
||||
wx.showToast({ title: '标签已新增', icon: 'success' })
|
||||
} catch (error) {
|
||||
this.setData({ tagError: error.message || '标签新增失败' })
|
||||
wx.showToast({ title: error.message || '标签新增失败', icon: 'none' })
|
||||
} finally {
|
||||
this.setData({ tagCreating: false })
|
||||
}
|
||||
},
|
||||
|
||||
onManualTagChange(event) {
|
||||
const tag = this.data.tagOptions[Number(event.detail.value)]
|
||||
if (!tag) {
|
||||
return
|
||||
}
|
||||
const nextValue = toggleTagValue(this.data.form.manualProductTags, tag.name)
|
||||
this.setData({
|
||||
tagPickerIndex: Number(event.detail.value),
|
||||
'form.manualProductTags': tag.name
|
||||
'form.manualProductTags': nextValue,
|
||||
tagOptions: buildSelectableTagOptions(this.data.tagOptions, nextValue)
|
||||
})
|
||||
},
|
||||
|
||||
@@ -1483,7 +1633,7 @@ Page({
|
||||
payload.manualProductTitle = String(form.manualProductTitle || '').trim()
|
||||
payload.manualProductPrice = appointmentPrice
|
||||
payload.manualProductDescription = String(form.manualProductDescription || '').trim() || undefined
|
||||
payload.manualProductTags = String(form.manualProductTags || '').trim() || undefined
|
||||
payload.manualProductTags = resolveTagValue(this.data.tagOptions, form.manualProductTags) || undefined
|
||||
payload.manualProductPrecautions = String(form.manualProductPrecautions || '').trim() || undefined
|
||||
payload.manualProductImageFileIds = String(form.manualProductImageFileIds || '').trim() || undefined
|
||||
}
|
||||
|
||||
@@ -142,13 +142,18 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="manual-field manual-field-full">
|
||||
<text class="manual-field-label">标签</text>
|
||||
<picker range="{{tagOptions}}" range-key="name" value="{{tagPickerIndex}}" bindchange="onManualTagChange" disabled="{{tagOptions.length === 0}}">
|
||||
<view class="manual-picker {{form.manualProductTags ? '' : 'placeholder'}}">
|
||||
<text>{{form.manualProductTags || (tagOptions.length ? '请选择标签' : '暂无标签')}}</text>
|
||||
<text class="manual-picker-arrow">›</text>
|
||||
</view>
|
||||
</picker>
|
||||
<view class="manual-tag-head">
|
||||
<text class="manual-field-label">标签</text>
|
||||
<text wx:if="{{tagsLoading}}" class="manual-tag-loading">加载中</text>
|
||||
</view>
|
||||
<view wx:if="{{tagOptions.length}}" class="manual-tag-list">
|
||||
<view wx:for="{{tagOptions}}" wx:key="id" class="manual-tag-chip {{item.selected ? 'active' : ''}}" data-name="{{item.name}}" bindtap="toggleManualTag">{{item.name}}</view>
|
||||
</view>
|
||||
<view wx:else class="manual-tag-empty">暂无标签,可手动新增</view>
|
||||
<view class="manual-tag-input-row">
|
||||
<input class="manual-tag-input" value="{{manualTagInput}}" bindinput="onManualTagInput" placeholder="输入新标签" />
|
||||
<button class="secondary-btn manual-tag-add" loading="{{tagCreating}}" disabled="{{tagCreating || tagsLoading}}" bindtap="createManualTag">添加</button>
|
||||
</view>
|
||||
</view>
|
||||
<view wx:if="{{tagError}}" class="manual-tag-error">{{tagError}}</view>
|
||||
<view class="manual-field manual-field-full manual-remark-field">
|
||||
|
||||
@@ -1114,6 +1114,75 @@
|
||||
font-size: 22rpx;
|
||||
}
|
||||
|
||||
.manual-tag-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12rpx;
|
||||
}
|
||||
|
||||
.manual-tag-loading {
|
||||
color: #8f857a;
|
||||
font-size: 22rpx;
|
||||
}
|
||||
|
||||
.manual-tag-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10rpx;
|
||||
margin-top: 12rpx;
|
||||
}
|
||||
|
||||
.manual-tag-chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 56rpx;
|
||||
padding: 0 18rpx;
|
||||
border: 2rpx solid #e1d6c9;
|
||||
border-radius: 999rpx;
|
||||
background: #fffaf4;
|
||||
color: #6f6257;
|
||||
font-size: 24rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.manual-tag-chip.active {
|
||||
border-color: #6f8f83;
|
||||
background: #e5f2eb;
|
||||
color: #2f6b55;
|
||||
}
|
||||
|
||||
.manual-tag-empty {
|
||||
margin-top: 12rpx;
|
||||
color: #9a9288;
|
||||
font-size: 22rpx;
|
||||
}
|
||||
|
||||
.manual-tag-input-row {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) 140rpx;
|
||||
gap: 12rpx;
|
||||
margin-top: 12rpx;
|
||||
}
|
||||
|
||||
.manual-tag-input {
|
||||
min-width: 0;
|
||||
height: 70rpx;
|
||||
padding: 0 18rpx;
|
||||
border: 2rpx solid #eadfd2;
|
||||
border-radius: 14rpx;
|
||||
background: #fffaf4;
|
||||
color: #302923;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
.manual-tag-add {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
max-width: none;
|
||||
}
|
||||
|
||||
.manual-image-row {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const shopApi = require('../../api/shop')
|
||||
const tagsApi = require('../../api/tags')
|
||||
const dateUtil = require('../../utils/date')
|
||||
const { BRAND_CONFIG } = require('../../utils/config')
|
||||
const { markPlanningRefresh } = require('../../utils/planning-refresh')
|
||||
@@ -28,6 +29,13 @@ const EXCEPTION_TYPES = [
|
||||
]
|
||||
|
||||
const DEFAULT_SHOP_INTRO = '专注法式、晕染与手绘设计,适合想要温柔质感的客人。'
|
||||
const DEFAULT_TAG_STYLE = {
|
||||
textColor: '#333333',
|
||||
bgColor: '#FFFFFF',
|
||||
borderColor: '#E5E5E5',
|
||||
sortOrder: 100,
|
||||
frontVisible: 1
|
||||
}
|
||||
|
||||
function copyWorkDays(days) {
|
||||
if (Array.isArray(days)) {
|
||||
@@ -77,6 +85,61 @@ function introLength(value) {
|
||||
return String(value || '').length
|
||||
}
|
||||
|
||||
function normalizeTagOption(tag) {
|
||||
const name = String((tag && (tag.displayName || tag.tagName || tag.name)) || '').trim()
|
||||
if (!name) {
|
||||
return null
|
||||
}
|
||||
return {
|
||||
id: (tag && tag.id) || name,
|
||||
name,
|
||||
tagName: (tag && tag.tagName) || name,
|
||||
displayName: (tag && tag.displayName) || name,
|
||||
textColor: (tag && tag.textColor) || DEFAULT_TAG_STYLE.textColor,
|
||||
bgColor: (tag && tag.bgColor) || DEFAULT_TAG_STYLE.bgColor,
|
||||
borderColor: (tag && tag.borderColor) || DEFAULT_TAG_STYLE.borderColor,
|
||||
sortOrder: (tag && tag.sortOrder) || DEFAULT_TAG_STYLE.sortOrder,
|
||||
frontVisible: (tag && tag.frontVisible) === 0 ? 0 : DEFAULT_TAG_STYLE.frontVisible
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeTagOptions(tags) {
|
||||
const source = Array.isArray(tags) ? tags : []
|
||||
const names = new Set()
|
||||
return source
|
||||
.map(normalizeTagOption)
|
||||
.filter(Boolean)
|
||||
.filter(item => {
|
||||
if (names.has(item.name)) {
|
||||
return false
|
||||
}
|
||||
names.add(item.name)
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
function resolveCurrentShopId() {
|
||||
const app = getApp()
|
||||
const userInfo = (app && app.globalData && app.globalData.userInfo) || {}
|
||||
return userInfo.shopId || (app && app.globalData && app.globalData.shopId) || ''
|
||||
}
|
||||
|
||||
function buildTagPayload(tagName, sourceTag) {
|
||||
const shopId = resolveCurrentShopId()
|
||||
const payload = {
|
||||
tagName,
|
||||
textColor: (sourceTag && sourceTag.textColor) || DEFAULT_TAG_STYLE.textColor,
|
||||
bgColor: (sourceTag && sourceTag.bgColor) || DEFAULT_TAG_STYLE.bgColor,
|
||||
borderColor: (sourceTag && sourceTag.borderColor) || DEFAULT_TAG_STYLE.borderColor,
|
||||
sortOrder: (sourceTag && sourceTag.sortOrder) || DEFAULT_TAG_STYLE.sortOrder,
|
||||
frontVisible: (sourceTag && sourceTag.frontVisible) === 0 ? 0 : DEFAULT_TAG_STYLE.frontVisible
|
||||
}
|
||||
if (shopId) {
|
||||
payload.shopId = shopId
|
||||
}
|
||||
return payload
|
||||
}
|
||||
|
||||
Page({
|
||||
data: {
|
||||
presets: PRESETS,
|
||||
@@ -89,9 +152,16 @@ Page({
|
||||
exceptions: [],
|
||||
loading: false,
|
||||
saving: false,
|
||||
tagsLoading: false,
|
||||
tagSaving: false,
|
||||
coverUploading: false,
|
||||
coverImagePreviewUrl: '',
|
||||
introLength: introLength(DEFAULT_SHOP_INTRO),
|
||||
tagList: [],
|
||||
tagForm: {
|
||||
id: '',
|
||||
name: ''
|
||||
},
|
||||
form: {
|
||||
shopName: BRAND_CONFIG.defaultShopName,
|
||||
startTime: '10:00',
|
||||
@@ -116,12 +186,25 @@ Page({
|
||||
this.loadSettings()
|
||||
},
|
||||
|
||||
async loadTags() {
|
||||
this.setData({ tagsLoading: true })
|
||||
try {
|
||||
const tagsData = await tagsApi.listAll()
|
||||
this.setData({ tagList: normalizeTagOptions(tagsData.list || tagsData || []) })
|
||||
} catch (error) {
|
||||
wx.showToast({ title: error.message || '标签加载失败', icon: 'none' })
|
||||
} finally {
|
||||
this.setData({ tagsLoading: false })
|
||||
}
|
||||
},
|
||||
|
||||
async loadSettings() {
|
||||
this.setData({ loading: true })
|
||||
try {
|
||||
const [settings, exceptions] = await Promise.all([
|
||||
const [settings, exceptions, tagsData] = await Promise.all([
|
||||
shopApi.settings(),
|
||||
shopApi.scheduleExceptions()
|
||||
shopApi.scheduleExceptions(),
|
||||
tagsApi.listAll()
|
||||
])
|
||||
const hours = String(settings.businessHours || '').split('-')
|
||||
const preset = buildPreset(settings.schedulePresetType || 'EVERYDAY')
|
||||
@@ -147,7 +230,8 @@ Page({
|
||||
startTime: item.startTime ? String(item.startTime).slice(0, 5) : '',
|
||||
endTime: item.endTime ? String(item.endTime).slice(0, 5) : '',
|
||||
summary: buildExceptionSummary(item)
|
||||
}))
|
||||
})),
|
||||
tagList: normalizeTagOptions(tagsData.list || tagsData || [])
|
||||
})
|
||||
} catch (error) {
|
||||
wx.showToast({ title: error.message || '店铺设置加载失败', icon: 'none' })
|
||||
@@ -166,6 +250,98 @@ Page({
|
||||
this.setData(nextData)
|
||||
},
|
||||
|
||||
onTagInput(event) {
|
||||
this.setData({ 'tagForm.name': event.detail.value })
|
||||
},
|
||||
|
||||
editTag(event) {
|
||||
const tagId = String(event.currentTarget.dataset.id || '')
|
||||
const tag = this.data.tagList.find(item => String(item.id) === tagId)
|
||||
if (!tag) {
|
||||
wx.showToast({ title: '标签不存在', icon: 'none' })
|
||||
return
|
||||
}
|
||||
this.setData({
|
||||
tagForm: {
|
||||
id: tag.id,
|
||||
name: tag.tagName || tag.name
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
clearTagForm() {
|
||||
this.setData({
|
||||
tagForm: {
|
||||
id: '',
|
||||
name: ''
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
async saveTag() {
|
||||
if (this.data.tagSaving) {
|
||||
return
|
||||
}
|
||||
const tagName = String(this.data.tagForm.name || '').trim()
|
||||
if (!tagName) {
|
||||
wx.showToast({ title: '请输入标签名称', icon: 'none' })
|
||||
return
|
||||
}
|
||||
const tagId = this.data.tagForm.id
|
||||
const editingTag = tagId
|
||||
? this.data.tagList.find(item => String(item.id) === String(tagId))
|
||||
: null
|
||||
this.setData({ tagSaving: true })
|
||||
try {
|
||||
if (tagId) {
|
||||
await tagsApi.update(tagId, buildTagPayload(tagName, editingTag))
|
||||
wx.showToast({ title: '标签已更新', icon: 'success' })
|
||||
} else {
|
||||
await tagsApi.create(buildTagPayload(tagName, null))
|
||||
wx.showToast({ title: '标签已新增', icon: 'success' })
|
||||
}
|
||||
this.clearTagForm()
|
||||
await this.loadTags()
|
||||
} catch (error) {
|
||||
wx.showToast({ title: error.message || '标签保存失败', icon: 'none' })
|
||||
} finally {
|
||||
this.setData({ tagSaving: false })
|
||||
}
|
||||
},
|
||||
|
||||
deleteTag(event) {
|
||||
const tagId = String(event.currentTarget.dataset.id || '')
|
||||
const tag = this.data.tagList.find(item => String(item.id) === tagId)
|
||||
if (!tag) {
|
||||
wx.showToast({ title: '标签不存在', icon: 'none' })
|
||||
return
|
||||
}
|
||||
wx.showModal({
|
||||
title: '删除标签',
|
||||
content: `确认删除标签“${tag.name}”?`,
|
||||
confirmText: '删除',
|
||||
confirmColor: '#d98d8d',
|
||||
success: async result => {
|
||||
if (!result.confirm) {
|
||||
return
|
||||
}
|
||||
this.setData({ tagSaving: true })
|
||||
try {
|
||||
await tagsApi.delete(tag.id)
|
||||
if (String(this.data.tagForm.id) === String(tag.id)) {
|
||||
this.clearTagForm()
|
||||
}
|
||||
await this.loadTags()
|
||||
wx.showToast({ title: '标签已删除', icon: 'success' })
|
||||
} catch (error) {
|
||||
wx.showToast({ title: error.message || '标签删除失败', icon: 'none' })
|
||||
} finally {
|
||||
this.setData({ tagSaving: false })
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
async chooseCoverImage() {
|
||||
if (this.data.coverUploading || this.data.saving) {
|
||||
return
|
||||
|
||||
@@ -63,6 +63,31 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="section">
|
||||
<view class="section-title">标签设置</view>
|
||||
<view class="card tag-setting-card">
|
||||
<view class="tag-form-row">
|
||||
<input class="tag-input" value="{{tagForm.name}}" bindinput="onTagInput" placeholder="输入标签名称" />
|
||||
<button class="secondary-btn tag-save-btn" loading="{{tagSaving}}" disabled="{{tagSaving || tagsLoading}}" bindtap="saveTag">{{tagForm.id ? '更新' : '新增'}}</button>
|
||||
</view>
|
||||
<view wx:if="{{tagForm.id}}" class="tag-edit-tip">
|
||||
<text>正在编辑“{{tagForm.name}}”</text>
|
||||
<text class="tag-clear" bindtap="clearTagForm">取消</text>
|
||||
</view>
|
||||
<view wx:if="{{tagsLoading}}" class="tag-empty">标签加载中</view>
|
||||
<view wx:elif="{{tagList.length}}" class="tag-list">
|
||||
<view wx:for="{{tagList}}" wx:key="id" class="tag-item">
|
||||
<view class="tag-preview" style="background: {{item.bgColor}}; color: {{item.textColor}}; border-color: {{item.borderColor}};">{{item.name}}</view>
|
||||
<view class="tag-actions">
|
||||
<text data-id="{{item.id}}" bindtap="editTag">编辑</text>
|
||||
<text class="danger" data-id="{{item.id}}" bindtap="deleteTag">删除</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view wx:else class="tag-empty">暂无标签,可用于新建预约时快速选择</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="section">
|
||||
<view class="section-title">店铺排班</view>
|
||||
<view class="card rule-card">
|
||||
|
||||
@@ -278,6 +278,94 @@
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.tag-setting-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 18rpx;
|
||||
padding: 20rpx 24rpx;
|
||||
}
|
||||
|
||||
.tag-form-row {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) 150rpx;
|
||||
gap: 12rpx;
|
||||
}
|
||||
|
||||
.tag-input {
|
||||
min-width: 0;
|
||||
height: 70rpx;
|
||||
padding: 0 18rpx;
|
||||
border: 1rpx solid #eadfd2;
|
||||
border-radius: 14rpx;
|
||||
background: #fff8f2;
|
||||
color: #3d3128;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
.tag-save-btn {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.tag-edit-tip {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12rpx;
|
||||
color: #7b7167;
|
||||
font-size: 22rpx;
|
||||
}
|
||||
|
||||
.tag-clear {
|
||||
color: #2f6b55;
|
||||
}
|
||||
|
||||
.tag-list {
|
||||
display: grid;
|
||||
gap: 12rpx;
|
||||
}
|
||||
|
||||
.tag-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12rpx;
|
||||
}
|
||||
|
||||
.tag-preview {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
min-width: 0;
|
||||
max-width: 100%;
|
||||
min-height: 54rpx;
|
||||
padding: 0 16rpx;
|
||||
overflow: hidden;
|
||||
border: 1rpx solid;
|
||||
border-radius: 999rpx;
|
||||
font-size: 24rpx;
|
||||
font-weight: 800;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.tag-actions {
|
||||
display: flex;
|
||||
flex: 0 0 auto;
|
||||
gap: 16rpx;
|
||||
color: #2f6b55;
|
||||
font-size: 22rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.tag-actions .danger {
|
||||
color: #c36a6a;
|
||||
}
|
||||
|
||||
.tag-empty {
|
||||
color: #8c8177;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.rule-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
@@ -404,3 +404,11 @@
|
||||
- 数据库说明:本次不新增 SQL,不修改初始化 SQL,不需要执行数据库迁移;生产库已在上一轮执行过预约作品快照和员工全周全天排班相关迁移。
|
||||
- 影响范围:更新 `JY-Core` 预约状态、预约详情、预约图片快照回显/删除、预约价格维护和手工预约日历兜底相关能力;不更新 Gateway、Web 静态资源、Nacos、Nginx 和数据库结构。
|
||||
- 验证方式:发布前 `PlanningServiceImplTest` 20 个用例通过、`JayuCloudSqlSchemaTest` 9 个用例通过,店务小程序相关 JS 语法检查通过;发布后三台 Core 均为 `active`,本机 `/health/check` 正常,公网 `https://yunail.art/health/check` 与 `https://yunail.art/api/shop/list` 均返回 200。生产执行与验证时间为 `2026-07-23 18:43-18:50 +08:00`。
|
||||
|
||||
## 2026-07-23 店务小程序新增预约标签设置与展示
|
||||
|
||||
- 变更原因:店务端需要在店铺设置里维护预约标签,并在新建预约时支持复用标签、手动输入即建标签,同时在预约详情展示这些标签。
|
||||
- 处理方式:仅改动 `JY-Salon-WeChat`。在店铺设置页新增标签管理区,复用现有 `/admin/tag` 接口完成列表、创建、编辑、删除;在预约表单手工项目面板改为标签多选 + 手动新增标签;保留预约详情页现有 `productTags` 展示链路,不新增后端或 SQL 改动。
|
||||
- 数据库说明:本次不新增 SQL,不修改初始化 SQL,不需要执行数据库迁移。
|
||||
- 影响范围:影响 `JY-Salon-WeChat/pages/shop-settings/`、`JY-Salon-WeChat/pages/appointment-form/` 与标签 API 封装;预约详情页继续通过既有 `appointment.productTags` 渲染标签。
|
||||
- 验证方式:`JY-Salon-WeChat/api/tags.js`、预约表单页、店铺设置页 JS 语法检查通过;相关文件 `git diff --check` 通过;微信开发者工具运行态验证 `pages/shop-settings/index` 可见“标签设置”区,`pages/appointment-form/index` 可打开手工预约面板并展示标签输入/添加控件;GitNexus staged `detect-changes` 结果为 low risk、0 affected processes。
|
||||
|
||||
@@ -487,3 +487,15 @@
|
||||
以后避免:小程序自动化验证前必须同时确认项目路径和端口,不只看路由;多项目并行时优先使用固定端口映射。
|
||||
|
||||
验证方式:发现 `sourceProjectPath` 不匹配时停止截图验证,改用静态样式检查、`git diff --check` 和 GitNexus 变更检测兜底。
|
||||
|
||||
## 2026-07-23 GitNexus / pnpm 在 Windows PowerShell 下被微信开发者工具 Node 抢占 PATH
|
||||
|
||||
问题:在 `D:\code\JayuCloud` 目录直接运行 GitNexus、`pnpm`、`npx` 或依赖较新 Node 版本的命令时,默认 `node` 会先命中微信开发者工具自带的 Node 16,导致命令报错或行为异常。
|
||||
|
||||
原因:当前环境的 PATH 顺序里,微信开发者工具内置 Node 排在前面;PowerShell 直接执行时不会自动切回项目常用的 Node 24。
|
||||
|
||||
处理方式:执行这类命令前,改用 `cmd /c "set PATH=E:\Development\Node\node-v24;E:\Development\Node\npm-global;%PATH%&& ..."` 临时把 Node 24 放到当前命令 PATH 最前面;必要时先跑 `node -v` 确认版本。
|
||||
|
||||
以后避免:凡是在 JayuCloud 里运行 GitNexus、`pnpm`、`npx`、`.gitnexus/run.cjs` 之类命令,先检查 `Get-Command node` 和 `node -v`;如果命中微信开发者工具 Node,立刻切换到带 PATH 前缀的 `cmd /c` 写法。
|
||||
|
||||
验证方式:切换前后分别执行 `node -v`,应从 `16.x` 变成 `24.x`;之后 GitNexus `impact` / `detect_changes` 与 `pnpm` 命令可正常完成。
|
||||
|
||||
@@ -49,3 +49,9 @@
|
||||
- 下一步:提交本次生产发布记录;店务小程序由用户发布。
|
||||
- 当前阻塞点:无。
|
||||
- 最近一次重要操作结果:三台 Core 均为 `active/enabled`,本机 `/health/check` 正常,公网 `https://yunail.art/health/check` 与 `https://yunail.art/api/shop/list` 均返回 200。
|
||||
|
||||
## 2026-07-23 店务小程序预约标签设置与展示
|
||||
- 已完成:店铺设置页新增标签管理区,预约表单手工项目面板支持标签多选和手动输入新建标签,预约详情展示链路已确认复用既有 `productTags`。
|
||||
- 下一步:保持当前暂存范围,提交本次中文 commit。
|
||||
- 当前阻塞点:无。
|
||||
- 最近一次重要操作结果:微信开发者工具运行态验证已通过,`pages/shop-settings/index` 可见“标签设置”区,`pages/appointment-form/index` 可打开手工预约面板并显示标签输入/添加控件;GitNexus staged `detect-changes` 结果为 low risk、0 affected processes。
|
||||
|
||||
Reference in New Issue
Block a user