no message
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
exports.messages = {
|
||||
en: {
|
||||
"uni-countdown.day": "day",
|
||||
"uni-countdown.h": "h",
|
||||
"uni-countdown.m": "m",
|
||||
"uni-countdown.s": "s",
|
||||
},
|
||||
"zh-Hans": {
|
||||
"uni-countdown.day": "天",
|
||||
"uni-countdown.h": "时",
|
||||
"uni-countdown.m": "分",
|
||||
"uni-countdown.s": "秒",
|
||||
},
|
||||
"zh-Hant": {
|
||||
"uni-countdown.day": "天",
|
||||
"uni-countdown.h": "時",
|
||||
"uni-countdown.m": "分",
|
||||
"uni-countdown.s": "秒",
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,203 @@
|
||||
var t = require("../../../../common/vendor.js"),
|
||||
i = require("./i18n/index.js"),
|
||||
e = t.initVueI18n(i.messages).t,
|
||||
n = {
|
||||
name: "UniCountdown",
|
||||
emits: ["timeup"],
|
||||
props: {
|
||||
showDay: { type: Boolean, default: !0 },
|
||||
showColon: { type: Boolean, default: !0 },
|
||||
start: { type: Boolean, default: !0 },
|
||||
backgroundColor: { type: String, default: "" },
|
||||
color: { type: String, default: "#333" },
|
||||
fontSize: { type: Number, default: 14 },
|
||||
splitorColor: { type: String, default: "#333" },
|
||||
day: { type: Number, default: 0 },
|
||||
hour: { type: Number, default: 0 },
|
||||
minute: { type: Number, default: 0 },
|
||||
second: { type: Number, default: 0 },
|
||||
milliSecond: { type: Number, default: 0 },
|
||||
timestamp: { type: Number, default: 0 },
|
||||
},
|
||||
data: function () {
|
||||
return {
|
||||
timer: null,
|
||||
syncFlag: !1,
|
||||
d: "00",
|
||||
h: "00",
|
||||
i: "00",
|
||||
s: "00",
|
||||
ms: "00",
|
||||
milliSeconds: 0,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
dayText: function () {
|
||||
return e("uni-countdown.day");
|
||||
},
|
||||
hourText: function (t) {
|
||||
return e("uni-countdown.h");
|
||||
},
|
||||
minuteText: function (t) {
|
||||
return e("uni-countdown.m");
|
||||
},
|
||||
secondText: function (t) {
|
||||
return e("uni-countdown.s");
|
||||
},
|
||||
timeStyle: function () {
|
||||
var t = this.color,
|
||||
i = this.backgroundColor,
|
||||
e = this.fontSize;
|
||||
return {
|
||||
color: t,
|
||||
backgroundColor: i,
|
||||
fontSize: "".concat(e, "rpx"),
|
||||
width: (22 * e) / 14 + "rpx",
|
||||
lineHeight: (20 * e) / 14 + "rpx",
|
||||
borderRadius: (3 * e) / 14 + "rpx",
|
||||
};
|
||||
},
|
||||
splitorStyle: function () {
|
||||
var t = this.splitorColor,
|
||||
i = this.fontSize;
|
||||
this.backgroundColor;
|
||||
return { color: t, fontSize: "".concat(i, "rpx") };
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
day: function (t) {
|
||||
this.changeFlag();
|
||||
},
|
||||
hour: function (t) {
|
||||
this.changeFlag();
|
||||
},
|
||||
minute: function (t) {
|
||||
this.changeFlag();
|
||||
},
|
||||
second: function (t) {
|
||||
this.changeFlag();
|
||||
},
|
||||
milliSecond: function (t) {
|
||||
this.changeFlag();
|
||||
},
|
||||
start: {
|
||||
immediate: !0,
|
||||
handler: function (t, i) {
|
||||
if (t) this.startData();
|
||||
else {
|
||||
if (!i) return;
|
||||
clearInterval(this.timer);
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
created: function (t) {
|
||||
(this.milliSeconds = this.toMilliSeconds(
|
||||
this.day,
|
||||
this.hour,
|
||||
this.minute,
|
||||
this.second,
|
||||
this.milliSecond
|
||||
)),
|
||||
this.countDown();
|
||||
},
|
||||
unmounted: function () {
|
||||
clearInterval(this.timer);
|
||||
},
|
||||
methods: {
|
||||
toMilliSeconds: function (t, i, e, n, o) {
|
||||
return (
|
||||
24 * t * 60 * 60 * 1e3 +
|
||||
60 * i * 60 * 1e3 +
|
||||
60 * e * 1e3 +
|
||||
1e3 * n +
|
||||
o
|
||||
);
|
||||
},
|
||||
timeUp: function () {
|
||||
clearInterval(this.timer), this.$emit("timeup");
|
||||
},
|
||||
countDown: function () {
|
||||
var t = this.milliSeconds,
|
||||
i = 0,
|
||||
e = 0,
|
||||
n = 0,
|
||||
o = 0,
|
||||
s = 0;
|
||||
t > 0
|
||||
? ((i = Math.floor(t / 864e5)),
|
||||
(e = Math.floor(t / 36e5) - 24 * i),
|
||||
(n = Math.floor(t / 6e4) - 24 * i * 60 - 60 * e),
|
||||
(o = Math.floor(t / 1e3) - 24 * i * 60 * 60 - 60 * e * 60 - 60 * n),
|
||||
(s = Math.floor(t) - 24 * i * 60 * 60 - 60 * e * 60 - 60 * n - o))
|
||||
: this.timeUp(),
|
||||
i < 10 && (i = "0" + i),
|
||||
e < 10 && (e = "0" + e),
|
||||
n < 10 && (n = "0" + n),
|
||||
o < 10 && (o = "0" + o),
|
||||
(s = s < 10 ? "0" + s : ((s % 1e3) / 10).toFixed(0)),
|
||||
(this.d = i),
|
||||
(this.h = e),
|
||||
(this.i = n),
|
||||
(this.s = o),
|
||||
(this.ms = s);
|
||||
},
|
||||
startData: function () {
|
||||
var t = this;
|
||||
if (
|
||||
((this.milliSeconds = this.toMilliSeconds(
|
||||
this.day,
|
||||
this.hour,
|
||||
this.minute,
|
||||
this.second,
|
||||
this.milliSecond
|
||||
)),
|
||||
this.milliSeconds <= 0)
|
||||
)
|
||||
return (
|
||||
(this.milliSeconds = this.toMilliSeconds(0, 0, 0, 0, 0)),
|
||||
void this.countDown()
|
||||
);
|
||||
clearInterval(this.timer),
|
||||
this.countDown(),
|
||||
(this.timer = setInterval(function () {
|
||||
(t.milliSeconds = t.milliSeconds - 10),
|
||||
t.milliSeconds < 0 ? t.timeUp() : t.countDown();
|
||||
}, 10));
|
||||
},
|
||||
update: function () {
|
||||
this.startData();
|
||||
},
|
||||
changeFlag: function () {
|
||||
this.syncFlag ||
|
||||
((this.milliSeconds = this.toSeconds(
|
||||
this.day,
|
||||
this.hour,
|
||||
this.minute,
|
||||
this.second,
|
||||
this.milliSecond
|
||||
)),
|
||||
this.startData(),
|
||||
(this.syncFlag = !0));
|
||||
},
|
||||
},
|
||||
},
|
||||
o = t._export_sfc(n, [
|
||||
[
|
||||
"render",
|
||||
function (i, e, n, o, s, r) {
|
||||
return {
|
||||
a: t.t(s.i),
|
||||
b: t.s(r.timeStyle),
|
||||
c: t.s(r.splitorStyle),
|
||||
d: t.t(s.s),
|
||||
e: t.s(r.timeStyle),
|
||||
f: t.s(r.splitorStyle),
|
||||
g: t.t(s.ms),
|
||||
h: t.s(r.timeStyle),
|
||||
};
|
||||
},
|
||||
],
|
||||
["__scopeId", "data-v-edf646b4"],
|
||||
]);
|
||||
wx.createComponent(o);
|
||||
@@ -0,0 +1 @@
|
||||
{ "component": true, "usingComponents": {} }
|
||||
@@ -0,0 +1,7 @@
|
||||
<view class="uni-countdown data-v-edf646b4">
|
||||
<text class="uni-countdown__number data-v-edf646b4" style="{{b}}">{{a}}</text>
|
||||
<text class="uni-countdown__splitor data-v-edf646b4" style="{{c}}">分</text>
|
||||
<text class="uni-countdown__number data-v-edf646b4" style="{{e}}">{{d}}</text>
|
||||
<text class="uni-countdown__splitor data-v-edf646b4" style="{{f}}">秒</text>
|
||||
<text class="uni-countdown__number data-v-edf646b4" style="{{h}}">{{g}}</text>
|
||||
</view>
|
||||
@@ -0,0 +1,17 @@
|
||||
.uni-countdown.data-v-edf646b4 {
|
||||
align-items: center;
|
||||
display: -webkit-flex;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
.uni-countdown__splitor.data-v-edf646b4 {
|
||||
color: #333;
|
||||
font-size: 14px;
|
||||
margin: 0 2px;
|
||||
}
|
||||
.uni-countdown__number.data-v-edf646b4 {
|
||||
border-radius: 3px;
|
||||
font-size: 14px;
|
||||
text-align: center;
|
||||
}
|
||||
Reference in New Issue
Block a user