diff --git a/dist/cell/index.js b/dist/cell/index.js index cb0e0f84..9a168522 100644 --- a/dist/cell/index.js +++ b/dist/cell/index.js @@ -48,29 +48,24 @@ Component({ isLastCell: true }, methods: { - navigateTo() { - const { url = '' } = this.data; - const type = typeof this.data.isLink; + footerTap() { + // 如果并没有设置只点击 footer 生效,那就不需要额外处理。cell 上有事件会自动处理 + if (!this.data.onlyTapFooter) { + return; + } this.triggerEvent('tap', {}); - - if (!this.data.isLink || !url || url === 'true' || url === 'false') return; - - if (type !== 'boolean' && type !== 'string') { - warn('isLink 属性值必须是一个字符串或布尔值', this.data.isLink); - return; - } - - if (['navigateTo', 'redirectTo', 'switchTab', 'reLaunch'].indexOf(this.data.linkType) === -1) { - warn('linkType 属性可选值为 navigateTo,redirectTo,switchTab,reLaunch', this.data.linkType); - return; - } - wx[this.data.linkType].call(wx, { url }); + doNavigate.call(this); }, + cellTap() { - if (!this.data.onlyTapFooter) { - this.navigateTo(); + // 如果只点击 footer 生效,那就不需要在 cell 根节点上处理 + if (this.data.onlyTapFooter) { + return; } + + this.triggerEvent('tap', {}); + doNavigate.call(this); }, // 用于被 cell-group 更新,标志是否是最后一个 cell @@ -79,3 +74,22 @@ Component({ } } }); + +// 处理跳转 +function doNavigate() { + const { url = '' } = this.data; + const type = typeof this.data.isLink; + + if (!this.data.isLink || !url || url === 'true' || url === 'false') return; + + if (type !== 'boolean' && type !== 'string') { + warn('isLink 属性值必须是一个字符串或布尔值', this.data.isLink); + return; + } + + if (['navigateTo', 'redirectTo', 'switchTab', 'reLaunch'].indexOf(this.data.linkType) === -1) { + warn('linkType 属性可选值为 navigateTo,redirectTo,switchTab,reLaunch', this.data.linkType); + return; + } + wx[this.data.linkType].call(wx, { url }); +} diff --git a/dist/cell/index.wxml b/dist/cell/index.wxml index a3ccd2a7..6c3f620d 100644 --- a/dist/cell/index.wxml +++ b/dist/cell/index.wxml @@ -1,5 +1,5 @@ @@ -12,7 +12,7 @@ - + {{ value }} diff --git a/dist/dialog/index.wxml b/dist/dialog/index.wxml index 019d17c5..8eba385b 100644 --- a/dist/dialog/index.wxml +++ b/dist/dialog/index.wxml @@ -23,6 +23,7 @@ class="zan-dialog__button" custom-class="{{ index === 0 ? 'zan-dialog__button-inside--first' : 'zan-dialog__button-inside' }}" data-type="{{ item.type }}" + open-type="{{ item.openType }}" bind:btnclick="handleButtonClick" >