调整日程日期选择与预约入口
This commit is contained in:
@@ -192,40 +192,56 @@ async function run() {
|
||||
global.wx.navigateTo = options => navigations.push(options.url)
|
||||
global.wx.showToast = options => toasts.push(options.title)
|
||||
|
||||
const quickCreatePage = createPage({ canCreateAppointment: true, businessHoursConfigured: true, selectedArtistId: '88' })
|
||||
const today = dateUtil.formatDate(new Date())
|
||||
quickCreatePage.quickCreateAppointment({ currentTarget: { dataset: { date: today } } })
|
||||
assert.strictEqual(navigations.pop(), `/pages/appointment-form/index?date=${today}&artistId=88`)
|
||||
const monthPage = createPage({ viewMode: 'month', canCreateAppointment: true, currentDateText: '2026-10-12' })
|
||||
let loadedDate = ''
|
||||
monthPage.loadCalendar = () => { loadedDate = monthPage.data.currentDateText }
|
||||
monthPage.selectMonthDate({ currentTarget: { dataset: { date: '2000-01-01' } } })
|
||||
assert.strictEqual(monthPage.data.viewMode, 'day')
|
||||
assert.strictEqual(monthPage.data.currentDateText, '2000-01-01')
|
||||
assert.strictEqual(loadedDate, '2000-01-01')
|
||||
assert.strictEqual(navigations.length, 0)
|
||||
|
||||
quickCreatePage.quickCreateAppointment({ currentTarget: { dataset: { date: '2099-12-31' } } })
|
||||
assert.strictEqual(navigations.pop(), '/pages/appointment-form/index?date=2099-12-31&artistId=88')
|
||||
const weekPage = createPage({ viewMode: 'week', currentDateText: '2026-10-12' })
|
||||
let preparedView = false
|
||||
weekPage.prepareView = () => { preparedView = true }
|
||||
weekPage.selectWeekDate({ currentTarget: { dataset: { date: '2026-10-15' } } })
|
||||
assert.strictEqual(weekPage.data.viewMode, 'week')
|
||||
assert.strictEqual(weekPage.data.currentDateText, '2026-10-15')
|
||||
assert.strictEqual(preparedView, true)
|
||||
assert.strictEqual(navigations.length, 0)
|
||||
|
||||
quickCreatePage.quickCreateAppointment({ currentTarget: { dataset: { date: '2000-01-01' } } })
|
||||
assert.strictEqual(navigations.pop(), '/pages/backfill-order/index?serviceDate=2000-01-01&artistId=88')
|
||||
const dayFabPage = createPage({ viewMode: 'day', canCreateAppointment: true, businessHoursConfigured: true, currentDateText: '2026-11-02', selectedArtistId: '99' })
|
||||
dayFabPage.createAppointment()
|
||||
assert.strictEqual(navigations.pop(), '/pages/appointment-form/index?date=2026-11-02&artistId=99')
|
||||
|
||||
quickCreatePage.data.selectedArtistId = ''
|
||||
quickCreatePage.quickCreateAppointment({ currentTarget: { dataset: { date: '2099-11-30' } } })
|
||||
assert.strictEqual(navigations.pop(), '/pages/appointment-form/index?date=2099-11-30')
|
||||
const monthFabPage = createPage({ viewMode: 'month', canCreateAppointment: true, businessHoursConfigured: true, currentDateText: '2026-11-02', selectedArtistId: '88' })
|
||||
monthFabPage.createAppointment()
|
||||
assert.strictEqual(navigations.pop(), '/pages/appointment-form/index?dateMode=manual&artistId=88')
|
||||
|
||||
quickCreatePage.quickCreateAppointment({ currentTarget: { dataset: { date: '2000-01-01' } } })
|
||||
assert.strictEqual(navigations.pop(), '/pages/backfill-order/index?serviceDate=2000-01-01')
|
||||
const weekFabPage = createPage({ viewMode: 'week', canCreateAppointment: true, businessHoursConfigured: true, currentDateText: '2026-11-02' })
|
||||
weekFabPage.createAppointment()
|
||||
assert.strictEqual(navigations.pop(), '/pages/appointment-form/index?dateMode=manual')
|
||||
|
||||
const readonlyPage = createPage({ canCreateAppointment: false, businessHoursConfigured: true, selectedArtistId: '88' })
|
||||
readonlyPage.quickCreateAppointment({ currentTarget: { dataset: { date: '2099-12-31' } } })
|
||||
readonlyPage.createAppointment()
|
||||
assert.strictEqual(navigations.length, 0)
|
||||
assert.strictEqual(toasts.pop(), '当前账号仅支持查看预约')
|
||||
|
||||
const fabPage = createPage({ canCreateAppointment: true, businessHoursConfigured: true, currentDateText: '2026-10-12', selectedArtistId: '99' })
|
||||
const fabPage = createPage({ viewMode: 'day', canCreateAppointment: true, businessHoursConfigured: true, currentDateText: '2026-10-12', selectedArtistId: '99' })
|
||||
fabPage.createAppointment()
|
||||
assert.strictEqual(navigations.pop(), '/pages/appointment-form/index?date=2026-10-12&artistId=99')
|
||||
|
||||
const unconfiguredPage = createPage({ canCreateAppointment: true, businessHoursConfigured: false })
|
||||
unconfiguredPage.quickCreateAppointment({ currentTarget: { dataset: { date: '2099-12-31' } } })
|
||||
unconfiguredPage.createAppointment()
|
||||
assert.strictEqual(navigations.length, 0)
|
||||
assert.strictEqual(toasts.pop(), '请先在店铺设置中配置营业时间')
|
||||
unconfiguredPage.openShopSettings()
|
||||
assert.strictEqual(navigations.pop(), '/pages/shop-settings/index')
|
||||
assert.strictEqual(unconfiguredPage._refreshCalendarOnShow, true)
|
||||
|
||||
assert.match(planningWxml, /bindtap="selectMonthDate" aria-label="查看\{\{item\.date\}\}日程"/)
|
||||
assert.match(planningWxml, /bindtap="selectWeekDate" aria-label="查看\{\{item\.date\}\}日程"/)
|
||||
assert.match(planningWxml, /class="fab" bindtap="createAppointment"/)
|
||||
}
|
||||
|
||||
run().catch(error => {
|
||||
|
||||
Reference in New Issue
Block a user