This commit is contained in:
2026-09-15 17:22:35 +08:00
parent 469a361a2b
commit 35b814279e
2 changed files with 17 additions and 4 deletions
+10 -2
View File
@@ -65,8 +65,16 @@ Component({
onBtn(e: WechatMiniprogram.TouchEvent) {
const index = Number((e.currentTarget.dataset as any).index) || 0
const btn = (this.data.buttons[index] || {}) as any
logger.debug(LOG, 'modal 按钮点击, index=', index, 'value=', btn.value)
this.triggerEvent('confirm', { index, value: btn.value || '' })
const value = btn.value || ''
// 按语义分流:主按钮抛 confirm,其余(取消 / 稍后再说 / 再想想…)抛 cancel。
// 否则「取消」也会落进页面的确认分支,取消后没有出口(曾出现停在空页)
if (btn.type === 'main') {
logger.debug(LOG, 'modal 主按钮点击, index=', index, 'value=', value)
this.triggerEvent('confirm', { index, value })
return
}
logger.debug(LOG, 'modal 取消按钮点击, index=', index, 'value=', value)
this.triggerEvent('cancel', { index, value })
},
onItem(e: WechatMiniprogram.TouchEvent) {