更新访客预约提交页面

This commit is contained in:
chenglijuan
2026-04-28 18:13:22 +08:00
parent 1ba5ea1084
commit 1ae4ba166a
+31 -8
View File
@@ -29,17 +29,40 @@ Page({
}, },
onLoad() { onLoad() {
if (!app.globalData.isLoggedIn) { if (app.globalData.isLoggedIn) {
wx.showToast({ title: '请先登录', icon: 'none' }) this.initPage()
setTimeout(() => { } else if (app.globalData.loginFailed) {
wx.navigateBack() this.showLoginTipAndGoBack()
}, 1500) } else {
return // 登录异步未完成,等待回调
app.loginReadyCallback = (userInfo) => {
app.loginReadyCallback = null
if (userInfo) {
this.initPage()
} else {
this.showLoginTipAndGoBack()
}
}
} }
},
initPage() {
// 使用本地时区获取当天日期,用于 picker 最小日期限制
const today = formatDate(new Date()) const today = formatDate(new Date())
this.setData({ today }) 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) { onNameInput(e) {
this.setData({ 'form.name': e.detail.value }) this.setData({ 'form.name': e.detail.value })
}, },
@@ -98,7 +121,7 @@ Page({
onPersonChange(e) { onPersonChange(e) {
const index = Number(e.detail.value) const index = Number(e.detail.value)
const person = this.data.persons[index] const person = this.data.persons[index]
if (person) { if (person && person.personId) {
this.setData({ this.setData({
personIndex: index, personIndex: index,
'form.hostId': person.personId, 'form.hostId': person.personId,
@@ -121,7 +144,7 @@ Page({
wx.showToast({ title: '请输入访客姓名', icon: 'none' }) wx.showToast({ title: '请输入访客姓名', icon: 'none' })
return false return false
} }
if (!phone.trim() || phone.length !== 11) { if (!phone.trim() || !/^1\d{10}$/.test(phone)) {
wx.showToast({ title: '请输入正确的手机号', icon: 'none' }) wx.showToast({ title: '请输入正确的手机号', icon: 'none' })
return false return false
} }