search.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. const _Http = getApp().globalData.http,
  2. getHeight = require("../../utils/getRheRemainingHeight");
  3. Page({
  4. data: {
  5. content: {
  6. "type": 0,
  7. "pageNumber": 1,
  8. "pageSize": 20,
  9. "where": {
  10. "condition": "",
  11. "status": "",
  12. "startdate": "",
  13. "enddate": ""
  14. },
  15. "sort": [{
  16. sortname: "默认",
  17. sorted: 1,
  18. sortid: 68,
  19. reversed: 0
  20. }]
  21. },
  22. },
  23. onLoad(options) {
  24. this.getList();
  25. },
  26. startSearch({
  27. detail
  28. }) {
  29. this.setData({
  30. "content.where.condition": detail
  31. })
  32. this.getList(true);
  33. },
  34. onClear() {
  35. this.setData({
  36. "content.where.condition": ""
  37. })
  38. this.getList(true);
  39. },
  40. getList(init = false) {
  41. if (init.detail != undefined) init = init.detail;
  42. let content = this.data.content;
  43. if (init) content.pageNumber = 1;
  44. if (content.pageNumber > content.pageTotal) return;
  45. _Http.basic({
  46. "id": 20221020143502,
  47. content
  48. }).then(res => {
  49. console.log("客户商机列表", res)
  50. this.selectComponent('#ListBox').RefreshToComplete();
  51. if (res.msg != '成功') return wx.showToast({
  52. title: res.data,
  53. icon: "none"
  54. })
  55. res.data = res.data.map(v => {
  56. v.winrate = parseFloat(v.winrate.substring(0, v.winrate.length - 1));
  57. return v
  58. })
  59. this.setData({
  60. 'content.pageNumber': res.pageNumber + 1,
  61. 'content.pageTotal': res.pageTotal,
  62. 'content.total': res.total,
  63. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data)
  64. })
  65. })
  66. },
  67. onReady() {
  68. getHeight.getHeight('.total', this).then(res => this.setData({
  69. listHeight: res
  70. }));
  71. },
  72. })