search.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. content: {
  5. nocache: true,
  6. "type": 0,
  7. "pageNumber": 1,
  8. "pageSize": 20,
  9. "isExport": 0,
  10. "where": {
  11. "condition": "",
  12. "status": "", //状态
  13. "startdate": "",
  14. "enddate": ""
  15. },
  16. },
  17. list: []
  18. },
  19. onLoad(options) {
  20. this.getList();
  21. },
  22. /* 开始搜索 */
  23. startSearch({
  24. detail
  25. }) {
  26. this.setData({
  27. "content.where.condition": detail
  28. });
  29. this.getList(true);
  30. },
  31. onClear() {
  32. this.setData({
  33. "content.where.condition": ""
  34. });
  35. this.getList(true);
  36. },
  37. getList(init = false) {
  38. //init 用于初始化分页
  39. let content = this.data.content;
  40. if (init) content.pageNumber = 1;
  41. if (content.pageNumber > content.pageTotal) return;
  42. _Http.basic({
  43. "id": 20221012164402,
  44. content
  45. }).then(res => {
  46. console.log("搜索客户列表", res)
  47. if (res.msg != '成功') return wx.showToast({
  48. title: res.data,
  49. icon: "none"
  50. })
  51. // this.getTags(res.data.map(v => v.sys_enterpriseid));
  52. this.setData({
  53. 'content.pageNumber': res.pageNumber + 1,
  54. 'content.pageTotal': res.pageTotal,
  55. 'content.total': res.total,
  56. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data)
  57. })
  58. })
  59. },
  60. onReachBottom() {
  61. this.getList();
  62. },
  63. })