
var app = getApp()
var that;
Page({
  data: {
    date: app.globalData.month,
    activeIndex: 1,
    id: '',
  },
  onLoad(e) {
    that = this;
    dd.setNavigationBar({ title: "重复任务详情" });
    if (e.id) {
      that.getDetail(e.id);
      this.setData({
        id: e.id,
      })
    }
  },
  //显示图片
  showImg(e) {
    var index = e.target.dataset.index;
    var item = e.target.dataset.item
    dd.previewImage({
      current: index,
      urls: item
    });
  },
  formSubmit() {
    dd.confirm({
      title: '删除任务',
      content: '删除此任务将会删除其相关记录和积分数据，确认删除吗？',
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      success: (result) => {
        if (result.confirm) {
          app.$get('api/integral/schedule/delete', { schedule_id: this.data.id }).then(res => {
            app.globalData.showToast(res.data.msg);
            setTimeout(() => {
              dd.navigateBack({ delta: 1 })
            }, 1000);
          })
        }
      },
    });
  },
  //显示图片
  showImg(e) {
    var index = e.target.dataset.index;
    var item = e.target.dataset.item
    dd.previewImage({
      current: index,
      urls: item
    });
  },
  getDetail(id) {
    app.$get("api/integral/schedule", { schedule_id: id }).then((res) => {
      var data=res.data.data;
      data.img_url=app.globalData.userData.img_url;
      this.setData({ dataDetail: res.data.data })
    })
  },
});
