Component({
  data: {
    starCount: 0,
    forksCount: 0,
    visitTotal: 0,
  },
  methods: {
    onLoad(options) {
      let that = this;
      wx.showLoading({
        title: '数据加载中',
        mask: true,
      })
      let i = 0;
      numDH();
      function numDH() {
        if (i < 20) {
          setTimeout(function() {
            that.setData({
              visitTotal: i,
              forksCount: i,
              visitTotal: i
            })
            i++
            numDH();
          }, 20)
        } else {
          that.setData({
            starCount: that.coutNum(999),
            forksCount: that.coutNum(8888),
            visitTotal: that.coutNum(77777)
          })
        }
      }
      wx.hideLoading()
    },
    coutNum(e) {
      if (e > 1000 && e < 10000) {
        e = (e / 1000).toFixed(1) + 'k'
      }
      if (e > 10000) {
        e = (e / 10000).toFixed(1) + 'W'
      }
      return e
    },
    CopyLink(e) {
      wx.setClipboardData({
        data: e.currentTarget.dataset.link,
        success: res => {
          wx.showToast({
            title: '已复制',
            duration: 1000,
          })
        }
      })
    },
    showModal(e) {
      this.setData({
        modalName: e.currentTarget.dataset.target
      })
    },
    hideModal(e) {
      this.setData({
        modalName: null
      })
    },
    showQrcode() {
      wx.previewImage({
        urls: ['https://image.weilanwl.com/color2.0/zanCode.jpg'],
        current: 'https://image.weilanwl.com/color2.0/zanCode.jpg' // 当前显示图片的http链接      
      })
    },
  },
  pageLifetimes: {
    show() {
      if (typeof this.getTabBar === 'function' &&
        this.getTabBar()) {
        this.getTabBar().setData({
          selected: 3
        })
      }
    }
  }
})