@10yun/cv-mobile-ui 0.4.1 → 0.4.2
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/package.json +1 -1
- package/ui-cv/cv-badge/{uni-badge.vue → cv-badge.vue} +2 -2
- package/ui-cv/cv-calendar/calendar.js +762 -345
- package/ui-cv/cv-calendar/cv-calendar-item.vue +198 -0
- package/ui-cv/cv-calendar/cv-calendar.vue +508 -0
- package/ui-cv/cv-card/cv-card.vue +427 -0
- package/ui-cv/cv-col/cv-col.vue +2965 -0
- package/ui-cv/cv-collapse/cv-collapse.vue +146 -0
- package/ui-cv/cv-collapse-item/cv-collapse-item.vue +395 -0
- package/ui-cv/cv-combox/cv-combox.vue +250 -0
- package/ui-cv/cv-countdown/cv-countdown.vue +245 -0
- package/ui-cv/cv-data-checkbox/cv-data-checkbox.vue +841 -0
- package/ui-cv/cv-data-indexed-list/cv-data-indexed-list-item.vue +154 -0
- package/ui-cv/cv-data-indexed-list/cv-data-indexed-list.vue +376 -0
- package/ui-cv/cv-data-picker/cv-data-picker.vue +486 -0
- package/ui-cv/cv-data-pickerview/{uni-data-picker.js → cv-data-picker.js} +0 -0
- package/ui-cv/cv-data-pickerview/cv-data-pickerview.vue +304 -0
- package/ui-cv/cv-dateformat/cv-dateformat.vue +86 -0
- package/ui-cv/cv-datetime-picker/calendar.vue +752 -738
- package/ui-cv/cv-datetime-picker/cv-datetime-picker.vue +958 -0
- package/ui-cv/cv-datetime-picker/time-picker.vue +900 -892
- package/ui-cv/cv-easyinput/cv-easyinput.vue +514 -0
- package/ui-cv/cv-fab/cv-fab.vue +465 -0
- package/ui-cv/cv-fab/{uni-fab.vue.bak → cv-fab.vue.bak} +2 -2
- package/ui-cv/cv-fav/cv-fav.vue +150 -0
- package/ui-cv/cv-file-picker/cv-file-picker.vue +619 -0
- package/ui-cv/cv-form-item/cv-form-item.vue +1 -1
- package/ui-cv/cv-goods-nav/{uni-goods-nav.vue → cv-goods-nav.vue} +1 -1
- package/ui-cv/{cv-icons2/cv-icons2.vue → cv-icon2/cv-icon2.vue} +3 -3
- package/ui-cv/{cv-icons2 → cv-icon2}/icons.js +0 -0
- package/ui-cv/{cv-icons2 → cv-icon2}/uni.ttf +0 -0
- package/ui-cv/cv-indexed-list/cv-indexed-list-item.vue +154 -0
- package/ui-cv/cv-indexed-list/cv-indexed-list.vue +371 -0
- package/ui-cv/cv-input-password/cv-input-password.vue +2 -2
- package/ui-cv/{cv-link/uni-link.vue → cv-link2/cv-link2.vue} +1 -1
- package/ui-cv/cv-list/cv-list.vue +107 -0
- package/ui-cv/cv-list/cv-refresh.vue +65 -0
- package/ui-cv/cv-list-ad/cv-list-ad.vue +113 -0
- package/ui-cv/cv-list-chat/{uni-list-chat.scss → cv-list-chat.scss} +0 -0
- package/ui-cv/cv-list-chat/{uni-list-chat.vue → cv-list-chat.vue} +0 -0
- package/ui-cv/cv-list-item/cv-list-item.vue +449 -0
- package/ui-cv/cv-nav-bar/cv-nav-bar.vue +256 -0
- package/ui-cv/cv-nav-bar/{uni-status-bar.vue → cv-status-bar.vue} +0 -0
- package/ui-cv/cv-notice-bar/cv-notice-bar.vue +453 -0
- package/ui-cv/cv-number-box/cv-number-box.vue +223 -0
- package/ui-cv/cv-pagination/cv-pagination.vue +397 -0
- package/ui-cv/cv-popup/cv-popup.vue +429 -0
- package/ui-cv/cv-popup-dialog/{uni-popup-dialog.vue → cv-popup-dialog.vue} +0 -0
- package/ui-cv/cv-popup-message/cv-popup-message.vue +143 -0
- package/ui-cv/cv-popup-share/{uni-popup-share.vue → cv-popup-share.vue} +0 -0
- package/ui-cv/cv-row/{uni-row.vue → cv-row.vue} +1 -1
- package/ui-cv/cv-search-bar/cv-search-bar.vue +280 -0
- package/ui-cv/cv-section/{uni-section.vue → cv-section.vue} +0 -0
- package/ui-cv/cv-segmented-control/{uni-segmented-control.vue → cv-segmented-control.vue} +0 -0
- package/ui-cv/cv-status-bar/{uni-status-bar.vue → cv-status-bar.vue} +0 -0
- package/ui-cv/cv-steps/cv-steps.vue +293 -0
- package/ui-cv/cv-swipe-action/{uni-swipe-action.vue → cv-swipe-action.vue} +0 -0
- package/ui-cv/cv-swipe-action-item/{uni-swipe-action-item.vue → cv-swipe-action-item.vue} +0 -0
- package/ui-cv/cv-swiper-dot/cv-swiper-dot.vue +255 -0
- package/ui-cv/cv-table/cv-table.vue +460 -0
- package/ui-cv/cv-tag/cv-tag.vue +276 -0
- package/ui-cv/cv-tbody/cv-tbody.vue +28 -0
- package/ui-cv/cv-td/cv-td.vue +93 -0
- package/ui-cv/cv-test/{uni-test.vue → cv-test.vue} +0 -0
- package/ui-cv/cv-th/cv-th.vue +270 -0
- package/ui-cv/cv-thead/cv-thead.vue +114 -0
- package/ui-cv/cv-title/cv-title.vue +168 -0
- package/ui-cv/cv-tr/cv-tr.vue +166 -0
- package/ui-cv/cv-transition/cv-transition.vue +279 -0
- package/ui-cv/cv-calendar/uni-calendar-item.vue +0 -171
- package/ui-cv/cv-calendar/uni-calendar.vue +0 -504
- package/ui-cv/cv-card/uni-card.vue +0 -420
- package/ui-cv/cv-col/uni-col.vue +0 -2968
- package/ui-cv/cv-collapse/uni-collapse.vue +0 -146
- package/ui-cv/cv-collapse-item/uni-collapse-item.vue +0 -378
- package/ui-cv/cv-combox/uni-combox.vue +0 -237
- package/ui-cv/cv-countdown/uni-countdown.vue +0 -234
- package/ui-cv/cv-data-checkbox/uni-data-checkbox.vue +0 -792
- package/ui-cv/cv-data-indexed-list/uni-data-indexed-list-item.vue +0 -142
- package/ui-cv/cv-data-indexed-list/uni-data-indexed-list.vue +0 -364
- package/ui-cv/cv-data-picker/uni-data-picker.vue +0 -468
- package/ui-cv/cv-data-pickerview/uni-data-pickerview.vue +0 -298
- package/ui-cv/cv-dateformat/uni-dateformat.vue +0 -88
- package/ui-cv/cv-datetime-picker/uni-datetime-picker.vue +0 -874
- package/ui-cv/cv-easyinput/uni-easyinput.vue +0 -438
- package/ui-cv/cv-fab/uni-fab.vue +0 -443
- package/ui-cv/cv-fav/uni-fav.vue +0 -136
- package/ui-cv/cv-file-picker/uni-file-picker.vue +0 -614
- package/ui-cv/cv-indexed-list/uni-indexed-list-item.vue +0 -142
- package/ui-cv/cv-indexed-list/uni-indexed-list.vue +0 -357
- package/ui-cv/cv-list/uni-list.vue +0 -107
- package/ui-cv/cv-list/uni-refresh.vue +0 -65
- package/ui-cv/cv-list-ad/uni-list-ad.vue +0 -106
- package/ui-cv/cv-list-item/uni-list-item.vue +0 -428
- package/ui-cv/cv-nav-bar/uni-nav-bar.vue +0 -244
- package/ui-cv/cv-notice-bar/uni-notice-bar.vue +0 -394
- package/ui-cv/cv-number-box/uni-number-box.vue +0 -224
- package/ui-cv/cv-pagination/uni-pagination.vue +0 -376
- package/ui-cv/cv-popup/uni-popup.vue +0 -412
- package/ui-cv/cv-popup-message/uni-popup-message.vue +0 -143
- package/ui-cv/cv-search-bar/uni-search-bar.vue +0 -262
- package/ui-cv/cv-steps/uni-steps.vue +0 -250
- package/ui-cv/cv-swiper-dot/uni-swiper-dot.vue +0 -205
- package/ui-cv/cv-table/uni-table.vue +0 -455
- package/ui-cv/cv-tag/uni-tag.vue +0 -283
- package/ui-cv/cv-tbody/uni-tbody.vue +0 -30
- package/ui-cv/cv-td/uni-td.vue +0 -88
- package/ui-cv/cv-th/uni-th.vue +0 -259
- package/ui-cv/cv-thead/uni-thead.vue +0 -114
- package/ui-cv/cv-title/uni-title.vue +0 -171
- package/ui-cv/cv-tr/uni-tr.vue +0 -156
- package/ui-cv/cv-transition/uni-transition.vue +0 -287
|
@@ -0,0 +1,250 @@
|
|
|
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>
|
|
@@ -0,0 +1,245 @@
|
|
|
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>
|