@10yun/cv-mobile-ui 0.4.2 → 0.4.3

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 (166) hide show
  1. package/package.json +1 -1
  2. package/ui-uni/amap-wx/js/util.js +166 -158
  3. package/ui-uni/page-foot/page-foot.vue +38 -0
  4. package/ui-uni/page-head/page-head.vue +16 -0
  5. package/ui-uni/product.vue +52 -52
  6. package/ui-uni/u-charts/u-charts.js +743 -1092
  7. package/ui-uni/u-link/u-link.vue +59 -0
  8. package/ui-uni/uni-badge/uni-badge.vue +250 -0
  9. package/ui-uni/uni-calendar/calendar.js +546 -0
  10. package/ui-uni/uni-calendar/uni-calendar-item.vue +171 -0
  11. package/ui-uni/uni-calendar/uni-calendar.vue +504 -0
  12. package/{ui-cv/cv-calendar → ui-uni/uni-calendar}/util.js +0 -0
  13. package/ui-uni/uni-card/uni-card.vue +420 -0
  14. package/ui-uni/uni-col/uni-col.vue +2968 -0
  15. package/ui-uni/uni-collapse/uni-collapse.vue +146 -0
  16. package/ui-uni/uni-collapse-item/uni-collapse-item.vue +378 -0
  17. package/ui-uni/uni-combox/uni-combox.vue +237 -0
  18. package/ui-uni/uni-countdown/uni-countdown.vue +234 -0
  19. package/ui-uni/uni-data-checkbox/uni-data-checkbox.vue +792 -0
  20. package/{ui-cv/cv-data-indexed-list → ui-uni/uni-data-indexed-list}/clientdb.js +0 -0
  21. package/ui-uni/uni-data-indexed-list/uni-data-indexed-list-item.vue +142 -0
  22. package/ui-uni/uni-data-indexed-list/uni-data-indexed-list.vue +364 -0
  23. package/{ui-cv/cv-data-picker → ui-uni/uni-data-picker}/keypress.js +0 -0
  24. package/ui-uni/uni-data-picker/uni-data-picker.vue +468 -0
  25. package/{ui-cv/cv-data-pickerview/cv-data-picker.js → ui-uni/uni-data-pickerview/uni-data-picker.js} +0 -0
  26. package/ui-uni/uni-data-pickerview/uni-data-pickerview.vue +298 -0
  27. package/{ui-cv/cv-dateformat → ui-uni/uni-dateformat}/date-format.js +0 -0
  28. package/ui-uni/uni-dateformat/uni-dateformat.vue +88 -0
  29. package/{ui-cv/cv-datetime-picker → ui-uni/uni-datetime-picker}/calendar-item.vue +0 -0
  30. package/{ui-cv/cv-datetime-picker → ui-uni/uni-datetime-picker}/calendar.js +0 -0
  31. package/ui-uni/uni-datetime-picker/calendar.vue +747 -0
  32. package/{ui-cv/cv-datetime-picker → ui-uni/uni-datetime-picker}/keypress.js +0 -0
  33. package/ui-uni/uni-datetime-picker/time-picker.vue +899 -0
  34. package/ui-uni/uni-datetime-picker/uni-datetime-picker.vue +874 -0
  35. package/{ui-cv/cv-datetime-picker → ui-uni/uni-datetime-picker}/util.js +0 -0
  36. package/ui-uni/uni-drawer/keypress.js +45 -0
  37. package/ui-uni/uni-drawer/uni-drawer.vue +178 -0
  38. package/{ui-cv/cv-easyinput → ui-uni/uni-easyinput}/common.js +0 -0
  39. package/ui-uni/uni-easyinput/uni-easyinput.vue +438 -0
  40. package/ui-uni/uni-fab/uni-fab.vue +443 -0
  41. package/{ui-cv/cv-fab/cv-fab.vue.bak → ui-uni/uni-fab/uni-fab.vue.bak} +2 -2
  42. package/ui-uni/uni-fav/uni-fav.vue +136 -0
  43. package/{ui-cv/cv-file-picker → ui-uni/uni-file-picker}/choose-and-upload-file.js +0 -0
  44. package/ui-uni/uni-file-picker/uni-file-picker.vue +614 -0
  45. package/{ui-cv/cv-file-picker → ui-uni/uni-file-picker}/upload-file.vue +0 -0
  46. package/{ui-cv/cv-file-picker → ui-uni/uni-file-picker}/upload-image.vue +0 -0
  47. package/{ui-cv/cv-file-picker → ui-uni/uni-file-picker}/utils.js +0 -0
  48. package/ui-uni/uni-forms/uni-forms.vue +467 -0
  49. package/ui-uni/uni-forms/validate.js +486 -0
  50. package/ui-uni/uni-forms-item/uni-forms-item.vue +500 -0
  51. package/{ui-cv/cv-goods-nav/cv-goods-nav.vue → ui-uni/uni-goods-nav/uni-goods-nav.vue} +1 -1
  52. package/ui-uni/uni-grid/uni-grid.vue +141 -0
  53. package/ui-uni/uni-grid-item/uni-grid-item.vue +123 -0
  54. package/ui-uni/uni-group/uni-group.vue +123 -0
  55. package/ui-uni/uni-icons/icons.js +132 -0
  56. package/ui-uni/uni-icons/uni-icons.vue +72 -0
  57. package/{ui-cv/cv-icon2 → ui-uni/uni-icons}/uni.ttf +0 -0
  58. package/ui-uni/uni-indexed-list/uni-indexed-list-item.vue +142 -0
  59. package/ui-uni/uni-indexed-list/uni-indexed-list.vue +357 -0
  60. package/ui-uni/uni-link/uni-link.vue +117 -0
  61. package/ui-uni/uni-list/uni-list.vue +107 -0
  62. package/ui-uni/uni-list/uni-refresh.vue +65 -0
  63. package/{ui-cv/cv-list → ui-uni/uni-list}/uni-refresh.wxs +0 -0
  64. package/ui-uni/uni-list-ad/uni-list-ad.vue +106 -0
  65. package/{ui-cv/cv-list-chat/cv-list-chat.scss → ui-uni/uni-list-chat/uni-list-chat.scss} +0 -0
  66. package/{ui-cv/cv-list-chat/cv-list-chat.vue → ui-uni/uni-list-chat/uni-list-chat.vue} +0 -0
  67. package/ui-uni/uni-list-item/uni-list-item.vue +428 -0
  68. package/ui-uni/uni-load-more/uni-load-more.vue +366 -0
  69. package/ui-uni/uni-nav-bar/uni-nav-bar.vue +244 -0
  70. package/{ui-cv/cv-nav-bar/cv-status-bar.vue → ui-uni/uni-nav-bar/uni-status-bar.vue} +0 -0
  71. package/ui-uni/uni-notice-bar/uni-notice-bar.vue +394 -0
  72. package/ui-uni/uni-number-box/uni-number-box.vue +224 -0
  73. package/ui-uni/uni-pagination/uni-pagination.vue +376 -0
  74. package/{ui-cv/cv-popup → ui-uni/uni-popup}/keypress.js +0 -0
  75. package/{ui-cv/cv-popup → ui-uni/uni-popup}/popup.js +0 -0
  76. package/ui-uni/uni-popup/uni-popup.vue +412 -0
  77. package/{ui-cv/cv-popup-dialog → ui-uni/uni-popup-dialog}/keypress.js +0 -0
  78. package/{ui-cv/cv-popup-dialog/cv-popup-dialog.vue → ui-uni/uni-popup-dialog/uni-popup-dialog.vue} +0 -0
  79. package/ui-uni/uni-popup-message/uni-popup-message.vue +143 -0
  80. package/{ui-cv/cv-popup-share/cv-popup-share.vue → ui-uni/uni-popup-share/uni-popup-share.vue} +0 -0
  81. package/ui-uni/uni-rate/uni-rate.vue +357 -0
  82. package/ui-uni/uni-row/uni-row.vue +155 -0
  83. package/ui-uni/uni-search-bar/uni-search-bar.vue +262 -0
  84. package/{ui-cv/cv-section/cv-section.vue → ui-uni/uni-section/uni-section.vue} +0 -0
  85. package/{ui-cv/cv-segmented-control/cv-segmented-control.vue → ui-uni/uni-segmented-control/uni-segmented-control.vue} +0 -0
  86. package/{ui-cv/cv-status-bar/cv-status-bar.vue → ui-uni/uni-status-bar/uni-status-bar.vue} +0 -0
  87. package/ui-uni/uni-steps/uni-steps.vue +250 -0
  88. package/{ui-cv/cv-swipe-action/cv-swipe-action.vue → ui-uni/uni-swipe-action/uni-swipe-action.vue} +0 -0
  89. package/{ui-cv/cv-swipe-action-item → ui-uni/uni-swipe-action-item}/bindingx.js +0 -0
  90. package/{ui-cv/cv-swipe-action-item → ui-uni/uni-swipe-action-item}/index.wxs +0 -0
  91. package/{ui-cv/cv-swipe-action-item → ui-uni/uni-swipe-action-item}/isPC.js +0 -0
  92. package/{ui-cv/cv-swipe-action-item → ui-uni/uni-swipe-action-item}/mpalipay.js +0 -0
  93. package/{ui-cv/cv-swipe-action-item → ui-uni/uni-swipe-action-item}/mpother.js +0 -0
  94. package/{ui-cv/cv-swipe-action-item → ui-uni/uni-swipe-action-item}/mpwxs.js +0 -0
  95. package/{ui-cv/cv-swipe-action-item/cv-swipe-action-item.vue → ui-uni/uni-swipe-action-item/uni-swipe-action-item.vue} +0 -0
  96. package/ui-uni/uni-swiper-dot/uni-swiper-dot.vue +205 -0
  97. package/ui-uni/uni-table/uni-table.vue +455 -0
  98. package/ui-uni/uni-tag/uni-tag.vue +283 -0
  99. package/ui-uni/uni-tbody/uni-tbody.vue +30 -0
  100. package/ui-uni/uni-td/uni-td.vue +88 -0
  101. package/{ui-cv/cv-test/cv-test.vue → ui-uni/uni-test/uni-test.vue} +0 -0
  102. package/{ui-cv/cv-th → ui-uni/uni-th}/filter-dropdown.vue +0 -0
  103. package/ui-uni/uni-th/uni-th.vue +259 -0
  104. package/ui-uni/uni-thead/uni-thead.vue +114 -0
  105. package/ui-uni/uni-title/uni-title.vue +171 -0
  106. package/{ui-cv/cv-tr → ui-uni/uni-tr}/table-checkbox.vue +0 -0
  107. package/ui-uni/uni-tr/uni-tr.vue +156 -0
  108. package/{ui-cv/cv-transition → ui-uni/uni-transition}/createAnimation.js +0 -0
  109. package/ui-uni/uni-transition/uni-transition.vue +287 -0
  110. package/ui-cv/cv-badge/cv-badge.vue +0 -249
  111. package/ui-cv/cv-calendar/calendar.js +0 -963
  112. package/ui-cv/cv-calendar/cv-calendar-item.vue +0 -198
  113. package/ui-cv/cv-calendar/cv-calendar.vue +0 -508
  114. package/ui-cv/cv-card/cv-card.vue +0 -427
  115. package/ui-cv/cv-col/cv-col.vue +0 -2965
  116. package/ui-cv/cv-collapse/cv-collapse.vue +0 -146
  117. package/ui-cv/cv-collapse-item/cv-collapse-item.vue +0 -395
  118. package/ui-cv/cv-combox/cv-combox.vue +0 -250
  119. package/ui-cv/cv-countdown/cv-countdown.vue +0 -245
  120. package/ui-cv/cv-data-checkbox/cv-data-checkbox.vue +0 -841
  121. package/ui-cv/cv-data-indexed-list/cv-data-indexed-list-item.vue +0 -154
  122. package/ui-cv/cv-data-indexed-list/cv-data-indexed-list.vue +0 -376
  123. package/ui-cv/cv-data-picker/cv-data-picker.vue +0 -486
  124. package/ui-cv/cv-data-pickerview/cv-data-pickerview.vue +0 -304
  125. package/ui-cv/cv-dateformat/cv-dateformat.vue +0 -86
  126. package/ui-cv/cv-datetime-picker/calendar.vue +0 -761
  127. package/ui-cv/cv-datetime-picker/cv-datetime-picker.vue +0 -958
  128. package/ui-cv/cv-datetime-picker/time-picker.vue +0 -907
  129. package/ui-cv/cv-drawer/cv-drawer.vue +0 -185
  130. package/ui-cv/cv-drawer/keypress.js +0 -45
  131. package/ui-cv/cv-easyinput/cv-easyinput.vue +0 -514
  132. package/ui-cv/cv-fab/cv-fab.vue +0 -465
  133. package/ui-cv/cv-fav/cv-fav.vue +0 -150
  134. package/ui-cv/cv-file-picker/cv-file-picker.vue +0 -619
  135. package/ui-cv/cv-form-base/cv-form-base.vue +0 -470
  136. package/ui-cv/cv-form-base/validate.js +0 -477
  137. package/ui-cv/cv-grid-group/cv-grid-group.vue +0 -148
  138. package/ui-cv/cv-grid-item/cv-grid-item.vue +0 -132
  139. package/ui-cv/cv-icon2/cv-icon2.vue +0 -78
  140. package/ui-cv/cv-icon2/icons.js +0 -132
  141. package/ui-cv/cv-indexed-list/cv-indexed-list-item.vue +0 -154
  142. package/ui-cv/cv-indexed-list/cv-indexed-list.vue +0 -371
  143. package/ui-cv/cv-link2/cv-link2.vue +0 -130
  144. package/ui-cv/cv-list/cv-list.vue +0 -107
  145. package/ui-cv/cv-list/cv-refresh.vue +0 -65
  146. package/ui-cv/cv-list-ad/cv-list-ad.vue +0 -113
  147. package/ui-cv/cv-list-item/cv-list-item.vue +0 -449
  148. package/ui-cv/cv-nav-bar/cv-nav-bar.vue +0 -256
  149. package/ui-cv/cv-notice-bar/cv-notice-bar.vue +0 -453
  150. package/ui-cv/cv-number-box/cv-number-box.vue +0 -223
  151. package/ui-cv/cv-pagination/cv-pagination.vue +0 -397
  152. package/ui-cv/cv-popup/cv-popup.vue +0 -429
  153. package/ui-cv/cv-popup-message/cv-popup-message.vue +0 -143
  154. package/ui-cv/cv-row/cv-row.vue +0 -157
  155. package/ui-cv/cv-search-bar/cv-search-bar.vue +0 -280
  156. package/ui-cv/cv-steps/cv-steps.vue +0 -293
  157. package/ui-cv/cv-swiper-dot/cv-swiper-dot.vue +0 -255
  158. package/ui-cv/cv-table/cv-table.vue +0 -460
  159. package/ui-cv/cv-tag/cv-tag.vue +0 -276
  160. package/ui-cv/cv-tbody/cv-tbody.vue +0 -28
  161. package/ui-cv/cv-td/cv-td.vue +0 -93
  162. package/ui-cv/cv-th/cv-th.vue +0 -270
  163. package/ui-cv/cv-thead/cv-thead.vue +0 -114
  164. package/ui-cv/cv-title/cv-title.vue +0 -168
  165. package/ui-cv/cv-tr/cv-tr.vue +0 -166
  166. package/ui-cv/cv-transition/cv-transition.vue +0 -279
@@ -1,250 +0,0 @@
1
- <template>
2
- <view class="uni-combox">
3
- <view v-if="label" class="uni-combox__label" :style="labelStyle">
4
- <text>{{ label }}</text>
5
- </view>
6
- <view class="uni-combox__input-box">
7
- <input
8
- class="uni-combox__input"
9
- type="text"
10
- :placeholder="placeholder"
11
- v-model="inputVal"
12
- @input="onInput"
13
- @focus="onFocus"
14
- @blur="onBlur"
15
- />
16
- <cv-icon2 class="uni-combox__input-arrow" type="arrowdown" size="14" @click="toggleSelector"></cv-icon2>
17
- <view class="uni-combox__selector" v-if="showSelector">
18
- <scroll-view scroll-y="true" class="uni-combox__selector-scroll">
19
- <view class="uni-combox__selector-empty" v-if="filterCandidatesLength === 0">
20
- <text>{{ emptyTips }}</text>
21
- </view>
22
- <view
23
- class="uni-combox__selector-item"
24
- v-for="(item, index) in filterCandidates"
25
- :key="index"
26
- @click="onSelectorClick(index)"
27
- >
28
- <text>{{ item }}</text>
29
- </view>
30
- </scroll-view>
31
- </view>
32
- </view>
33
- </view>
34
- </template>
35
-
36
- <script>
37
- /**
38
- * Combox 组合输入框
39
- * @description 组合输入框一般用于既可以输入也可以选择的场景
40
- * @tutorial https://ext.dcloud.net.cn/plugin?id=1261
41
- * @property {String} label 左侧文字
42
- * @property {String} labelWidth 左侧内容宽度
43
- * @property {String} placeholder 输入框占位符
44
- * @property {Array} candidates 候选项列表
45
- * @property {String} emptyTips 筛选结果为空时显示的文字
46
- * @property {String} value 组合框的值
47
- */
48
- export default {
49
- name: 'cvCombox',
50
- emits: ['input', 'update:modelValue'],
51
- props: {
52
- label: {
53
- type: String,
54
- default: ''
55
- },
56
- labelWidth: {
57
- type: String,
58
- default: 'auto'
59
- },
60
- placeholder: {
61
- type: String,
62
- default: ''
63
- },
64
- candidates: {
65
- type: Array,
66
- default() {
67
- return [];
68
- }
69
- },
70
- emptyTips: {
71
- type: String,
72
- default: '无匹配项'
73
- },
74
- // #ifndef VUE3
75
- value: {
76
- type: [String, Number],
77
- default: ''
78
- },
79
- // #endif
80
- // #ifdef VUE3
81
- modelValue: {
82
- type: [String, Number],
83
- default: ''
84
- }
85
- // #endif
86
- },
87
- data() {
88
- return {
89
- showSelector: false,
90
- inputVal: ''
91
- };
92
- },
93
- computed: {
94
- labelStyle() {
95
- if (this.labelWidth === 'auto') {
96
- return {};
97
- }
98
- return {
99
- width: this.labelWidth
100
- };
101
- },
102
- filterCandidates() {
103
- return this.candidates.filter((item) => {
104
- return item.toString().indexOf(this.inputVal) > -1;
105
- });
106
- },
107
- filterCandidatesLength() {
108
- return this.filterCandidates.length;
109
- }
110
- },
111
- watch: {
112
- // #ifndef VUE3
113
- value: {
114
- handler(newVal) {
115
- this.inputVal = newVal;
116
- },
117
- immediate: true
118
- },
119
- // #endif
120
- // #ifdef VUE3
121
- modelValue: {
122
- handler(newVal) {
123
- this.inputVal = newVal;
124
- },
125
- immediate: true
126
- }
127
- // #endif
128
- },
129
- methods: {
130
- toggleSelector() {
131
- this.showSelector = !this.showSelector;
132
- },
133
- onFocus() {
134
- this.showSelector = true;
135
- },
136
- onBlur() {
137
- setTimeout(() => {
138
- this.showSelector = false;
139
- }, 153);
140
- },
141
- onSelectorClick(index) {
142
- this.inputVal = this.filterCandidates[index];
143
- this.showSelector = false;
144
- this.$emit('input', this.inputVal);
145
- this.$emit('update:modelValue', this.inputVal);
146
- },
147
- onInput() {
148
- setTimeout(() => {
149
- this.$emit('input', this.inputVal);
150
- this.$emit('update:modelValue', this.inputVal);
151
- });
152
- }
153
- }
154
- };
155
- </script>
156
-
157
- <style scoped>
158
- .uni-combox {
159
- /* #ifndef APP-NVUE */
160
- display: flex;
161
- /* #endif */
162
- height: 40px;
163
- flex-direction: row;
164
- align-items: center;
165
- }
166
-
167
- .uni-combox__label {
168
- font-size: 16px;
169
- line-height: 22px;
170
- padding-right: 10px;
171
- color: #999999;
172
- }
173
-
174
- .uni-combox__input-box {
175
- position: relative;
176
- /* #ifndef APP-NVUE */
177
- display: flex;
178
- /* #endif */
179
- flex: 1;
180
- flex-direction: row;
181
- align-items: center;
182
- }
183
-
184
- .uni-combox__input {
185
- flex: 1;
186
- font-size: 16px;
187
- height: 22px;
188
- line-height: 22px;
189
- }
190
-
191
- .uni-combox__input-arrow {
192
- padding: 10px;
193
- }
194
-
195
- .uni-combox__selector {
196
- /* #ifndef APP-NVUE */
197
- box-sizing: border-box;
198
- /* #endif */
199
- position: absolute;
200
- top: 42px;
201
- left: 0;
202
- width: 100%;
203
- background-color: #ffffff;
204
- border-radius: 6px;
205
- box-shadow: #dddddd 4px 4px 8px, #dddddd -4px -4px 8px;
206
- z-index: 2;
207
- }
208
-
209
- .uni-combox__selector-scroll {
210
- /* #ifndef APP-NVUE */
211
- max-height: 200px;
212
- box-sizing: border-box;
213
- /* #endif */
214
- }
215
-
216
- .uni-combox__selector::before {
217
- /* #ifndef APP-NVUE */
218
- content: '';
219
- /* #endif */
220
- position: absolute;
221
- width: 0;
222
- height: 0;
223
- border-bottom: solid 6px #ffffff;
224
- border-right: solid 6px transparent;
225
- border-left: solid 6px transparent;
226
- left: 50%;
227
- top: -6px;
228
- margin-left: -6px;
229
- }
230
-
231
- .uni-combox__selector-empty,
232
- .uni-combox__selector-item {
233
- /* #ifndef APP-NVUE */
234
- display: flex;
235
- cursor: pointer;
236
- /* #endif */
237
- line-height: 36px;
238
- font-size: 14px;
239
- text-align: center;
240
- border-bottom: solid 1px #dddddd;
241
- margin: 0px 10px;
242
- }
243
-
244
- .uni-combox__selector-empty:last-child,
245
- .uni-combox__selector-item:last-child {
246
- /* #ifndef APP-NVUE */
247
- border-bottom: none;
248
- /* #endif */
249
- }
250
- </style>
@@ -1,245 +0,0 @@
1
- <template>
2
- <view class="uni-countdown">
3
- <text
4
- v-if="showDay"
5
- :style="{ borderColor: borderColor, color: color, backgroundColor: backgroundColor }"
6
- class="uni-countdown__number"
7
- >
8
- {{ d }}
9
- </text>
10
- <text v-if="showDay" :style="{ color: splitorColor }" class="uni-countdown__splitor">天</text>
11
- <text :style="{ borderColor: borderColor, color: color, backgroundColor: backgroundColor }" class="uni-countdown__number">
12
- {{ h }}
13
- </text>
14
- <text :style="{ color: splitorColor }" class="uni-countdown__splitor">{{ showColon ? ':' : '时' }}</text>
15
- <text :style="{ borderColor: borderColor, color: color, backgroundColor: backgroundColor }" class="uni-countdown__number">
16
- {{ i }}
17
- </text>
18
- <text :style="{ color: splitorColor }" class="uni-countdown__splitor">{{ showColon ? ':' : '分' }}</text>
19
- <text :style="{ borderColor: borderColor, color: color, backgroundColor: backgroundColor }" class="uni-countdown__number">
20
- {{ s }}
21
- </text>
22
- <text v-if="!showColon" :style="{ color: splitorColor }" class="uni-countdown__splitor">秒</text>
23
- </view>
24
- </template>
25
- <script>
26
- /**
27
- * Countdown 倒计时
28
- * @description 倒计时组件
29
- * @tutorial https://ext.dcloud.net.cn/plugin?id=25
30
- * @property {String} backgroundColor 背景色
31
- * @property {String} color 文字颜色
32
- * @property {Number} day 天数
33
- * @property {Number} hour 小时
34
- * @property {Number} minute 分钟
35
- * @property {Number} second 秒
36
- * @property {Number} timestamp 时间戳
37
- * @property {Boolean} showDay = [true|false] 是否显示天数
38
- * @property {Boolean} showColon = [true|false] 是否以冒号为分隔符
39
- * @property {String} splitorColor 分割符号颜色
40
- * @event {Function} timeup 倒计时时间到触发事件
41
- * @example <cv-countdown :day="1" :hour="1" :minute="12" :second="40"></cv-countdown>
42
- */
43
- export default {
44
- name: 'cvCountdown',
45
- emits: ['timeup'],
46
- props: {
47
- showDay: {
48
- type: Boolean,
49
- default: true
50
- },
51
- showColon: {
52
- type: Boolean,
53
- default: true
54
- },
55
- start: {
56
- type: Boolean,
57
- default: true
58
- },
59
- backgroundColor: {
60
- type: String,
61
- default: '#FFFFFF'
62
- },
63
- borderColor: {
64
- type: String,
65
- default: '#000000'
66
- },
67
- color: {
68
- type: String,
69
- default: '#000000'
70
- },
71
- splitorColor: {
72
- type: String,
73
- default: '#000000'
74
- },
75
- day: {
76
- type: Number,
77
- default: 0
78
- },
79
- hour: {
80
- type: Number,
81
- default: 0
82
- },
83
- minute: {
84
- type: Number,
85
- default: 0
86
- },
87
- second: {
88
- type: Number,
89
- default: 0
90
- },
91
- timestamp: {
92
- type: Number,
93
- default: 0
94
- }
95
- },
96
- data() {
97
- return {
98
- timer: null,
99
- syncFlag: false,
100
- d: '00',
101
- h: '00',
102
- i: '00',
103
- s: '00',
104
- leftTime: 0,
105
- seconds: 0
106
- };
107
- },
108
- watch: {
109
- day(val) {
110
- this.changeFlag();
111
- },
112
- hour(val) {
113
- this.changeFlag();
114
- },
115
- minute(val) {
116
- this.changeFlag();
117
- },
118
- second(val) {
119
- this.changeFlag();
120
- },
121
- start: {
122
- immediate: true,
123
- handler(newVal, oldVal) {
124
- if (newVal) {
125
- this.startData();
126
- } else {
127
- if (!oldVal) return;
128
- clearInterval(this.timer);
129
- }
130
- }
131
- }
132
- },
133
- created: function (e) {
134
- this.seconds = this.toSeconds(this.timestamp, this.day, this.hour, this.minute, this.second);
135
- this.countDown();
136
- },
137
- // #ifndef VUE3
138
- destroyed() {
139
- clearInterval(this.timer);
140
- },
141
- // #endif
142
- // #ifdef VUE3
143
- unmounted() {
144
- clearInterval(this.timer);
145
- },
146
- // #endif
147
- methods: {
148
- toSeconds(timestamp, day, hours, minutes, seconds) {
149
- if (timestamp) {
150
- return timestamp - parseInt(new Date().getTime() / 1000, 10);
151
- }
152
- return day * 60 * 60 * 24 + hours * 60 * 60 + minutes * 60 + seconds;
153
- },
154
- timeUp() {
155
- clearInterval(this.timer);
156
- this.$emit('timeup');
157
- },
158
- countDown() {
159
- let seconds = this.seconds;
160
- let [day, hour, minute, second] = [0, 0, 0, 0];
161
- if (seconds > 0) {
162
- day = Math.floor(seconds / (60 * 60 * 24));
163
- hour = Math.floor(seconds / (60 * 60)) - day * 24;
164
- minute = Math.floor(seconds / 60) - day * 24 * 60 - hour * 60;
165
- second = Math.floor(seconds) - day * 24 * 60 * 60 - hour * 60 * 60 - minute * 60;
166
- } else {
167
- this.timeUp();
168
- }
169
- if (day < 10) {
170
- day = '0' + day;
171
- }
172
- if (hour < 10) {
173
- hour = '0' + hour;
174
- }
175
- if (minute < 10) {
176
- minute = '0' + minute;
177
- }
178
- if (second < 10) {
179
- second = '0' + second;
180
- }
181
- this.d = day;
182
- this.h = hour;
183
- this.i = minute;
184
- this.s = second;
185
- },
186
- startData() {
187
- this.seconds = this.toSeconds(this.timestamp, this.day, this.hour, this.minute, this.second);
188
- if (this.seconds <= 0) {
189
- return;
190
- }
191
- clearInterval(this.timer);
192
- this.countDown();
193
- this.timer = setInterval(() => {
194
- this.seconds--;
195
- if (this.seconds < 0) {
196
- this.timeUp();
197
- return;
198
- }
199
- this.countDown();
200
- }, 1000);
201
- },
202
- changeFlag() {
203
- if (!this.syncFlag) {
204
- this.seconds = this.toSeconds(this.timestamp, this.day, this.hour, this.minute, this.second);
205
- this.startData();
206
- this.syncFlag = true;
207
- }
208
- }
209
- }
210
- };
211
- </script>
212
- <style scoped>
213
- .uni-countdown {
214
- /* #ifndef APP-NVUE */
215
- display: flex;
216
- /* #endif */
217
- flex-direction: row;
218
- justify-content: flex-start;
219
- padding: 2rpx 0;
220
- }
221
-
222
- .uni-countdown__splitor {
223
- /* #ifndef APP-NVUE */
224
- display: flex;
225
- /* #endif */
226
- justify-content: center;
227
- line-height: 48rpx;
228
- padding: 5rpx;
229
- font-size: 12px;
230
- }
231
-
232
- .uni-countdown__number {
233
- /* #ifndef APP-NVUE */
234
- display: flex;
235
- /* #endif */
236
- justify-content: center;
237
- align-items: center;
238
- width: 52rpx;
239
- height: 48rpx;
240
- line-height: 48rpx;
241
- margin: 5rpx;
242
- text-align: center;
243
- font-size: 12px;
244
- }
245
- </style>