Skip to content

Commit

Permalink
feat:uni-countdown支持控制显示位数
Browse files Browse the repository at this point in the history
  • Loading branch information
GRCmade committed Sep 3, 2024
1 parent 2c9c16b commit 24aa6a2
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
3 changes: 3 additions & 0 deletions pages/vue/countdown/countdown.nvue
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
</uni-section>
<uni-section title="动态赋值" type="line" padding>
<uni-countdown :show-day="false" :hour="testHour" :minute="testMinute" :second="testSecond" />
</uni-section>
<uni-section title="filterShow自由控制显示位数" sub-title="默认都是显示2位" type="line" padding>
<uni-countdown :filterShow="{d:1,h:1,m:2,s:2}" :day="1" :hour="8" :minute="12" :second="40" />
</uni-section>
</view>
</template>
Expand Down
2 changes: 2 additions & 0 deletions uni_modules/uni-countdown/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## 1.2.4 (2024-09-3)
- 新增 支持控制显示位数 默认显示2位
## 1.2.3(2024-02-20)
- 新增 支持控制小时,分钟的显隐:showHour showMinute
## 1.2.2(2022-01-19)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@
timestamp: {
type: Number,
default: 0
},
filterShow : {
type:Object,
default:{}
}
},
data() {
Expand Down Expand Up @@ -208,23 +212,14 @@
second = Math.floor(seconds) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60)
} else {
this.timeUp()
}
if (day < 10) {
day = '0' + day
}
if (hour < 10) {
hour = '0' + hour
}
if (minute < 10) {
minute = '0' + minute
}
if (second < 10) {
second = '0' + second
}
this.d = day
this.h = hour
this.i = minute
this.s = second
}
this.d = String(day).padStart(this.validFilterShow(this.filterShow.d), '0')
this.h = String(hour).padStart(this.validFilterShow(this.filterShow.h), '0')
this.i = String(minute).padStart(this.validFilterShow(this.filterShow.m), '0')
this.s = String(second).padStart(this.validFilterShow(this.filterShow.s), '0')
},
validFilterShow(filter){
return (filter && filter > 0) ? filter : 2;
},
startData() {
this.seconds = this.toSeconds(this.timestamp, this.day, this.hour, this.minute, this.second)
Expand Down
4 changes: 2 additions & 2 deletions uni_modules/uni-countdown/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "uni-countdown",
"displayName": "uni-countdown 倒计时",
"version": "1.2.3",
"version": "1.2.4",
"description": "CountDown 倒计时组件",
"keywords": [
"uni-ui",
Expand Down Expand Up @@ -80,4 +80,4 @@
}
}
}
}
}

0 comments on commit 24aa6a2

Please sign in to comment.