const util = require('../../../utils/util.js')
Page({
  data: {
    fabulous: 123,
    isFabulous: false,
    isCollection: false,
    loadding: false,
    pullUpOn: true,
    left: 0,
    right: 10,
    bottom: 100,
    bgColor: "#5677fc",
    btnList: [],
    list: [{
      bgColor: "#16C2C2",
      //图标/图片地址
      imgUrl: "/static/images/fab/fab_about.png",
      //图片高度 rpx
      imgHeight: 64,
      //图片宽度 rpx
      imgWidth: 64,
      //名称
      text: "关于",
      //字体大小
      fontSize: 34,
      //字体颜色
      color: "#fff"
    }, {
      bgColor: "#64B532",
      //图标/图片地址
      imgUrl: "/static/images/fab/fab_share.png",
      //图片高度 rpx
      imgHeight: 64,
      //图片宽度 rpx
      imgWidth: 64,
      //名称
      text: "我要打卡",
      //字体大小
      fontSize: 34,
      //字体颜色
      color: "#fff"
    }, {
      bgColor: "#FFA000",
      //图标/图片地址
      imgUrl: "/static/images/fab/fab_reward.png",
      //图片高度 rpx
      imgHeight: 64,
      //图片宽度 rpx
      imgWidth: 64,
      //名称
      text: "赞赏",
      //字体大小
      fontSize: 34,
      //字体颜色
      color: "#fff"
    }],
    list2: [{
      bgColor: "#16C2C2",
      //名称
      text: "关于",
      //字体大小
      fontSize: 28,
      //字体颜色
      color: "#fff"
    }, {
      bgColor: "#64B532",
      //名称
      text: "分享",
      //字体大小
      fontSize: 28,
      //字体颜色
      color: "#fff"
    }, {
      bgColor: "#FFA000",
      //名称
      text: "赞赏",
      //字体大小
      fontSize: 28,
      //字体颜色
      color: "#fff"
    }]
  },
  onLoad: function (options) {
    this.setData({
      btnList: [...this.data.list]
    })
  },
  btnFabulous: function () {
    this.setData({
      fabulous: this.data.isFabulous ? 123 : 124,
      isFabulous: !this.data.isFabulous
    })
  },
  cmtFabulous: function (e) {
    let index = e.currentTarget.id;
    let fabulousObj = `cmtList[${index}].fabulous`;
    let isFabulousObj = `cmtList[${index}].isFabulous`;
    let isFabulous = this.data.cmtList[index].isFabulous;
    let fabulous = this.data.cmtList[index].fabulous;
    let fabulousNum = isFabulous ? fabulous - 1 : fabulous + 1;
    this.setData({
      [fabulousObj]: fabulousNum,
      [isFabulousObj]: !isFabulous
    })
  },
  onClick(e) {
    let index = e.detail.index
    switch (index) {
      case -1:
        util.toast("您点击了悬浮按钮")
        break;
      case 0:
        wx.navigateTo({
          url: "/pages/about/about"
        })
        break;
      case 1:
        wx.navigateTo({
          url: "/pages/spot/card/card"
        })
        break;
      case 2:
        wx.previewImage({
          urls: ["https://thorui.cn/img/reward.jpg"]
        })
        break;
      default:
        break;
    }
  },
})