倒计时

发布于 3 年前作者 yang764750 次浏览最后编辑 3 年前来自 share

<view class="">

    <text class="">{{ d }}</text>

    <text class=""></text>

    <text class="">{{ h }}</text>

    <text class=""></text>

    <text class="">{{ i }}</text>

    <text class=""></text>

    <text class="">{{ s }}</text>

    <text class=""></text>

</view>

Page({

    /**

     * 组件的初始数据

     */

    data: {

expire_second: 12332423000,

        _timer: null,

        _syncFlag: false,

        d: '00',

        h: '00',

        i: '00',

        s: '00',

        _seconds: 0

    },

onLoad(){

if (this.data._timer{

                this.data._syncFlag = false;

                clearInterval(this.data._timer)

            }

            this.changeFlag()

},

    onHide() {

            if (this.data._timer{

                this.data._syncFlag = false;

                clearInterval(this.data._timer);

            }

    }

        timeUp() {

            this.data._syncFlag = false;

            clearInterval(this.data._timer)

        },

        countDown() {

            let seconds = this.data._seconds;

            let [day, hour, minute, second] = [0, 0, 0, 0]

            if (seconds > 0{

                day = Math.floor(seconds / (60 * 60 * 24))

                hour = Math.floor(seconds / (60 * 60)) - (day * 24)

                minute = Math.floor(seconds / 60- (day * 24 * 60- (hour * 60)

                second = Math.floor(seconds- (day * 24 * 60 * 60- (hour * 60 * 60- (minute * 60)

            } else {

                this.timeUp()

                return;

            }

            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.setData({

                d: day,

                h:

...

0 回复
暂无回复