diff --git a/pages/index/index.js b/pages/index/index.js index 01d1437..2f6443c 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -28,6 +28,7 @@ Page({ planTotal: 7, planProgress: 0, showPicker: false, + pickerInputFocus: false, presets: [30, 60, 90, 120, 180, 300], customDuration: 60, customInput: '', @@ -170,7 +171,12 @@ Page({ onSelectPreset(e) { const val = e.currentTarget.dataset.value - this.setData({ customDuration: val, customInput: '' }) + // 收起键盘(失焦 input),避免清空 customInput 时触发 adjust-position 让页面向上跳 + this.setData({ pickerInputFocus: false, customDuration: val, customInput: '' }) + }, + + onPickerInputFocus() { + this.setData({ pickerInputFocus: true }) }, onCustomInput(e) { diff --git a/pages/index/index.wxml b/pages/index/index.wxml index 67771a5..5ea2220 100644 --- a/pages/index/index.wxml +++ b/pages/index/index.wxml @@ -118,7 +118,9 @@ type="number" placeholder="输入秒数" value="{{customInput}}" + focus="{{pickerInputFocus}}" bindinput="onCustomInput" + bindfocus="onPickerInputFocus" />