zengh
2022-05-09 52c39f5e2711e5535b689b66dfa5e100c7882b7f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<template>
    <cover-view class="clock">
        <cover-view>{{hour}}:</cover-view>
        <cover-view>{{minute}}:</cover-view>
        <cover-view>{{second}}</cover-view>
    </cover-view>
</template>
 
<script>
    export default {
        data(){
            return {
                count: 0,
                hour:"00",
                minute:"00",
                second:"00",
                // totalCount:0,
                timer:null
            };
        },
        computed:{
            
        },
        props:{
            timeOrigin:{
                type:Number,
                default:0
            }
        },
        methods:{
            end(){
                this.is_show = false;
                clearInterval(this.timer);
                // this.$emit('clockend',this.totalCount);
            },
            showNum(num) {
                if (num < 10) {
                    return '0' + num
                }
                return num
            },
            start(){
                let _this = this;
                // let count = 0;
                _this.timer = setInterval(function(){
                    _this.count++;
                    _this.second = _this.showNum(_this.count % 60);
                    _this.hour = _this.showNum(parseInt(_this.count / 60 / 60));
                    _this.minute = _this.showNum(parseInt(_this.count / 60) % 60);
                    // _this.totalCount = _this.count;
                },1000);
                // this.is_show = true;
            }
        },
        onLoad() {
            this.count = this.timeOrigin
            // let _this = this;
            // // let count = 0;
            // _this.timer = setInterval(function(){
            //     _this.count++;
            //     _this.second = _this.showNum(_this.count % 60);
            //     _this.hour = _this.showNum(parseInt(_this.count / 60 / 60));
            //     _this.minute = _this.showNum(parseInt(_this.count / 60) % 60);
            //     // _this.totalCount = _this.count;
            // },1000);
            // this.is_show = true;
        },
        onReady() {
            // this.start()
            
        }
    }
</script>
 
<style lang="scss">
    .clock{
        display: flex;
    }
</style>