From 1ae4ba166ad621699c325aed0aca4b18dda54604 Mon Sep 17 00:00:00 2001 From: chenglijuan Date: Tue, 28 Apr 2026 18:13:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=AE=BF=E5=AE=A2=E9=A2=84?= =?UTF-8?q?=E7=BA=A6=E6=8F=90=E4=BA=A4=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/appointment/appointment.js | 39 +++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/pages/appointment/appointment.js b/pages/appointment/appointment.js index 6827d0f..8f2bba2 100644 --- a/pages/appointment/appointment.js +++ b/pages/appointment/appointment.js @@ -29,17 +29,40 @@ Page({ }, onLoad() { - if (!app.globalData.isLoggedIn) { - wx.showToast({ title: '请先登录', icon: 'none' }) - setTimeout(() => { - wx.navigateBack() - }, 1500) - return + if (app.globalData.isLoggedIn) { + this.initPage() + } else if (app.globalData.loginFailed) { + this.showLoginTipAndGoBack() + } else { + // 登录异步未完成,等待回调 + app.loginReadyCallback = (userInfo) => { + app.loginReadyCallback = null + if (userInfo) { + this.initPage() + } else { + this.showLoginTipAndGoBack() + } + } } + }, + + initPage() { + // 使用本地时区获取当天日期,用于 picker 最小日期限制 const today = formatDate(new Date()) this.setData({ today }) }, + showLoginTipAndGoBack() { + wx.showToast({ title: '请先登录', icon: 'none', complete: () => { + const pages = getCurrentPages() + if (pages.length > 1) { + wx.navigateBack() + } else { + wx.redirectTo({ url: '/pages/index/index' }) + } + }}) + }, + onNameInput(e) { this.setData({ 'form.name': e.detail.value }) }, @@ -98,7 +121,7 @@ Page({ onPersonChange(e) { const index = Number(e.detail.value) const person = this.data.persons[index] - if (person) { + if (person && person.personId) { this.setData({ personIndex: index, 'form.hostId': person.personId, @@ -121,7 +144,7 @@ Page({ wx.showToast({ title: '请输入访客姓名', icon: 'none' }) return false } - if (!phone.trim() || phone.length !== 11) { + if (!phone.trim() || !/^1\d{10}$/.test(phone)) { wx.showToast({ title: '请输入正确的手机号', icon: 'none' }) return false }