50 lines
2.1 KiB
JavaScript
50 lines
2.1 KiB
JavaScript
const { BRAND_CONFIG } = require('../../utils/config')
|
|
const profileCache = require('../../utils/profile-cache')
|
|
|
|
Page({
|
|
data: {
|
|
profile: {},
|
|
businessExpireDateText: '未设置',
|
|
businessExpiryStatusText: '有效期未设置',
|
|
form: { shopName: BRAND_CONFIG.defaultShopName, startTime: '10:00', endTime: '22:00', defaultDuration: 60, rule: '必须选择已有作品作为项目来源' }
|
|
},
|
|
onShow() { this.loadProfile() },
|
|
async loadProfile(options = {}) {
|
|
try {
|
|
const profile = await profileCache.getProfile(options)
|
|
const businessExpireDateText = profile.shopBusinessExpireTime ? String(profile.shopBusinessExpireTime).slice(0, 10) : '未设置'
|
|
const remainingDays = profile.shopBusinessRemainingDays
|
|
const hasRemainingDays = remainingDays !== null && remainingDays !== undefined && remainingDays !== '' && Number.isFinite(Number(remainingDays))
|
|
const businessExpiryStatusText = profile.shopBusinessExpired
|
|
? '已过期,暂不能新增预约'
|
|
: hasRemainingDays
|
|
? `剩余 ${remainingDays} 天`
|
|
: '有效期未设置'
|
|
this.setData({ profile, businessExpireDateText, businessExpiryStatusText })
|
|
} catch (error) {
|
|
this.setData({ profile: {} })
|
|
}
|
|
},
|
|
onInput(event) { this.setData({ [`form.${event.currentTarget.dataset.field}`]: event.detail.value }) },
|
|
onStartChange(event) { this.setData({ 'form.startTime': event.detail.value }) },
|
|
onEndChange(event) { this.setData({ 'form.endTime': event.detail.value }) },
|
|
explainDefaultDuration() {
|
|
wx.showModal({
|
|
title: '默认时长',
|
|
content: '用于手动创建预约或未选择作品时的默认服务时长,会影响可约时间校验和预约结束时间估算。',
|
|
showCancel: false,
|
|
confirmText: '知道了'
|
|
})
|
|
},
|
|
explainBookingRule() {
|
|
wx.showModal({
|
|
title: '预约规则',
|
|
content: '这是店铺给美甲师看的预约备注或说明文案,不参与自动排班、容量或冲突校验。',
|
|
showCancel: false,
|
|
confirmText: '知道了'
|
|
})
|
|
},
|
|
save() { wx.showToast({ title: '已保存' }) },
|
|
back() { wx.navigateBack() }
|
|
})
|