✨ feat(颜色取样): 新增颜色取样模块

This commit is contained in:
xuan
2022-10-31 19:06:14 +08:00
parent e0de46c469
commit 2811f7eb60
15 changed files with 438 additions and 249 deletions
+2 -2
View File
@@ -107,7 +107,7 @@ export const alert = {
icon: 'error',
})
},
loading(title: string, mask: true | false = false) {
loading(title: string, mask: boolean = false) {
Taro.showToast({
title,
icon: 'loading',
@@ -152,4 +152,4 @@ export const formatKbPrice = (number: string) => {
export const checkKey = (key = "") => {
let getUser = JSON.parse(Taro.getStorageSync("userInfo"));
return getUser.mp_role_access_list?.includes(key);
};
};
+34
View File
@@ -159,6 +159,40 @@ export const toDecimal2 = x => {
return f
}
// 匹配前缀 例如://xxx.com 或者 http://xxx.com 或者 https://xxx.com
// eslint-disable-next-line no-useless-escape
const URL_REGEXP = /(https?:)?\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()!@:%_\+.~#?&=]*)/gi
/**
* 判断是否有前缀
* @param {string} url url路径
*/
export const withBaseUrl = function(url) {
return URL_REGEXP.test(url)
}
/**
* 去除前缀 //xxx.com 或者 http://xxx.com 或者 https://xxx.com
* @param {string} url url路径
*/
export const breakupUrl = url => {
return url?.replace(URL_REGEXP, '') ?? url
}
/**
* 拼接前缀 http://xxx.com + /asdfsafdas/154531asdf465413.png
* @param {string} url url路径
*/
export const jointUrl = url => {
return withBaseUrl(url) ? url : `${IMG_CND_Prefix}${url}`
}
export const formatUrl = (url, suffix = '!w200') => {
if (url) {
url = url.includes(',') ? url.split(',')[0] : url
return withBaseUrl(url) ? url + suffix : jointUrl(url) + suffix
} else {
return IMG_CND_Prefix + '/mall/no_img.png'
}
}
/**
* 格式化图片路径
* @param {*} url