37 lines
1.2 KiB
JavaScript
37 lines
1.2 KiB
JavaScript
function showActionModal(page, options = {}) {
|
|
const modal = page && typeof page.selectComponent === 'function' ? page.selectComponent('#actionModal') : null
|
|
if (modal && typeof modal.open === 'function') {
|
|
return new Promise(resolve => {
|
|
modal.open({
|
|
title: options.title,
|
|
content: options.content,
|
|
icon: options.icon,
|
|
cancelText: options.cancelText,
|
|
confirmText: options.confirmText,
|
|
confirmType: options.confirmType,
|
|
layout: options.layout,
|
|
editable: options.editable,
|
|
placeholderText: options.placeholderText,
|
|
inputValue: options.inputValue,
|
|
inputType: options.inputType,
|
|
onClose: resolve
|
|
})
|
|
})
|
|
}
|
|
return new Promise(resolve => {
|
|
wx.showModal({
|
|
title: options.title,
|
|
content: options.content || '',
|
|
cancelText: options.cancelText,
|
|
confirmText: options.confirmText,
|
|
showCancel: !!options.cancelText,
|
|
editable: options.editable === true,
|
|
placeholderText: options.placeholderText,
|
|
success: resolve,
|
|
fail: () => resolve({ confirm: false, cancel: true, content: '' })
|
|
})
|
|
})
|
|
}
|
|
|
|
module.exports = { showActionModal }
|