let app = getApp();
let domain = app.globalData.domain;
//获取用户信息的url

let conferenceUrl = domain + "/dingding/conference";

Page({

  data: {
    conference: null,
     imageUrl: "http://139.159.202.24:8888" ,
    date: dateFtt("yyyy-MM-dd", new Date())  
  },
  goto:function(e){
    
   var cnum= e.currentTarget.dataset.cnum;
   var maxBookTime= e.currentTarget.dataset.maxBookTime;
   var maxBookDay= e.currentTarget.dataset.maxBookDay;
    dd.navigateTo({
      url: '../addmeeting/addmeeting?cnum=' + cnum +'&maxBookTime='+ maxBookTime +'&maxBookDay='+ maxBookDay
    })
  },
  setImageUrl: function(e) {
    //console.log("图片加载错误detail");
    var index = e.currentTarget.dataset.index;
    // document.getElementById(id).src = "../../../resource/images/list-room.png";
  
    var conference = this.data.conference;
    if(conference!=null){
    if (conference.photoUrl)
    conference.photoUrl = "/images/conference/dd-defalut.png"
    this.setData({
      conference
    });
  }
  },
  onLoad: function(query) {
    // 生命周期函数--监听页面加载
   console.log("load会议室编号",query);
   var _this=this;

    _this.setData({
      conference: null

    })
   //获取是否已添加外部人员记录
  
    dd.httpRequest({
      url: conferenceUrl,
      method: 'POST',
      data: {
        cnum: query.cnum
      },
      dataType: 'json',
      success: function(res) {
        console.log('success----', res)
        //var maxBookTime= _this.data.result;

        _this.setData({
          conference: res.data.result,
          //maxBookTime
        })
        //console.log('maxbooktime',maxBookTime);
      },
      fail: function(res) {
        console.log("httpRequestFail---", res)
        dd.alert({ content: JSON.stringify(res) });
      },
      complete: function(res) {
        dd.hideLoading();
      }

    });
   
  },

  
  onReady(query) {
    // 页面加载完成
  // console.log("ready会议室编号",query)

  },
  onShow(query) {
     dd.removeStorage({
     key:'signList',
     success:function(res){
       //console.log('清除已添加外部人员记录成功');
     }
   })
    // 页面显示
    // console.log("show会议室编号",query)
  },
  onHide() {
    // 页面隐藏
  },
  onUnload() {
    // 页面被关闭
  },
  onTitleClick() {
    // 标题被点击
  },
  onPullDownRefresh() {
    // 页面被下拉
  },
  onReachBottom() {
    // 页面被拉到底部
  },
  onShareAppMessage() {
    // 返回自定义分享信息
    return {
      title: 'My App',
      desc: 'My App description',
      path: 'pages/index/index',
    };
  },
});
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;
}