// packageD/member/myOrder/refund/components/pickUpTimePop/pickUpTimePop.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    popShow:false,
    day_list:[],
    day_index:0,
    time_list:[],
    time_index:null
  },

  /**
   * 组件的方法列表
   */
  methods: {
    setPopShow(){
      if(this.data.day_list.length == 0){
        wx.showModal({
          title: '提示',
          showCancel: false,
          content: '该地区暂无取货服务，请修改其他地址',
          success (res) {}
        })
        return;
      }
      this.setData({
        popShow:!this.data.popShow
      });
    },
    setListData(arr){
      this.setData({
        day_list:arr,
        time_list:arr[0]&&arr[0].pickupTimeRangeList||[]
      });
    },
    setTimeList(evt){
      let index = evt.currentTarget.dataset.index;
      if(this.data.day_index == index) return;
      this.setData({
        day_index:index,
        time_index:null,
        time_list:this.data.day_list[index]&&this.data.day_list[index].pickupTimeRangeList||[]
      });
    },
    send(evt){
      let index = evt.currentTarget.dataset.index;
      this.setData({
        time_index:index
      });
      let day = this.data.day_list[this.data.day_index].complete_day;
      let start_time = day + " " +  this.data.time_list[index].pickupStartTime;
      let end_time = day + " " +  this.data.time_list[index].pickupEndTime;
      console.log(start_time,end_time);
      this.triggerEvent("confirm",{start_time,end_time});
      //this.$emit('confirm',{start_time,end_time});
      this.setPopShow();
    }

  }
});
