@10yun/cv-mobile-ui 0.5.19 → 0.5.21
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/other/mpvue-picker/mpvuePicker.vue +402 -0
- package/{uni-ui/lib → other}/mpvue-picker/style.css +0 -1
- package/{uni-ui/lib → other}/tab-nvue/style.css +0 -1
- package/other/uParse/components/style.css +1 -0
- package/other/uParse/components/wxParseAudio.vue +1 -0
- package/other/uParse/components/wxParseImg.vue +86 -0
- package/other/uParse/components/wxParseTable.vue +54 -0
- package/other/uParse/components/wxParseTemplate0.vue +98 -0
- package/other/uParse/components/wxParseTemplate1.vue +81 -0
- package/other/uParse/components/wxParseTemplate10.vue +81 -0
- package/other/uParse/components/wxParseTemplate11.vue +79 -0
- package/other/uParse/components/wxParseTemplate2.vue +81 -0
- package/other/uParse/components/wxParseTemplate3.vue +81 -0
- package/other/uParse/components/wxParseTemplate4.vue +81 -0
- package/other/uParse/components/wxParseTemplate5.vue +81 -0
- package/other/uParse/components/wxParseTemplate6.vue +81 -0
- package/other/uParse/components/wxParseTemplate7.vue +81 -0
- package/other/uParse/components/wxParseTemplate8.vue +81 -0
- package/other/uParse/components/wxParseTemplate9.vue +81 -0
- package/other/uParse/components/wxParseVideo.vue +14 -0
- package/other/uParse/editor.css +495 -0
- package/{uni-ui/lib/uParse/src → other/uParse}/libs/html2json.js +19 -22
- package/{uni-ui/lib/uParse/src → other/uParse}/libs/htmlparser.js +12 -5
- package/{uni-ui/lib/uParse/src → other/uParse}/libs/wxDiscode.js +2 -2
- package/other/uParse/wxParse.vue +196 -0
- package/package.json +1 -1
- package/plugins/map/amqp-wx.js +173 -0
- package/{uni-ui/lib/mpvueGestureLock/index.vue → ui-cv/components/cv-draw-gesture-lock/cv-draw-gesture-lock.vue} +4 -1
- package/ui-cv/components/cv-draw-gesture-lock/gestureLock.js +169 -0
- package/{uni-ui/lib/mpvueGestureLock → ui-cv/components/cv-draw-gesture-lock}/style.css +0 -1
- package/{uni-ui/lib/mpvue-citypicker → ui-cv/components/cv-geo-region}/style.css +0 -1
- package/ui-cv/components/cv-grid-item/cv-grid-item.vue +1 -1
- package/uni-ui/lib/uni-badge/uni-badge.vue +150 -1
- package/uni-ui/lib/uni-breadcrumb/uni-breadcrumb.vue +37 -1
- package/uni-ui/lib/uni-breadcrumb-item/uni-breadcrumb-item.vue +83 -1
- package/uni-ui/lib/uni-calendar/uni-calendar-item.vue +122 -1
- package/uni-ui/lib/uni-calendar/uni-calendar.vue +366 -1
- package/uni-ui/lib/uni-card/uni-card.vue +124 -1
- package/uni-ui/lib/uni-col/uni-col.vue +1 -1
- package/uni-ui/lib/uni-collapse/uni-collapse.vue +135 -1
- package/uni-ui/lib/uni-collapse-item/uni-collapse-item.vue +266 -1
- package/uni-ui/lib/uni-combox/uni-combox.vue +1 -1
- package/uni-ui/lib/uni-countdown/uni-countdown.vue +239 -1
- package/uni-ui/lib/uni-data-checkbox/uni-data-checkbox.vue +487 -1
- package/uni-ui/lib/uni-data-picker/uni-data-picker.vue +530 -1
- package/uni-ui/lib/uni-data-pickerview/uni-data-picker.js +157 -150
- package/uni-ui/lib/uni-data-pickerview/uni-data-pickerview.vue +166 -1
- package/uni-ui/lib/uni-data-select/uni-data-select.vue +289 -1
- package/uni-ui/lib/uni-datetime-picker/calendar-item.vue +70 -1
- package/uni-ui/lib/uni-datetime-picker/calendar.vue +629 -1
- package/uni-ui/lib/uni-datetime-picker/time-picker.vue +741 -1
- package/uni-ui/lib/uni-datetime-picker/uni-datetime-picker.vue +847 -1
- package/uni-ui/lib/uni-drawer/uni-drawer.vue +115 -1
- package/uni-ui/lib/uni-easyinput/uni-easyinput.vue +515 -1
- package/uni-ui/lib/uni-fab/uni-fab.vue +257 -1
- package/uni-ui/lib/uni-fav/uni-fav.vue +123 -1
- package/uni-ui/lib/uni-file-picker/uni-file-picker.vue +642 -1
- package/uni-ui/lib/uni-file-picker/upload-file.vue +177 -1
- package/uni-ui/lib/uni-file-picker/upload-image.vue +176 -1
- package/uni-ui/lib/uni-forms/uni-forms.vue +375 -1
- package/uni-ui/lib/uni-forms-item/uni-forms-item.vue +429 -1
- package/uni-ui/lib/uni-goods-nav/uni-goods-nav.vue +129 -1
- package/uni-ui/lib/uni-grid/uni-grid.vue +115 -1
- package/uni-ui/lib/uni-grid-item/uni-grid-item.vue +78 -1
- package/uni-ui/lib/uni-group/uni-group.vue +85 -1
- package/uni-ui/lib/uni-icons/uni-icons.vue +85 -1
- package/uni-ui/lib/uni-indexed-list/uni-indexed-list-item.vue +68 -1
- package/uni-ui/lib/uni-indexed-list/uni-indexed-list.vue +294 -1
- package/uni-ui/lib/uni-list/uni-list.vue +81 -1
- package/uni-ui/lib/uni-list-ad/uni-list-ad.vue +77 -1
- package/uni-ui/lib/uni-list-chat/uni-list-chat.vue +294 -1
- package/uni-ui/lib/uni-list-item/uni-list-item.vue +346 -1
- package/uni-ui/lib/uni-load-more/uni-load-more.vue +172 -1
- package/uni-ui/lib/uni-nav-bar/uni-nav-bar.vue +205 -1
- package/uni-ui/lib/uni-nav-bar/uni-status-bar.vue +18 -1
- package/uni-ui/lib/uni-notice-bar/uni-notice-bar.vue +331 -1
- package/uni-ui/lib/uni-number-box/uni-number-box.vue +166 -1
- package/uni-ui/lib/uni-pagination/uni-pagination.vue +323 -1
- package/uni-ui/lib/uni-popup/uni-popup.vue +1 -1
- package/uni-ui/lib/uni-popup-dialog/uni-popup-dialog.vue +173 -1
- package/uni-ui/lib/uni-popup-message/uni-popup-message.vue +74 -1
- package/uni-ui/lib/uni-popup-share/uni-popup-share.vue +106 -1
- package/uni-ui/lib/uni-rate/uni-rate.vue +322 -1
- package/uni-ui/lib/uni-row/uni-row.vue +1 -1
- package/uni-ui/lib/uni-search-bar/uni-search-bar.vue +236 -1
- package/uni-ui/lib/uni-section/uni-section.vue +109 -1
- package/uni-ui/lib/uni-segmented-control/uni-segmented-control.vue +103 -1
- package/uni-ui/lib/uni-status-bar/uni-status-bar.vue +1 -1
- package/uni-ui/lib/uni-steps/uni-steps.vue +120 -1
- package/uni-ui/lib/uni-swipe-action-item/uni-swipe-action-item.vue +226 -3
- package/uni-ui/lib/uni-swiper-dot/uni-swiper-dot.vue +167 -1
- package/uni-ui/lib/uni-table/uni-table.vue +297 -1
- package/uni-ui/lib/uni-tag/uni-tag.vue +100 -1
- package/uni-ui/lib/uni-td/uni-td.vue +78 -1
- package/uni-ui/lib/uni-th/filter-dropdown.vue +1 -1
- package/uni-ui/lib/uni-th/uni-th.vue +224 -1
- package/uni-ui/lib/uni-thead/uni-thead.vue +77 -1
- package/uni-ui/lib/uni-tr/table-checkbox.vue +79 -1
- package/uni-ui/lib/uni-tr/uni-tr.vue +135 -1
- package/uni-ui/lib/amap-wx/js/util.js +0 -181
- package/uni-ui/lib/marked/index.js +0 -1
- package/uni-ui/lib/mpvue-citypicker/city-data/area.js +0 -12542
- package/uni-ui/lib/mpvue-citypicker/city-data/city.js +0 -1503
- package/uni-ui/lib/mpvue-citypicker/city-data/province.js +0 -139
- package/uni-ui/lib/mpvue-picker/mpvuePicker.vue +0 -3
- package/uni-ui/lib/mpvueGestureLock/gestureLock.js +0 -175
- package/uni-ui/lib/uParse/src/components/style.css +0 -2
- package/uni-ui/lib/uParse/src/components/wxParseAudio.vue +0 -1
- package/uni-ui/lib/uParse/src/components/wxParseImg.vue +0 -1
- package/uni-ui/lib/uParse/src/components/wxParseTable.vue +0 -3
- package/uni-ui/lib/uParse/src/components/wxParseTemplate0.vue +0 -1
- package/uni-ui/lib/uParse/src/components/wxParseTemplate1.vue +0 -1
- package/uni-ui/lib/uParse/src/components/wxParseTemplate10.vue +0 -1
- package/uni-ui/lib/uParse/src/components/wxParseTemplate11.vue +0 -1
- package/uni-ui/lib/uParse/src/components/wxParseTemplate2.vue +0 -1
- package/uni-ui/lib/uParse/src/components/wxParseTemplate3.vue +0 -1
- package/uni-ui/lib/uParse/src/components/wxParseTemplate4.vue +0 -1
- package/uni-ui/lib/uParse/src/components/wxParseTemplate5.vue +0 -1
- package/uni-ui/lib/uParse/src/components/wxParseTemplate6.vue +0 -1
- package/uni-ui/lib/uParse/src/components/wxParseTemplate7.vue +0 -1
- package/uni-ui/lib/uParse/src/components/wxParseTemplate8.vue +0 -1
- package/uni-ui/lib/uParse/src/components/wxParseTemplate9.vue +0 -1
- package/uni-ui/lib/uParse/src/components/wxParseVideo.vue +0 -1
- package/uni-ui/lib/uParse/src/editor.css +0 -495
- package/uni-ui/lib/uParse/src/wxParse.vue +0 -1
- /package/{uni-ui/lib → other}/api-set-tabbar.nvue +0 -0
- /package/{uni-ui/lib → other}/mpvue-echarts/src/echarts.vue +0 -0
- /package/{uni-ui/lib → other}/mpvue-echarts/src/style.css +0 -0
- /package/{uni-ui/lib → other}/mpvue-echarts/src/wx-canvas.js +0 -0
- /package/{uni-ui/lib → other}/product.vue +0 -0
- /package/{uni-ui/lib → other}/style.css +0 -0
- /package/{uni-ui/lib → other}/tab-nvue/mediaList.vue +0 -0
- /package/{uni-ui/lib → other}/u-charts/u-charts.js +0 -0
- /package/{uni-ui/lib/uParse/src → other/uParse}/wxParse.css +0 -0
- /package/{uni-ui/lib/amap-wx → plugins/map}/lib/amap-wx.js +0 -0
- /package/{uni-ui/lib/mpvue-citypicker → ui-cv/components/cv-geo-region}/mpvueCityPicker.vue +0 -0
- /package/{uni-ui/lib/marked → ui-cv/components/cv-markdown-show}/lib/marked.js +0 -0
|
@@ -1 +1,239 @@
|
|
|
1
|
-
<template>
|
|
2
1
|
<view class="uni-countdown">
|
|
3
2
|
<text v-if="showDay" :style="[timeStyle]" class="uni-countdown__number">{{ d }}</text>
|
|
4
3
|
<text v-if="showDay" :style="[splitorStyle]" class="uni-countdown__splitor">{{ dayText }}</text>
|
|
5
4
|
<text :style="[timeStyle]" class="uni-countdown__number">{{ h }}</text>
|
|
6
5
|
<text :style="[splitorStyle]" class="uni-countdown__splitor">{{ showColon ? ':' : hourText }}</text>
|
|
7
6
|
<text :style="[timeStyle]" class="uni-countdown__number">{{ i }}</text>
|
|
8
7
|
<text :style="[splitorStyle]" class="uni-countdown__splitor">{{ showColon ? ':' : minuteText }}</text>
|
|
9
8
|
<text :style="[timeStyle]" class="uni-countdown__number">{{ s }}</text>
|
|
10
9
|
<text v-if="!showColon" :style="[splitorStyle]" class="uni-countdown__splitor">{{ secondText }}</text>
|
|
11
10
|
</view>
|
|
12
11
|
* Countdown 倒计时
|
|
13
12
|
* @description 倒计时组件
|
|
14
13
|
* @tutorial https://ext.dcloud.net.cn/plugin?id=25
|
|
15
14
|
* @property {String} backgroundColor 背景色
|
|
16
15
|
* @property {String} color 文字颜色
|
|
17
16
|
* @property {Number} day 天数
|
|
18
17
|
* @property {Number} hour 小时
|
|
19
18
|
* @property {Number} minute 分钟
|
|
20
19
|
* @property {Number} second 秒
|
|
21
20
|
* @property {Number} timestamp 时间戳
|
|
22
21
|
* @property {Boolean} showDay = [true|false] 是否显示天数
|
|
23
22
|
* @property {Boolean} show-colon = [true|false] 是否以冒号为分隔符
|
|
24
23
|
* @property {String} splitorColor 分割符号颜色
|
|
25
24
|
* @event {Function} timeup 倒计时时间到触发事件
|
|
26
25
|
* @example <uni-countdown :day="1" :hour="1" :minute="12" :second="40"></uni-countdown>
|
|
27
26
|
*/
|
|
28
27
|
name: 'UniCountdown',
|
|
29
28
|
emits: ['timeup'],
|
|
30
29
|
props: {
|
|
31
30
|
showDay: {
|
|
32
31
|
type: Boolean,
|
|
33
32
|
default: true
|
|
34
33
|
},
|
|
35
34
|
showColon: {
|
|
36
35
|
type: Boolean,
|
|
37
36
|
default: true
|
|
38
37
|
},
|
|
39
38
|
start: {
|
|
40
39
|
type: Boolean,
|
|
41
40
|
default: true
|
|
42
41
|
},
|
|
43
42
|
backgroundColor: {
|
|
44
43
|
type: String,
|
|
45
44
|
default: ''
|
|
46
45
|
},
|
|
47
46
|
color: {
|
|
48
47
|
type: String,
|
|
49
48
|
default: '#333'
|
|
50
49
|
},
|
|
51
50
|
fontSize: {
|
|
52
51
|
type: Number,
|
|
53
52
|
default: 14
|
|
54
53
|
},
|
|
55
54
|
splitorColor: {
|
|
56
55
|
type: String,
|
|
57
56
|
default: '#333'
|
|
58
57
|
},
|
|
59
58
|
day: {
|
|
60
59
|
type: Number,
|
|
61
60
|
default: 0
|
|
62
61
|
},
|
|
63
62
|
hour: {
|
|
64
63
|
type: Number,
|
|
65
64
|
default: 0
|
|
66
65
|
},
|
|
67
66
|
minute: {
|
|
68
67
|
type: Number,
|
|
69
68
|
default: 0
|
|
70
69
|
},
|
|
71
70
|
second: {
|
|
72
71
|
type: Number,
|
|
73
72
|
default: 0
|
|
74
73
|
},
|
|
75
74
|
timestamp: {
|
|
76
75
|
type: Number,
|
|
77
76
|
default: 0
|
|
78
77
|
},
|
|
79
78
|
zeroPad: {
|
|
80
79
|
type: Boolean,
|
|
81
80
|
default: true
|
|
82
81
|
}
|
|
83
82
|
},
|
|
84
83
|
data() {
|
|
85
84
|
return {
|
|
86
85
|
timer: null,
|
|
87
86
|
syncFlag: false,
|
|
88
87
|
d: '00',
|
|
89
88
|
h: '00',
|
|
90
89
|
i: '00',
|
|
91
90
|
s: '00',
|
|
92
91
|
leftTime: 0,
|
|
93
92
|
seconds: 0
|
|
94
93
|
};
|
|
95
94
|
},
|
|
96
95
|
computed: {
|
|
97
96
|
dayText() {
|
|
98
97
|
return t('uni-countdown.day');
|
|
99
98
|
},
|
|
100
99
|
hourText(val) {
|
|
101
100
|
return t('uni-countdown.h');
|
|
102
101
|
},
|
|
103
102
|
minuteText(val) {
|
|
104
103
|
return t('uni-countdown.m');
|
|
105
104
|
},
|
|
106
105
|
secondText(val) {
|
|
107
106
|
return t('uni-countdown.s');
|
|
108
107
|
},
|
|
109
108
|
timeStyle() {
|
|
110
109
|
const { color, backgroundColor, fontSize } = this;
|
|
111
110
|
return {
|
|
112
111
|
color,
|
|
113
112
|
backgroundColor,
|
|
114
113
|
fontSize: `${fontSize}px`,
|
|
115
114
|
width: `${(fontSize * 22) / 14}px`, // 按字体大小为 14px 时的比例缩放
|
|
116
115
|
lineHeight: `${(fontSize * 20) / 14}px`,
|
|
117
116
|
borderRadius: `${(fontSize * 3) / 14}px`
|
|
118
117
|
};
|
|
119
118
|
},
|
|
120
119
|
splitorStyle() {
|
|
121
120
|
const { splitorColor, fontSize, backgroundColor } = this;
|
|
122
121
|
return {
|
|
123
122
|
color: splitorColor,
|
|
124
123
|
fontSize: `${(fontSize * 12) / 14}px`,
|
|
125
124
|
margin: backgroundColor ? `${(fontSize * 4) / 14}px` : ''
|
|
126
125
|
};
|
|
127
126
|
}
|
|
128
127
|
},
|
|
129
128
|
watch: {
|
|
130
129
|
day(val) {
|
|
131
130
|
this.changeFlag();
|
|
132
131
|
},
|
|
133
132
|
hour(val) {
|
|
134
133
|
this.changeFlag();
|
|
135
134
|
},
|
|
136
135
|
minute(val) {
|
|
137
136
|
this.changeFlag();
|
|
138
137
|
},
|
|
139
138
|
second(val) {
|
|
140
139
|
this.changeFlag();
|
|
141
140
|
},
|
|
142
141
|
start: {
|
|
143
142
|
immediate: true,
|
|
144
143
|
handler(newVal, oldVal) {
|
|
145
144
|
if (newVal) {
|
|
146
145
|
this.startData();
|
|
147
146
|
} else {
|
|
148
147
|
if (!oldVal) return;
|
|
149
148
|
clearInterval(this.timer);
|
|
150
149
|
}
|
|
151
150
|
}
|
|
152
151
|
}
|
|
153
152
|
},
|
|
154
153
|
created: function (e) {
|
|
155
154
|
this.seconds = this.toSeconds(this.timestamp, this.day, this.hour, this.minute, this.second);
|
|
156
155
|
this.countDown();
|
|
157
156
|
},
|
|
158
157
|
// #ifndef VUE3
|
|
159
158
|
destroyed() {
|
|
160
159
|
clearInterval(this.timer);
|
|
161
160
|
},
|
|
162
161
|
// #endif
|
|
163
162
|
// #ifdef VUE3
|
|
164
163
|
unmounted() {
|
|
165
164
|
clearInterval(this.timer);
|
|
166
165
|
},
|
|
167
166
|
// #endif
|
|
168
167
|
methods: {
|
|
169
168
|
toSeconds(timestamp, day, hours, minutes, seconds) {
|
|
170
169
|
if (timestamp) {
|
|
171
170
|
return timestamp - parseInt(new Date().getTime() / 1000, 10);
|
|
172
171
|
}
|
|
173
172
|
return day * 60 * 60 * 24 + hours * 60 * 60 + minutes * 60 + seconds;
|
|
174
173
|
},
|
|
175
174
|
timeUp() {
|
|
176
175
|
clearInterval(this.timer);
|
|
177
176
|
this.$emit('timeup');
|
|
178
177
|
},
|
|
179
178
|
countDown() {
|
|
180
179
|
let seconds = this.seconds;
|
|
181
180
|
let [day, hour, minute, second] = [0, 0, 0, 0];
|
|
182
181
|
if (seconds > 0) {
|
|
183
182
|
day = Math.floor(seconds / (60 * 60 * 24));
|
|
184
183
|
hour = Math.floor(seconds / (60 * 60)) - day * 24;
|
|
185
184
|
minute = Math.floor(seconds / 60) - day * 24 * 60 - hour * 60;
|
|
186
185
|
second = Math.floor(seconds) - day * 24 * 60 * 60 - hour * 60 * 60 - minute * 60;
|
|
187
186
|
} else {
|
|
188
187
|
this.timeUp();
|
|
189
188
|
}
|
|
190
189
|
day = day < 10 && this.zeroPad ? `0${day}` : day;
|
|
191
190
|
hour = hour < 10 && this.zeroPad ? `0${hour}` : hour;
|
|
192
191
|
minute = minute < 10 && this.zeroPad ? `0${minute}` : minute;
|
|
193
192
|
second = second < 10 && this.zeroPad ? `0${second}` : second;
|
|
194
193
|
this.d = day;
|
|
195
194
|
this.h = hour;
|
|
196
195
|
this.i = minute;
|
|
197
196
|
this.s = second;
|
|
198
197
|
},
|
|
199
198
|
startData() {
|
|
200
199
|
this.seconds = this.toSeconds(this.timestamp, this.day, this.hour, this.minute, this.second);
|
|
201
200
|
if (this.seconds <= 0) {
|
|
202
201
|
this.seconds = this.toSeconds(0, 0, 0, 0, 0);
|
|
203
202
|
this.countDown();
|
|
204
203
|
return;
|
|
205
204
|
}
|
|
206
205
|
clearInterval(this.timer);
|
|
207
206
|
this.countDown();
|
|
208
207
|
this.timer = setInterval(() => {
|
|
209
208
|
this.seconds--;
|
|
210
209
|
if (this.seconds < 0) {
|
|
211
210
|
this.timeUp();
|
|
212
211
|
return;
|
|
213
212
|
}
|
|
214
213
|
this.countDown();
|
|
215
214
|
}, 1000);
|
|
216
215
|
},
|
|
217
216
|
update() {
|
|
218
217
|
this.startData();
|
|
219
218
|
},
|
|
220
219
|
changeFlag() {
|
|
221
220
|
if (!this.syncFlag) {
|
|
222
221
|
this.seconds = this.toSeconds(this.timestamp, this.day, this.hour, this.minute, this.second);
|
|
223
222
|
this.startData();
|
|
224
223
|
this.syncFlag = true;
|
|
225
224
|
}
|
|
226
225
|
}
|
|
227
226
|
}
|
|
227
|
+
<template>
|
|
228
|
+
<view class="uni-countdown">
|
|
229
|
+
<text v-if="showDay" :style="[timeStyle]" class="uni-countdown__number">{{ d }}</text>
|
|
230
|
+
<text v-if="showDay" :style="[splitorStyle]" class="uni-countdown__splitor">{{ dayText }}</text>
|
|
231
|
+
<text :style="[timeStyle]" class="uni-countdown__number">{{ h }}</text>
|
|
232
|
+
<text :style="[splitorStyle]" class="uni-countdown__splitor">{{ showColon ? ':' : hourText }}</text>
|
|
233
|
+
<text :style="[timeStyle]" class="uni-countdown__number">{{ i }}</text>
|
|
234
|
+
<text :style="[splitorStyle]" class="uni-countdown__splitor">{{ showColon ? ':' : minuteText }}</text>
|
|
235
|
+
<text :style="[timeStyle]" class="uni-countdown__number">{{ s }}</text>
|
|
236
|
+
<text v-if="!showColon" :style="[splitorStyle]" class="uni-countdown__splitor">{{ secondText }}</text>
|
|
237
|
+
</view>
|
|
238
|
+
</template>
|
|
239
|
+
<script>
|
|
240
|
+
import { initVueI18n } from '@dcloudio/uni-i18n';
|
|
241
|
+
import messages from './i18n/index.js';
|
|
242
|
+
const { t } = initVueI18n(messages);
|
|
243
|
+
/**
|
|
244
|
+
* Countdown 倒计时
|
|
245
|
+
* @description 倒计时组件
|
|
246
|
+
* @tutorial https://ext.dcloud.net.cn/plugin?id=25
|
|
247
|
+
* @property {String} backgroundColor 背景色
|
|
248
|
+
* @property {String} color 文字颜色
|
|
249
|
+
* @property {Number} day 天数
|
|
250
|
+
* @property {Number} hour 小时
|
|
251
|
+
* @property {Number} minute 分钟
|
|
252
|
+
* @property {Number} second 秒
|
|
253
|
+
* @property {Number} timestamp 时间戳
|
|
254
|
+
* @property {Boolean} showDay = [true|false] 是否显示天数
|
|
255
|
+
* @property {Boolean} show-colon = [true|false] 是否以冒号为分隔符
|
|
256
|
+
* @property {String} splitorColor 分割符号颜色
|
|
257
|
+
* @event {Function} timeup 倒计时时间到触发事件
|
|
258
|
+
* @example <uni-countdown :day="1" :hour="1" :minute="12" :second="40"></uni-countdown>
|
|
259
|
+
*/
|
|
260
|
+
export default {
|
|
261
|
+
name: 'UniCountdown',
|
|
262
|
+
emits: ['timeup'],
|
|
263
|
+
props: {
|
|
264
|
+
showDay: {
|
|
265
|
+
type: Boolean,
|
|
266
|
+
default: true
|
|
267
|
+
},
|
|
268
|
+
showColon: {
|
|
269
|
+
type: Boolean,
|
|
270
|
+
default: true
|
|
271
|
+
},
|
|
272
|
+
start: {
|
|
273
|
+
type: Boolean,
|
|
274
|
+
default: true
|
|
275
|
+
},
|
|
276
|
+
backgroundColor: {
|
|
277
|
+
type: String,
|
|
278
|
+
default: ''
|
|
279
|
+
},
|
|
280
|
+
color: {
|
|
281
|
+
type: String,
|
|
282
|
+
default: '#333'
|
|
283
|
+
},
|
|
284
|
+
fontSize: {
|
|
285
|
+
type: Number,
|
|
286
|
+
default: 14
|
|
287
|
+
},
|
|
288
|
+
splitorColor: {
|
|
289
|
+
type: String,
|
|
290
|
+
default: '#333'
|
|
291
|
+
},
|
|
292
|
+
day: {
|
|
293
|
+
type: Number,
|
|
294
|
+
default: 0
|
|
295
|
+
},
|
|
296
|
+
hour: {
|
|
297
|
+
type: Number,
|
|
298
|
+
default: 0
|
|
299
|
+
},
|
|
300
|
+
minute: {
|
|
301
|
+
type: Number,
|
|
302
|
+
default: 0
|
|
303
|
+
},
|
|
304
|
+
second: {
|
|
305
|
+
type: Number,
|
|
306
|
+
default: 0
|
|
307
|
+
},
|
|
308
|
+
timestamp: {
|
|
309
|
+
type: Number,
|
|
310
|
+
default: 0
|
|
311
|
+
},
|
|
312
|
+
zeroPad: {
|
|
313
|
+
type: Boolean,
|
|
314
|
+
default: true
|
|
315
|
+
}
|
|
316
|
+
},
|
|
317
|
+
data() {
|
|
318
|
+
return {
|
|
319
|
+
timer: null,
|
|
320
|
+
syncFlag: false,
|
|
321
|
+
d: '00',
|
|
322
|
+
h: '00',
|
|
323
|
+
i: '00',
|
|
324
|
+
s: '00',
|
|
325
|
+
leftTime: 0,
|
|
326
|
+
seconds: 0
|
|
327
|
+
};
|
|
328
|
+
},
|
|
329
|
+
computed: {
|
|
330
|
+
dayText() {
|
|
331
|
+
return t('uni-countdown.day');
|
|
332
|
+
},
|
|
333
|
+
hourText(val) {
|
|
334
|
+
return t('uni-countdown.h');
|
|
335
|
+
},
|
|
336
|
+
minuteText(val) {
|
|
337
|
+
return t('uni-countdown.m');
|
|
338
|
+
},
|
|
339
|
+
secondText(val) {
|
|
340
|
+
return t('uni-countdown.s');
|
|
341
|
+
},
|
|
342
|
+
timeStyle() {
|
|
343
|
+
const { color, backgroundColor, fontSize } = this;
|
|
344
|
+
return {
|
|
345
|
+
color,
|
|
346
|
+
backgroundColor,
|
|
347
|
+
fontSize: `${fontSize}px`,
|
|
348
|
+
width: `${(fontSize * 22) / 14}px`, // 按字体大小为 14px 时的比例缩放
|
|
349
|
+
lineHeight: `${(fontSize * 20) / 14}px`,
|
|
350
|
+
borderRadius: `${(fontSize * 3) / 14}px`
|
|
351
|
+
};
|
|
352
|
+
},
|
|
353
|
+
splitorStyle() {
|
|
354
|
+
const { splitorColor, fontSize, backgroundColor } = this;
|
|
355
|
+
return {
|
|
356
|
+
color: splitorColor,
|
|
357
|
+
fontSize: `${(fontSize * 12) / 14}px`,
|
|
358
|
+
margin: backgroundColor ? `${(fontSize * 4) / 14}px` : ''
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
},
|
|
362
|
+
watch: {
|
|
363
|
+
day(val) {
|
|
364
|
+
this.changeFlag();
|
|
365
|
+
},
|
|
366
|
+
hour(val) {
|
|
367
|
+
this.changeFlag();
|
|
368
|
+
},
|
|
369
|
+
minute(val) {
|
|
370
|
+
this.changeFlag();
|
|
371
|
+
},
|
|
372
|
+
second(val) {
|
|
373
|
+
this.changeFlag();
|
|
374
|
+
},
|
|
375
|
+
start: {
|
|
376
|
+
immediate: true,
|
|
377
|
+
handler(newVal, oldVal) {
|
|
378
|
+
if (newVal) {
|
|
379
|
+
this.startData();
|
|
380
|
+
} else {
|
|
381
|
+
if (!oldVal) return;
|
|
382
|
+
clearInterval(this.timer);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
},
|
|
387
|
+
created: function (e) {
|
|
388
|
+
this.seconds = this.toSeconds(this.timestamp, this.day, this.hour, this.minute, this.second);
|
|
389
|
+
this.countDown();
|
|
390
|
+
},
|
|
391
|
+
// #ifndef VUE3
|
|
392
|
+
destroyed() {
|
|
393
|
+
clearInterval(this.timer);
|
|
394
|
+
},
|
|
395
|
+
// #endif
|
|
396
|
+
// #ifdef VUE3
|
|
397
|
+
unmounted() {
|
|
398
|
+
clearInterval(this.timer);
|
|
399
|
+
},
|
|
400
|
+
// #endif
|
|
401
|
+
methods: {
|
|
402
|
+
toSeconds(timestamp, day, hours, minutes, seconds) {
|
|
403
|
+
if (timestamp) {
|
|
404
|
+
return timestamp - parseInt(new Date().getTime() / 1000, 10);
|
|
405
|
+
}
|
|
406
|
+
return day * 60 * 60 * 24 + hours * 60 * 60 + minutes * 60 + seconds;
|
|
407
|
+
},
|
|
408
|
+
timeUp() {
|
|
409
|
+
clearInterval(this.timer);
|
|
410
|
+
this.$emit('timeup');
|
|
411
|
+
},
|
|
412
|
+
countDown() {
|
|
413
|
+
let seconds = this.seconds;
|
|
414
|
+
let [day, hour, minute, second] = [0, 0, 0, 0];
|
|
415
|
+
if (seconds > 0) {
|
|
416
|
+
day = Math.floor(seconds / (60 * 60 * 24));
|
|
417
|
+
hour = Math.floor(seconds / (60 * 60)) - day * 24;
|
|
418
|
+
minute = Math.floor(seconds / 60) - day * 24 * 60 - hour * 60;
|
|
419
|
+
second = Math.floor(seconds) - day * 24 * 60 * 60 - hour * 60 * 60 - minute * 60;
|
|
420
|
+
} else {
|
|
421
|
+
this.timeUp();
|
|
422
|
+
}
|
|
423
|
+
day = day < 10 && this.zeroPad ? `0${day}` : day;
|
|
424
|
+
hour = hour < 10 && this.zeroPad ? `0${hour}` : hour;
|
|
425
|
+
minute = minute < 10 && this.zeroPad ? `0${minute}` : minute;
|
|
426
|
+
second = second < 10 && this.zeroPad ? `0${second}` : second;
|
|
427
|
+
this.d = day;
|
|
428
|
+
this.h = hour;
|
|
429
|
+
this.i = minute;
|
|
430
|
+
this.s = second;
|
|
431
|
+
},
|
|
432
|
+
startData() {
|
|
433
|
+
this.seconds = this.toSeconds(this.timestamp, this.day, this.hour, this.minute, this.second);
|
|
434
|
+
if (this.seconds <= 0) {
|
|
435
|
+
this.seconds = this.toSeconds(0, 0, 0, 0, 0);
|
|
436
|
+
this.countDown();
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
clearInterval(this.timer);
|
|
440
|
+
this.countDown();
|
|
441
|
+
this.timer = setInterval(() => {
|
|
442
|
+
this.seconds--;
|
|
443
|
+
if (this.seconds < 0) {
|
|
444
|
+
this.timeUp();
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
this.countDown();
|
|
448
|
+
}, 1000);
|
|
449
|
+
},
|
|
450
|
+
update() {
|
|
451
|
+
this.startData();
|
|
452
|
+
},
|
|
453
|
+
changeFlag() {
|
|
454
|
+
if (!this.syncFlag) {
|
|
455
|
+
this.seconds = this.toSeconds(this.timestamp, this.day, this.hour, this.minute, this.second);
|
|
456
|
+
this.startData();
|
|
457
|
+
this.syncFlag = true;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
};
|
|
462
|
+
</script>
|
|
463
|
+
<style scoped>
|
|
464
|
+
@import 'style.css';
|
|
465
|
+
</style>
|