From fb026e6052b4d843d327312db398cf791ac57ab9 Mon Sep 17 00:00:00 2001
From: cyy <cuiqian2004@163.com>
Date: 星期日, 28 九月 2025 22:43:29 +0800
Subject: [PATCH] test
---
comm/utils.js | 82 ++++++++++++++++++++++++++++++++++++----
1 files changed, 73 insertions(+), 9 deletions(-)
diff --git a/comm/utils.js b/comm/utils.js
index 9e3ec1a..8e8692a 100644
--- a/comm/utils.js
+++ b/comm/utils.js
@@ -1,11 +1,12 @@
-
var SESSION_SUFFIX = "diniu_app_"
-export function showModal(message, title = '鎻愮ず', iscancel = true) {
+export function showModal(message, title = '鎻愮ず', iscancel = true, confirmText = "鏄�, cancelText = "鍚�) {
return new Promise((resolve) => {
uni.showModal({
title: title,
content: message,
showCancel: iscancel,
+ confirmText,
+ cancelText,
success: function(res) {
if (res.confirm) {
resolve(true)
@@ -17,20 +18,83 @@
})
}
-export function showToast(title, icon) {
- uni.showToast({
- title: title,
- icon: icon ? icon : 'none'
- })
+export function showToast(ex) {
+ if (!ex)
+ return
+ let tip = ex
+ // console.log(ex);
+ if (typeof ex !== "string") {
+ let exStr = JSON.stringify(ex)
+ if (exStr == "{}")
+ exStr = ex
+ tip = typeof ex.errMsg == "string" ? ex.errMsg : typeof ex.msg == "string" ? ex.msg : typeof ex.message ==
+ "string" ? ex.message : exStr
+ }
+ plus.nativeUI.toast(tip, {
+ duration: "short",
+ verticalAlign: "center"
+ });
+ // uni.showToast({
+ // title: title,
+ // icon: icon ? icon : 'none'
+ // })
+}
+export function showInfo(ex) {
+ if (!ex)
+ return
+ let tip = ex
+ // console.log(ex);
+ if (typeof ex !== "string") {
+ let exStr = JSON.stringify(ex)
+ if (exStr == "{}")
+ exStr = ex
+ tip = typeof ex.errMsg == "string" ? ex.errMsg : typeof ex.msg == "string" ? ex.msg : typeof ex.message ==
+ "string" ? ex.message : exStr
+ }
+ // plus.nativeUI.toast(tip, {
+ // duration: "short",
+ // verticalAlign:"center"
+ // });
+ return uni.showModal({
+ title: "鎻愮ず",
+ content: tip,
+ showCancel: false
+ });
+}
+
+export function showError(ex, title = "閿欒") {
+ if (!ex)
+ return
+ let tip = ex
+ if (typeof ex !== "string") {
+ let exStr = JSON.stringify(ex)
+ if (exStr == "{}")
+ exStr = ex
+ tip = typeof ex.errMsg == "string" ? ex.errMsg : typeof ex.msg == "string" ? ex.msg : typeof ex.message ==
+ "string" ? ex.message : exStr
+ }
+ console.log(ex,tip)
+ //plus.nativeUI.alert(tip,title);
+ return uni.showModal({
+ title: title || "",
+ content: tip,
+ showCancel: false
+ });
}
export function showLoading(title) {
-
-
uni.showLoading({
title: title,
mask: true
})
+}
+
+export function hexToRGBA(hex, alpha) {
+ const r = parseInt(hex.slice(1, 3), 16);
+ const g = parseInt(hex.slice(3, 5), 16);
+ const b = parseInt(hex.slice(5, 7), 16);
+
+ return `rgba(${r}, ${g}, ${b}, ${alpha})`;
}
export function hideLoading() {
--
Gitblit v1.9.1