diff --git a/pages/seller/index.js b/pages/seller/index.js index f4ed25e..f581ad8 100644 --- a/pages/seller/index.js +++ b/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() {