contacts.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. content: {
  5. nocache: true,
  6. pageNumber: 1,
  7. pageSize: 20,
  8. ownertable: "",
  9. ownerid: "",
  10. pageTotal: 1,
  11. total: 0,
  12. where: {
  13. "condition": "",
  14. }
  15. },
  16. list: [],
  17. },
  18. getList(init = false) {
  19. const content = this.data.content;
  20. if (init) content.pageNumber = 1;
  21. if (content.pageNumber > content.pageTotal) return;
  22. _Http.basic({
  23. id: 20240531152004,
  24. content
  25. }).then(res => {
  26. console.log("通讯录列表", res)
  27. if (res.msg != '成功') return wx.showToast({
  28. title: res.data,
  29. icon: "none"
  30. });
  31. content.pageNumber = res.pageNumber + 1;
  32. content.pageTotal = res.pageTotal;
  33. content.total = res.total;
  34. this.setData({
  35. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  36. content
  37. })
  38. })
  39. },
  40. onLoad(options) {
  41. this.getList();
  42. },
  43. onClick(e) {
  44. const {
  45. item
  46. } = e.currentTarget.dataset;
  47. getApp().globalData.handleSelect(item)
  48. },
  49. onSearch({
  50. detail
  51. }) {
  52. console.log(detail)
  53. this.setData({
  54. 'content.where.condition': detail ? detail : ""
  55. });
  56. this.getList(true);
  57. },
  58. onClear() {
  59. this.setData({
  60. 'content.where.condition': ""
  61. });
  62. this.getList(true);
  63. },
  64. onReachBottom() {
  65. this.getList();
  66. },
  67. })