From c45554946b27564f884186cba894ac7e9dfcebed Mon Sep 17 00:00:00 2001 From: aihe <961836564@qq.com> Date: Thu, 13 Jun 2024 16:10:41 +0800 Subject: [PATCH] uu --- common/custom.scss | 15 +++++++++++++++ common/untool.js | 28 +++++++++++++++++++++++++--- common/validate.js | 2 +- 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/common/custom.scss b/common/custom.scss index c27900f..0678074 100644 --- a/common/custom.scss +++ b/common/custom.scss @@ -64,6 +64,21 @@ -webkit-line-clamp: 1; -webkit-box-orient: vertical; } +.label-text{ + position: relative; + display: inline-block; + margin-right: 20rpx; +} +.label-text-required{ + &::after{ + position: absolute; + font-size: 34rpx; + content: '*'; + color: $uni-color-primary; + right: -16rpx; + top: 8%; + } +} %blcok { margin-top: 30rpx; border-radius: 30rpx; diff --git a/common/untool.js b/common/untool.js index 91274d1..8b97971 100644 --- a/common/untool.js +++ b/common/untool.js @@ -11,6 +11,10 @@ const tabBarUrls = [ ] const goto = (url, type = 1)=> { + if(!url) { + console.error("goto 缺少入参 url=========") + return + } url = `/pages/${url}` if(tabBarUrls.indexOf(url) > -1) { return uni.switchTab({ @@ -50,11 +54,13 @@ const showToast = (val)=> { uni.showToast({ title: val, icon: 'none' }) } -const confirmModal = (title) => { +const confirmModal = (title, opt = {}) => { return new Promise((resolve)=> { - uni.showModal({ content: title, confirmColor: '#B12D29' }).then((res)=> { + uni.showModal({ content: title, confirmColor: '#B12D29', ...opt }).then((res)=> { if(res.confirm) { - resolve() + resolve(true) + } else { + resolve(false) } }) }) @@ -246,6 +252,20 @@ const promiseTimeout = (time) => { }) } +const setNavigationBarTitle = (title)=> { + uni.setNavigationBarTitle({ + title + }) +} + +const reloadCurrentPage = (_thisPage)=> { + let { fullPath } = _thisPage.$page + uni.redirectTo({ + url: fullPath + }); +} + + export { reLaunch, goto, @@ -265,4 +285,6 @@ export { getImageInfo, uniPromiseApi, promiseTimeout, + setNavigationBarTitle, + reloadCurrentPage, } diff --git a/common/validate.js b/common/validate.js index d59cf2d..767f6df 100644 --- a/common/validate.js +++ b/common/validate.js @@ -4,7 +4,7 @@ const checkParams = (param, validConfig)=> { let errMsg = '' Object.keys(validConfig).map(key=> { const itemConf = validConfig[key] - if(!errMsg && itemConf.required && !param[key]) { + if(!errMsg && itemConf.required && (!param[key] || param[key]?.length == 0)) { errMsg = itemConf.requiredMsg || `${itemConf.label}不能为空` } let customerValidMsg = itemConf?.validMsgFun?.({ val: param })