index.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. const getHeight = require("../../utils/getRheRemainingHeight"),
  2. _Http = getApp().globalData.http;
  3. Page({
  4. data: {
  5. content: {
  6. "nochace": true,
  7. "isAll": false,
  8. "pageNumber": 1,
  9. "pageSize": 20,
  10. "where": {
  11. "condition": "",
  12. "status": "待跟进"
  13. }
  14. },
  15. list: [],
  16. sort: null,
  17. tagColor: '#FA8C16',
  18. sheetTitle: '',
  19. scrollHeight: 0, //滚动区域高度
  20. initInsert: true, //用于初始化新建组件
  21. isReverse: false,
  22. },
  23. onLoad(options) {
  24. let auth = [],
  25. apps = options.auth ? JSON.parse(options.auth) : getApp().globalData.queryPer.query(wx.getStorageSync('userauth'), ['营销工具'], ['销售线索'])[0].apps;
  26. apps[0].meta.auth.forEach(v => auth.push(v.optionname))
  27. this.setData({
  28. auth
  29. })
  30. this.getList()
  31. },
  32. /* 打开弹窗 */
  33. openSheet(e) {
  34. this.setData({
  35. sheetTitle: "添加线索"
  36. })
  37. },
  38. /* 结束新建 */
  39. endInsert() {
  40. this.setData({
  41. initInsert: false,
  42. sheetTitle: ""
  43. })
  44. setTimeout(() => {
  45. this.setData({
  46. initInsert: true
  47. })
  48. }, 10);
  49. this.getList(true);
  50. },
  51. /* 查询列表 */
  52. getList(init = false) {
  53. if (init.detail != undefined) init = init.detail;
  54. if (init) this.setData({
  55. ['content.pageNumber']: 1
  56. })
  57. if (this.data.content.pageNumber > this.data.content.pageTotal) return;
  58. let content = this.data.content;
  59. if (this.data.sort != null) content.sort = this.data.sort;
  60. _Http.basic({
  61. "classname": "saletool.orderclue.web.orderclue",
  62. "method": "selectList",
  63. content
  64. }).then(res => {
  65. console.log("列表", res)
  66. this.selectComponent('#ListBox').RefreshToComplete();
  67. if (res.msg != '成功') return wx.showToast({
  68. title: res.msg,
  69. icon: "none"
  70. });
  71. this.setData({
  72. list: (res.pageNumber == 1) ? res.data : this.data.list.concat(res.data),
  73. ['content.pageNumber']: res.pageNumber + 1,
  74. ['content.pageTotal']: res.pageTotal,
  75. sort: res.sort
  76. })
  77. })
  78. },
  79. /* 切换tab分类 */
  80. tabsChange({
  81. detail
  82. }) {
  83. let tagColor = '#BBBBBB';
  84. switch (detail.title) {
  85. case '待跟进':
  86. tagColor = '#FA8C16'
  87. break;
  88. case '跟进中':
  89. tagColor = '#52C41A'
  90. break;
  91. case '已成交':
  92. tagColor = '#ffffff'
  93. break;
  94. case '丢单':
  95. tagColor = '#FF3B30'
  96. break;
  97. }
  98. this.setData({
  99. 'content.where.status': detail.title,
  100. tagColor,
  101. list: []
  102. })
  103. this.getList(true);
  104. },
  105. /* 搜索 */
  106. inputSharch({
  107. detail
  108. }) {
  109. this.setData({
  110. 'content.where.condition': detail
  111. });
  112. this.getList(true);
  113. },
  114. /* 选择排序方式 */
  115. selectSort() {
  116. if (this.data.sort[0].sorted == 1) {
  117. this.setData({
  118. 'sort[0].sorted': 0,
  119. 'sort[1].sorted': 1,
  120. })
  121. } else {
  122. this.setData({
  123. 'sort[0].sorted': 1,
  124. 'sort[1].sorted': 0,
  125. })
  126. };
  127. this.setData({
  128. isReverse: !this.data.isReverse
  129. })
  130. this.getList(true)
  131. },
  132. onReady() {
  133. getHeight.getHeight('.tabs', this).then(res => {
  134. this.setData({
  135. scrollHeight: res
  136. })
  137. })
  138. },
  139. onShareAppMessage(res) { }
  140. })