@ecolovo/uniapp-components 2.0.4 → 2.0.6
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/components/badge/badge.vue +22 -11
- package/components/badge/types.d.ts +6 -0
- package/components/badge/types.js +4 -0
- package/components/badge/types.ts +10 -0
- package/components/button/button.vue +77 -48
- package/components/button/types.d.ts +20 -0
- package/components/button/types.js +4 -0
- package/components/button/types.ts +24 -0
- package/components/checkbox/checkbox.scss +1 -1
- package/components/checkbox/checkbox.vue +2 -0
- package/components/checkbox/types.d.ts +10 -0
- package/components/checkbox/types.js +4 -0
- package/components/checkbox/types.ts +16 -0
- package/components/checkbox-group/checkbox-group.vue +2 -0
- package/components/checkbox-group/types.d.ts +10 -0
- package/components/checkbox-group/types.js +8 -0
- package/components/checkbox-group/types.ts +20 -0
- package/components/checkbox-group2/checkbox-group2.vue +2 -0
- package/components/data-list/data-list.vue +13 -7
- package/components/date-picker/date-picker.vue +2 -0
- package/components/date-picker/types.d.ts +12 -0
- package/components/date-picker/types.js +4 -0
- package/components/date-picker/types.ts +18 -0
- package/components/dialog/dialog-content.vue +61 -46
- package/components/dialog/dialog.vue +55 -29
- package/components/dialog/types.d.ts +20 -0
- package/components/dialog/types.js +4 -0
- package/components/dialog/types.ts +24 -0
- package/components/dropdown/dropdown.vue +2 -0
- package/components/dropdown/types.d.ts +10 -0
- package/components/dropdown/types.js +4 -0
- package/components/dropdown/types.ts +16 -0
- package/components/empty/empty.vue +37 -20
- package/components/empty/types.d.ts +12 -0
- package/components/empty/types.js +9 -0
- package/components/empty/types.ts +21 -0
- package/components/flex/flex.vue +2 -0
- package/components/flex/types.d.ts +12 -0
- package/components/flex/types.js +4 -0
- package/components/flex/types.ts +22 -0
- package/components/form/form.vue +2 -0
- package/components/form/types.d.ts +6 -0
- package/components/form/types.js +4 -0
- package/components/form/types.ts +10 -0
- package/components/form-item/form-item.scss +6 -0
- package/components/form-item/form-item.vue +9 -3
- package/components/form-item/types.d.ts +6 -0
- package/components/form-item/types.js +4 -0
- package/components/form-item/types.ts +12 -0
- package/components/image/image.vue +28 -21
- package/components/image/types.d.ts +18 -0
- package/components/image/types.js +4 -0
- package/components/image/types.ts +23 -0
- package/components/index.d.ts +1 -0
- package/components/index.js +1 -0
- package/components/index.ts +1 -0
- package/components/input/input.scss +9 -0
- package/components/input/input.vue +11 -4
- package/components/input/password-input.vue +3 -1
- package/components/input/types.d.ts +20 -0
- package/components/input/types.js +8 -0
- package/components/input/types.ts +31 -0
- package/components/list-page/list-page.vue +21 -24
- package/components/list-page/types.d.ts +6 -0
- package/components/list-page/types.js +4 -0
- package/components/list-page/types.ts +12 -0
- package/components/load-more/load-more.scss +1 -0
- package/components/load-more/load-more.vue +66 -6
- package/components/load-more/types.d.ts +6 -0
- package/components/load-more/types.js +4 -0
- package/components/load-more/types.ts +12 -0
- package/components/loading/loading.vue +2 -0
- package/components/loading/types.d.ts +6 -0
- package/components/loading/types.js +4 -0
- package/components/loading/types.ts +12 -0
- package/components/message-box/message-box.d.ts +14 -16
- package/components/message-box/message-box.ts +0 -2
- package/components/message-box/message-box.vue +18 -43
- package/components/message-box/types.d.ts +16 -0
- package/components/message-box/types.js +4 -0
- package/components/message-box/types.ts +22 -0
- package/components/number-dialog/number-dialog.vue +5 -3
- package/components/number-dialog/types.d.ts +18 -0
- package/components/number-dialog/types.js +4 -0
- package/components/number-dialog/types.ts +24 -0
- package/components/number-input/number-input.scss +1 -1
- package/components/number-input/number-input.vue +6 -4
- package/components/number-input/types.d.ts +20 -0
- package/components/number-input/types.js +4 -0
- package/components/number-input/types.ts +26 -0
- package/components/numpad/numpad.vue +2 -0
- package/components/numpad/types.d.ts +10 -0
- package/components/numpad/types.js +4 -0
- package/components/numpad/types.ts +14 -0
- package/components/page/page-body.scss +1 -1
- package/components/page/page-footer.vue +2 -3
- package/components/page/page-header.vue +19 -9
- package/components/page/page.vue +45 -14
- package/components/page/types.d.ts +16 -0
- package/components/page/types.js +8 -0
- package/components/page/types.ts +27 -0
- package/components/picker/picker-popup.vue +10 -6
- package/components/picker/picker.vue +8 -0
- package/components/picker/types.d.ts +14 -0
- package/components/picker/types.js +4 -0
- package/components/picker/types.ts +18 -0
- package/components/popover/popover-content.vue +10 -1
- package/components/popover/popover-mask.vue +5 -5
- package/components/popover/popover.vue +34 -29
- package/components/popover/types.d.ts +10 -0
- package/components/popover/types.js +4 -0
- package/components/popover/types.ts +16 -0
- package/components/popup/popup-content.vue +61 -43
- package/components/popup/popup.vue +34 -28
- package/components/popup/types.d.ts +20 -0
- package/components/popup/types.js +4 -0
- package/components/popup/types.ts +24 -0
- package/components/price/price.scss +7 -3
- package/components/price/price.vue +6 -0
- package/components/price/types.d.ts +10 -0
- package/components/price/types.js +4 -0
- package/components/price/types.ts +14 -0
- package/components/search/search.vue +4 -2
- package/components/search/types.d.ts +14 -0
- package/components/search/types.js +4 -0
- package/components/search/types.ts +18 -0
- package/components/searching/searching.vue +2 -0
- package/components/searching/types.d.ts +8 -0
- package/components/searching/types.js +4 -0
- package/components/searching/types.ts +14 -0
- package/components/switch/switch.vue +5 -8
- package/components/switch/types.d.ts +8 -0
- package/components/switch/types.js +4 -0
- package/components/switch/types.ts +12 -0
- package/components/tab/tab.vue +2 -0
- package/components/tab/types.d.ts +8 -0
- package/components/tab/types.js +4 -0
- package/components/tab/types.ts +12 -0
- package/components/textarea/textarea.scss +10 -0
- package/components/textarea/textarea.vue +17 -9
- package/components/textarea/types.d.ts +12 -0
- package/components/textarea/types.js +4 -0
- package/components/textarea/types.ts +18 -0
- package/components/upload/composable.d.ts +24 -0
- package/components/upload/composable.js +173 -0
- package/components/upload/composable.ts +228 -0
- package/components/upload/media-upload.scss +12 -0
- package/components/upload/media-upload.vue +250 -0
- package/components/upload/types.d.ts +29 -0
- package/components/upload/types.js +4 -0
- package/components/upload/types.ts +38 -0
- package/composable/component-name.d.ts +8 -0
- package/composable/component-name.js +11 -4
- package/composable/component-name.ts +8 -0
- package/composable/dialog.d.ts +40 -0
- package/composable/dialog.js +96 -0
- package/composable/dialog.ts +113 -0
- package/composable/index.d.ts +5 -0
- package/composable/index.js +5 -0
- package/composable/index.ts +5 -0
- package/composable/message-box.d.ts +45 -28
- package/composable/message-box.js +68 -53
- package/composable/message-box.ts +101 -36
- package/composable/model.d.ts +8 -0
- package/composable/model.js +23 -0
- package/composable/model.ts +27 -0
- package/composable/page.d.ts +72 -0
- package/composable/page.js +25 -0
- package/composable/page.ts +34 -0
- package/configs/index.d.ts +24 -19
- package/configs/index.js +38 -35
- package/configs/index.ts +19 -0
- package/easyCom.d.ts +6 -6
- package/easyCom.js +19 -31
- package/easyCom.ts +4 -4
- package/globals.d.ts +93 -33
- package/globals.js +1 -0
- package/globals.ts +118 -0
- package/index.d.ts +3 -2
- package/index.js +2 -2
- package/index.ts +3 -2
- package/init.d.ts +11 -6
- package/init.js +84 -14
- package/init.ts +86 -1
- package/package.json +15 -12
- package/styles/var/component.scss +1 -0
- package/utils/date.d.ts +14 -19
- package/utils/date.js +77 -87
- package/utils/freezeDeep.js +7 -7
- package/utils/price.d.ts +15 -18
- package/utils/price.js +36 -37
- package/utils/upload.d.ts +1 -0
- package/utils/upload.js +8 -0
- package/utils/upload.ts +12 -0
- package/utils/windowInfo.d.ts +1 -9
- package/utils/windowInfo.js +10 -17
- package/utils/round.d.ts +0 -2
- package/utils/round.js +0 -13
- package/utils/round.ts +0 -14
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
@forward '../../components/empty/empty.scss';
|
|
8
8
|
@forward '../../components/form-item/form-item.scss';
|
|
9
9
|
@forward '../../components/icon/icon.scss';
|
|
10
|
+
@forward '../../components/input/input.scss';
|
|
10
11
|
@forward '../../components/load-more/load-more.scss';
|
|
11
12
|
@forward '../../components/number-dialog/number-dialog.scss';
|
|
12
13
|
@forward '../../components/number-input/number-input.scss';
|
package/utils/date.d.ts
CHANGED
|
@@ -4,22 +4,20 @@ type ValidDateValue = Date | number | string;
|
|
|
4
4
|
* @param dateValue Date 对象、时间戳或时间格式字符串
|
|
5
5
|
* @returns Date 对象
|
|
6
6
|
*/
|
|
7
|
-
export declare function toDate(
|
|
8
|
-
dateValue: ValidDateValue | null | undefined
|
|
9
|
-
): Date | null;
|
|
7
|
+
export declare function toDate(dateValue: ValidDateValue | null | undefined): Date | null;
|
|
10
8
|
type FormatFn = {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
9
|
+
(date: Date | null | undefined, format?: string): string;
|
|
10
|
+
DATE: string;
|
|
11
|
+
DATE_WITH_YEAR: string;
|
|
12
|
+
TIME: string;
|
|
13
|
+
TIME_MS: string;
|
|
14
|
+
TIME_MINUTE: string;
|
|
15
|
+
DATE_TIME: string;
|
|
16
|
+
DATE_TIME_MS: string;
|
|
17
|
+
DATE_TIME_WITH_YEAR: string;
|
|
18
|
+
DATE_TIME_MS_WITH_YEAR: string;
|
|
19
|
+
DATE_MINUTE: string;
|
|
20
|
+
DATE_MINUTE_WITH_YEAR: string;
|
|
23
21
|
};
|
|
24
22
|
/**
|
|
25
23
|
* 格式化日期
|
|
@@ -45,8 +43,5 @@ export declare const formatDate: FormatFn;
|
|
|
45
43
|
* @param day2 时间2
|
|
46
44
|
* @returns 天数差,负数: day1 < day2
|
|
47
45
|
*/
|
|
48
|
-
export declare function daysDiff(
|
|
49
|
-
day1: ValidDateValue,
|
|
50
|
-
day2: ValidDateValue
|
|
51
|
-
): number;
|
|
46
|
+
export declare function daysDiff(day1: ValidDateValue, day2: ValidDateValue): number;
|
|
52
47
|
export {};
|
package/utils/date.js
CHANGED
|
@@ -4,24 +4,21 @@
|
|
|
4
4
|
* @returns Date 对象
|
|
5
5
|
*/
|
|
6
6
|
export function toDate(dateValue) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
throw new Error('dateValue cannot be parsed to Date object');
|
|
23
|
-
}
|
|
24
|
-
return result;
|
|
7
|
+
if (dateValue instanceof Date)
|
|
8
|
+
return new Date(dateValue);
|
|
9
|
+
if (typeof dateValue === 'number')
|
|
10
|
+
return new Date(dateValue);
|
|
11
|
+
if (!dateValue)
|
|
12
|
+
return null;
|
|
13
|
+
if (typeof dateValue !== 'string') {
|
|
14
|
+
throw new Error("dateValue's type is invalid");
|
|
15
|
+
}
|
|
16
|
+
// 兼容 iOS 日期格式
|
|
17
|
+
const result = new Date(dateValue.replace(/-/g, '/'));
|
|
18
|
+
if (isNaN(result.getTime())) {
|
|
19
|
+
throw new Error('dateValue cannot be parsed to Date object');
|
|
20
|
+
}
|
|
21
|
+
return result;
|
|
25
22
|
}
|
|
26
23
|
/**
|
|
27
24
|
* 格式化日期
|
|
@@ -41,61 +38,58 @@ export function toDate(dateValue) {
|
|
|
41
38
|
* @returns 格式化后的日期
|
|
42
39
|
*/
|
|
43
40
|
export const formatDate = (date, format = formatDate.DATE_WITH_YEAR) => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
return format;
|
|
41
|
+
if (!date)
|
|
42
|
+
return '';
|
|
43
|
+
const fullYear = date.getFullYear().toString();
|
|
44
|
+
const year = fullYear.substring(fullYear.length - 2);
|
|
45
|
+
const month = (date.getMonth() + 1).toString();
|
|
46
|
+
const day = date.getDate().toString();
|
|
47
|
+
const hour = date.getHours().toString();
|
|
48
|
+
const min = date.getMinutes().toString();
|
|
49
|
+
const sec = date.getSeconds().toString();
|
|
50
|
+
const ms = date.getMilliseconds().toString();
|
|
51
|
+
const week = date.getDay().toString();
|
|
52
|
+
let weekCN = '';
|
|
53
|
+
switch (week) {
|
|
54
|
+
case '0':
|
|
55
|
+
weekCN = '日';
|
|
56
|
+
break;
|
|
57
|
+
case '1':
|
|
58
|
+
weekCN = '一';
|
|
59
|
+
break;
|
|
60
|
+
case '2':
|
|
61
|
+
weekCN = '二';
|
|
62
|
+
break;
|
|
63
|
+
case '3':
|
|
64
|
+
weekCN = '三';
|
|
65
|
+
break;
|
|
66
|
+
case '4':
|
|
67
|
+
weekCN = '四';
|
|
68
|
+
break;
|
|
69
|
+
case '5':
|
|
70
|
+
weekCN = '五';
|
|
71
|
+
break;
|
|
72
|
+
case '6':
|
|
73
|
+
weekCN = '六';
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
const replacement = [
|
|
77
|
+
{ reg: 'Y{3,4}', val: fullYear, pad: 0 },
|
|
78
|
+
{ reg: 'Y{1,2}', val: year, pad: 0 },
|
|
79
|
+
{ reg: 'M{1,2}', val: month, pad: 2 },
|
|
80
|
+
{ reg: 'D{1,2}', val: day, pad: 2 },
|
|
81
|
+
{ reg: 'H{1,2}', val: hour, pad: 2 },
|
|
82
|
+
{ reg: 'm{1,2}', val: min, pad: 2 },
|
|
83
|
+
{ reg: 's{1,2}', val: sec, pad: 2 },
|
|
84
|
+
{ reg: 'S{1,3}', val: ms, pad: 3 },
|
|
85
|
+
{ reg: 'w', val: week, pad: 0 },
|
|
86
|
+
{ reg: 'W', val: weekCN, pad: 0 },
|
|
87
|
+
];
|
|
88
|
+
for (let i = 0; i < replacement.length; i++) {
|
|
89
|
+
const r = replacement[i];
|
|
90
|
+
format = format.replace(new RegExp(r.reg, 'g'), (m) => r.pad > 0 ? r.val.padStart(Math.min(r.pad, m.length), '0') : r.val);
|
|
91
|
+
}
|
|
92
|
+
return format;
|
|
99
93
|
};
|
|
100
94
|
/** 月日 */
|
|
101
95
|
formatDate.DATE = 'MM-DD';
|
|
@@ -127,16 +121,14 @@ const TIMEZONE_OFFSET = new Date().getTimezoneOffset() * 60 * 1000;
|
|
|
127
121
|
* @returns 毫秒数
|
|
128
122
|
*/
|
|
129
123
|
function toDayTimestamp(date) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
return Date.now() - TIMEZONE_OFFSET;
|
|
124
|
+
if (typeof date === 'number')
|
|
125
|
+
return date - TIMEZONE_OFFSET;
|
|
126
|
+
if (typeof date === 'string') {
|
|
127
|
+
return toDate(date).getTime() - TIMEZONE_OFFSET;
|
|
128
|
+
}
|
|
129
|
+
if (date instanceof Date)
|
|
130
|
+
return date.getTime() - TIMEZONE_OFFSET;
|
|
131
|
+
return Date.now() - TIMEZONE_OFFSET;
|
|
140
132
|
}
|
|
141
133
|
/**
|
|
142
134
|
* 获取两个时间的天数差
|
|
@@ -145,8 +137,6 @@ function toDayTimestamp(date) {
|
|
|
145
137
|
* @returns 天数差,负数: day1 < day2
|
|
146
138
|
*/
|
|
147
139
|
export function daysDiff(day1, day2) {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
Math.floor(toDayTimestamp(day2) / 8.64e7)
|
|
151
|
-
);
|
|
140
|
+
return (Math.floor(toDayTimestamp(day1) / 8.64e7) -
|
|
141
|
+
Math.floor(toDayTimestamp(day2) / 8.64e7));
|
|
152
142
|
}
|
package/utils/freezeDeep.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export function freezeDeep(obj) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
if (!(typeof obj === 'object' && obj)) {
|
|
3
|
+
return obj;
|
|
4
|
+
}
|
|
5
|
+
for (const key in obj) {
|
|
6
|
+
freezeDeep(obj[key]);
|
|
7
|
+
}
|
|
8
|
+
return Object.freeze(obj);
|
|
9
9
|
}
|
package/utils/price.d.ts
CHANGED
|
@@ -1,27 +1,24 @@
|
|
|
1
1
|
interface FormatPriceOption {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
/** 精度,默认为 2 */
|
|
3
|
+
precision: number;
|
|
4
|
+
/** 是否补齐小数部分 0 */
|
|
5
|
+
padDecimal: boolean;
|
|
6
6
|
}
|
|
7
7
|
interface FormatPriceResult {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
/** 格式化的价格字符串 */
|
|
9
|
+
price: string;
|
|
10
|
+
/** 是否负值 */
|
|
11
|
+
negative: boolean;
|
|
12
|
+
/** 整数部分价格 */
|
|
13
|
+
integer: string;
|
|
14
|
+
/** 小数部分价格 */
|
|
15
|
+
decimal: string;
|
|
16
|
+
/** 价格对应数值 */
|
|
17
|
+
number: number;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* 格式化价格
|
|
21
21
|
* @param price 价格
|
|
22
22
|
*/
|
|
23
|
-
export declare function formatPrice(
|
|
24
|
-
price: number | string,
|
|
25
|
-
option?: FormatPriceOption
|
|
26
|
-
): FormatPriceResult;
|
|
23
|
+
export declare function formatPrice(price: number | string, option?: FormatPriceOption): FormatPriceResult;
|
|
27
24
|
export {};
|
package/utils/price.js
CHANGED
|
@@ -3,41 +3,40 @@
|
|
|
3
3
|
* @param price 价格
|
|
4
4
|
*/
|
|
5
5
|
export function formatPrice(price, option) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
};
|
|
6
|
+
if (isNaN(Number(price))) {
|
|
7
|
+
return {
|
|
8
|
+
price: '',
|
|
9
|
+
negative: false,
|
|
10
|
+
integer: '',
|
|
11
|
+
decimal: '',
|
|
12
|
+
number: NaN,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
price = Number(price);
|
|
16
|
+
let negative = false;
|
|
17
|
+
if (price < 0) {
|
|
18
|
+
negative = true;
|
|
19
|
+
price = -price;
|
|
20
|
+
}
|
|
21
|
+
const integer = Math.floor(price).toString();
|
|
22
|
+
const decimalNum = Math.round(Number(price + 'e' + (option?.precision ?? 2))) % 100;
|
|
23
|
+
let decimal;
|
|
24
|
+
if (option?.padDecimal ?? true) {
|
|
25
|
+
decimal =
|
|
26
|
+
'.' + decimalNum.toString().padStart(option?.precision ?? 2, '0');
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
if (decimalNum === 0)
|
|
30
|
+
decimal = '';
|
|
31
|
+
else
|
|
32
|
+
decimal = decimalNum.toString().slice(1);
|
|
33
|
+
}
|
|
34
|
+
const formattedPrice = `${negative ? '-' : ''}${integer}.${decimal}`;
|
|
35
|
+
return {
|
|
36
|
+
price: formattedPrice, // 价格字符串
|
|
37
|
+
negative,
|
|
38
|
+
integer, // 整数部分
|
|
39
|
+
decimal, // 小数部分
|
|
40
|
+
number: Number(formattedPrice),
|
|
41
|
+
};
|
|
43
42
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const toUploadMediaFile: (files: (UniApp.UploadMediaFile | string)[]) => UniApp.UploadMediaFile[];
|
package/utils/upload.js
ADDED
package/utils/upload.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const toUploadMediaFile = (
|
|
2
|
+
files: (UniApp.UploadMediaFile | string)[]
|
|
3
|
+
): UniApp.UploadMediaFile[] => {
|
|
4
|
+
return files.map((file) =>
|
|
5
|
+
typeof file === 'string'
|
|
6
|
+
? { url: file, uploadStatus: 'success' }
|
|
7
|
+
: {
|
|
8
|
+
...file,
|
|
9
|
+
uploadStatus: file.uploadStatus || 'success',
|
|
10
|
+
}
|
|
11
|
+
);
|
|
12
|
+
};
|
package/utils/windowInfo.d.ts
CHANGED
|
@@ -12,12 +12,4 @@ declare let navBarTopOffset: number;
|
|
|
12
12
|
declare let navBarBottomOffset: number;
|
|
13
13
|
/** 底部安全区域高度 */
|
|
14
14
|
declare let safeAreaInsetBottom: number;
|
|
15
|
-
export {
|
|
16
|
-
menuButton,
|
|
17
|
-
menuButtonWidthInCss,
|
|
18
|
-
windowInfo,
|
|
19
|
-
navBarHeight,
|
|
20
|
-
navBarTopOffset,
|
|
21
|
-
navBarBottomOffset,
|
|
22
|
-
safeAreaInsetBottom,
|
|
23
|
-
};
|
|
15
|
+
export { menuButton, menuButtonWidthInCss, windowInfo, navBarHeight, navBarTopOffset, navBarBottomOffset, safeAreaInsetBottom, };
|
package/utils/windowInfo.js
CHANGED
|
@@ -21,25 +21,18 @@ windowInfo = uni.getWindowInfo();
|
|
|
21
21
|
// eslint-disable-next-line no-console
|
|
22
22
|
console.log('windowInfo:', windowInfo);
|
|
23
23
|
if (menuButton) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
24
|
+
if (navBarHeight < menuButton.height) {
|
|
25
|
+
navBarHeight = menuButton.height + 12;
|
|
26
|
+
}
|
|
27
|
+
navBarTopOffset = menuButton.top - (navBarHeight - menuButton.height) / 2;
|
|
28
|
+
menuButtonWidthInCss = 'calc(100vw - ' + menuButton.left + 'px)';
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
navBarTopOffset = windowInfo.safeArea.top || windowInfo.statusBarHeight;
|
|
31
32
|
}
|
|
32
33
|
navBarBottomOffset = navBarTopOffset + navBarHeight;
|
|
33
34
|
const _safeAreaBottom = windowInfo.screenHeight - windowInfo.safeArea.bottom;
|
|
34
35
|
if (_safeAreaBottom) {
|
|
35
|
-
|
|
36
|
+
safeAreaInsetBottom = _safeAreaBottom;
|
|
36
37
|
}
|
|
37
|
-
export {
|
|
38
|
-
menuButton,
|
|
39
|
-
menuButtonWidthInCss,
|
|
40
|
-
windowInfo,
|
|
41
|
-
navBarHeight,
|
|
42
|
-
navBarTopOffset,
|
|
43
|
-
navBarBottomOffset,
|
|
44
|
-
safeAreaInsetBottom,
|
|
45
|
-
};
|
|
38
|
+
export { menuButton, menuButtonWidthInCss, windowInfo, navBarHeight, navBarTopOffset, navBarBottomOffset, safeAreaInsetBottom, };
|
package/utils/round.d.ts
DELETED
package/utils/round.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export function round(val, precision = 0) {
|
|
2
|
-
if (val.toString().indexOf('e') >= 0) {
|
|
3
|
-
const exponential = val.toString().split('e');
|
|
4
|
-
return (
|
|
5
|
-
Math.round(+`${exponential[0]}e${+exponential[1] + precision}`) /
|
|
6
|
-
10 ** precision
|
|
7
|
-
);
|
|
8
|
-
}
|
|
9
|
-
return Math.round(+`${val}e${precision}`) / 10 ** precision;
|
|
10
|
-
}
|
|
11
|
-
export function round2(val) {
|
|
12
|
-
return round(val, 2);
|
|
13
|
-
}
|
package/utils/round.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export function round(val: number, precision = 0): number {
|
|
2
|
-
if (val.toString().indexOf('e') >= 0) {
|
|
3
|
-
const exponential = val.toString().split('e');
|
|
4
|
-
return (
|
|
5
|
-
Math.round(+`${exponential[0]}e${+exponential[1]! + precision}`) /
|
|
6
|
-
10 ** precision
|
|
7
|
-
);
|
|
8
|
-
}
|
|
9
|
-
return Math.round(+`${val}e${precision}`) / 10 ** precision;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function round2(val: number): number {
|
|
13
|
-
return round(val, 2);
|
|
14
|
-
}
|