Browse Source

为创建新货源功能的下拉框添加双击选择功能

pull/1/head
徐飞洋 3 months ago
parent
commit
86ab589429
  1. 38
      pages/seller/index.js

38
pages/seller/index.js

@ -2903,6 +2903,29 @@ Page({
});
},
// 双击检测变量
lastTapTime: {},
tapCount: {},
// 通用双击检测函数
handleDoubleTap: function(e, type, callback) {
const currentTime = Date.now();
const tapKey = `${type}-${e.currentTarget.dataset.index}`;
const lastTap = this.lastTapTime[tapKey] || 0;
const tapInterval = currentTime - lastTap;
if (tapInterval < 300 && tapInterval > 0) {
// 双击事件触发,执行确认选择
callback();
} else {
// 单击事件触发,执行选择操作
this.lastTapTime[tapKey] = currentTime;
setTimeout(() => {
delete this.lastTapTime[tapKey];
}, 300);
}
},
// 弹窗中选择规格
onModalSpecSelect: function (e) {
const index = e.currentTarget.dataset.index;
@ -2911,6 +2934,11 @@ Page({
selectedModalSpecIndex: index,
modalSpecSearchKeyword: selectedSpec // 自动填充搜索框为当前选择的规格
});
// 检测双击
this.handleDoubleTap(e, 'spec', () => {
this.confirmSpecSelection();
});
},
// 确认规格选择
@ -3401,6 +3429,11 @@ Page({
this.setData({
selectedNameIndex: index
});
// 检测双击
this.handleDoubleTap(e, 'name', () => {
this.confirmNameSelection();
});
},
confirmNameSelection() {
@ -3477,6 +3510,11 @@ Page({
this.setData({
selectedYolkIndex: index
});
// 检测双击
this.handleDoubleTap(e, 'yolk', () => {
this.confirmYolkSelection();
});
},
confirmYolkSelection() {

Loading…
Cancel
Save