zhl-methods 1.1.14 → 1.1.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/js/index.js CHANGED
@@ -30,7 +30,7 @@ export const isIDCode = (value) => {
30
30
  /**
31
31
  * 对象转url参数
32
32
  * @example toUrlQuery({a:1}) => '?a=1'
33
- * @param {value} 要转换的对象
33
+ * @param {Object} 要转换的对象
34
34
  * @returns {String} '?a=1'
35
35
  */
36
36
  export const toUrlQuery = (query) => {
@@ -44,6 +44,29 @@ export const toUrlQuery = (query) => {
44
44
  console.log(error, "toUrlQuery");
45
45
  }
46
46
  };
47
+ /**
48
+ * url参数转对象
49
+ * @example urlQueryToObject('?a=1') => {a:1}
50
+ * @param {String} 要转换的url参数
51
+ * @returns {Object} {a:1}
52
+ */
53
+ export const urlQueryToObject = (str) => {
54
+ try {
55
+ if (str) {
56
+ const params = new URLSearchParams(str);
57
+ let obj = {};
58
+ params.forEach((item, index) => {
59
+ obj[index] = item;
60
+ });
61
+ return obj;
62
+ } else {
63
+ return {};
64
+ }
65
+ } catch (error) {
66
+ console.log(error);
67
+ return {};
68
+ }
69
+ };
47
70
  /**
48
71
  * 将传入的数据转换成千位符
49
72
  * @example numberToPrice(1234.12) => '1,234.12'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zhl-methods",
3
- "version": "1.1.14",
3
+ "version": "1.1.15",
4
4
  "license": "ISC",
5
5
  "dependencies": {
6
6
  "dayjs": "^1.11.15",
package/index copy.js DELETED
@@ -1,58 +0,0 @@
1
- import jsMethods, {
2
- isPhone,
3
- isIDCode,
4
- toUrlQuery,
5
- numberToPrice,
6
- priceToNumber,
7
- setTwoDecimal,
8
- getRandomNumber,
9
- isType,
10
- toTypeDate,
11
- toInt,
12
- copyText,
13
- downloadFile,
14
- debounce,
15
- throttle,
16
- } from "./js";
17
- import ScanUDI from "./js/ScanUDI";
18
- import { useEmitter, useRequest, usePageRequest } from "./vue3";
19
- import wxMethods, {
20
- getNavBarHeight,
21
- confirmModal,
22
- getEnv,
23
- getAppId,
24
- getSafeBottom,
25
- } from "./wx";
26
- const copyText = (val) => {
27
- if (window) {
28
- return jsMethods.copyText(val);
29
- }
30
- if (uni || wx) {
31
- return wxMethods.copyText(val);
32
- }
33
- };
34
- export {
35
- isPhone,
36
- isIDCode,
37
- toUrlQuery,
38
- numberToPrice,
39
- priceToNumber,
40
- setTwoDecimal,
41
- getRandomNumber,
42
- isType,
43
- toTypeDate,
44
- toInt,
45
- downloadFile,
46
- debounce,
47
- throttle,
48
- ScanUDI,
49
- copyText,
50
- useEmitter,
51
- useRequest,
52
- usePageRequest,
53
- getNavBarHeight,
54
- confirmModal,
55
- getEnv,
56
- getAppId,
57
- getSafeBottom,
58
- };