增加部分样式,公共方法,增加保存员工登录保存商户号

This commit is contained in:
YeMingfei666 2024-10-16 14:14:30 +08:00
parent e0f0d90bae
commit a5c0ab54cc
4 changed files with 40 additions and 7 deletions

View File

@ -392,4 +392,8 @@ text {
// }
.line-th{
text-decoration: line-through;
}
//覆盖u-view-plus 颜色
.u-primary-light {
color: $my-main-color;
}

View File

@ -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))

View File

@ -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
}

View File

@ -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