UNPKG

upro.ui

Version:

upro.ui,是送气宝系列的共用工具套

94 lines (81 loc) 1.41 kB
const message = (title = '', options = {}) => { const { icon = 'none', duration = 1200, success, fail, complete, callback } = options const mask = options.mask ? options.mask : typeof callback != 'undefined' const onSuccess = (e) => { success && success(e) if (callback) { setTimeout(() => { callback(e) }, duration) } } uni.showToast({ icon, title, duration, mask, fail, complete, success: onSuccess }) } const success = (title, options) => { message(title, { icon: 'success', ...options }) } const error = (title, options) => { message(title, { icon: 'error', ...options }) } // 微信小程序不支持,暂时不实现 // const fail = (title, options) => { // message(title, { // icon: 'fail', // ...options // }) // } // const exception = (title, options) => { // message(title, { // icon: 'exception', // ...options // }) // } const hideLoading = () => { uni.hideLoading() } const loading = (title = '', options = {}) => { uni.showLoading({ title, ...options }) } const showModal = (content = '', options = {}) => { const { showCancel = false } = options uni.showModal({ title: '提示', content, showCancel, ...options }) } export default { message, success, // fail, error, // exception, loading, hideLoading, showModal }