diff --git a/commons/style/common.scss b/commons/style/common.scss index 1c5f255..5afbff7 100644 --- a/commons/style/common.scss +++ b/commons/style/common.scss @@ -392,4 +392,8 @@ text { // } .line-th{ text-decoration: line-through; +} +//覆盖u-view-plus 颜色 +.u-primary-light { + color: $my-main-color; } \ No newline at end of file diff --git a/commons/utils/format.js b/commons/utils/format.js index f8f915f..f3d5d0a 100644 --- a/commons/utils/format.js +++ b/commons/utils/format.js @@ -7,9 +7,10 @@ * @param {Boolean} returnIsArea - 是否返回值符合范围区间,默认为false。 * @returns {number} - 返回格式化后的价格,如果超出范围则返回最小值或最大值。 */ -export const formatPrice = (price,min=-Infinity, max = 100000000,returnIsArea=false ) => { +export const formatPrice = (price,min=-Infinity, max = 100000000,returnIsArea=false,isRerturnNullString=false) => { + if(price === undefined || price === null||price===''){ - return 0 + return isRerturnNullString?'':0 } // 将价格转换为浮点数并保留两位小数 const newval = parseFloat((Math.floor(price * 100) / 100).toFixed(2)) diff --git a/commons/utils/safe-bottom.js b/commons/utils/safe-bottom.js new file mode 100644 index 0000000..c8ed07d --- /dev/null +++ b/commons/utils/safe-bottom.js @@ -0,0 +1,26 @@ +import { + getCurrentInstance, +} from 'vue'; +export function getElRect(elClass, dataVal) { + const instance = getCurrentInstance(); + return new Promise((resolve, reject) => { + const query = uni.createSelectorQuery().in(instance.proxy); + query.select('.' + elClass).fields({ + size: true + }, res => { + // 如果节点尚未生成,res值为null,循环调用执行 + if (!res) { + setTimeout(() => { + getElRect(elClass); + }, 10); + return; + } + resolve(res); + }).exec(); + }) +} + +export async function getSafeBottomHeight(className, height = 16) { + const bottomEle = await getElRect(className) + return bottomEle.height + height +} \ No newline at end of file diff --git a/commons/utils/storageManage.js b/commons/utils/storageManage.js index bade3e4..690d214 100644 --- a/commons/utils/storageManage.js +++ b/commons/utils/storageManage.js @@ -18,24 +18,26 @@ const appCache = { const model = { setLogin(res){ + const user=res.user.user uni.setStorageSync('logoutHandle',false) uni.setStorageSync('shopId', res.shopId) uni.setStorageSync('shopName',res.shopName) uni.setStorageSync('logo',res.logo) uni.setStorageSync('loginType',res.loginType) - uni.setStorageSync('shopUserId',res.user.user.id) + uni.setStorageSync('shopUserId',user.id) + if(res.loginType=='staff'){ + uni.setStorageSync('merchantName',user.createBy||user.updateBy) + } }, // 退出清空所有的缓存数据。 (不包含 环境相关) cleanByLogout: () => { - // 1. 清空app级别缓存。 Object.keys(appCache).forEach(k => appCache[k] = null) - + const merchantName=uni.getStorageSync('merchantName') let envName = model.env() // 获取到当前的环境变量 uni.clearStorageSync() // 清除所有的缓存信息 + uni.setStorageSync('merchantName',merchantName) model.env(envName) // 重置env - - }, // 获取和放置token