@ecolovo/uniapp-components 1.0.9 → 2.0.0

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.
Files changed (117) hide show
  1. package/README.md +83 -51
  2. package/components/aspect/aspect.vue +24 -15
  3. package/components/badge/badge.scss +20 -0
  4. package/components/badge/badge.vue +49 -40
  5. package/components/button/button.scss +15 -0
  6. package/components/button/button.vue +125 -181
  7. package/components/checkbox/checkbox.scss +10 -0
  8. package/components/checkbox/checkbox.vue +118 -146
  9. package/components/checkbox-group/checkbox-group.vue +79 -81
  10. package/components/checkbox-group2/checkbox-group2.vue +111 -107
  11. package/components/checkbox-group2/checkbox2.vue +104 -0
  12. package/components/data-list/data-list.scss +9 -0
  13. package/components/data-list/data-list.vue +70 -79
  14. package/components/date-picker/date-picker-view.vue +125 -124
  15. package/components/date-picker/date-picker.vue +145 -146
  16. package/components/dialog/dialog-content.vue +39 -47
  17. package/components/dialog/dialog.scss +11 -0
  18. package/components/dialog/dialog.vue +125 -138
  19. package/components/dropdown/dropdown.scss +11 -0
  20. package/components/dropdown/dropdown.vue +55 -97
  21. package/components/empty/empty.scss +14 -0
  22. package/components/empty/empty.vue +42 -41
  23. package/components/flex/flex.vue +45 -54
  24. package/components/form/form.vue +29 -24
  25. package/components/form-item/form-item.scss +11 -0
  26. package/components/form-item/form-item.vue +43 -40
  27. package/components/icon/icon.vue +70 -85
  28. package/components/image/image.vue +35 -38
  29. package/components/input/input.vue +65 -79
  30. package/components/input/password-input.vue +34 -42
  31. package/components/list-page/list-page.vue +73 -99
  32. package/components/load-more/load-more.scss +12 -0
  33. package/components/load-more/load-more.vue +29 -29
  34. package/components/loading/animations/loading-animation1.vue +8 -8
  35. package/components/loading/animations/loading-animation2.vue +8 -9
  36. package/components/loading/animations/loading-animation3.vue +11 -11
  37. package/components/loading/animations/loading-animation4.vue +8 -8
  38. package/components/loading/loading.vue +19 -20
  39. package/components/message-box/message-box.vue +59 -41
  40. package/components/number-dialog/number-dialog.scss +9 -0
  41. package/components/number-dialog/number-dialog.vue +209 -204
  42. package/components/number-input/number-input.scss +9 -0
  43. package/components/number-input/number-input.vue +233 -232
  44. package/components/numpad/numpad.scss +9 -0
  45. package/components/numpad/numpad.vue +133 -150
  46. package/components/page/page-body.scss +15 -0
  47. package/components/page/page-body.vue +137 -119
  48. package/components/page/page-footer.scss +13 -0
  49. package/components/page/page-footer.vue +31 -33
  50. package/components/page/page-header.scss +17 -0
  51. package/components/page/page-header.vue +89 -94
  52. package/components/page/page.scss +9 -0
  53. package/components/page/page.vue +105 -81
  54. package/components/picker/picker-popup.vue +218 -209
  55. package/components/picker/picker.vue +99 -104
  56. package/components/popover/popover-content.vue +54 -63
  57. package/components/popover/popover-mask.vue +63 -63
  58. package/components/popover/popover.scss +28 -0
  59. package/components/popover/popover.vue +49 -47
  60. package/components/popup/popup-content.vue +49 -53
  61. package/components/popup/popup.scss +11 -0
  62. package/components/popup/popup.vue +117 -132
  63. package/components/price/price.scss +20 -0
  64. package/components/price/price.vue +31 -42
  65. package/components/search/search.scss +12 -0
  66. package/components/search/search.vue +93 -117
  67. package/components/searching/searching.vue +33 -40
  68. package/components/selector/selector.vue +43 -48
  69. package/components/switch/switch.scss +12 -0
  70. package/components/switch/switch.vue +99 -96
  71. package/components/tab/tab.scss +19 -0
  72. package/components/tab/tab.vue +151 -145
  73. package/components/textarea/textarea.vue +104 -101
  74. package/composable/component-name.ts +10 -0
  75. package/configs/index.ts +82 -0
  76. package/{easyCom.js → easyCom.ts} +1 -1
  77. package/index.ts +1 -0
  78. package/init.ts +34 -0
  79. package/package.json +12 -4
  80. package/styles/utils/css-var.scss +12 -15
  81. package/styles/utils/ellipsis.scss +0 -7
  82. package/styles/utils/z-index.scss +1 -1
  83. package/styles/var/component.scss +21 -245
  84. package/utils/{date.js → date.ts} +44 -42
  85. package/utils/freezeDeep.ts +9 -0
  86. package/utils/price.ts +57 -0
  87. package/utils/round.ts +11 -0
  88. package/utils/{windowInfo.js → windowInfo.ts} +12 -35
  89. package/components/checkbox-group2/checkbox.vue +0 -109
  90. package/components/datetime-picker/datetime-picker-view.vue +0 -209
  91. package/components/datetime-picker/datetime-picker.vue +0 -235
  92. package/components/form/mixin.js +0 -13
  93. package/components/list-page/list-page.js +0 -10
  94. package/components/table/table.vue +0 -112
  95. package/components/time-picker/time-picker-view.vue +0 -127
  96. package/components/time-picker/time-picker.vue +0 -140
  97. package/components/uploader/download.js +0 -81
  98. package/components/uploader/file-uploader.vue +0 -52
  99. package/components/uploader/files.js +0 -225
  100. package/components/uploader/media-uploader.vue +0 -179
  101. package/components/uploader/mixin.js +0 -171
  102. package/components/uploader/uni.js +0 -38
  103. package/components/uploader/upload-button.vue +0 -29
  104. package/components/uploader/uploader copy.vue +0 -547
  105. package/components/uploader/uploader.vue +0 -117
  106. package/configs/index.d.ts +0 -22
  107. package/configs/index.js +0 -68
  108. package/init.d.ts +0 -19
  109. package/init.js +0 -20
  110. package/mixins/componentName.js +0 -32
  111. package/mixins/listPage.js +0 -1
  112. package/mixins/windowInfo.js +0 -1
  113. package/utils/fileSize.js +0 -39
  114. package/utils/floor.js +0 -20
  115. package/utils/freezeDeep.js +0 -19
  116. package/utils/price.js +0 -32
  117. package/utils/round.js +0 -22
@@ -1,10 +0,0 @@
1
- const pulldownRefreshMixin = {
2
- onPullDownRefresh() {
3
- this.$refs.page.onRefresh();
4
- },
5
- onReachBottom() {
6
- this.$refs.page.onLoadMore();
7
- },
8
- };
9
-
10
- export { pulldownRefreshMixin };
@@ -1,112 +0,0 @@
1
- <template>
2
- <view :class="componentClassNames">
3
- <view :class="[$style['Table--row'], $style['Table--header']]">
4
- <view
5
- v-for="(h, i) in headers"
6
- :key="i"
7
- :class="[$style['Table--cell'], $style['Table--cell-align'] + (aligns[i] || 2)]"
8
- >
9
- <view>{{ h }}</view>
10
- </view>
11
- </view>
12
- <view v-for="(row, i) in value" :key="i" :class="$style['Table--row']">
13
- <view
14
- v-for="(col, j) in row"
15
- :key="j"
16
- :class="[$style['Table--cell'], $style['Table--cell-align'] + (aligns[j] || 2)]"
17
- :style="i === 0 && j < row.length - 1 ? { width: widths[j] || colWidth } : ''"
18
- >
19
- <view>{{ col }}</view>
20
- </view>
21
- </view>
22
- </view>
23
- </template>
24
-
25
- <script>
26
- import componentName from '../../mixins/componentName';
27
- import { floor2 } from '../../utils/floor';
28
-
29
- export default {
30
- name: 'Table',
31
- options: {
32
- virtualHost: true,
33
- styleIsolation: 'shared',
34
- },
35
- mixins: [componentName],
36
- props: {
37
- /** 各个列的数据 */
38
- value: {
39
- type: Array,
40
- default: () => [],
41
- },
42
- /** 定义各个列的表头 */
43
- headers: {
44
- type: Array,
45
- default: () => [],
46
- },
47
- /** 定义各个列的对齐方式,默认居中对齐,1左对齐,2居中,3右对齐 */
48
- aligns: {
49
- type: Array,
50
- default: () => [],
51
- },
52
- /** 定义各个列的宽度百分比 */
53
- widths: {
54
- type: Array,
55
- default: () => [],
56
- },
57
- },
58
- computed: {
59
- /** 总列数 */
60
- colCount() {
61
- return this.value[0]?.length || 0;
62
- },
63
- /** 每列所占宽度百分比 */
64
- colWidth() {
65
- return floor2(100 / this.colCount) + '%';
66
- },
67
- },
68
- };
69
- </script>
70
-
71
- <style lang="scss" module>
72
- @use '../../styles/index' as *;
73
-
74
- // 自定义样式变量前缀,与组件名称一致
75
- $component-prefix: '#{$ec-component-prefix}-table';
76
- // 自定义样式变量
77
- %external-vars {
78
- @include define-component-vars($cell-padding: get-value('size-l') get-value('size-xxs'));
79
- }
80
-
81
- .Table {
82
- @extend %external-vars;
83
- display: table;
84
- width: 100%;
85
- border: 2rpx solid get-value('color-background');
86
- border-radius: get-value('size-radius-s');
87
- overflow: hidden;
88
- }
89
- .Table--header {
90
- color: get-value('color-info-6');
91
- }
92
- .Table--row {
93
- display: table-row;
94
- &:nth-child(odd) {
95
- background: get-value('color-background');
96
- }
97
- }
98
- .Table--cell {
99
- display: table-cell;
100
- padding: var(--cell-padding);
101
- vertical-align: middle;
102
- }
103
- .Table--cell-align1 {
104
- text-align: start;
105
- }
106
- .Table--cell-align2 {
107
- text-align: center;
108
- }
109
- .Table--cell-align3 {
110
- text-align: end;
111
- }
112
- </style>
@@ -1,127 +0,0 @@
1
- <template>
2
- <picker-view
3
- immediate-change
4
- :value="pickerValue"
5
- :class="componentClassNames"
6
- @change="handlePickerChange"
7
- @pickend="onPickEnd"
8
- >
9
- <picker-view-column>
10
- <view v-for="item in hourOptions" :key="item" :class="$style['TimePickerView--option']">
11
- {{ item }} 时
12
- </view>
13
- </picker-view-column>
14
- <picker-view-column>
15
- <view v-for="item in minuteOptions" :key="item" :class="$style['TimePickerView--option']">
16
- {{ item }} 分
17
- </view>
18
- </picker-view-column>
19
- </picker-view>
20
- </template>
21
-
22
- <script>
23
- import range from 'lodash-es/range';
24
- import componentName from '../../mixins/componentName';
25
- import { formatDate } from '../../utils/date';
26
-
27
- const hourOptions = range(0, 24).map((item) => ('' + item).padStart(2, '0'));
28
-
29
- export default {
30
- name: 'TimePickerView',
31
- options: {
32
- virtualHost: true,
33
- styleIsolation: 'shared',
34
- },
35
- mixins: [componentName],
36
- props: {
37
- /** 绑定值 */
38
- value: {
39
- type: [String, null],
40
- default: null,
41
- },
42
- /** 分钟步长 */
43
- step: {
44
- type: Number,
45
- default: 5,
46
- },
47
- },
48
- data() {
49
- return {
50
- innerValue: '',
51
- /** 小时选项列表 */
52
- hourOptions,
53
- /** 分钟选项列表 */
54
- minuteOptions: [],
55
- /** picker-view 绑定值 */
56
- pickerValue: [0, 0],
57
- };
58
- },
59
- computed: {
60
- currentValue: {
61
- get: function () {
62
- return this.value === null ? this.innerValue : this.value;
63
- },
64
- set: function (value) {
65
- this.$emit('input', value);
66
- this.innerValue = value;
67
- this.$emit('change', value);
68
- },
69
- },
70
- },
71
- created() {
72
- this.minuteOptions = range(0, 60, this.step);
73
- },
74
- mounted() {
75
- this.$nextTick(() => {
76
- this.syncPickerValue(this.currentValue || new Date());
77
- });
78
- },
79
- methods: {
80
- /** 同步 picker-view 选中索引 */
81
- syncPickerValue(time) {
82
- const [h, m] = time.split(':');
83
- const i1 = this.hourOptions.indexOf(h);
84
- const i2 = Math.max(this.minuteOptions.indexOf(Math.round(Number(m) / this.step) * this.step), 0);
85
- this.$nextTick(() => {
86
- this.pickerValue =
87
- typeof this.pickerValue[0] === 'number' ? [i1, i2].map((item) => item.toString()) : [i1, i2];
88
- });
89
- },
90
- /** picker-view 选项值变化处理 */
91
- handlePickerChange(e) {
92
- const newPickerValue = e.detail.value;
93
- const hour = this.hourOptions[newPickerValue[0]];
94
- const minute = this.step >= 0 ? this.minuteOptions[newPickerValue[1]] : '00';
95
- this.pickerValue = newPickerValue;
96
- const dateValue = new Date(0, 0, 1, hour, minute, 0, 0);
97
- let dateStr = formatDate(dateValue, formatDate.TIME_MINUTE);
98
- this.currentValue = dateStr;
99
- },
100
- /** 滑动结束处理,保持选择器显示值与输入框值一致 */
101
- onPickEnd() {
102
- this.$nextTick(() => {
103
- this.syncPickerValue(this.currentValue);
104
- });
105
- },
106
- },
107
- };
108
- </script>
109
-
110
- <style lang="scss" module>
111
- @use '../../styles/index' as *;
112
-
113
- :host {
114
- display: flex;
115
- }
116
-
117
- .TimePickerView {
118
- margin-top: 24rpx;
119
- height: 300rpx;
120
- }
121
- .TimePickerView--option {
122
- display: flex;
123
- align-items: center;
124
- justify-content: center;
125
- white-space: nowrap;
126
- }
127
- </style>
@@ -1,140 +0,0 @@
1
- <template>
2
- <view :class="componentClassNames">
3
- <selector-cpn
4
- :value="showText"
5
- :readonly="isReadonly"
6
- :disabled="disabled"
7
- :placeholder="placeholder"
8
- @click="showPicker"
9
- />
10
-
11
- <!-- 选择器弹框 -->
12
- <popup-cpn
13
- v-if="isShowPopup"
14
- ref="popup"
15
- v-model="isShowPopup"
16
- :cancel="false"
17
- title="选择时间"
18
- @click.native.stop.prevent="doNothing"
19
- @confirm="onConfirm"
20
- >
21
- <view class="TimePicker--picker-area">
22
- <time-picker-view-cpn v-model="startStr" :step="step" />
23
- <template v-if="range">
24
- <view>至</view>
25
- <time-picker-view-cpn v-model="endStr" :step="step" />
26
- </template>
27
- </view>
28
- </popup-cpn>
29
- </view>
30
- </template>
31
-
32
- <script>
33
- import componentName from '../../mixins/componentName';
34
- import { isFormReadonly } from '../form/mixin';
35
- import PopupCpn from '../popup/popup.vue';
36
- import SelectorCpn from '../selector/selector.vue';
37
- import TimePickerViewCpn from './time-picker-view.vue';
38
-
39
- export default {
40
- name: 'TimePicker',
41
- options: {
42
- virtualHost: true,
43
- styleIsolation: 'shared',
44
- },
45
- components: { PopupCpn, SelectorCpn, TimePickerViewCpn },
46
- mixins: [componentName, isFormReadonly],
47
- props: {
48
- /** 绑定值 */
49
- value: {
50
- type: [String, null, Array],
51
- default: null,
52
- },
53
- /** 是否禁用 */
54
- disabled: {
55
- type: Boolean,
56
- default: false,
57
- },
58
- /** 是否只读 */
59
- readonly: {
60
- type: Boolean,
61
- default: false,
62
- },
63
- /** 占位文本 */
64
- placeholder: {
65
- type: String,
66
- default: '请选择',
67
- },
68
- /** 是否时间范围选择器 */
69
- range: {
70
- type: Boolean,
71
- default: false,
72
- },
73
- /** 分钟步长 */
74
- step: {
75
- type: Number,
76
- default: 5,
77
- },
78
- },
79
- data() {
80
- return {
81
- /** 选择框是否可见 */
82
- isShowPopup: false,
83
- /** 开始日期 */
84
- startStr: '',
85
- /** 结束日期 */
86
- endStr: '',
87
- };
88
- },
89
- computed: {
90
- isReadonly() {
91
- return this.readonly || this.isFormReadonly;
92
- },
93
- startTime() {
94
- return this.range && Array.isArray(this.value) ? this.value[0] : this.value;
95
- },
96
- endTime() {
97
- return this.range && Array.isArray(this.value) ? this.value[1] : '';
98
- },
99
- showText() {
100
- return this.range && this.startTime && this.endTime
101
- ? `${this.startTime} 至 ${this.endTime}`
102
- : this.startTime;
103
- },
104
- },
105
- methods: {
106
- doNothing() {},
107
- /** 显示选择器弹出框 */
108
- showPicker() {
109
- if (this.disabled || this.isReadonly) {
110
- return;
111
- }
112
-
113
- this.startStr = this.startTime;
114
- this.endStr = this.endTime;
115
-
116
- this.isShowPopup = true;
117
- this.$emit('show');
118
- },
119
- onConfirm() {
120
- this.$refs.popup.close();
121
- this.$emit('input', this.range ? [this.startStr, this.endStr] : this.startStr);
122
- this.$emit('change', this.range ? [this.startStr, this.endStr] : this.startStr);
123
- },
124
- },
125
- };
126
- </script>
127
-
128
- <style lang="scss" module>
129
- @use '../../styles/index' as *;
130
-
131
- .TimePicker {
132
- width: 100%;
133
- height: 100%;
134
- }
135
-
136
- .TimePicker--picker-area {
137
- display: flex;
138
- align-items: center;
139
- }
140
- </style>
@@ -1,81 +0,0 @@
1
- const STORAGE_KEY = 'cached_files';
2
-
3
- function hasFile(url) {
4
- const files = uni.getStorageSync(STORAGE_KEY);
5
- if (!files || !files[url]) {
6
- return false;
7
- }
8
- try {
9
- uni.getFileSystemManager().accessSync(files[url]);
10
- return files[url];
11
- } catch {
12
- return false;
13
- }
14
- }
15
-
16
- /**
17
- * 缓存文件
18
- * @param {string} url 文件下载路径
19
- * @param {string} name 带后缀的文件名
20
- * @returns 缓存后的路口
21
- */
22
- function cacheFile(url, name) {
23
- const filePath = hasFile(url);
24
- if (filePath) {
25
- return Promise.resolve(filePath);
26
- }
27
- return download(url).then((res) => {
28
- let filePath = uni.getFileSystemManager().saveFileSync(
29
- res.filePath,
30
- /* #ifdef MP-WEIXIN */
31
- `${wx.env.USER_DATA_PATH}/${name}`,
32
- /* #endif */
33
- /* #ifdef MP-ALIPAY */
34
- `${my.env.USER_DATA_PATH}/${name}`
35
- /* #endif */
36
- );
37
- const files = uni.getStorageSync(STORAGE_KEY) || {};
38
- /* #ifdef MP-ALIPAY */
39
- filePath = filePath.savedFilePath;
40
- /* #endif */
41
- files[url] = filePath;
42
- uni.setStorageSync(STORAGE_KEY, files);
43
-
44
- return filePath;
45
- });
46
- }
47
-
48
- /**
49
- * 下载文件
50
- * @param {string} url 文件下载路径
51
- * @param {string} name 文件下载后名称
52
- * @returns 下载后的临时路径
53
- */
54
- function download(url, name) {
55
- return new Promise((resolve, reject) => {
56
- uni.downloadFile({
57
- url,
58
- filePath: name ? `${wx.env.USER_DATA_PATH}/${name}` : undefined,
59
- success: function (res) {
60
- const filePath = res.filePath || res.tempFilePath;
61
- let fileName = name || '';
62
- // 从响应头获取文件名
63
- if (!fileName && res.header) {
64
- const match = /(filename=(.*))|(filename\*=[^']*'[^']*'(.*))/.exec(
65
- res.header['Content-Disposition']
66
- );
67
- if (match) {
68
- fileName = decodeURI(match[2] || match[4]);
69
- fileName = fileName.replace(/^["']*|["']*$/g, '');
70
- }
71
- }
72
- resolve({ res, filePath, fileName });
73
- },
74
- fail: function (error) {
75
- reject(error);
76
- },
77
- });
78
- });
79
- }
80
-
81
- export { download, cacheFile };
@@ -1,52 +0,0 @@
1
- <template>
2
- <view :class="componentClassNames">
3
- <view>
4
- <button-cpn>上传</button-cpn>
5
- </view>
6
- <view>
7
- <view v-for="(file, idx) in currentValue" :key="idx" :class="$style['Uploader--file-item']">
8
- {{ file.name || file.path }}
9
- </view>
10
- </view>
11
- </view>
12
- </template>
13
-
14
- <script>
15
- import componentName from '../../mixins/componentName';
16
- import ButtonCpn from '../button/button.vue';
17
- import UploadMixin from './mixin';
18
-
19
- export default {
20
- name: 'Uploader',
21
- options: {
22
- virtualHost: true,
23
- styleIsolation: 'shared',
24
- },
25
- components: { ButtonCpn },
26
- mixins: [componentName, UploadMixin],
27
- props: {
28
- /** 文件列表 */
29
- value: {
30
- type: Array,
31
- default: () => [],
32
- },
33
- },
34
- methods: {},
35
- };
36
- </script>
37
-
38
- <style lang="scss" module>
39
- .Uploader {
40
- width: 100%;
41
- }
42
- .Uploader--file-item {
43
- &:first-child {
44
- margin-top: 20rpx;
45
- }
46
- padding: 15rpx 0;
47
- font-size: 28rpx;
48
- white-space: nowrap;
49
- overflow: hidden;
50
- text-overflow: ellipsis;
51
- }
52
- </style>