index.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. contactsid: 0,
  5. tabsActive: 0, //tabs 选中项
  6. tabsList: [{
  7. label: "详细信息",
  8. num: 132
  9. }, {
  10. label: "跟进动态",
  11. num: 132
  12. }, {
  13. label: "地址",
  14. num: 132
  15. }],
  16. },
  17. onLoad(options) {
  18. if (options.contactsid) {
  19. this.setData({
  20. contactsid: options.contactsid
  21. });
  22. this.getDetail();
  23. }
  24. },
  25. /* 获取详情信息 */
  26. getDetail() {
  27. _Http.basic({
  28. "id": 20221026110602,
  29. "content": {
  30. "contactsid": this.data.contactsid
  31. }
  32. }).then(res => {
  33. console.log("联系人详情", res)
  34. const item = res.data;
  35. this.setData({
  36. detail: item,
  37. briefs: [{
  38. label: "手机号码",
  39. value: item.phonenumber
  40. }, {
  41. label: "性别",
  42. value: item.sex
  43. }, {
  44. label: "生日",
  45. value: item.birthday
  46. }, {
  47. label: "最近跟进时间",
  48. value: ""
  49. }],
  50. list1: [{
  51. label: "手机号码",
  52. value: item.phonenumber
  53. }, {
  54. label: "性别",
  55. value: item.sex
  56. }, {
  57. label: "生日",
  58. value: item.birthday
  59. }, {
  60. label: "邮箱",
  61. value: item.email
  62. }, {
  63. label: "部门",
  64. value: item.depname
  65. }, {
  66. label: "职位",
  67. value: item.position
  68. }, {
  69. label: "备注",
  70. value: item.remarks
  71. }]
  72. });
  73. })
  74. },
  75. //tabs 切换
  76. tabsChange({
  77. detail
  78. }) {
  79. this.setData({
  80. tabsActive: detail
  81. });
  82. this.partialRenewal();
  83. },
  84. //局部数据更新 tabs
  85. partialRenewal(init = false) {
  86. const id = this.data.detail.contactsid;
  87. let model = '';
  88. let name = this.data.tabsList[this.data.tabsActive].label;
  89. switch (name) {
  90. case "跟进动态":
  91. model = "#Trace"
  92. break;
  93. case "地址":
  94. model = "#Address"
  95. break;
  96. };
  97. if (model) {
  98. // 确定好模块ID total = null 是第一次加载 加载数据
  99. // init是新增或修改需要清数据
  100. let Component = this.selectComponent(model);
  101. const {
  102. total,
  103. pageNumber,
  104. pageTotal
  105. } = Component.data.content;
  106. if (total == null || init) {
  107. Component.getList(id, init);
  108. } else if (pageNumber <= pageTotal) {
  109. Component.getList(id, false);
  110. }
  111. }
  112. },
  113. //更新标签
  114. getTags() {
  115. this.selectComponent("#Tags").getTags();
  116. },
  117. //更新团队成员
  118. getGroup() {
  119. this.selectComponent("#Group").getList();
  120. },
  121. onReachBottom() {
  122. this.partialRenewal();
  123. },
  124. onShareAppMessage() {}
  125. })