修复:收口小程序键盘遮挡适配
This commit is contained in:
@@ -5,11 +5,21 @@ const authStore = require('../../utils/auth')
|
||||
const actionGuard = require('../../utils/action-guard')
|
||||
const navigation = require('../../utils/navigation')
|
||||
const { runWithLoading } = require('../../utils/loading')
|
||||
const {
|
||||
createKeyboardSafeData,
|
||||
attachKeyboardSafe,
|
||||
detachKeyboardSafe,
|
||||
handleKeyboardFocus,
|
||||
handleKeyboardBlur,
|
||||
resetKeyboardSafe
|
||||
} = require('../../utils/keyboard-safe')
|
||||
|
||||
const phoneRegex = /^1[3-9]\d{9}$/
|
||||
|
||||
Page({
|
||||
data: {
|
||||
data: Object.assign(createKeyboardSafeData({
|
||||
cursorSpacing: 108
|
||||
}), {
|
||||
redirect: '',
|
||||
activeTab: 'login',
|
||||
loginType: 'password',
|
||||
@@ -59,9 +69,10 @@ Page({
|
||||
verificationCode: '',
|
||||
newPassword: ''
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
onLoad(options) {
|
||||
this.ensureKeyboardSafe()
|
||||
this.setData({
|
||||
redirect: options && options.redirect ? options.redirect : '',
|
||||
authHelperText: this.buildAuthHelperText('login', 'password')
|
||||
@@ -73,11 +84,37 @@ Page({
|
||||
},
|
||||
|
||||
onShow() {
|
||||
this.ensureKeyboardSafe()
|
||||
this.consumePendingWechatMiniLogin()
|
||||
},
|
||||
|
||||
onHide() {
|
||||
resetKeyboardSafe(this)
|
||||
detachKeyboardSafe(this)
|
||||
},
|
||||
|
||||
onUnload() {
|
||||
resetKeyboardSafe(this)
|
||||
detachKeyboardSafe(this)
|
||||
},
|
||||
|
||||
noop() {},
|
||||
|
||||
ensureKeyboardSafe() {
|
||||
attachKeyboardSafe(this, {
|
||||
cursorSpacing: 108,
|
||||
spacerExtraRpx: 56
|
||||
})
|
||||
},
|
||||
|
||||
handleKeyboardFocus(event) {
|
||||
handleKeyboardFocus(this, event)
|
||||
},
|
||||
|
||||
handleKeyboardBlur() {
|
||||
handleKeyboardBlur(this)
|
||||
},
|
||||
|
||||
detectWechatMiniCapability() {
|
||||
let supported = false
|
||||
let disabledReason = ''
|
||||
@@ -158,6 +195,7 @@ Page({
|
||||
|
||||
handleTabChange(event) {
|
||||
const tab = event.currentTarget.dataset.tab
|
||||
resetKeyboardSafe(this)
|
||||
this.setData({
|
||||
activeTab: tab,
|
||||
authHelperText: this.buildAuthHelperText(tab, this.data.loginType),
|
||||
@@ -174,6 +212,7 @@ Page({
|
||||
|
||||
handleLoginTypeChange(event) {
|
||||
const type = event.currentTarget.dataset.type
|
||||
resetKeyboardSafe(this)
|
||||
this.setData({
|
||||
loginType: type,
|
||||
authHelperText: this.buildAuthHelperText(this.data.activeTab, type),
|
||||
@@ -189,6 +228,7 @@ Page({
|
||||
},
|
||||
|
||||
handleShowTraditionalLogin() {
|
||||
resetKeyboardSafe(this)
|
||||
this.setData({
|
||||
traditionalLoginExpanded: true,
|
||||
showResetPanel: false
|
||||
@@ -196,6 +236,7 @@ Page({
|
||||
},
|
||||
|
||||
handleToggleResetPanel() {
|
||||
resetKeyboardSafe(this)
|
||||
this.setData({
|
||||
showResetPanel: !this.data.showResetPanel
|
||||
})
|
||||
@@ -299,6 +340,7 @@ Page({
|
||||
},
|
||||
|
||||
async handleAccountBlur() {
|
||||
this.handleKeyboardBlur()
|
||||
const account = this.data.form.account.trim()
|
||||
if (!account) {
|
||||
return
|
||||
@@ -320,6 +362,7 @@ Page({
|
||||
},
|
||||
|
||||
async handlePhoneBlur() {
|
||||
this.handleKeyboardBlur()
|
||||
const phone = this.data.form.phone.trim()
|
||||
if (!phone) {
|
||||
return
|
||||
@@ -849,6 +892,7 @@ Page({
|
||||
},
|
||||
|
||||
openMiniShopSelector(result) {
|
||||
resetKeyboardSafe(this)
|
||||
const shops = Array.isArray(result && result.shops) ? result.shops : []
|
||||
if (!shops.length) {
|
||||
wx.showToast({
|
||||
@@ -887,6 +931,7 @@ Page({
|
||||
},
|
||||
|
||||
async finishLogin(payload, successMessage) {
|
||||
resetKeyboardSafe(this)
|
||||
getApp().setUserSession(payload)
|
||||
this.clearMiniShopSelector()
|
||||
this.setData({
|
||||
|
||||
Reference in New Issue
Block a user