<template>
  <div class="content">
    <div class="logout">
        <div class="tips">注销后账号不可恢复，是否确定注销</div>
        <van-button v-if="active == 1" round size="large" type="default">
            <van-count-down :time="time" @finish="finish">
                <template #default="timeData">
                    <span>确认({{ timeData.seconds }}s)</span>
                </template>
            </van-count-down>
        </van-button>
        <van-button v-else @click="initData" round color="rgb(243, 101, 74)" size="large">确认</van-button>
    </div>
  </div>
</template>

<script>
import Vue from 'vue';
import { Button,CountDown  } from 'vant';
import { logoutUser } from '@/api/cancellation'

Vue.use(Button)
    .use(CountDown);
export default {
    data() {
        return {
            active: 1,
            time: 5000,
        }
    },
    created() {
        console.log(this.$route);  
    },
    methods: {
        finish(){
            this.active = 2
        },
        // 注销
        initData(){
            logoutUser({ mobile:this.$route.params.mobile,code:this.$route.params.code,uid:this.$route.params.uid }).then((res) => {
                this.dataList = res
                console.log('00000',this.dataList);
                // 返回登陆页面
                if (window.android !== window.androidundefined) {
                    window.android.loginOut(); // 这是一个json字符串
                } else if (window.webkit) {
                    window.webkit && window.webkit.messageHandlers.loginOut.postMessage('loginOut');
                }
            })
            
        },    
    },
    
}
</script>

<style lang="stylus" scoped>
.logout{
    display flex;
    flex-direction column;
    justify-content center;
    align-items center;
    padding 4rem 1rem 0 1rem; 
    .tips{
        font-size: 1rem;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #333333;
        margin-bottom 3rem;
    }
}
</style>