将门店有效期展示移至店铺设置
This commit is contained in:
@@ -1,9 +1,30 @@
|
||||
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 }) },
|
||||
|
||||
Reference in New Issue
Block a user