From dfecc5efaa6fa81dbcf307f1e1b6759f3084e0d0 Mon Sep 17 00:00:00 2001 From: YOS-DRVOGPU6U78\Administrator <chenky0613@qq.com> Date: 星期一, 17 七月 2023 12:20:40 +0800 Subject: [PATCH] 增加utils工具 --- utils/common.js | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 52 insertions(+), 4 deletions(-) diff --git a/utils/common.js b/utils/common.js index f447160..00d4137 100644 --- a/utils/common.js +++ b/utils/common.js @@ -1,6 +1,54 @@ +/** +* 鏄剧ず娑堟伅鎻愮ず妗� +* @param content 鎻愮ず鐨勬爣棰� +*/ export function toast(content) { - uni.showToast({ - icon:'none', - title:content - }) + uni.showToast({ + icon: 'none', + title: content + }) +} + +/** +* 鏄剧ず妯℃�佸脊绐� +* @param content 鎻愮ず鐨勬爣棰� +*/ +export function showConfirm(content) { + return new Promise((resolve, reject) => { + uni.showModal({ + title: '鎻愮ず', + content: content, + cancelText: '鍙栨秷', + confirmText: '纭畾', + success: function(res) { + resolve(res) + } + }) + }) +} + +/** +* 鍙傛暟澶勭悊 +* @param params 鍙傛暟 +*/ +export function tansParams(params) { + let result = '' + for (const propName of Object.keys(params)) { + const value = params[propName] + var part = encodeURIComponent(propName) + "=" + if (value !== null && value !== "" && typeof (value) !== "undefined") { + if (typeof value === 'object') { + for (const key of Object.keys(value)) { + if (value[key] !== null && value[key] !== "" && typeof (value[key]) !== 'undefined') { + let params = propName + '[' + key + ']' + var subPart = encodeURIComponent(params) + "=" + result += subPart + encodeURIComponent(value[key]) + "&" + } + } + } else { + result += part + encodeURIComponent(value) + "&" + } + } + } + return result } \ No newline at end of file -- Gitblit v1.9.3