修复:收口小程序键盘遮挡适配
This commit is contained in:
@@ -5,6 +5,14 @@ const navigation = require('../../utils/navigation')
|
||||
const { DEFAULT_AVATAR } = require('../../utils/config')
|
||||
const { getDraftValue, clearDraft, scheduleDraftSave, clearDraftTimer } = require('../../utils/form-draft')
|
||||
const { runWithLoading } = require('../../utils/loading')
|
||||
const {
|
||||
createKeyboardSafeData,
|
||||
attachKeyboardSafe,
|
||||
detachKeyboardSafe,
|
||||
handleKeyboardFocus,
|
||||
handleKeyboardBlur,
|
||||
resetKeyboardSafe
|
||||
} = require('../../utils/keyboard-safe')
|
||||
|
||||
const phoneRegex = /^1[3-9]\d{9}$/
|
||||
const passwordRegex = /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d@$!%*#?&]{8,}$/
|
||||
@@ -41,7 +49,9 @@ const placeholderEntries = [
|
||||
]
|
||||
|
||||
Page({
|
||||
data: {
|
||||
data: Object.assign(createKeyboardSafeData({
|
||||
cursorSpacing: 108
|
||||
}), {
|
||||
isLoggedIn: false,
|
||||
loading: false,
|
||||
savingProfile: false,
|
||||
@@ -72,22 +82,46 @@ Page({
|
||||
password: '',
|
||||
confirmPassword: ''
|
||||
}
|
||||
}),
|
||||
|
||||
onLoad() {
|
||||
this.ensureKeyboardSafe()
|
||||
},
|
||||
|
||||
onShow() {
|
||||
this.ensureKeyboardSafe()
|
||||
this.loadSettings()
|
||||
},
|
||||
|
||||
onHide() {
|
||||
resetKeyboardSafe(this)
|
||||
detachKeyboardSafe(this)
|
||||
this.clearCountdown()
|
||||
clearDraftTimer(this)
|
||||
},
|
||||
|
||||
onUnload() {
|
||||
resetKeyboardSafe(this)
|
||||
detachKeyboardSafe(this)
|
||||
this.clearCountdown()
|
||||
clearDraftTimer(this)
|
||||
},
|
||||
|
||||
ensureKeyboardSafe() {
|
||||
attachKeyboardSafe(this, {
|
||||
cursorSpacing: 108,
|
||||
spacerExtraRpx: 48
|
||||
})
|
||||
},
|
||||
|
||||
handleKeyboardFocus(event) {
|
||||
handleKeyboardFocus(this, event)
|
||||
},
|
||||
|
||||
handleKeyboardBlur() {
|
||||
handleKeyboardBlur(this)
|
||||
},
|
||||
|
||||
clearCountdown() {
|
||||
if (this.countdownTimer) {
|
||||
clearInterval(this.countdownTimer)
|
||||
@@ -252,6 +286,7 @@ Page({
|
||||
handleToggleSecurityPanel(event) {
|
||||
const panel = event.currentTarget.dataset.panel
|
||||
const nextPanel = this.data.activeSecurityPanel === panel ? '' : panel
|
||||
resetKeyboardSafe(this)
|
||||
this.clearCountdown()
|
||||
this.resetSecurityForms()
|
||||
this.setData({
|
||||
@@ -262,6 +297,7 @@ Page({
|
||||
},
|
||||
|
||||
handleCloseSecurityPanel() {
|
||||
resetKeyboardSafe(this)
|
||||
this.resetSecurityForms()
|
||||
this.clearCountdown()
|
||||
this.setData({
|
||||
|
||||
Reference in New Issue
Block a user