更新访客预约提交页面
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user