Files
JayuCloud/JC-Salon-WeChat/components/action-modal/index.js
T

57 lines
1.4 KiB
JavaScript
Raw Normal View History

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() {
}
}
})