From f6d9ef93208cabcb120260d98c7b9036dda8446b Mon Sep 17 00:00:00 2001 From: inter Date: Tue, 16 Sep 2025 10:38:30 +0800 Subject: [PATCH] Add File --- plugins/modal.js | 78 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 plugins/modal.js diff --git a/plugins/modal.js b/plugins/modal.js new file mode 100644 index 0000000..eb0825b --- /dev/null +++ b/plugins/modal.js @@ -0,0 +1,78 @@ +export default { + // 消息提示 + msg(content) { + uni.showToast({ + title: content, + icon: 'none' + }) + }, + // 错误消息 + msgError(content) { + uni.showToast({ + title: content, + icon: 'error' + }) + }, + // 成功消息 + msgSuccess(content) { + uni.showToast({ + title: content, + icon: 'success' + }) + }, + // 隐藏消息 + hideMsg(content) { + uni.hideToast() + }, + // 弹出提示 + alert(content, title) { + uni.showModal({ + title: title || '系统提示', + content: content, + showCancel: false + }) + }, + // 确认窗体 + confirm(content, title) { + return new Promise((resolve, reject) => { + uni.showModal({ + title: title || '系统提示', + content: content, + cancelText: '取消', + confirmText: '确定', + success: function(res) { + if (res.confirm) { + resolve(res.confirm) + } + } + }) + }) + }, + // 提示信息 + showToast(option) { + if (typeof option === "object") { + uni.showToast(option) + } else { + uni.showToast({ + title: option, + icon: "none", + duration: 2500 + }) + } + }, + // 打开遮罩层 + loading(content) { + uni.showLoading({ + title: content, + icon: 'none' + }) + }, + // 关闭遮罩层 + closeLoading() { + try { + uni.hideLoading() + } catch (e) { + console.log(e) + } + } +}