回溯点:保存注册预约客户流程修复进度
This commit is contained in:
@@ -1,17 +1,37 @@
|
||||
const { BRAND_CONFIG } = require('../../utils/config')
|
||||
const profileCache = require('../../utils/profile-cache')
|
||||
const shopApi = require('../../api/shop')
|
||||
|
||||
function resolveNameStatus(value) {
|
||||
const status = String(value || '').toUpperCase()
|
||||
if (status === 'PENDING' || status === 'RETRY') return '名称审核中'
|
||||
if (status === 'REJECTED') return '名称审核未通过'
|
||||
if (status === 'APPROVED') return '名称已通过审核'
|
||||
return '尚未提交审核'
|
||||
}
|
||||
|
||||
Page({
|
||||
data: {
|
||||
profile: {},
|
||||
businessExpireDateText: '未设置',
|
||||
businessExpiryStatusText: '有效期未设置',
|
||||
form: { shopName: BRAND_CONFIG.defaultShopName, startTime: '10:00', endTime: '22:00', defaultDuration: 60, rule: '必须选择已有作品作为项目来源' }
|
||||
nameModerationText: '尚未提交审核',
|
||||
settingsLoading: false,
|
||||
settingsSaving: false,
|
||||
nameSaving: false,
|
||||
settingsError: '',
|
||||
form: { shopName: BRAND_CONFIG.defaultShopName, pendingShopName: '', startTime: '10:00', endTime: '22:00', defaultDuration: 60 }
|
||||
},
|
||||
onShow() { this.loadProfile() },
|
||||
async loadProfile(options = {}) {
|
||||
|
||||
onShow() { this.loadProfileAndSettings() },
|
||||
|
||||
async loadProfileAndSettings(options = {}) {
|
||||
this.setData({ settingsLoading: true, settingsError: '' })
|
||||
try {
|
||||
const profile = await profileCache.getProfile(options)
|
||||
const [profile, settings] = await Promise.all([
|
||||
profileCache.getProfile(options),
|
||||
shopApi.appointmentSettings()
|
||||
])
|
||||
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))
|
||||
@@ -20,30 +40,79 @@ Page({
|
||||
: hasRemainingDays
|
||||
? `剩余 ${remainingDays} 天`
|
||||
: '有效期未设置'
|
||||
this.setData({ profile, businessExpireDateText, businessExpiryStatusText })
|
||||
const [startTime, endTime] = String(settings.businessHours || '10:00-22:00').split('-')
|
||||
this.setData({
|
||||
profile,
|
||||
businessExpireDateText,
|
||||
businessExpiryStatusText,
|
||||
nameModerationText: resolveNameStatus(settings.shopNameModerationStatus),
|
||||
form: {
|
||||
...this.data.form,
|
||||
shopName: settings.pendingShopName || settings.shopName || profile.shopName || BRAND_CONFIG.defaultShopName,
|
||||
pendingShopName: settings.pendingShopName || '',
|
||||
startTime: startTime || '10:00',
|
||||
endTime: endTime || '22:00',
|
||||
defaultDuration: Number(settings.defaultAppointmentDurationMinutes) || 60
|
||||
}
|
||||
})
|
||||
} catch (error) {
|
||||
this.setData({ profile: {} })
|
||||
this.setData({ settingsError: error.message || '设置加载失败' })
|
||||
} finally {
|
||||
this.setData({ settingsLoading: false })
|
||||
}
|
||||
},
|
||||
|
||||
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 }) },
|
||||
|
||||
async saveAppointmentSettings() {
|
||||
const { startTime, endTime, defaultDuration } = this.data.form
|
||||
const duration = Number(defaultDuration)
|
||||
if (startTime >= endTime) {
|
||||
wx.showToast({ title: '营业结束时间必须晚于开始时间', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!Number.isInteger(duration) || duration < 15 || duration > 720) {
|
||||
wx.showToast({ title: '默认时长需在15至720分钟之间', icon: 'none' })
|
||||
return
|
||||
}
|
||||
this.setData({ settingsSaving: true })
|
||||
try {
|
||||
await shopApi.saveAppointmentSettings({ businessHours: `${startTime}-${endTime}`, defaultAppointmentDurationMinutes: duration })
|
||||
wx.showToast({ title: '预约设置已生效', icon: 'success' })
|
||||
} catch (error) {
|
||||
wx.showToast({ title: error.message || '保存失败,请重试', icon: 'none' })
|
||||
} finally {
|
||||
this.setData({ settingsSaving: false })
|
||||
}
|
||||
},
|
||||
|
||||
async submitShopName() {
|
||||
const shopName = String(this.data.form.shopName || '').trim()
|
||||
if (!shopName) {
|
||||
wx.showToast({ title: '请输入店铺名称', icon: 'none' })
|
||||
return
|
||||
}
|
||||
this.setData({ nameSaving: true })
|
||||
try {
|
||||
await shopApi.updateName(shopName)
|
||||
wx.showToast({ title: '店铺名称已提交审核', icon: 'success' })
|
||||
await this.loadProfileAndSettings({ force: true })
|
||||
} catch (error) {
|
||||
wx.showToast({ title: error.message || '提交审核失败', icon: 'none' })
|
||||
} finally {
|
||||
this.setData({ nameSaving: false })
|
||||
}
|
||||
},
|
||||
|
||||
explainDefaultDuration() {
|
||||
wx.showModal({
|
||||
title: '默认时长',
|
||||
content: '用于手动创建预约或未选择作品时的默认服务时长,会影响可约时间校验和预约结束时间估算。',
|
||||
content: '用于新建预约表单的初始值和未设置款式时的后备时长。已选款式的时长或你在预约中修改的时长优先。',
|
||||
showCancel: false,
|
||||
confirmText: '知道了'
|
||||
})
|
||||
},
|
||||
explainBookingRule() {
|
||||
wx.showModal({
|
||||
title: '预约规则',
|
||||
content: '这是店铺给美甲师看的预约备注或说明文案,不参与自动排班、容量或冲突校验。',
|
||||
showCancel: false,
|
||||
confirmText: '知道了'
|
||||
})
|
||||
},
|
||||
save() { wx.showToast({ title: '已保存' }) },
|
||||
back() { wx.navigateBack() }
|
||||
})
|
||||
|
||||
@@ -10,6 +10,14 @@ global.wx = { showToast: () => {} }
|
||||
|
||||
const profileCache = require('../../utils/profile-cache')
|
||||
profileCache.getProfile = async () => currentProfile
|
||||
const shopApi = require('../../api/shop')
|
||||
shopApi.appointmentSettings = async () => ({
|
||||
shopName: '薄荷美甲',
|
||||
businessHours: '09:30-21:30',
|
||||
defaultAppointmentDurationMinutes: 75,
|
||||
shopNameModerationStatus: 'PENDING',
|
||||
pendingShopName: '薄荷指尖'
|
||||
})
|
||||
require('./index')
|
||||
|
||||
async function loadProfile(profile) {
|
||||
@@ -24,7 +32,7 @@ async function loadProfile(profile) {
|
||||
})
|
||||
}
|
||||
}
|
||||
await pageDefinition.loadProfile.call(page)
|
||||
await pageDefinition.loadProfileAndSettings.call(page)
|
||||
return page.data
|
||||
}
|
||||
|
||||
@@ -54,11 +62,19 @@ async function run() {
|
||||
shopBusinessRemainingDays: 0
|
||||
})
|
||||
assert.strictEqual(expired.businessExpiryStatusText, '已过期,暂不能新增预约')
|
||||
assert.strictEqual(expired.form.startTime, '09:30')
|
||||
assert.strictEqual(expired.form.endTime, '21:30')
|
||||
assert.strictEqual(expired.form.defaultDuration, 75)
|
||||
assert.strictEqual(expired.nameModerationText, '名称审核中')
|
||||
assert.strictEqual(expired.form.pendingShopName, '薄荷指尖')
|
||||
|
||||
const shopSettingsWxml = fs.readFileSync(path.join(__dirname, 'index.wxml'), 'utf8')
|
||||
const accountSettingsWxml = fs.readFileSync(path.join(__dirname, '../account-settings/index.wxml'), 'utf8')
|
||||
assert(shopSettingsWxml.includes('wx:if="{{profile.type == 2}}" class="card business-expiry-card"'))
|
||||
assert(!accountSettingsWxml.includes('business-expiry-card'))
|
||||
assert(!shopSettingsWxml.includes('预约规则'))
|
||||
assert(shopSettingsWxml.includes('提交名称审核'))
|
||||
assert(shopSettingsWxml.includes('保存预约设置'))
|
||||
}
|
||||
|
||||
run().catch(error => {
|
||||
|
||||
@@ -1,28 +1,21 @@
|
||||
<view class="page no-tab">
|
||||
<view wx:if="{{settingsError}}" class="settings-error"><text>{{settingsError}}</text><button class="secondary-btn" bindtap="loadProfileAndSettings">重试</button></view>
|
||||
<view wx:if="{{profile.type == 2}}" class="card business-expiry-card">
|
||||
<view class="business-expiry-head"><text class="section-title">门店经营有效期</text><text class="business-expiry-status {{profile.shopBusinessExpired ? 'expired' : ''}}">{{businessExpiryStatusText}}</text></view>
|
||||
<view class="business-expiry-date"><text>有效期至</text><strong>{{businessExpireDateText}}</strong></view>
|
||||
<text wx:if="{{profile.shopBusinessExpired}}" class="business-expiry-note">到期后暂不可新增普通预约,历史订单、查询和补录不受影响。请联系平台管理员办理续期。</text>
|
||||
</view>
|
||||
<view class="card form-card">
|
||||
<view class="field"><text class="field-label">店铺名称</text><input value="{{form.shopName}}" data-field="shopName" bindinput="onInput" /></view>
|
||||
<view class="field"><text class="field-label">营业开始</text><picker mode="time" value="{{form.startTime}}" bindchange="onStartChange"><view class="field-value">{{form.startTime}}</view></picker></view>
|
||||
<view class="field"><text class="field-label">营业结束</text><picker mode="time" value="{{form.endTime}}" bindchange="onEndChange"><view class="field-value">{{form.endTime}}</view></picker></view>
|
||||
<view class="field">
|
||||
<view class="label-with-help">
|
||||
<text class="field-label">默认时长</text>
|
||||
<text class="help-badge" catchtap="explainDefaultDuration">?</text>
|
||||
</view>
|
||||
<input type="number" value="{{form.defaultDuration}}" data-field="defaultDuration" bindinput="onInput" />
|
||||
<text class="muted">分钟</text>
|
||||
</view>
|
||||
<view class="field">
|
||||
<view class="label-with-help">
|
||||
<text class="field-label">预约规则</text>
|
||||
<text class="help-badge" catchtap="explainBookingRule">?</text>
|
||||
</view>
|
||||
<input value="{{form.rule}}" data-field="rule" bindinput="onInput" placeholder="例如:必须选择已有作品作为项目来源" />
|
||||
</view>
|
||||
<view wx:if="{{!settingsLoading && !settingsError}}" class="settings-section">
|
||||
<view class="settings-section-head"><view><text class="section-title">门店名称</text><text class="settings-section-note">名称修改需审核,通过后对外展示</text></view><text class="moderation-status">{{nameModerationText}}</text></view>
|
||||
<view class="shop-name-field"><input value="{{form.shopName}}" data-field="shopName" bindinput="onInput" placeholder="请输入门店名称" /></view>
|
||||
<view wx:if="{{form.pendingShopName}}" class="pending-name-note">审核中的名称:{{form.pendingShopName}}</view>
|
||||
<button class="settings-action secondary" loading="{{nameSaving}}" disabled="{{nameSaving}}" bindtap="submitShopName">提交名称审核</button>
|
||||
|
||||
<view class="settings-divider"></view>
|
||||
<view class="settings-section-head"><view><text class="section-title">预约运营设置</text><text class="settings-section-note">保存后立即生效,不需要门店资料审核</text></view></view>
|
||||
<view class="settings-field-row"><text class="settings-label">营业时间</text><view class="time-range"><picker mode="time" value="{{form.startTime}}" bindchange="onStartChange"><view class="time-value">{{form.startTime}}</view></picker><text>至</text><picker mode="time" value="{{form.endTime}}" bindchange="onEndChange"><view class="time-value">{{form.endTime}}</view></picker></view></view>
|
||||
<view class="settings-field-row duration-row"><view class="label-with-help"><text class="settings-label">默认预约时长</text><text class="help-badge" catchtap="explainDefaultDuration">?</text></view><view class="duration-input"><input type="number" value="{{form.defaultDuration}}" data-field="defaultDuration" bindinput="onInput" /><text>分钟</text></view></view>
|
||||
<button class="settings-action" loading="{{settingsSaving}}" disabled="{{settingsSaving}}" bindtap="saveAppointmentSettings">保存预约设置</button>
|
||||
</view>
|
||||
<view class="fixed-bottom"><button class="primary-btn" bindtap="save">保存设置</button></view>
|
||||
<view wx:elif="{{settingsLoading}}" class="settings-loading">正在加载店铺设置…</view>
|
||||
</view>
|
||||
|
||||
@@ -1,6 +1,29 @@
|
||||
|
||||
.business-expiry-card { margin-top:20rpx; padding:26rpx; }.business-expiry-head,.business-expiry-date { display:flex; align-items:center; justify-content:space-between; gap:16rpx; }.business-expiry-status { color:#397055; font-size:22rpx; }.business-expiry-status.expired { color:#a24f42; }.business-expiry-date { margin-top:20rpx; padding-top:18rpx; border-top:1rpx solid #e5ebe7; color:#71807a; font-size:23rpx; }.business-expiry-date strong { color:#17211f; font-size:25rpx; }.business-expiry-note { display:block; margin-top:14rpx; color:#a24f42; font-size:21rpx; line-height:1.6; }
|
||||
|
||||
.settings-section { margin-top: 24rpx; padding: 0 8rpx 36rpx; }
|
||||
.settings-section-head { display: flex; align-items: center; justify-content: space-between; gap: 20rpx; }
|
||||
.settings-section-head > view { display: flex; min-width: 0; flex-direction: column; }
|
||||
.settings-section-note { margin-top: 8rpx; color: #7a8981; font-size: 21rpx; line-height: 1.45; }
|
||||
.moderation-status { flex: none; color: #58826a; font-size: 21rpx; }
|
||||
.shop-name-field { margin-top: 20rpx; }
|
||||
.shop-name-field input { box-sizing: border-box; width: 100%; height: 82rpx; padding: 0 20rpx; border: 1rpx solid #dce8e0; border-radius: 12rpx; background: #f7faf8; color: #17211f; font-size: 25rpx; }
|
||||
.pending-name-note { margin-top: 12rpx; color: #8b7554; font-size: 21rpx; }
|
||||
.settings-action { height: 76rpx; margin: 18rpx 0 0; padding: 0 26rpx; border-radius: 12rpx; background: #247b63; color: #fff; font-size: 24rpx; line-height: 76rpx; }
|
||||
.settings-action.secondary { background: #e9f3ed; color: #397055; }
|
||||
.settings-divider { height: 1rpx; margin: 32rpx 0 28rpx; background: #e4ebe6; }
|
||||
.settings-field-row { display: flex; min-height: 90rpx; align-items: center; justify-content: space-between; gap: 20rpx; border-bottom: 1rpx solid #e8eee9; }
|
||||
.settings-label { color: #26342d; font-size: 24rpx; font-weight: 600; }
|
||||
.time-range { display: flex; align-items: center; gap: 15rpx; color: #859189; font-size: 21rpx; }
|
||||
.time-value { min-width: 102rpx; padding: 13rpx 14rpx; border-radius: 10rpx; background: #f0f6f2; color: #247b63; font-size: 24rpx; text-align: center; }
|
||||
.duration-row { align-items: center; }
|
||||
.duration-input { display: flex; align-items: center; gap: 12rpx; color: #748279; font-size: 22rpx; }
|
||||
.duration-input input { box-sizing: border-box; width: 150rpx; height: 68rpx; padding: 0 16rpx; border: 1rpx solid #dce8e0; border-radius: 10rpx; background: #f7faf8; color: #17211f; text-align: right; }
|
||||
.label-with-help { display: flex; align-items: center; }
|
||||
.settings-error { display: flex; align-items: center; justify-content: space-between; gap: 16rpx; padding: 18rpx 8rpx; color: #a24f42; font-size: 22rpx; }
|
||||
.settings-error button { margin: 0; color: #397055; font-size: 21rpx; }
|
||||
.settings-loading { padding: 40rpx 8rpx; color: #71807a; font-size: 23rpx; }
|
||||
|
||||
.label-with-help {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
Reference in New Issue
Block a user