index.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. classShow: false,
  5. classActions: [{
  6. name: '全部',
  7. index: 0
  8. }, {
  9. name: '我负责的',
  10. index: 1
  11. },
  12. {
  13. name: '我参与的',
  14. index: 2
  15. },
  16. {
  17. name: "我下属负责的",
  18. index: 3
  19. }, {
  20. name: "我下属参与的",
  21. index: 4
  22. }
  23. ],
  24. content: {
  25. nocache: true,
  26. "type": 0,
  27. "pageNumber": 1,
  28. "pageSize": 20,
  29. "where": {
  30. "condition": "", //模糊搜索
  31. },
  32. "sort": []
  33. }
  34. },
  35. onLoad(options) {
  36. this.getList();
  37. },
  38. /* 获取列表 */
  39. getList(init = false) {
  40. if (init.detail != undefined) init = init.detail;
  41. let content = this.data.content;
  42. if (init) content.pageNumber = 1;
  43. if (content.pageNumber > content.pageTotal) return;
  44. _Http.basic({
  45. "id": 20221020143502,
  46. content
  47. }).then(res => {
  48. console.log("客户商机列表", res)
  49. this.selectComponent('#ListBox').RefreshToComplete();
  50. if (res.msg != '成功') return wx.showToast({
  51. title: res.data,
  52. icon: "none"
  53. })
  54. this.setData({
  55. 'content.pageNumber': res.pageNumber + 1,
  56. 'content.pageTotal': res.pageTotal,
  57. 'content.total': res.total,
  58. 'content.sort': res.sort,
  59. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data)
  60. });
  61. this.getTags();
  62. })
  63. },
  64. /* 获取列表标签 */
  65. getTags() {
  66. let list = this.data.list,
  67. ownerids = list.map(v => v.sa_projectid);
  68. _Http.basic({
  69. "id": 20221018102001,
  70. "content": {
  71. nocache: true,
  72. "ownertable": "sa_project",
  73. ownerids
  74. }
  75. }).then(res => {
  76. console.log("标签", res)
  77. for (let key in res.data) {
  78. let index = list.findIndex(v => v.sa_projectid == key);
  79. list[index].tags = res.data[key]
  80. };
  81. console.log(list)
  82. this.setData({
  83. list
  84. })
  85. })
  86. },
  87. /* 处理筛选 */
  88. handleFilter({
  89. detail
  90. }) {
  91. console.log(detail)
  92. },
  93. /* 处理搜索 */
  94. onSearch({
  95. detail
  96. }) {
  97. this.setData({
  98. "content.where.condition": detail
  99. });
  100. this.getList(true);
  101. },
  102. /* 顶部条件导航回调 */
  103. navClick({
  104. detail
  105. }) {
  106. switch (detail.id) {
  107. case '1':
  108. this.setData({
  109. classShow: true
  110. })
  111. break;
  112. }
  113. },
  114. /* 选择分类 */
  115. classSelect({
  116. detail
  117. }) {
  118. if (this.data.content.type == detail.index) return this.classClose();
  119. this.setData({
  120. "content.type": detail.index,
  121. 'navList[0].label': detail.name
  122. })
  123. this.classClose();
  124. this.getList(true)
  125. },
  126. classClose() {
  127. this.setData({
  128. classShow: false
  129. })
  130. },
  131. onReady() {
  132. this.setListHeight()
  133. },
  134. /* 设置页面高度 */
  135. setListHeight() {
  136. this.selectComponent("#ListBox").setHeight(".total", this);
  137. },
  138. onShareAppMessage() {}
  139. })