图片 倒计时
This commit is contained in:
parent
4faff9db61
commit
9c8f6b30ae
|
|
@ -494,6 +494,7 @@ See https://github.com/adobe-type-tools/cmap-resources
|
||||||
console.log('params:',params)
|
console.log('params:',params)
|
||||||
if (params > 0) {
|
if (params > 0) {
|
||||||
let minute = Math.floor(params / 60);
|
let minute = Math.floor(params / 60);
|
||||||
|
minute = String(minute).padStart(2, '0')
|
||||||
let second = params % 60;
|
let second = params % 60;
|
||||||
let time = minute + ':' + second;
|
let time = minute + ':' + second;
|
||||||
let interval = setInterval(() => {
|
let interval = setInterval(() => {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,9 @@
|
||||||
<template>
|
<template>
|
||||||
<view class="content">
|
<view class="content">
|
||||||
|
<div style="margin: 10px; color: #2979ff">
|
||||||
|
<span v-if="!isEnd">剩余学习时间:{{ time }}</span>
|
||||||
|
<span v-else>已完成学习</span>
|
||||||
|
</div>
|
||||||
<u--image :showLoading="true" :src="path" width="300px" height="600px" @click="handleImage"></u--image>
|
<u--image :showLoading="true" :src="path" width="300px" height="600px" @click="handleImage"></u--image>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -15,7 +19,8 @@ export default {
|
||||||
params: {},
|
params: {},
|
||||||
timer: null,
|
timer: null,
|
||||||
isEnd: false,
|
isEnd: false,
|
||||||
isShowImg: false
|
isShowImg: false,
|
||||||
|
time: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad(opt) {
|
onLoad(opt) {
|
||||||
|
|
@ -75,6 +80,10 @@ export default {
|
||||||
countDown() {
|
countDown() {
|
||||||
let allStudyDuration = Number(this.params.allStudyDuration) - Number(this.params.studyDuration)
|
let allStudyDuration = Number(this.params.allStudyDuration) - Number(this.params.studyDuration)
|
||||||
// let studyDuration = Number(this.params.studyDuration)
|
// let studyDuration = Number(this.params.studyDuration)
|
||||||
|
let minute = Math.floor(allStudyDuration / 60)
|
||||||
|
minute = String(minute).padStart(2, '0')
|
||||||
|
let second = allStudyDuration % 60
|
||||||
|
this.time = minute + ':' + second
|
||||||
this.timer = setInterval(() => {
|
this.timer = setInterval(() => {
|
||||||
allStudyDuration--
|
allStudyDuration--
|
||||||
this.params.studyDuration++
|
this.params.studyDuration++
|
||||||
|
|
@ -92,6 +101,25 @@ export default {
|
||||||
this.updStudyDuration()
|
this.updStudyDuration()
|
||||||
}, 1000)
|
}, 1000)
|
||||||
}
|
}
|
||||||
|
let arr = this.time.split(':')
|
||||||
|
let minute = parseInt(arr[0])
|
||||||
|
let second = parseInt(arr[1])
|
||||||
|
if (second == 0) {
|
||||||
|
minute -= 1
|
||||||
|
second = 59
|
||||||
|
if (minute < 10) {
|
||||||
|
minute = String(minute).padStart(2, '0')
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
second -= 1
|
||||||
|
if (minute < 10) {
|
||||||
|
minute = String(minute).padStart(2, '0')
|
||||||
|
}
|
||||||
|
if (second < 10) {
|
||||||
|
second = String(second).padStart(2, '0')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.time = minute + ':' + second
|
||||||
console.log('🚀 ~ countDown ~ 剩余时间-->:', allStudyDuration)
|
console.log('🚀 ~ countDown ~ 剩余时间-->:', allStudyDuration)
|
||||||
console.log('🚀 ~ countDown ~ this.params.studyDuration:', this.params.studyDuration)
|
console.log('🚀 ~ countDown ~ this.params.studyDuration:', this.params.studyDuration)
|
||||||
}, 1000)
|
}, 1000)
|
||||||
|
|
@ -148,6 +176,7 @@ export default {
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.content {
|
.content {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue