contacts.js 1.9 KB

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