let app=getApp();
//替换成开发者后台设置的安全域名
let domain = app.globalData.domain;
let myhistoryUrl = domain + "/dingding/myhistory";
Page({
  data: {
    dates: null,
    historyList:[]
  },
    //  点击时间组件确定事件  
    bindDateChange(e) {
      this.setData({
        dates: e.detail.value
      })

      var that = this;
      var userId = app.globalData.userId;


      dd.httpRequest({
        url: myhistoryUrl,
        method: 'POST',
        data: {
          userId: userId,
          date: that.data.dates
        },
        dataType: 'json',
        success: function(res) {
          console.log('success----历史记录', res)
          var historyList = that.data.historyList;
          historyList = res.data.result;
          that.setData({

            historyList
          });
          //console.log(that.data.historyList);
        },
        fail: function(res) {
          console.log("httpRequestFail---", res)
          //   dd.alert({ content: JSON.stringify(res) });
        },
        complete: function(res) {
          dd.hideLoading();
        }

      });

    },

  summary(e){
    var mid=   e.currentTarget.dataset.mid;
    let minutesCode = e.currentTarget.dataset.minutesCode;
    console.log("minutesCode" ,minutesCode);
   //console.log(e)
   if(minutesCode != ""  && minutesCode !=null ){
           dd.navigateTo({ 
            url: '/pages/meeting/summary/summary?mid='+mid ,
            type:'redirect'
            })
     }else{
         dd.alert({
           content: '没有授权,无法查看',
           buttonText: '我知道了',
       })
      }
    
  },
  destine(e){
    console.log(e.currentTarget.dataset.cnum);
    //var cnum = e.currentTarget.dataset.cnum;
    dd.navigateTo({
      url: '/pages/conference/addmeeting/addmeeting?cnum='+ e.currentTarget.dataset.cnum + '&messageName=' + e.currentTarget.dataset.messageName + "&messageCompere=" + e.currentTarget.dataset.messageCompere
       + "&topicList=" + e.currentTarget.dataset.topicList + "&department=" + e.currentTarget.dataset.department + "&conferenceName=" + e.currentTarget.dataset.conferenceName
       + "&messageContent=" + e.currentTarget.dataset.messageContent + "&remindMethod=" + e.currentTarget.dataset.remindMethod + "&remindTime=" + e.currentTarget.dataset.remindTime
    })
  },
  details(e){
   // console.log(e.currentTarget.dataset.messageName);

    dd.navigateTo({
      url: '/pages/meeting/details/details?mid='+e.currentTarget.dataset.mid+'&messageName=' + e.currentTarget.dataset.messageName + '&conferenceName=' + e.currentTarget.dataset.conferenceName 
      + "&messageCompere=" + e.currentTarget.dataset.messageCompere+ "&topicList=" + e.currentTarget.dataset.topicList + "&startTime=" + e.currentTarget.dataset.startTime 
      + "&endTime=" + e.currentTarget.dataset.endTime +  "&department=" + e.currentTarget.dataset.department + "&messageContent=" + e.currentTarget.dataset.messageContent 
      + "&configValueIdString=" + e.currentTarget.dataset.configValueIdString

    })
  },

  onLoad: function(options) {
    var that = this;
    //高度自适应
    var userId = app.globalData.userId;


    
  },
  onReady() {
    // 页面加载完成
  },

  onShow() {
    var that = this;
    var userId = app.globalData.userId;


    dd.httpRequest({
      url: myhistoryUrl,
      method: 'POST',
      data: {
        userId: userId,
        date: that.data.dates
      },
      dataType: 'json',
      success: function(res) {
        console.log('success----历史记录', res)
        var historyList = that.data.historyList;
        historyList = res.data.result;
        that.setData({

          historyList
        });
        console.log(that.data.historyList);
      },
      fail: function(res) {
        console.log("httpRequestFail---", res)
        //   dd.alert({ content: JSON.stringify(res) });
      },
      complete: function(res) {
        dd.hideLoading();
      }

    });
  },
 
  onHide() {
    // 页面隐藏
  },
  onUnload() {
    // 页面被关闭
  },
  onTitleClick() {
    // 标题被点击
  },
  onPullDownRefresh() {
    // 页面被下拉
  },
  onReachBottom() {
    // 页面被拉到底部
  },
  onShareAppMessage() {
    // 返回自定义分享信息

  },
});
function dateFtt(fmt, date) { //author: meizz   
  var o = {
    "M+": date.getMonth() + 1,                 //月份   
    "d+": date.getDate(),                    //日   
    "h+": date.getHours(),                   //小时   
    "m+": date.getMinutes(),                 //分   
    "s+": date.getSeconds(),                 //秒   
    "q+": Math.floor((date.getMonth() + 3) / 3), //季度   
    "S": date.getMilliseconds()             //毫秒   
  };
  if (/(y+)/.test(fmt))
    fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
  for (var k in o)
    if (new RegExp("(" + k + ")").test(fmt))
      fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  return fmt;
}