BUG 25647

This commit is contained in:
aixianling
2021-12-23 11:07:33 +08:00
parent eb136723af
commit 0e455c79a4
3 changed files with 156 additions and 108 deletions

View File

@@ -33,7 +33,6 @@ const calcAge = (code) => {
return Math.ceil($moment().year() - $moment(birthday).year())
}
export default {
dict,
confirm,
@@ -52,5 +51,27 @@ export default {
},
hideLoading: () => {
uni.hideLoading()
},
colorUtils: {
Hex2RGBA(color, alpha = 1) {
let hex = 0;
if (color.charAt(0) == "#") {
if (color.length == 4) {
//检测诸如#FFF简写格式
color = "#" + color.charAt(1).repeat(2) +
color.charAt(2).repeat(2) +
color.charAt(3).repeat(2);
}
hex = parseInt(color.slice(1), 16);
}
let r = hex >> 16 & 0xFF;
let g = hex >> 8 & 0xFF;
let b = hex & 0xFF;
return `rgba(${r},${g},${b},${alpha})`;
},
RGBtoHex(r, g, b) {
let hex = r << 16 | g << 8 | b;
return "#" + hex.toString(16);
}
}
}