提交 Salon 小程序现有调整
This commit is contained in:
@@ -16,11 +16,11 @@ Page({
|
||||
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}` }))
|
||||
const normalized = list.map(item => ({ ...item, name: item.name || item.nickname || item.account || `美甲师${item.id}` }))
|
||||
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' }) }
|
||||
} 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 || []; this.setData({ products: list, productError: '' }); this.refreshProductOptions() } catch (error) { this.setData({ products: [], allProductOptions: [], productOptions: [], productError: error.message || '项目加载失败' }) } finally { this.setData({ loadingProducts: false }) } },
|
||||
refreshProductOptions() {
|
||||
@@ -35,7 +35,7 @@ Page({
|
||||
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}位员工可做` : '全部员工',
|
||||
artistText: artistIds.length ? artistNames.join('、') || `${artistIds.length}位美甲师可做` : '全部美甲师',
|
||||
tagList: tagList.slice(0, 3)
|
||||
}
|
||||
})
|
||||
@@ -78,7 +78,7 @@ Page({
|
||||
selectStatus(e) { this.setData({ 'form.status': Number(e.currentTarget.dataset.status) }) },
|
||||
async submit() {
|
||||
const form = this.data.form
|
||||
if (!form.serviceDate || (!form.productId && !form.manualProductTitle) || !form.amount || !form.artistId) { wx.showToast({ title: '请填写项目、金额、日期和员工', icon: 'none' }); return }
|
||||
if (!form.serviceDate || (!form.productId && !form.manualProductTitle) || !form.amount || !form.artistId) { wx.showToast({ title: '请填写项目、金额、日期和美甲师', icon: 'none' }); return }
|
||||
if (form.phone && !/^1[3-9]\d{9}$/.test(form.phone)) { wx.showToast({ title: '手机号格式不正确', icon: 'none' }); return }
|
||||
this.setData({ submitting: true })
|
||||
try { await planningApi.createBackfillOrder(form); wx.showToast({ title: '补单已保存', icon: 'success' }); const app = getApp(); app.globalData.planningNeedRefresh = true; setTimeout(() => wx.navigateBack(), 500) }
|
||||
|
||||
Reference in New Issue
Block a user