Files
JayuCloud/JC-Salon-WeChat/components/action-modal/index.js
T
xiaowang 1482bda1fa
自动发布开发环境 Nacos 配置 / publish (push) Successful in 27s
小程序浮层动作项按钮化并统一按钮样式
2026-11-07 00:38:22 +08:00

57 lines
1.4 KiB
JavaScript

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