@ecolovo/uniapp-components 1.0.10 → 2.0.1
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/README.md +202 -66
- package/components/aspect/aspect.vue +24 -15
- package/components/badge/badge.scss +20 -0
- package/components/badge/badge.vue +49 -40
- package/components/button/button.scss +15 -0
- package/components/button/button.vue +121 -177
- package/components/checkbox/checkbox.scss +10 -0
- package/components/checkbox/checkbox.vue +118 -146
- package/components/checkbox-group/checkbox-group.vue +79 -85
- package/components/checkbox-group2/checkbox-group2.vue +111 -107
- package/components/checkbox-group2/checkbox2.vue +104 -0
- package/components/data-list/data-list.scss +9 -0
- package/components/data-list/data-list.vue +70 -79
- package/components/date-picker/date-picker-view.vue +125 -124
- package/components/date-picker/date-picker.vue +145 -146
- package/components/dialog/dialog-content.vue +39 -47
- package/components/dialog/dialog.scss +11 -0
- package/components/dialog/dialog.vue +125 -138
- package/components/dropdown/dropdown.scss +11 -0
- package/components/dropdown/dropdown.vue +55 -97
- package/components/empty/empty.scss +14 -0
- package/components/empty/empty.vue +42 -41
- package/components/flex/flex.vue +45 -54
- package/components/form/form.vue +29 -24
- package/components/form-item/form-item.scss +11 -0
- package/components/form-item/form-item.vue +43 -40
- package/components/icon/icon.vue +70 -85
- package/components/image/image.vue +35 -38
- package/components/input/input.vue +65 -79
- package/components/input/password-input.vue +34 -42
- package/components/list-page/list-page.vue +73 -99
- package/components/load-more/load-more.scss +12 -0
- package/components/load-more/load-more.vue +29 -29
- package/components/loading/animations/loading-animation1.vue +8 -8
- package/components/loading/animations/loading-animation2.vue +8 -9
- package/components/loading/animations/loading-animation3.vue +11 -11
- package/components/loading/animations/loading-animation4.vue +8 -8
- package/components/loading/loading.vue +19 -20
- package/components/message-box/message-box.vue +59 -41
- package/components/number-dialog/number-dialog.scss +9 -0
- package/components/number-dialog/number-dialog.vue +209 -204
- package/components/number-input/number-input.scss +9 -0
- package/components/number-input/number-input.vue +233 -232
- package/components/numpad/numpad.scss +9 -0
- package/components/numpad/numpad.vue +133 -150
- package/components/page/page-body.scss +15 -0
- package/components/page/page-body.vue +137 -119
- package/components/page/page-footer.scss +13 -0
- package/components/page/page-footer.vue +31 -33
- package/components/page/page-header.scss +17 -0
- package/components/page/page-header.vue +89 -94
- package/components/page/page.scss +9 -0
- package/components/page/page.vue +105 -81
- package/components/picker/picker-popup.vue +218 -209
- package/components/picker/picker.vue +99 -104
- package/components/popover/popover-content.vue +54 -63
- package/components/popover/popover-mask.vue +63 -63
- package/components/popover/popover.scss +28 -0
- package/components/popover/popover.vue +49 -47
- package/components/popup/popup-content.vue +49 -53
- package/components/popup/popup.scss +11 -0
- package/components/popup/popup.vue +117 -132
- package/components/price/price.scss +20 -0
- package/components/price/price.vue +31 -42
- package/components/search/search.scss +12 -0
- package/components/search/search.vue +93 -117
- package/components/searching/searching.vue +33 -40
- package/components/selector/selector.vue +43 -48
- package/components/switch/switch.scss +12 -0
- package/components/switch/switch.vue +99 -96
- package/components/tab/tab.scss +19 -0
- package/components/tab/tab.vue +151 -145
- package/components/textarea/textarea.vue +104 -101
- package/composable/component-name.d.ts +2 -0
- package/composable/component-name.js +8 -0
- package/composable/component-name.ts +10 -0
- package/configs/index.d.ts +25 -10
- package/configs/index.js +14 -23
- package/configs/index.ts +82 -0
- package/easyCom.d.ts +9 -0
- package/easyCom.js +1 -2
- package/easyCom.ts +31 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/index.ts +1 -0
- package/init.d.ts +4 -7
- package/init.js +5 -4
- package/init.ts +34 -0
- package/package.json +14 -4
- package/styles/utils/css-var.scss +12 -15
- package/styles/utils/ellipsis.scss +0 -7
- package/styles/utils/z-index.scss +1 -1
- package/styles/var/component.scss +21 -245
- package/utils/date.d.ts +47 -0
- package/utils/date.js +23 -43
- package/utils/date.ts +153 -0
- package/utils/freezeDeep.d.ts +1 -0
- package/utils/freezeDeep.js +4 -14
- package/utils/freezeDeep.ts +9 -0
- package/utils/price.d.ts +24 -0
- package/utils/price.js +14 -8
- package/utils/price.ts +57 -0
- package/utils/round.d.ts +2 -0
- package/utils/round.js +2 -14
- package/utils/round.ts +11 -0
- package/utils/windowInfo.d.ts +24 -0
- package/utils/windowInfo.js +8 -36
- package/utils/windowInfo.ts +50 -0
- package/components/checkbox-group2/checkbox.vue +0 -109
- package/components/datetime-picker/datetime-picker-view.vue +0 -209
- package/components/datetime-picker/datetime-picker.vue +0 -235
- package/components/form/mixin.js +0 -13
- package/components/list-page/list-page.js +0 -10
- package/components/table/table.vue +0 -112
- package/components/time-picker/time-picker-view.vue +0 -127
- package/components/time-picker/time-picker.vue +0 -140
- package/components/uploader/download.js +0 -81
- package/components/uploader/file-uploader.vue +0 -52
- package/components/uploader/files.js +0 -225
- package/components/uploader/media-uploader.vue +0 -189
- package/components/uploader/mixin.js +0 -171
- package/components/uploader/uni.js +0 -38
- package/components/uploader/upload-button.vue +0 -29
- package/components/uploader/uploader copy.vue +0 -547
- package/components/uploader/uploader.vue +0 -117
- package/mixins/componentName.js +0 -32
- package/mixins/listPage.js +0 -1
- package/mixins/windowInfo.js +0 -1
- package/utils/fileSize.js +0 -39
- package/utils/floor.js +0 -20
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<view :class="
|
|
2
|
+
<view :class="[...classNames, $style['Input']]" @click="setFocus">
|
|
3
3
|
<view
|
|
4
|
-
v-if="isReadonly || (useText &&
|
|
4
|
+
v-if="isReadonly || (useText && modelValue && !focused)"
|
|
5
5
|
:class="[$style['Input--text'], { [$style['Input--ellipsis']]: ellipsis }]"
|
|
6
6
|
>
|
|
7
|
-
{{
|
|
7
|
+
{{ modelValue }}
|
|
8
8
|
</view>
|
|
9
9
|
<input
|
|
10
10
|
v-else
|
|
11
|
-
:value="
|
|
11
|
+
:value="modelValue"
|
|
12
12
|
:type="type"
|
|
13
13
|
:disabled="disabled"
|
|
14
14
|
:maxlength="maxlength"
|
|
@@ -17,100 +17,86 @@
|
|
|
17
17
|
always-embed
|
|
18
18
|
:class="$style['Input--input']"
|
|
19
19
|
:placeholder-class="$style['Input--input-placeholder']"
|
|
20
|
-
@input="$emit('
|
|
20
|
+
@input="$emit('update:modelValue', $event.detail.value)"
|
|
21
21
|
@confirm="focused = false"
|
|
22
22
|
@blur="focused = false"
|
|
23
23
|
/>
|
|
24
24
|
<icon-cpn
|
|
25
|
-
v-if="!isReadonly && clearable &&
|
|
25
|
+
v-if="!isReadonly && clearable && modelValue"
|
|
26
26
|
icon="close-circle-filled"
|
|
27
27
|
:class="$style['Input--icon']"
|
|
28
28
|
tap-size="80rpx"
|
|
29
|
-
@click="$emit('
|
|
29
|
+
@click="$emit('update:modelValue', '')"
|
|
30
30
|
>
|
|
31
31
|
</icon-cpn>
|
|
32
32
|
</view>
|
|
33
33
|
</template>
|
|
34
34
|
|
|
35
|
-
<script>
|
|
36
|
-
import
|
|
37
|
-
import
|
|
35
|
+
<script lang="ts" setup>
|
|
36
|
+
import { computed, inject, ref } from 'vue';
|
|
37
|
+
import useClassNames from '../../composable/component-name';
|
|
38
38
|
import IconCpn from '../icon/icon.vue';
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
name: 'Input',
|
|
40
|
+
defineOptions({
|
|
42
41
|
options: {
|
|
43
42
|
virtualHost: true,
|
|
44
43
|
styleIsolation: 'shared',
|
|
45
44
|
},
|
|
46
|
-
|
|
47
|
-
mixins: [componentName, isFormReadonly],
|
|
48
|
-
props: {
|
|
49
|
-
/** 绑定值 */
|
|
50
|
-
value: {
|
|
51
|
-
type: String,
|
|
52
|
-
default: '',
|
|
53
|
-
},
|
|
54
|
-
/** 键盘类型 */
|
|
55
|
-
type: {
|
|
56
|
-
type: String,
|
|
57
|
-
default: 'text',
|
|
58
|
-
},
|
|
59
|
-
/** 是否添加清空图标 */
|
|
60
|
-
clearable: {
|
|
61
|
-
type: Boolean,
|
|
62
|
-
default: false,
|
|
63
|
-
},
|
|
64
|
-
/** 是否禁用 */
|
|
65
|
-
disabled: {
|
|
66
|
-
type: Boolean,
|
|
67
|
-
default: false,
|
|
68
|
-
},
|
|
69
|
-
/** 是否只读 */
|
|
70
|
-
readonly: {
|
|
71
|
-
type: Boolean,
|
|
72
|
-
default: false,
|
|
73
|
-
},
|
|
74
|
-
/** 文本超长时是否省略 */
|
|
75
|
-
ellipsis: {
|
|
76
|
-
type: Boolean,
|
|
77
|
-
default: false,
|
|
78
|
-
},
|
|
79
|
-
/** 最大输入长度 */
|
|
80
|
-
maxlength: {
|
|
81
|
-
type: Number,
|
|
82
|
-
default: 140,
|
|
83
|
-
},
|
|
84
|
-
/** 占位文本 */
|
|
85
|
-
placeholder: {
|
|
86
|
-
type: String,
|
|
87
|
-
default: '请输入',
|
|
88
|
-
},
|
|
89
|
-
/** 当不聚焦时是否使用文本替换 input */
|
|
90
|
-
useText: {
|
|
91
|
-
type: Boolean,
|
|
92
|
-
default: false,
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
data() {
|
|
96
|
-
return {
|
|
97
|
-
/** 是否聚焦 */
|
|
98
|
-
focused: false,
|
|
99
|
-
};
|
|
100
|
-
},
|
|
101
|
-
computed: {
|
|
102
|
-
isReadonly() {
|
|
103
|
-
return this.readonly || this.isFormReadonly;
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
methods: {
|
|
107
|
-
/** 设置焦点 */
|
|
108
|
-
setFocus() {
|
|
109
|
-
if (this.disabled || this.isReadonly) return;
|
|
45
|
+
});
|
|
110
46
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
47
|
+
const classNames = useClassNames('input');
|
|
48
|
+
|
|
49
|
+
type _Props = {
|
|
50
|
+
/** 绑定值 */
|
|
51
|
+
modelValue?: string;
|
|
52
|
+
/** 键盘类型 */
|
|
53
|
+
type?: 'text' | 'number' | 'idcard' | 'digit' | 'tel' | 'safe-password' | 'nickname';
|
|
54
|
+
/** 是否添加清空图标 */
|
|
55
|
+
clearable?: boolean;
|
|
56
|
+
/** 是否禁用 */
|
|
57
|
+
disabled?: boolean;
|
|
58
|
+
/** 是否只读 */
|
|
59
|
+
readonly?: boolean;
|
|
60
|
+
/** 文本超长时是否省略 */
|
|
61
|
+
ellipsis?: boolean;
|
|
62
|
+
/** 最大输入长度 */
|
|
63
|
+
maxlength?: number;
|
|
64
|
+
/** 占位文本 */
|
|
65
|
+
placeholder?: string;
|
|
66
|
+
/** 当不聚焦时是否使用文本替换 input */
|
|
67
|
+
useText?: boolean;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const props = withDefaults(defineProps<_Props>(), {
|
|
71
|
+
modelValue: '',
|
|
72
|
+
type: 'text',
|
|
73
|
+
clearable: false,
|
|
74
|
+
disabled: false,
|
|
75
|
+
readonly: false,
|
|
76
|
+
ellipsis: false,
|
|
77
|
+
maxlength: 140,
|
|
78
|
+
placeholder: '请输入',
|
|
79
|
+
useText: false,
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
defineEmits<{
|
|
83
|
+
(e: 'update:modelValue', val: string): void;
|
|
84
|
+
}>();
|
|
85
|
+
|
|
86
|
+
/** 是否聚焦 */
|
|
87
|
+
const focused = ref(false);
|
|
88
|
+
|
|
89
|
+
const isFormReadonly = inject(
|
|
90
|
+
'ecolovo/form/readonly',
|
|
91
|
+
computed(() => false)
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
const isReadonly = computed(() => props.readonly || isFormReadonly.value);
|
|
95
|
+
|
|
96
|
+
/** 设置焦点 */
|
|
97
|
+
const setFocus = () => {
|
|
98
|
+
if (props.disabled || isReadonly.value) return;
|
|
99
|
+
focused.value = true;
|
|
114
100
|
};
|
|
115
101
|
</script>
|
|
116
102
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<view :class="
|
|
2
|
+
<view :class="[...classNames, $style['PasswordInput']]">
|
|
3
3
|
<input
|
|
4
|
-
:value="
|
|
4
|
+
:value="modelValue"
|
|
5
5
|
:disabled="disabled"
|
|
6
6
|
:maxlength="maxlength"
|
|
7
7
|
:password="!isShowPassword"
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
always-embed
|
|
10
10
|
:class="$style['PasswordInput--input']"
|
|
11
11
|
:placeholder-class="$style['PasswordInput--input-placeholder']"
|
|
12
|
-
@input="$emit('
|
|
12
|
+
@input="$emit('update:modelValue', $event.detail.value)"
|
|
13
13
|
/>
|
|
14
14
|
<icon-cpn
|
|
15
15
|
:icon="isShowPassword ? 'password-show' : 'password-hide'"
|
|
@@ -20,52 +20,44 @@
|
|
|
20
20
|
</view>
|
|
21
21
|
</template>
|
|
22
22
|
|
|
23
|
-
<script>
|
|
24
|
-
import
|
|
23
|
+
<script lang="ts" setup>
|
|
24
|
+
import { ref } from 'vue';
|
|
25
|
+
import useClassNames from '../../composable/component-name';
|
|
25
26
|
import IconCpn from '../icon/icon.vue';
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
name: 'PasswordInput',
|
|
28
|
+
defineOptions({
|
|
29
29
|
options: {
|
|
30
30
|
virtualHost: true,
|
|
31
31
|
styleIsolation: 'shared',
|
|
32
32
|
},
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
/** 最大输入长度 */
|
|
47
|
-
maxlength: {
|
|
48
|
-
type: Number,
|
|
49
|
-
default: 140,
|
|
50
|
-
},
|
|
51
|
-
/** 占位文本 */
|
|
52
|
-
placeholder: {
|
|
53
|
-
type: String,
|
|
54
|
-
default: '请输入密码',
|
|
55
|
-
},
|
|
56
|
-
/** 是否只读 */
|
|
57
|
-
readonly: {
|
|
58
|
-
type: Boolean,
|
|
59
|
-
default: false,
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
data() {
|
|
63
|
-
return {
|
|
64
|
-
/** 是否显示明文 */
|
|
65
|
-
isShowPassword: false,
|
|
66
|
-
};
|
|
67
|
-
},
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const classNames = useClassNames('password-input');
|
|
36
|
+
|
|
37
|
+
type _Props = {
|
|
38
|
+
/** 绑定值 */
|
|
39
|
+
modelValue?: string;
|
|
40
|
+
/** 是否禁用 */
|
|
41
|
+
disabled?: boolean;
|
|
42
|
+
/** 最大输入长度 */
|
|
43
|
+
maxlength?: number;
|
|
44
|
+
/** 占位文本 */
|
|
45
|
+
placeholder?: string;
|
|
68
46
|
};
|
|
47
|
+
|
|
48
|
+
withDefaults(defineProps<_Props>(), {
|
|
49
|
+
modelValue: '',
|
|
50
|
+
disabled: false,
|
|
51
|
+
maxlength: 140,
|
|
52
|
+
placeholder: '请输入密码',
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
defineEmits<{
|
|
56
|
+
(e: 'update:modelValue', val: string): void;
|
|
57
|
+
}>();
|
|
58
|
+
|
|
59
|
+
/** 是否显示明文 */
|
|
60
|
+
const isShowPassword = ref(false);
|
|
69
61
|
</script>
|
|
70
62
|
|
|
71
63
|
<style lang="scss" module>
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
enable-refresh
|
|
9
9
|
:refreshing="isRefreshing"
|
|
10
10
|
:loading="loading"
|
|
11
|
-
:class="
|
|
11
|
+
:class="classNames"
|
|
12
12
|
@refresh="onRefresh"
|
|
13
13
|
@reach-bottom="onLoadMore"
|
|
14
14
|
>
|
|
@@ -29,114 +29,88 @@
|
|
|
29
29
|
</page-cpn>
|
|
30
30
|
</template>
|
|
31
31
|
|
|
32
|
-
<script>
|
|
33
|
-
import
|
|
32
|
+
<script lang="ts" setup>
|
|
33
|
+
import { ref } from 'vue';
|
|
34
|
+
import { PagingData } from '@ecolovo/utils/uniapp/paging';
|
|
35
|
+
import useClassNames from '../../composable/component-name';
|
|
34
36
|
import DataListCpn from '../data-list/data-list.vue';
|
|
35
37
|
import EmptyCpn from '../empty/empty.vue';
|
|
36
38
|
import PageCpn from '../page/page.vue';
|
|
37
39
|
|
|
38
|
-
|
|
39
|
-
name: 'ListPage',
|
|
40
|
+
defineOptions({
|
|
40
41
|
options: {
|
|
41
42
|
virtualHost: true,
|
|
42
43
|
styleIsolation: 'shared',
|
|
43
44
|
},
|
|
44
|
-
|
|
45
|
-
mixins: [componentName],
|
|
46
|
-
props: {
|
|
47
|
-
/** 是否使用自定义导航栏 */
|
|
48
|
-
custom: {
|
|
49
|
-
type: Boolean,
|
|
50
|
-
default: true,
|
|
51
|
-
},
|
|
52
|
-
/** 页面标题 */
|
|
53
|
-
title: {
|
|
54
|
-
type: String,
|
|
55
|
-
default: '',
|
|
56
|
-
},
|
|
57
|
-
/** 页面头部样式,主要用于控制导航栏字体颜色 */
|
|
58
|
-
theme: {
|
|
59
|
-
type: String,
|
|
60
|
-
default: 'light',
|
|
61
|
-
},
|
|
62
|
-
/** 是否使用底部操作栏 */
|
|
63
|
-
hasFooter: {
|
|
64
|
-
type: Boolean,
|
|
65
|
-
default: false,
|
|
66
|
-
},
|
|
67
|
-
/** 是否使用scroll-view */
|
|
68
|
-
useScroll: {
|
|
69
|
-
type: Boolean,
|
|
70
|
-
default: true,
|
|
71
|
-
},
|
|
72
|
-
/** 分页大小 */
|
|
73
|
-
pagingData: {
|
|
74
|
-
type: Object,
|
|
75
|
-
default: null,
|
|
76
|
-
},
|
|
77
|
-
// /** 分页大小 */
|
|
78
|
-
// pageSize: {
|
|
79
|
-
// type: [Number, String],
|
|
80
|
-
// default: 0,
|
|
81
|
-
// },
|
|
82
|
-
/** 是否显示加载更多 */
|
|
83
|
-
showLoadMore: {
|
|
84
|
-
type: Boolean,
|
|
85
|
-
default: true,
|
|
86
|
-
},
|
|
87
|
-
/** 页面加载 */
|
|
88
|
-
loading: {
|
|
89
|
-
type: [Boolean, String],
|
|
90
|
-
default: false,
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
data() {
|
|
94
|
-
return {
|
|
95
|
-
/** 是否正在刷新中 */
|
|
96
|
-
isRefreshing: false,
|
|
97
|
-
/** 是否正在加载更多中 */
|
|
98
|
-
isLoadingMore: false,
|
|
99
|
-
/** scroll-view 的当前滚动距离 */
|
|
100
|
-
scrollOffset: 0,
|
|
101
|
-
/** 传递给 scroll-view ,用于控制其滚动距离 */
|
|
102
|
-
scrollTop: 0,
|
|
103
|
-
/** 传递给 scroll-view ,用于控制其是否有滚动动画 */
|
|
104
|
-
scrollWithAnimation: true,
|
|
105
|
-
};
|
|
106
|
-
},
|
|
107
|
-
methods: {
|
|
108
|
-
/** 触发下拉刷新 */
|
|
109
|
-
onRefresh() {
|
|
110
|
-
if (this.isRefreshing) {
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
45
|
+
});
|
|
113
46
|
|
|
114
|
-
|
|
115
|
-
const { promise, resolve, reject } = Promise.withResolvers();
|
|
116
|
-
promise.finally(() => {
|
|
117
|
-
this.isRefreshing = false;
|
|
118
|
-
uni.stopPullDownRefresh();
|
|
119
|
-
});
|
|
120
|
-
this.$emit('refresh', { resolve, reject });
|
|
121
|
-
},
|
|
122
|
-
/** 抵达底部触发加载更多 */
|
|
123
|
-
onLoadMore() {
|
|
124
|
-
if (this.isLoadingMore) {
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
if (!this.pagingData.hasMore) {
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
47
|
+
const classNames = useClassNames('list-page');
|
|
130
48
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
49
|
+
type _Props = {
|
|
50
|
+
/** 是否使用自定义导航栏 */
|
|
51
|
+
custom?: boolean;
|
|
52
|
+
/** 页面标题 */
|
|
53
|
+
title?: string;
|
|
54
|
+
/** 页面头部样式,主要用于控制导航栏字体颜色 */
|
|
55
|
+
theme?: 'light' | 'dark';
|
|
56
|
+
/** 是否使用底部操作栏 */
|
|
57
|
+
hasFooter?: boolean;
|
|
58
|
+
/** 是否使用scroll-view */
|
|
59
|
+
useScroll?: boolean;
|
|
60
|
+
/** 分页数据 */
|
|
61
|
+
pagingData?: PagingData | null;
|
|
62
|
+
/** 是否显示加载更多 */
|
|
63
|
+
showLoadMore?: boolean;
|
|
64
|
+
/** 页面加载 */
|
|
65
|
+
loading?: boolean | string;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const props = withDefaults(defineProps<_Props>(), {
|
|
69
|
+
custom: true,
|
|
70
|
+
title: '',
|
|
71
|
+
theme: 'light',
|
|
72
|
+
hasFooter: false,
|
|
73
|
+
useScroll: true,
|
|
74
|
+
pagingData: null,
|
|
75
|
+
showLoadMore: true,
|
|
76
|
+
loading: false,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const emit = defineEmits<{
|
|
80
|
+
(e: 'refresh', payload?: Omit<PromiseWithResolvers<unknown>, 'promise'>): void;
|
|
81
|
+
(e: 'reach-bottom', payload?: Omit<PromiseWithResolvers<unknown>, 'promise'>): void;
|
|
82
|
+
}>();
|
|
83
|
+
|
|
84
|
+
/** 是否正在刷新中 */
|
|
85
|
+
const isRefreshing = ref(false);
|
|
86
|
+
/** 是否正在加载更多中 */
|
|
87
|
+
const isLoadingMore = ref(false);
|
|
88
|
+
|
|
89
|
+
/** 触发下拉刷新 */
|
|
90
|
+
const onRefresh = () => {
|
|
91
|
+
if (isRefreshing.value) return;
|
|
92
|
+
|
|
93
|
+
isRefreshing.value = true;
|
|
94
|
+
const { promise, resolve, reject } = Promise.withResolvers();
|
|
95
|
+
promise.finally(() => {
|
|
96
|
+
isRefreshing.value = false;
|
|
97
|
+
uni.stopPullDownRefresh();
|
|
98
|
+
});
|
|
99
|
+
emit('refresh', { resolve, reject });
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/** 抵达底部触发加载更多 */
|
|
103
|
+
const onLoadMore = () => {
|
|
104
|
+
if (isLoadingMore.value) return;
|
|
105
|
+
if (!props.pagingData?.hasMore) return;
|
|
106
|
+
|
|
107
|
+
isLoadingMore.value = true;
|
|
108
|
+
const { promise, resolve, reject } = Promise.withResolvers();
|
|
109
|
+
promise.finally(() => {
|
|
110
|
+
isLoadingMore.value = false;
|
|
111
|
+
uni.stopPullDownRefresh();
|
|
112
|
+
});
|
|
113
|
+
emit('reach-bottom', { resolve, reject });
|
|
140
114
|
};
|
|
141
115
|
</script>
|
|
142
116
|
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
@use 'sass:map';
|
|
2
|
+
@use '../../styles/utils' as *;
|
|
3
|
+
|
|
4
|
+
// 可配置的变量
|
|
5
|
+
$load-more: () !default;
|
|
6
|
+
$load-more-default: (
|
|
7
|
+
height: 60rpx,
|
|
8
|
+
space: 40rpx,
|
|
9
|
+
color: #ccc,
|
|
10
|
+
font-size: UTILS__GLOBAL_VAR(font-size, normal),
|
|
11
|
+
);
|
|
12
|
+
$load-more: map.merge($load-more-default, $load-more);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<view :class="
|
|
2
|
+
<view :class="[...classNames, $style['LoadMore']]">
|
|
3
3
|
<template v-if="end">
|
|
4
4
|
<view :class="$style['LoadMore--content']">{{ endTitle }}</view>
|
|
5
5
|
</template>
|
|
@@ -11,46 +11,46 @@
|
|
|
11
11
|
</view>
|
|
12
12
|
</template>
|
|
13
13
|
|
|
14
|
-
<script>
|
|
15
|
-
import
|
|
14
|
+
<script lang="ts" setup>
|
|
15
|
+
import useClassNames from '../../composable/component-name';
|
|
16
16
|
import IconCpn from '../icon/icon.vue';
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
name: 'LoadMore',
|
|
18
|
+
defineOptions({
|
|
20
19
|
options: {
|
|
21
|
-
virtualHost: true,
|
|
22
20
|
styleIsolation: 'shared',
|
|
21
|
+
virtualHost: true,
|
|
23
22
|
},
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
default: false,
|
|
36
|
-
},
|
|
37
|
-
/** 到最后一页时文本 */
|
|
38
|
-
endTitle: {
|
|
39
|
-
type: String,
|
|
40
|
-
default: '没有更多了',
|
|
41
|
-
},
|
|
42
|
-
},
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const classNames = useClassNames('load-more');
|
|
26
|
+
|
|
27
|
+
type _Props = {
|
|
28
|
+
/** 是否加载中 */
|
|
29
|
+
loading?: boolean;
|
|
30
|
+
/** 是否到最后一页 */
|
|
31
|
+
end?: boolean;
|
|
32
|
+
/** 到最后一页时文本 */
|
|
33
|
+
endTitle?: string;
|
|
43
34
|
};
|
|
35
|
+
|
|
36
|
+
withDefaults(defineProps<_Props>(), {
|
|
37
|
+
loading: false,
|
|
38
|
+
end: false,
|
|
39
|
+
endTitle: '没有更多了',
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
defineEmits<{
|
|
43
|
+
(event: 'load-more'): void;
|
|
44
|
+
}>();
|
|
44
45
|
</script>
|
|
45
46
|
|
|
46
47
|
<style lang="scss" module>
|
|
47
|
-
@use '../../styles/
|
|
48
|
+
@use '../../styles/utils' as *;
|
|
49
|
+
@use './load-more' as *;
|
|
48
50
|
|
|
49
51
|
// 定义外部变量
|
|
50
|
-
$component-name: 'load-more';
|
|
51
|
-
$component-vars: $load-more;
|
|
52
52
|
%external-vars {
|
|
53
|
-
@include UTILS__DEFINE_COMPONENT_VARS();
|
|
53
|
+
@include UTILS__DEFINE_COMPONENT_VARS($load-more, 'load-more');
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
.LoadMore {
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<view :class="
|
|
2
|
+
<view :class="[...classNames, $style['LoadingAnimation1']]">
|
|
3
3
|
<view :class="$style['LoadingAnimation1--dot']"></view>
|
|
4
4
|
<view :class="$style['LoadingAnimation1--dot']"></view>
|
|
5
5
|
</view>
|
|
6
6
|
</template>
|
|
7
7
|
|
|
8
|
-
<script>
|
|
9
|
-
import
|
|
8
|
+
<script lang="ts" setup>
|
|
9
|
+
import useClassNames from '../../../composable/component-name';
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
name: 'LoadingAnimation1',
|
|
11
|
+
defineOptions({
|
|
13
12
|
options: {
|
|
14
|
-
virtualHost: true,
|
|
15
13
|
styleIsolation: 'shared',
|
|
14
|
+
virtualHost: true,
|
|
16
15
|
},
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const classNames = useClassNames('loading-animation1');
|
|
19
19
|
</script>
|
|
20
20
|
|
|
21
21
|
<style lang="scss" module>
|
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<view :class="
|
|
2
|
+
<view :class="[...classNames, $style['LoadingAnimation2']]">
|
|
3
3
|
<icon-cpn icon="loading" :class="$style['LoadingAnimation2--icon']" />
|
|
4
4
|
</view>
|
|
5
5
|
</template>
|
|
6
6
|
|
|
7
|
-
<script>
|
|
8
|
-
import
|
|
7
|
+
<script lang="ts" setup>
|
|
8
|
+
import useClassNames from '../../../composable/component-name';
|
|
9
9
|
import IconCpn from '../../icon/icon.vue';
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
name: 'LoadingAnimation2',
|
|
11
|
+
defineOptions({
|
|
13
12
|
options: {
|
|
14
|
-
virtualHost: true,
|
|
15
13
|
styleIsolation: 'shared',
|
|
14
|
+
virtualHost: true,
|
|
16
15
|
},
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const classNames = useClassNames('loading-animation2');
|
|
20
19
|
</script>
|
|
21
20
|
|
|
22
21
|
<style lang="scss" module>
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<view :class="
|
|
2
|
+
<view :class="[...classNames, $style['LoadingAnimation3']]">
|
|
3
3
|
<view :class="$style['LoadingAnimation3--animation']"></view>
|
|
4
4
|
</view>
|
|
5
5
|
</template>
|
|
6
6
|
|
|
7
|
-
<script>
|
|
8
|
-
import
|
|
7
|
+
<script lang="ts" setup>
|
|
8
|
+
import useClassNames from '../../../composable/component-name';
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
name: 'LoadingAnimation3',
|
|
10
|
+
defineOptions({
|
|
12
11
|
options: {
|
|
13
|
-
virtualHost: true,
|
|
14
12
|
styleIsolation: 'shared',
|
|
13
|
+
virtualHost: true,
|
|
15
14
|
},
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const classNames = useClassNames('loading-animation3');
|
|
18
18
|
</script>
|
|
19
19
|
|
|
20
20
|
<style lang="scss" module>
|
|
@@ -45,9 +45,9 @@ export default {
|
|
|
45
45
|
border-radius: 50%;
|
|
46
46
|
box-shadow: $left-x $translate-y 0 $size-s, 0 $translate-y 0 $size-s, $right-x $translate-y 0 $size-s;
|
|
47
47
|
translate: 0 (-1 * $translate-y);
|
|
48
|
-
animation: loading-dots 1.5s infinite linear;
|
|
48
|
+
animation: LoadingAnimation3--loading-dots 1.5s infinite linear;
|
|
49
49
|
|
|
50
|
-
@keyframes loading-dots {
|
|
50
|
+
@keyframes LoadingAnimation3--loading-dots {
|
|
51
51
|
15% {
|
|
52
52
|
box-shadow: $left-x $translate-y 0 $size-l, 0 $translate-y 0 $size-s, $right-x $translate-y 0 $size-s;
|
|
53
53
|
}
|
|
@@ -62,7 +62,7 @@ export default {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
// @keyframes loading-dots2 {
|
|
65
|
+
// @keyframes LoadingAnimation3--loading-dots2 {
|
|
66
66
|
// 25% {
|
|
67
67
|
// box-shadow: $left-x $translate-y 0 $size-l, 0 $translate-y 0 $size-s, $right-x $translate-y 0 $size-s;
|
|
68
68
|
// }
|