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

    //表格请求参数~~ 
    table: {
      getdataListParm: {
        name: 'getContactsByCid',
        page: 1,
        offset: 1,
        pagecount: 100,
        returntype: 'Map',
        parammaps: {
          cid: "",
        }
      },
      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,
    },

  },

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


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

  //查看
  on_see_tap: function (e) {
    var id = e.currentTarget.dataset.id;
    wx.navigateTo({ url:"../contactSee/contactSee?id=" + id})
  },
  //编辑
  on_edit_tap: function (e) {
    var id = e.currentTarget.dataset.id;
    wx.navigateTo({ url:"../contactEdit/contactEdit?id=" + id})
  },

  //新增
  on_add_tap: function (e) {
    var id = this.data.customerId;
    console.log(id)
    wx.navigateTo({ url:"../contactAdd/contactAdd?id=" + id})
  },
 


})