 
var util = require('../../utils/util.js')
const app = getApp();
Page({
  data: {
    calcDate: util.getToday(),
    isShow: true,
    noData:'../../images/noData.png',
    dataListTips: "暂无数据",
    g_createrId:"",
   
    customerId:"",

    //表格请求参数~~ 
    table: {
      getdataListParm: {
        name: 'getEventsByCid',
        page: 1,
        offset: 1,
        pagecount: 20,
        returntype: 'Map',
        parammaps: {
          customerId: "",
          beginDate: util.get91daysAgo(),
          endDate: util.getToday(),
     
        }
      },
      tableKey: 0,
      list: [
        // {"content":"想做计步器宣传，目前已让任老师帮忙做。","customerId":378,"customerName":"天津振杰","id":827,"receiverId":1497,"receiverName":"张振强","receiverTel":"","remark":"","vdate":"2020-10-16","visiterId":30,"visiterName":"高占永"},
        // {"content":"兴安盟牧场已确定安装我司饲喂系统，目前正在走流程。","customerId":255,"customerName":"原阳富源牧业","id":826,"receiverId":1341,"receiverName":"贾又春","receiverTel":"","remark":"","vdate":"2020-09-27","visiterId":30,"visiterName":"高占永"},
        // {"content":"沟通款项，已支付","customerId":643,"customerName":"木易牧场","id":825,"receiverId":1333,"receiverName":"李宝丽","receiverTel":"","remark":"","vdate":"2020-09-24","visiterId":30,"visiterName":"高占永"}
      ],
      total: 0,
      listLoading: true,
    },

  },
  onReachBottom: function () {
    console.log('下拉分页')
    var offset = this.data.table.getdataListParm.offset + 1
    this.setData({['table.getdataListParm.offset']:  offset})

    this.getList()
  },
  onLoad: function (options) {
    var id = options.id;
    console.log(id)
    //获取编辑内容
    this.setData({
      ['table.getdataListParm.parammaps.customerId']: id,
      "customerId": id,
    })
     util.getDataByName(this.data.table.getdataListParm, this.getListSuccess1)
  
  },
 


  //加载表格
  getList() {
    console.log("表格请求数据：", this.data.table.getdataListParm)
    util.getDataByName(this.data.table.getdataListParm, this.getListSuccess2)
  },
  getListSuccess1:  function (res) {
    console.log('table数据======>', res.data.list)
    if (res.data.list !== null) {
      this.setData({
        isShow: true,
        ['table.list']: res.data.list,
        ['table.getdataListParm.offset']: res.data.pageNum,
        ['table.total']: res.data.total
      })
    } else {
      this.setData({
        ['table.list']: [],
        ['table.getdataListParm.offset']: res.data.pageNum,
        isShow: false,
        dataListTips: "暂无数据"
      })
    }
  },

  getListSuccess2:  function (res) {
    console.log('table数据======>', res.data)
    var tempList = res.data.list;
    if (res.data.list !== null) {
      this.setData({
        isShow: true,
        ['table.list']: this.data.table.list.concat(tempList),
        ['table.getdataListParm.offset']: res.data.pageNum,
        ['table.total']: res.data.total
      })
    } else {
      this.setData({
        ['table.getdataListParm.offset']: res.data.pageNum 
      })
    }
  },

  
  
   

  
  //日期1
  bindDateChange1: function (e) {
    this.setData({
      ['table.getdataListParm.offset']:1,
      ['table.getdataListParm.parammaps.beginDate']: e.detail.value
    })
    console.log("表格请求数据：", this.data.table.getdataListParm)
    util.getDataByName(this.data.table.getdataListParm, this.getListSuccess1)
  },
  //日期2
  bindDateChange2: function (e) {
    this.setData({
      ['table.getdataListParm.offset']:1,
      ['table.getdataListParm.parammaps.endDate']: e.detail.value
    })
    console.log("表格请求数据：", this.data.table.getdataListParm)
    util.getDataByName(this.data.table.getdataListParm, this.getListSuccess1)
  },


  //查看
  on_see_tap1: function (e) {
    var id = e.currentTarget.dataset.id;
    wx.navigateTo({ url:"../workbench/visitRecordSee/visitRecordSee?id=" + id})
  },
  on_see_tap2: function (e) {
    var id = e.currentTarget.dataset.id;
    wx.navigateTo({ url:"../workbench/telephoneFollowSee/telephoneFollowSee?id=" + id})
  },
  on_see_tap3: function (e) {
    
    var id = e.currentTarget.dataset.id;
    console.log(id )
    wx.navigateTo({ url:"../workbench/remoteServiceSee/remoteServiceSee?id=" + id})
  },
  on_see_tap4: function (e) {
    var id = e.currentTarget.dataset.id;
    wx.navigateTo({ url:"../workbench/siteServiceSee/siteServiceSee?id=" + id})
  },
  on_see_tap5: function (e) {
    var id = e.currentTarget.dataset.id;
    wx.navigateTo({ url:"../workbench/complaintRecordSee/complaintRecordSee?id=" + id})
  },
   


})