<template>
<view class="count-down-box" v-if="show">
    <view class="mask">

    </view>
    <view class="box">
        <view class="title">
            <view>抢购的人数较多</view>
            <view>服务器拥挤</view>
        </view>
        <view class="img-box">
            <image mode="widthFix" src="https://ibrand-miniprogram.oss-cn-hangzhou.aliyuncs.com/%E5%B0%8F%E7%A8%8B%E5%BA%8F/time-bg.png" alt></image>
            <view class="num" :class="'num' + '-' + num">
                {{num}}
            </view>
            <view class="mountain">
                <image mode="widthFix" src="https://ibrand-miniprogram.oss-cn-hangzhou.aliyuncs.com/%E5%B0%8F%E7%A8%8B%E5%BA%8F/time-bg-mountain.png" alt></image>
            </view>
        </view>
        <view class="clone" @tap="close">
            X
        </view>
    </view>
</view>
</template>
<script>

export default {
  data() {
    return {
      interval: '',
      lodNum: ''
    };
  },

  components: {},
  props: {
	  
	    show: {
	    type: Boolean,
	    observer: '_change'
	  },
	  num: {
	    type: Number,
	    value: 10
	  }
  },
 
    methods: {
      close() {
        this.setData({
          num: this.data.lodNum,
          show: false
        });
        clearInterval(this.data.interval);
        this.$emit('endTen');
      },

      _change(newVal, oldVal) {// if (newVal) {
        // 	var interval = setInterval(() => {
        // 		var num = this.data.num;
        // 		num--
        // 		this.setData({
        // 			num: num
        // 		});
        // 		if (this.data.num == 0) {
        // 			this.close()
        // 		}
        // 	}, 1000);
        // 	this.setData({
        // 		interval: interval
        // 	})
        // }
      }

    },

    ready() {
      this.setData({
        lodNum: this.data.num
      });
    },

    setData: function (obj) {
      let that = this;
      let keys = [];
      let val, data;
      Object.keys(obj).forEach(function (key) {
        keys = key.split('.');
        val = obj[key];
        data = that.$data;
        keys.forEach(function (key2, index) {
          if (index + 1 == keys.length) {
            that.$set(data, key2, val);
          } else {
            if (!data[key2]) {
              that.$set(data, key2, {});
            }
          }

          data = data[key2];
        });
      });
    },
	
  computed: {},
  watch: {}
};
</script>
<style rel="stylesheet/less" lang="less">
    @import "ten";
</style>