Files
JayuCloud/JC-Salon-WeChat/components/action-modal/index.js
T
xiaowang 69ea01eaa4
自动发布开发环境 Nacos 配置 / publish (push) Successful in 34s
环境分支晋级检查 / environment-promotion-source (pull_request_target) Successful in 11s
小程序预约详情支持图片预览、编辑预约与完成收款拆分
2026-11-09 15:18:27 +08:00

59 lines
1.5 KiB
JavaScript

Component({
data: {
visible: false,
title: '',
content: '',
icon: '',
cancelText: '',
confirmText: '确定',
confirmType: 'primary',
layout: 'column',
editable: false,
placeholderText: '',
inputValue: '',
inputType: 'text'
},
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: options.inputValue === undefined || options.inputValue === null ? '' : String(options.inputValue),
inputType: options.inputType || 'text'
})
},
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() {
}
}
})