From 1bd1061c60c286e3b2216a67090c4976c9c7b35f Mon Sep 17 00:00:00 2001
From: yyb <995253665@qq.com>
Date: 星期六, 18 四月 2026 17:50:29 +0800
Subject: [PATCH] 出入库扫码
---
src/plugins/modal.ts | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 112 insertions(+), 0 deletions(-)
diff --git a/src/plugins/modal.ts b/src/plugins/modal.ts
new file mode 100644
index 0000000..46d622c
--- /dev/null
+++ b/src/plugins/modal.ts
@@ -0,0 +1,112 @@
+export default {
+ /**
+ * 娑堟伅鎻愮ず
+ * @param content 娑堟伅鍐呭
+ */
+ msg(content: string): void {
+ uni.showToast({
+ title: content,
+ icon: 'none'
+ })
+ },
+ /**
+ * 閿欒娑堟伅
+ * @param content 娑堟伅鍐呭
+ */
+ msgError(content: string): void {
+ const text = (content ?? '').toString()
+ // showToast 鍦ㄥ绔粡甯镐細瀵� title 鍋氬崟琛�/闀垮害鎴柇锛涢暱鏂囨鐢� showModal 淇濊瘉瀹屾暣灞曠ず
+ const shouldUseModal = text.length > 16 || text.includes('\n')
+ if (shouldUseModal) {
+ uni.showModal({
+ title: '閿欒',
+ content: text,
+ showCancel: false,
+ confirmText: '鐭ラ亾浜�',
+ })
+ return
+ }
+ uni.showToast({
+ title: text,
+ icon: 'none',
+ duration: 2500,
+ })
+ },
+ /**
+ * 鎴愬姛娑堟伅
+ * @param content 娑堟伅鍐呭
+ */
+ msgSuccess(content: string): void {
+ uni.showToast({
+ title: content,
+ icon: 'success'
+ })
+ },
+ /**
+ * 闅愯棌娑堟伅
+ */
+ hideMsg(): void {
+ uni.hideToast()
+ },
+ /**
+ * 寮瑰嚭鎻愮ず
+ * @param content 鎻愮ず鍐呭
+ */
+ alert(content: string): void {
+ uni.showModal({
+ title: '鎻愮ず',
+ content: content,
+ showCancel: false
+ })
+ },
+ /**
+ * 纭绐椾綋
+ * @param content 鎻愮ず鍐呭
+ * @returns
+ */
+ confirm(content: string): Promise<unknown> {
+ return new Promise((resolve: Function, reject: Function) => {
+ uni.showModal({
+ title: '绯荤粺鎻愮ず',
+ content: content,
+ cancelText: '鍙栨秷',
+ confirmText: '纭畾',
+ success: function (res) {
+ if (res.confirm) {
+ resolve(res.confirm)
+ }
+ }
+ })
+ })
+ },
+ /**
+ * 鎻愮ず淇℃伅
+ * @param option 鎻愮ず鍐呭鎴栬�呮彁绀烘閰嶇疆
+ */
+ showToast(option: string | object): void {
+ if (typeof option === "object") {
+ uni.showToast(option)
+ } else {
+ uni.showToast({
+ title: option,
+ icon: "none",
+ duration: 2500
+ })
+ }
+ },
+ /**
+ * 鎵撳紑閬僵灞傦紝闇�瑕佹墜鍔ㄥ叧闂伄缃╁眰
+ * @param content 閬僵灞傚唴瀹�
+ */
+ loading(content: string): void {
+ uni.showLoading({
+ title: content
+ })
+ },
+ /**
+ * 鍏抽棴閬僵灞�
+ */
+ closeLoading(): void {
+ uni.hideLoading()
+ }
+}
--
Gitblit v1.9.3