client.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. import agentApi from '../../apis/agent'
  2. import { encryption } from '../../utils/encryption'
  3. import { bindInput } from '../../utils/utils'
  4. import { isPhoneX } from './../../utils/tools'
  5. const panelData={
  6. 'mudi':[
  7. {
  8. id:'mudi',
  9. items:[{
  10. name:'不限',
  11. id:''
  12. },{
  13. name:'刚需',
  14. id:''
  15. },{
  16. name:'改善',
  17. id:''
  18. }]
  19. }
  20. ],
  21. 'yixiang':[
  22. {
  23. id:'yixiang',
  24. items:[{
  25. name:'不限',
  26. id:''
  27. },{
  28. name:'强烈',
  29. id:3,
  30. icon_num: 3,
  31. icon: 'iconcus_star',
  32. },{
  33. name:'一般',
  34. id:2,
  35. icon: 'iconcus_star',
  36. icon_num: 2
  37. },{
  38. name:'较弱',
  39. id:1,
  40. icon: 'iconcus_star',
  41. icon_num: 1
  42. },{
  43. name:'暂不关注',
  44. id:0
  45. }]
  46. }
  47. ],
  48. 'paixu':[
  49. {
  50. id:'paixu',
  51. items:[{
  52. name:'不限',
  53. id:''
  54. },{
  55. name:'最近维护',
  56. id:'time'
  57. }]
  58. }
  59. ]
  60. }
  61. let type_acive = ''
  62. const app = getApp();
  63. Page({
  64. /**
  65. * 组件的属性列表
  66. */
  67. data: {
  68. clients: [],
  69. //todo 4个 icon栏位,可后台配置, 调用IconClick函数。
  70. icon_list: [
  71. {name: '目的',icon:'edit',type:"mudi"},
  72. {name: '意向',icon:'edit',type:"yixiang"},
  73. {name: '排序',icon:'write',type:"paixu"}
  74. ],
  75. type_acive,
  76. tab_panel:panelData[type_acive]||[],
  77. fetcherData: {
  78. page: 1,
  79. agency_user_id: '',
  80. size: 10,
  81. user_wish: '',
  82. purpose:''
  83. },
  84. has_next: true,
  85. navbarInitTop: 0,
  86. seachKey:'',
  87. },
  88. bindInput,
  89. changeListType(e){
  90. let {type} = e.currentTarget.dataset
  91. let obj = {
  92. type_acive:type,
  93. tab_panel:panelData[type]
  94. }
  95. if (type===this.data.type_acive) {
  96. obj['type_acive'] =''
  97. }
  98. this.setData(obj)
  99. },
  100. selecthandle(e){
  101. let {selectObj} = e.detail
  102. let tmp = Object.assign(this.data.fetcherData,{
  103. purpose:(selectObj.mudi)?String(selectObj.mudi.name):'',
  104. user_wish:selectObj.yixiang?selectObj.yixiang.id:'',
  105. order: selectObj.paixu ? selectObj.paixu.id : ''
  106. })
  107. this.setData({
  108. fetcherData: tmp
  109. })
  110. this.getClientList()
  111. },
  112. closeTypeActive(){
  113. this.setData({
  114. type_acive:''
  115. })
  116. },
  117. toAddClient(){
  118. wx.navigateTo({
  119. url: '/pages/add-client/add-client'
  120. })
  121. },
  122. onReachBottomDistance: 50,
  123. onReachBottom: function () {
  124. let page = this.data.fetcherData.page++
  125. this.setData({
  126. 'fetcherData.page': page
  127. })
  128. this.getClientList()
  129. },
  130. // onPageScroll: function (e) { // 调用showImg函数
  131. // var top = e.scrollTop;
  132. // try {
  133. // //判断'滚动条'滚动的距离 和 '元素在初始时'距顶部的距离进行判断
  134. // var isSatisfy = top >= this.data.navbarInitTop ? true : false;
  135. // //为了防止不停的setData, 这儿做了一个等式判断。 只有处于吸顶的临界值才会不相等
  136. // if (this.data.isFixedTop === isSatisfy) {
  137. // return false;
  138. // }
  139. // console.log(isSatisfy)
  140. // this.setData({
  141. // isFixedTop: isSatisfy
  142. // });
  143. // } catch (e) {
  144. // console.log(e)
  145. // }
  146. // },
  147. onShow: function () {
  148. this.getClientList()
  149. },
  150. getClientList: function () {
  151. this.setData({
  152. 'fetcherData.agency_user_id': app.globalData.userinfo.agency_user_id
  153. })
  154. app.wxshowloading('拼命加载中...');
  155. agentApi.fetchCustomers(this.data.fetcherData).then(res => {
  156. this.setData({
  157. clients: res.data.list
  158. })
  159. }).finally(() => {
  160. wx.hideLoading()
  161. })
  162. },
  163. tapSearch(){
  164. this.setData({
  165. 'fetcherData.user_name': this.data.seachKey,
  166. })
  167. this.getClientList()
  168. },
  169. onLoad: function (options) {
  170. isPhoneX().then(res => {
  171. this.setData({
  172. isPhoneX: res
  173. })
  174. })
  175. }
  176. });