
var app = getApp()
var that;
Page({
  data: {
    date: app.globalData.month,
    review_id:'',
    userId:''
  },
  onLoad(e) {
    that = this;
    dd.setNavigationBar({ title: "事件详情" });
    that.setData({
      userId:app.globalData.userData.id
    })
    if(e.id){
        that.setData({
          review_id:e.id
        })
        that.getDetail(e.id);
    }
  },
  openCx() {
    dd.confirm({
      title: '撤销奖扣',
      content: '你确定撤销此项吗?',
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      success: (result) => {
        if (result.confirm) {
          app.$post("api/integral/review/prize/destroy", { target_id: that.data.review_id,type:1 }).then((res) => {
            app.globalData.showToast("已撤销");
            // var pages=getCurrentPages();//当上一页的page不等于一时，执行上一页的方法
            // var active=pages[pages.length-2];
            // if(active.data.page!=1){
            //     active.refreshData(that.data.review_id);
            // }
            setTimeout(() => {
              dd.navigateBack({
                delta: 1
              })
            }, 1000);
          })
        }
      },
    });
  },
  // 查看日志详情
  openLog(){
    dd.navigateTo({
      url: '../logDetail/logDetail?id=' + this.data.review_id
    })
  },
  showImg(e){
      var index=e.target.dataset.index;
      var item=e.target.dataset.item
      dd.previewImage({
        current: index,
        urls: item
      });
  },
  activeItem(e) {
    var index = e.target.dataset.index;
    this.setData({ activeIndex: index })
  },
  openSearch() {
    app.globalData.showToast("暂不支持筛选");
  },
  getDetail(id) {
    app.$get("api/integral/statistics/integral/info", { event_id: id }).then((res) => {
      var data = res.data.data;
      app.globalData.types.forEach(item => {
        if (item.id == data.pt_id) {
          data.typeName = item.name
        }
      });
      this.setData({ dataDetail: data })
    })
  },
});
