营销:商城装修增加控件【APP 链接选择】

(cherry picked from commit 23a6bf5ef5)
This commit is contained in:
owen
2023-12-01 00:39:10 +08:00
committed by shizhong
parent 99a1587113
commit a8f9fa152a
14 changed files with 526 additions and 13 deletions

View File

@ -1,3 +1,5 @@
import { toNumber } from 'lodash-es'
/**
*
* @param component 需要注册的组件
@ -264,6 +266,26 @@ export const calculateRelativeRate = (value?: number, reference?: number) => {
return ((100 * ((value || 0) - reference)) / reference).toFixed(0)
}
/**
* 获取链接的参数值
* @param key 参数键名
* @param urlStr 链接地址,默认为当前浏览器的地址
*/
export const getUrlValue = (key: string, urlStr: string = location.href): string => {
if (!urlStr || !key) return ''
const url = new URL(decodeURIComponent(urlStr))
return url.searchParams.get(key) ?? ''
}
/**
* 获取链接的参数值(值类型)
* @param key 参数键名
* @param urlStr 链接地址,默认为当前浏览器的地址
*/
export const getUrlNumberValue = (key: string, urlStr: string = location.href): number => {
return toNumber(getUrlValue(key, urlStr))
}
export const treeFormatter = (ary: any, val: string, valueField = 'value', nameField = 'label') => {
let o = ''
if (ary != null) {