This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
Component({
|
||||
data: {
|
||||
visible: false,
|
||||
title: '',
|
||||
content: '',
|
||||
icon: '',
|
||||
cancelText: '',
|
||||
confirmText: '确定',
|
||||
confirmType: 'primary',
|
||||
layout: 'column',
|
||||
editable: false,
|
||||
placeholderText: '',
|
||||
inputValue: ''
|
||||
},
|
||||
|
||||
methods: {
|
||||
open(options = {}) {
|
||||
this._onClose = typeof options.onClose === 'function' ? options.onClose : null
|
||||
this.setData({
|
||||
visible: true,
|
||||
title: options.title || '',
|
||||
content: options.content || '',
|
||||
icon: options.icon || '',
|
||||
cancelText: options.cancelText || '',
|
||||
confirmText: options.confirmText || '确定',
|
||||
confirmType: options.confirmType || 'primary',
|
||||
layout: options.layout || (options.cancelText ? 'row' : 'column'),
|
||||
editable: options.editable === true,
|
||||
placeholderText: options.placeholderText || '',
|
||||
inputValue: ''
|
||||
})
|
||||
},
|
||||
|
||||
close(result) {
|
||||
this.setData({ visible: false })
|
||||
const onClose = this._onClose
|
||||
this._onClose = null
|
||||
if (onClose) onClose(result)
|
||||
},
|
||||
|
||||
onInput(event) {
|
||||
this.setData({ inputValue: event.detail.value })
|
||||
},
|
||||
|
||||
onConfirm() {
|
||||
this.close({ confirm: true, cancel: false, content: this.data.inputValue })
|
||||
},
|
||||
|
||||
onCancel() {
|
||||
this.close({ confirm: false, cancel: true, content: this.data.inputValue })
|
||||
},
|
||||
|
||||
stopEvent() {
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user