Files
JayuCloud/JC-Salon-WeChat/pages/shop-settings/index.js
T

50 lines
2.1 KiB
JavaScript
Raw Normal View History

2026-06-24 22:13:00 +08:00
const { BRAND_CONFIG } = require('../../utils/config')
2026-10-27 17:46:40 +08:00
const profileCache = require('../../utils/profile-cache')
2026-06-24 22:13:00 +08:00
2026-06-04 16:39:06 +08:00
Page({
data: {
2026-10-27 17:46:40 +08:00
profile: {},
businessExpireDateText: '未设置',
businessExpiryStatusText: '有效期未设置',
2026-06-24 22:13:00 +08:00
form: { shopName: BRAND_CONFIG.defaultShopName, startTime: '10:00', endTime: '22:00', defaultDuration: 60, rule: '必须选择已有作品作为项目来源' }
2026-06-04 16:39:06 +08:00
},
2026-10-27 17:46:40 +08:00
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: {} })
}
},
2026-06-04 16:39:06 +08:00
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 }) },
2026-06-27 02:52:47 +08:00
explainDefaultDuration() {
wx.showModal({
title: '默认时长',
content: '用于手动创建预约或未选择作品时的默认服务时长,会影响可约时间校验和预约结束时间估算。',
showCancel: false,
confirmText: '知道了'
})
},
explainBookingRule() {
wx.showModal({
title: '预约规则',
2026-10-20 18:02:49 +08:00
content: '这是店铺给美甲师看的预约备注或说明文案,不参与自动排班、容量或冲突校验。',
2026-06-27 02:52:47 +08:00
showCancel: false,
confirmText: '知道了'
})
},
2026-06-04 16:39:06 +08:00
save() { wx.showToast({ title: '已保存' }) },
back() { wx.navigateBack() }
})