distributor.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. // components/BdList/BdList.js
  2. const {
  3. api_teamMember_list,
  4. } = require('../../utils/api.js');
  5. const {
  6. net
  7. } = require('../../utils/net.js');
  8. const util = require('../../utils/util.js');
  9. Component({
  10. /**
  11. * 组件的属性列表
  12. */
  13. properties: {
  14. checkType: {
  15. type: String,
  16. value: ''
  17. },
  18. radioId: {
  19. type: [String, Number],
  20. value: ''
  21. },
  22. height: {
  23. type: [String, Number],
  24. value: ''
  25. },
  26. sourceUserIds: {
  27. type: Array,
  28. value: []
  29. },
  30. auditStatus: {
  31. type: [String, Number],
  32. value: ''
  33. }
  34. },
  35. /**
  36. * 组件的初始数据
  37. */
  38. data: {
  39. isFliter: false,
  40. positionType: 8,
  41. dataArr: [],
  42. loadingFlag: true,
  43. totalCount: null,
  44. page: 1,
  45. limit: 10,
  46. keyWord: "",
  47. resultData: {},
  48. scrollViewHeight: 0,
  49. sourceUserIdArr: []
  50. },
  51. /**
  52. * 组件的方法列表
  53. */
  54. methods: {
  55. getScrollViewHeight() {
  56. let height = this.data.height
  57. const query = wx.createSelectorQuery().in(this)
  58. query.select('.search-wrap').boundingClientRect()
  59. query.exec(res => {
  60. res.forEach(element => {
  61. if (element && element.height) {
  62. height = height - element.height
  63. }
  64. });
  65. this.setData({
  66. scrollViewHeight: height
  67. })
  68. })
  69. },
  70. getResultDataCallack(data) {
  71. this.setData({
  72. totalCount: null,
  73. resultData: data,
  74. isFliter: Object.keys(data).length === 0 ? false : true
  75. }, () => {
  76. this.data.page = 1
  77. this.getData();
  78. })
  79. },
  80. goFilterHandle() {
  81. wx.navigateTo({
  82. url: `/pages/mydistributorfilter/mydistributorfilter?resultData=${JSON.stringify(this.data.resultData)}`
  83. })
  84. },
  85. reachBottomHandle() {
  86. let page = this.data.page + 1
  87. this.data.page = page
  88. this.getData(page)
  89. },
  90. // 实时搜索
  91. touchSearch(event) {
  92. let _this = this;
  93. clearTimeout(this.timer)
  94. this.timer = setTimeout(() => {
  95. _this.searchHandle(event);
  96. }, 500)
  97. },
  98. // 完成搜索
  99. searchHandle(event) {
  100. this.setData({
  101. totalCount: null,
  102. keyWord: event.detail.value,
  103. }, () => {
  104. this.data.page = 1
  105. this.getData();
  106. })
  107. },
  108. getData() {
  109. const { totalCount, dataArr } = this.data
  110. if ((totalCount && parseInt(totalCount)) === dataArr.length) {
  111. return false
  112. }
  113. let params = {
  114. url: api_teamMember_list,
  115. data: {
  116. page: this.data.page,
  117. limit: this.data.limit,
  118. keyWord: this.data.keyWord,
  119. positionType: this.data.positionType,
  120. }
  121. }
  122. if (this.data.auditStatus) {
  123. params.data.auditStatus = this.data.auditStatus
  124. }
  125. params.data = Object.assign({}, params.data, this.data.resultData)
  126. if (this.data.keywords) {
  127. params.data.keywords = this.data.keywords
  128. }
  129. this.setData({
  130. loadingFlag: true
  131. })
  132. net.req(params).then((res) => {
  133. this.setData({
  134. loadingFlag: false,
  135. dataArr: this.data.page > 1 ? this.data.dataArr.concat(res.data.list) : res.data.list || [],
  136. totalCount: res.data.pages.totalCount
  137. }, () => {
  138. this.getScrollViewHeight()
  139. })
  140. })
  141. },
  142. showDetail(options) {
  143. const {
  144. item
  145. } = options.currentTarget.dataset;
  146. const { checkType } = this.data
  147. if (checkType) {
  148. if (checkType == 1) {
  149. // 单选来源人
  150. this.triggerEvent('radioEvent', item)
  151. } else if (checkType == 2) {
  152. this.triggerEvent('checkBoxEvent', item)
  153. }
  154. return false
  155. }
  156. wx.navigateTo({
  157. url: `/pages/mydistributorsdetail/mydistributorsdetail?id=${item.id}`
  158. })
  159. },
  160. },
  161. observers: {
  162. 'sourceUserIds': function (subfield) {
  163. this.setData({
  164. sourceUserIdArr: subfield
  165. })
  166. },
  167. },
  168. lifetimes: {
  169. attached: function () {
  170. },
  171. ready() {
  172. this.getData()
  173. }
  174. },
  175. })