// packageH/turmaroundTime/turmaroundIndex/turmaroundIndex.js
const app = getApp();
// import util from "../../../utils/util";
import utils from "../../../utils/util";
const isuid = wx.getStorageSync("yz_uid");
var date = new Date();
Page({
  /**
   * 页面的初始数据
   */
  data: {
    navlis: ["日榜", "周榜", "月榜", "年榜", "总榜"],
    carlis: [],
    geade: ["排名", "会员", "车号", "圈数", "总用时", "最快圈"],
    group: [],
    navTaps: 0, //顶部导航
    topNav: 1, //榜单导航
    carTaps: 0, //车类导航
    GroupTaps: 0, //实时组类导航
    show: false,
    nowTime: "",
    showIn: false, // 历史成绩是否显示
    postTime: Date.parse(new Date()), // 接口时间戳
    info: [], //排名信息
    GroupList: [],
    interval: null,
    local_time: "00:00:00",
    myUid: isuid,
    my_info: [],
    memberInfo: [],
    minDate: new Date(date.getFullYear() - 1, 0, 1).getTime(),
    maxDate: Date.parse(new Date()),
    realTimeIn_set: null,
    realTimeAll: null,
    istemp: true,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    if (options.id) {
      this.setData({
        id: options.id,
      });
    }

    this.init();
    this.setData({
      nowTime: utils.formatTimes(new Date()),
    });
  },
  onChange(e) {
    this.setData({
      timeData: e.detail,
    });
  },
  test() {
    var now = new Date();
    var nowTime = now.getTime();
    var day = now.getDay() || 7; //为周日的时候 day 修改为7  否则当天周天会有问题
    var oneDayTime = 24 * 60 * 60 * 1000;
    var MondayTime = nowTime - (day - 1) * oneDayTime; //显示周一
    var SundayTime = nowTime + (7 - day) * oneDayTime; //显示周日
    return {
      monday: Date.parse(new Date(MondayTime)),
      sunday: Date.parse(new Date(SundayTime))
    };
  },
  init() {
    this.setData({
      topNav: 0,
      navTaps: 0,
    });
  },
  showHistory(e) {
    console.log(e);
    this.setData({
      showIn: !this.data.showIn,
    });
    let that = this;
    let urlStr = app.getNetAddresss(
      "plugin.kart.Frontend.Store.Modules.Ranking.Controllers.MyGradeHistory.index"
    );
    app._postNetWork({
      url: urlStr,
      data: {
        store_id: this.data.id,
      },
      success: (resdata) => {
        var res = resdata.data;
        if (res.result == 1) {
          that.setData({
            history: res.data,
          });
        } else {
          wx.showToast({
            title: res.msg,
            duration: 1000,
            icon: "none",
          });
        }
      },
    });
  },
  tapGroupNav(e) {
    let ind = e.currentTarget.dataset.ind;
    console.log(ind);
    this.setData({
      GroupTaps: ind,
    });
    if (this.data.realTimeIn_set) {
      clearInterval(this.data.realTimeIn_set);
    }
    this.getData();
  },
  tapCarNav(e) {
    let ind = e.currentTarget.dataset.ind;
    console.log(ind);
    this.setData({
      carTaps: ind,
    });
    this.getData();
  },
  tapTopNav(e) {
    let ind = e.currentTarget.dataset.ind;
    this.setData({
      topNav: ind,
    });
    if (this.data.interval) {
      clearInterval(this.data.interval);
      this.setData({
        interval: null
      });
    }
    if (this.data.realTimeIn_set) {
      clearInterval(this.data.realTimeIn_set);
      this.setData({
        realTimeIn_set: null
      });
    }
    if (this.data.realTimeAll) {
      clearInterval(this.data.realTimeAll);
      this.setData({
        realTimeAll: null
      });
    }
    console.log(this.data.interval);
    if (ind == 2) {
      this.data.realTimeAll = setInterval(() => {
        this.timeIsReal();
      }, 1000);
      this.data.interval = setInterval(() => {
        this.setData({
          local_time: utils.formatTime(new Date()).slice(11),
        });
      }, 1000);
    }
    this.getData();
  },

  monthYearShow() {
    console.log(this.data.textTime_class);
    this.setData({
      monthYearShow: false,
    });
  },
  tapCalendar(e) {
    console.log(e);
    let now = e.detail[0];
    now = Date.parse(now);
    now = now / 1000;
    now = utils.formatTimeTwo(now, "Y-M-D");
    console.log(now);
    let dayNow = this.getSteven(now);
    this.setData({
      calendarArr: [dayNow.monday, dayNow.sunday],
    });
  },
  getSteven(stime) {
    var now = new Date(stime);
    var nowTime = now.getTime();
    var day = now.getDay() || 7;
    var oneDayLong = 24 * 60 * 60 * 1000;

    var MondayTime = nowTime - (day - 1) * oneDayLong;
    var SundayTime = nowTime + (7 - day) * oneDayLong;

    var monday = new Date(MondayTime);

    for (let i = 0; i < 7; i++) {
      var tmpDate = new Date(MondayTime);
      tmpDate = tmpDate.setDate(tmpDate.getDate() + i);
      tmpDate = new Date(tmpDate);
      console.log(tmpDate);

      var mondayDateStr = tmpDate.getMonth() + 1 + "月";
      mondayDateStr += tmpDate.getDate() + "日";

      let days = tmpDate.getDay();
      console.log(days);
      switch (days) {
      case 1:
        days = "星期一";
        break;
      case 2:
        days = "星期二";
        break;
      case 3:
        days = "星期三";
        break;
      case 4:
        days = "星期四";
        break;
      case 5:
        days = "星期五";
        break;
      case 6:
        days = "星期六";
        break;
      case 0:
        days = "星期日";
        break;
      }
      mondayDateStr += days;
      console.log(mondayDateStr);
    }

    var sunday = new Date(SundayTime);
    return {
      monday: Date.parse(monday),
      sunday: Date.parse(sunday),
    };
  },
  getTimeC(e) {
    console.log(e.detail.postTime);
    let time = e.detail;
    if (this.data.navTaps == 3) {
      this.setData({
        postTime: time.postTime,
        textTime_class: time.textTime_class,
        monthYearShow: false,
      });
    } else {
      this.setData({
        postTime: time.postTime,
        textTime_class: time.textTime_class,
        monthYearShow: false,
      });
    }

    this.getData();
  },
  // 日 周 月 年 榜单选项
  tapNav(e) {
    let ind = e.currentTarget.dataset.ind;
    if (ind == 1) {
      //周榜需要自动选择
      // 一周前的日期 和 当天的日期  格式 2021-05
      console.log(this.data.nowTime.slice(0, 7));
      let dayNow = this.data.nowTime.slice(0, 7);
      dayNow = this.test(dayNow);
      console.log(dayNow);
      this.setData({
        textTime_class: this.data.nowTime.slice(0, 7),
        calendarArr: [dayNow.monday, dayNow.sunday],
      });
    } else if (ind == 2) {
      let date = new Date();
      let month = date.getMonth();
      console.log(month);
      this.setData({
        textTime_class: this.data.nowTime.slice(0, 7),
        monthIndex: month,
      });
    } else if (ind == 3) {
      let date = new Date();
      let year = date.getFullYear();
      console.log(year);
      this.setData({
        textTime_class: this.data.nowTime.slice(0, 4),
        monthIndex: year,
      });
    }

    this.setData({
      navTaps: ind,
      postTime: Date.parse(new Date()),
    });
    console.log(this.data.navTaps);
    this.getData();
  },
  tapCaledar() {
    let navTaps = this.data.navTaps;
    // 日，周榜使用组件
    if (navTaps == 1 || navTaps == 0) {
      this.setData({
        show: true,
      });
    } else {
      this.setData({
        show: false,
      });
      if (this.data.navTaps == 2) {
        this.setData({
          monthYearShow: true,
          selectMonth: this.data.textTime_class,
        });
      }
      if (this.data.navTaps == 3) {
        console.log(this.data.textTime_class);
        let arr = [];
        for (let i = 0; i < 10; i++) {
          arr = arr.concat(this.data.textTime_class - i);
        }
        console.log(arr);
        this.setData({
          yearArr: arr,
          monthYearShow: true,
          selectMonth: this.data.textTime_class,
        });
      }
    }
  },
  onConfirm(e) {
    let time = e.detail;
    if (this.data.navTaps == 1) {
      console.log(utils.formatTimes(time[0]));
      this.setData({
        show: false,
        textTime_class: utils.formatTimes(time[0]).slice(0, 7),
      });
    } else {
      this.setData({
        show: false,
        nowTime: utils.formatTimes(time),
        postTime: Date.parse(time),
      });
    }

    this.getData();
  },
  yesterday(e) {
    // let day = new Date();
    if (this.data.navTaps == 0) {
      let Arr = this.data.nowTime.split("-");
      let now = new Date(
        Number(Arr["0"]),
        Number(Arr["1"]) - 1,
        Number(Arr["2"])
      );
      now.setDate(now.getDate() - 1);
      now = this.formatTime(now);
      this.setData({
        nowTime: now,
        postTime: Date.parse(new Date(now)),
      });
    } else if (this.data.navTaps == 1) {
      let lastMonday = utils.formatTimeTwo(
        this.data.calendarArr[0] / 1000 - 86400,
        "Y-M-D"
      );
      lastMonday = this.getSteven(lastMonday);
      let now = utils.formatTimeTwo(lastMonday.monday / 1000, "Y-M-D");
      now = now.slice(0, 7);
      let arr = [lastMonday.monday, lastMonday.sunday];
      console.log(now);
      this.setData({
        textTime_class: now,
        calendarArr: arr,
      });
    } else if (this.data.navTaps == 2) {
      let last = this.data.postTime;
      let date = utils.formatTimeTwo(last / 1000, "Y-M-D");
      let islast = this.etXmonthToday(-1, date);
      date = Date.parse(new Date(islast));
      this.setData({
        postTime: date,
        textTime_class: islast.slice(0, 7),
      });
    } else if (this.data.navTaps == 3) {
      let year = Number(this.data.textTime_class) - 1;
      let now = `${year}-01-01`;
      this.setData({
        textTime_class: year,
        postTime: Date.parse(now),
      });
    }

    this.getData();
  },
  tomorrow() {
    if (this.data.navTaps == 0) {
      let Arr = this.data.nowTime.split("-");
      let now = new Date(
        Number(Arr["0"]),
        Number(Arr["1"]) - 1,
        Number(Arr["2"])
      );
      now.setDate(now.getDate() + 1);
      now = this.formatTime(now);
      this.setData({
        nowTime: now,
        postTime: Date.parse(new Date(now)),
      });
    } else if (this.data.navTaps == 1) {
      let lastMonday = utils.formatTimeTwo(
        this.data.calendarArr[0] / 1000 + 86400 * 7,
        "Y-M-D"
      );
      console.log(lastMonday);
      lastMonday = this.getSteven(lastMonday);
      let now = utils.formatTimeTwo(lastMonday.monday / 1000, "Y-M-D");
      now = now.slice(0, 7);
      let arr = [lastMonday.monday, lastMonday.sunday];
      console.log(now);
      this.setData({
        textTime_class: now,
        calendarArr: arr,
      });
    } else if (this.data.navTaps == 2) {
      let last = this.data.postTime;
      let date = utils.formatTimeTwo(last / 1000, "Y-M-D");
      let islast = this.etXmonthToday(1, date);
      date = Date.parse(new Date(islast));
      this.setData({
        postTime: date,
        textTime_class: islast.slice(0, 7),
      });
    } else if (this.data.navTaps == 3) {
      let year = Number(this.data.textTime_class) + 1;
      let now = `${year}-01-01`;
      this.setData({
        textTime_class: year,
        postTime: Date.parse(now),
      });
    }

    this.getData();
  },
  onClose(e) {
    this.setData({
      show: false,
    });
  },
  formatTime(date) {
    var year = date.getFullYear();

    let month = date.getMonth() + 1;
    month = month < 10 ? "0" + month : month;

    let day = date.getDate();
    day = day < 10 ? "0" + day : day;

    return year + "-" + month + "-" + day;
  },
  goMy(e) {
    console.log(this.data.realTimeAll);
    if (this.data.realTimeAll) {
      clearInterval(this.data.realTimeAll);
      this.setData({
        realTimeAll: null
      });
    }
    // if (e.currentTarget.dataset.item.ranking != 0) {
    let uid = e.currentTarget.dataset.item.uid;
    let rank = e.currentTarget.dataset.item.ranking;
    let myuid = wx.getStorageSync("yz_uid");
    if (uid == myuid) {
      wx.navigateTo({
        url: "/packageH/turmaroundTime/turmaroundMy/turmaroundMy?id=" +
          this.data.id +
          "&ranking=" +
          rank,
      });
    } else {
      wx.navigateTo({
        url: "/packageH/turmaroundTime/turmaroundMy/turmaroundMy?id=" +
          this.data.id +
          "&ranking=" +
          rank +
          "&uid=" +
          uid,
      });
    }
    // }
  },
  etXmonthToday(type, time) {
    // type 0 是当天 -1 是上个月   1是下个月
    var now = new Date(time); // 可以传值调式 now = new Date(2019,2,30); 今天是3月30号
    var year = now.getFullYear(); //getYear()+1900=getFullYear()
    var month = now.getMonth() + 1; //0-11表示1-12月
    var day = now.getDate(); // 当天日期
    if (parseInt(month) < 10) {
      month = "0" + month;
    }
    if (parseInt(day) < 10) {
      day = "0" + day;
    }
    now = year + "-" + month + "-" + day; // 如果取当月日期可直接 return 返回

    var preMonth = parseInt(month) - 1;
    preMonth = preMonth < 10 ? "0" + preMonth : preMonth; // 获取上个月的值
    var nextMonth = parseInt(month) + 1;
    nextMonth = nextMonth < 10 ? "0" + nextMonth : nextMonth; // 获取下个月个月的值

    if (parseInt(month) == 1 && type == -1) {
      //如果是1月份，要上个月 ，则取上一年的12月份
      return parseInt(year) - 1 + "-12-" + day;
    } else if (parseInt(month) == 12 && type == 1) {
      // 如果是12月，要下个月，取下一年的1月
      return parseInt(year) + 1 + "-01-" + day;
    }

    var preSize = new Date(year, parseInt(month) - 1, 0).getDate(); //上月总天数
    var nextSize = new Date(year, parseInt(month) + 1, 0).getDate(); //下月总天数
    console.log(preSize, nextSize);
    if (preSize < parseInt(day) && type == -1) {
      // 取上个月，如果上个月总天数小于本月今天，取上个月最后一天
      return year + "-" + preMonth + "-" + preSize;
    } else if (nextSize < parseInt(day) && type == 1) {
      // 如果下个月总天数小于本月今天，取下个月最后一天
      return year + "-" + nextMonth + "-" + nextSize;
    }

    if (type == -1) {
      return year + "-" + preMonth + "-" + day;
    } else if (type == 1) {
      return year + "-" + nextMonth + "-" + day;
    } else if (type == 0) {
      return now;
    }
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {},

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.setData({
      topNav: 0,
      navTaps: 0
    });
    this.getCartClass();
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {},

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    if (this.data.interval) {
      clearInterval(this.data.interval);
      this.setData({
        interval: null
      });
    }
    if (this.data.realTimeIn_set) {
      clearInterval(this.data.realTimeIn_set);
      this.setData({
        realTimeIn_set: null
      });
    }
    if (this.data.realTimeAll) {
      clearInterval(this.data.realTimeAll);
      this.setData({
        realTimeAll: null
      });
    }
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {},

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {},

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    return {
      path: "/packageH/turmaroundTime/turmaroundIndex/turmaroundIndex?id=" +
        this.data.id,
    };
  },
  getCartClass() {
    let that = this;
    let urlStr = app.getNetAddresss(
      "plugin.kart.Frontend.Account.Modules.KartType.Controllers.records.index"
    );
    app._postNetWork({
      url: urlStr,
      success: (resdata) => {
        var res = resdata.data;
        console.log(res);
        that.setData({
          carlis: res.data,
          carTaps: String(res.data[this.data.carTaps].id),
        });
        that.getData();
      },
    });
  },
  getData() {
    let json = {};
    let urlStr;
    let that = this;
    if (this.data.topNav == "0") {
      // 成绩排行
      urlStr = app.getNetAddresss(
        "plugin.kart.Frontend.Store.Modules.Ranking.Controllers.records.index"
      );
      if (this.data.navTaps == 1) {
        json = {
          store_id: Number(this.data.id),
          ranking_type: this.data.navTaps + 1,
          kart_type_id: Number(this.data.carTaps),
          start_time: this.data.calendarArr[0] / 1000,
          end_time: this.data.calendarArr[1] / 1000,
        };
      } else {
        json = {
          store_id: Number(this.data.id),
          ranking_type: this.data.navTaps + 1,
          kart_type_id: Number(this.data.carTaps),
          start_time: this.data.postTime / 1000,
          end_time: this.data.postTime / 1000,
        };
      }
    } else if (this.data.topNav == "1") {
      // 我的成绩
      urlStr = app.getNetAddresss(
        "plugin.kart.Frontend.Account.Modules.Store.Controllers.Store.index"
      );
      json = {
        store_id: Number(this.data.id),
      };
    } else {
      // 实时成绩
      urlStr = app.getNetAddresss(
        "plugin.kart.Frontend.Store.Modules.Screen.Controllers.records.index"
      );
      json = {
        store_id: Number(this.data.id),
        screen_id: "real_time",
        kart_match_id: this.data.GroupTaps,
      };
    }

    app._postNetWork({
      url: urlStr,
      data: json,
      success: (resdata) => {
        var res = resdata.data;
        if (res.result == 1) {
          if (that.data.topNav == "0") {
            console.log("成绩排行================>>>>>>>>");
            that.setData({
              first_info: res.data.ranking.slice(0, 3),
              info: res.data.ranking.slice(3),
              is_ranking: res.data.member_ranking.is_ranking,
              title: res.data.title ? res.data.title : "",
              my_info: res.data.member_ranking,
            });
            if (res.data.ranking.length == 0) {
              that.setData({
                istemp: false,
              });
            } else {
              that.setData({
                istemp: true,
              });
            }
            console.log(that.data.istemp);
            wx.setNavigationBarTitle({
              title: res.data.title,
            });
            for (let i = 0; i < res.data.ranking.length; i++) {
              if (res.data.ranking[i].uid == that.data.myUid) {
                console.log(res.data.ranking[i]);
                that.setData({
                  my_info_ind: i,
                });
              }
            }
          }
          if (that.data.topNav == 2) {
            console.log("实时成绩================>>>>>>>>");
            that.setData({
              group: res.data.kart_match,
              first_info: res.data.member_ranking.slice(0, 3),
              info: res.data.member_ranking.slice(3),
            });
            if (
              res.data.member_ranking == 0 &&
              res.data.kart_match.length == 0
            ) {
              that.setData({
                istemp: false,
              });
            } else {
              that.setData({
                istemp: true,
              });
            }
            for (let i = 0; i < res.data.kart_match.length; i++) {
              console.log(res.data.kart_match[i]);

              if (that.data.GroupTaps) {
                if (res.data.kart_match[i].id == that.data.GroupTaps) {
                  if (res.data.kart_match[i].state != 6) {
                    // if (res.data.kart_match[i].running_at == 0) {
                    that.realTimeIn(i, res);
                    // }else{
                    //   let nowTime = Date.parse(new Date()) / 1000;
                    // }
                  }
                  res.data.kart_match[i].started_at = utils.formatTimeTwo(
                    res.data.kart_match[i].started_at,
                    "Y-M-D"
                  );
                  that.setData({
                    GroupList: res.data.kart_match[i],
                    GroupTaps: res.data.kart_match[i].id,
                  });
                }
              } else {
                that.setData({
                  GroupList: res.data.kart_match[0],
                  GroupTaps: Number(res.data.kart_match[0].id),
                });
                if (res.data.kart_match[0].state != 6) {
                  if (res.data.kart_match[0].running_at == 0) {
                    that.realTimeIn(0, res);
                  } else {
                    console.log("000000000000000000000");
                    that.realTimeIn(0, res);
                  }
                }
              }
            }
            // if (res.data.kart_match.length > 0) {
            //   that.data.interval = setInterval(() => {
            //     that.setData({
            //       local_time: utils.formatTime(new Date()).slice(11),
            //     });
            //     console.log(that.data.interval)
            //   }, 1000);
            // }
          }
          if (that.data.topNav == 1) {
            that.setData({
              memberInfo: res.data,
            });
          }
        } else {
          console.log(res.msg);
        }
      },
    });
  },
  realTimeIn(i, res) {
    res.data.kart_match[i].running_at = res.data.kart_match[i].started_at;
    let nowTime = Date.parse(new Date()) / 1000;
    console.log(nowTime);
    // let that = this;
    this.data.realTimeIn_set = setInterval(() => {
      let isnow = nowTime++;
      this.settime_a(res.data.kart_match[i].running_at, isnow);
    }, 1000);
  },
  settime_a(time, nowTime) {
    let timeing = time;
    this.time_endS(timeing, nowTime);
    console.log((nowTime - timeing) * 1000);
    let date3 = (nowTime - timeing) * 1000;
    // var day = Math.floor(date3 / (24 * 3600 * 1000));
    var leave1 = date3 % (24 * 3600 * 1000);
    var hours = Math.floor(leave1 / (3600 * 1000));
    var leave2 = leave1 % (3600 * 1000); //计算小时数后剩余的毫秒数
    var minutes = Math.floor(leave2 / (60 * 1000));
    var leave3 = leave2 % (60 * 1000); //计算分钟数后剩余的毫秒数
    var seconds = Math.round(leave3 / 1000);
    if (hours < 10) {
      hours = `0${hours}`;
    }
    if (minutes < 10) {
      minutes = `0${minutes}`;
    }
    if (seconds < 10) {
      seconds = `0${seconds}`;
    }
    let txt = `${hours}:${minutes}:${seconds}`;
    this.setData({
      is_running_at: txt,
    });
    return txt;
  },
  time_endS(time, nowTime) {
    let start_at_time = (time + this.data.GroupList.countdown) - nowTime;
    start_at_time = start_at_time * 1000;
    let date3 = start_at_time;
    // var day = Math.floor(date3 / (24 * 3600 * 1000));
    var leave1 = date3 % (24 * 3600 * 1000);
    var hours = Math.floor(leave1 / (3600 * 1000));
    var leave2 = leave1 % (3600 * 1000); //计算小时数后剩余的毫秒数
    var minutes = Math.floor(leave2 / (60 * 1000));
    var leave3 = leave2 % (60 * 1000); //计算分钟数后剩余的毫秒数
    var seconds = Math.round(leave3 / 1000);
    if (hours < 10) {
      hours = `0${hours}`;
    }
    if (minutes < 10) {
      minutes = `0${minutes}`;
    }
    if (seconds < 10) {
      seconds = `0${seconds}`;
    }
    let txt = `${hours}:${minutes}:${seconds}`;
    this.setData({
      start_at_time: txt
    });
  },
  timeIsReal() {
    let json = {};
    let urlStr;
    let that = this;

    // 实时成绩
    urlStr = app.getNetAddresss(
      "plugin.kart.Frontend.Store.Modules.Screen.Controllers.records.index"
    );
    json = {
      store_id: Number(this.data.id),
      screen_id: "real_time",
      kart_match_id: this.data.GroupTaps,
    };

    app._postNetWork({
      url: urlStr,
      data: json,
      success: (resdata) => {
        var res = resdata.data;
        if (res.result == 1) {
          if (that.data.topNav == 2) {
            console.log("实时成绩================>>>>>>>>");
            that.setData({
              group: res.data.kart_match,
              first_info: res.data.member_ranking.slice(0, 3),
              info: res.data.member_ranking.slice(3),
            });
            if (
              res.data.member_ranking == 0 &&
              res.data.kart_match.length == 0
            ) {
              that.setData({
                istemp: false,
              });
            } else {
              that.setData({
                istemp: true,
              });
            }
            for (let i = 0; i < res.data.kart_match.length; i++) {
              console.log(res.data.kart_match[i]);

              if (that.data.GroupTaps) {
                if (res.data.kart_match[i].id == that.data.GroupTaps) {
                  res.data.kart_match[i].started_at = utils.formatTimeTwo(res.data.kart_match[i].started_at, "Y-M-D");
                  that.setData({
                    GroupList: res.data.kart_match[i],
                    GroupTaps: res.data.kart_match[i].id,
                  });
                }
              } else {
                that.setData({
                  GroupList: res.data.kart_match[0],
                  GroupTaps: Number(res.data.kart_match[0].id),
                });
              }
            }
          }
        } else {
          console.log(res.msg);
        }
      },
    });
  },
});