index.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. content: {
  5. nocache: true,
  6. "sa_projectid": 1,
  7. "pageNumber": 1,
  8. "pageTotal": 1,
  9. "pageSize": 20,
  10. total: null,
  11. "where": {
  12. "condition": ""
  13. }
  14. },
  15. },
  16. onLoad(options) {
  17. this.setData({
  18. "content.sa_projectid": options.sa_projectid
  19. })
  20. this.getList();
  21. },
  22. getList(init = false) {
  23. if (init.detail != undefined) init = init.detail;
  24. let content = this.data.content;
  25. if (init) content.pageNumber = 1;
  26. if (content.pageNumber > content.pageTotal) return;
  27. _Http.basic({
  28. "id": 20221111131004,
  29. content
  30. }).then(res => {
  31. console.log("项目联系人搜索", res)
  32. this.selectComponent('#ListBox').RefreshToComplete();
  33. if (res.msg != '成功') return wx.showToast({
  34. title: res.data,
  35. icon: "none"
  36. })
  37. this.setData({
  38. 'content.pageNumber': res.pageNumber + 1,
  39. 'content.pageTotal': res.pageTotal,
  40. 'content.total': res.total,
  41. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data)
  42. })
  43. })
  44. },
  45. /* 开始搜索 */
  46. onSearch({
  47. detail
  48. }) {
  49. if (this.data.content.where.condition == detail) return;
  50. this.setData({
  51. 'content.where.condition': detail
  52. });
  53. this.getList(true)
  54. },
  55. onClear() {
  56. this.setData({
  57. 'content.where.condition': ""
  58. });
  59. this.getList(true)
  60. },
  61. onReady() {
  62. this.selectComponent("#ListBox").setHeight(".search", this);
  63. },
  64. })