index.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. content: {
  5. "ownertable": "sa_project",
  6. sa_projectid: "",
  7. nocache: true,
  8. pageNumber: 1,
  9. pageSize: 20,
  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. if (options.sa_projectid) this.setData({
  42. 'content.ownertable': "sa_project",
  43. 'content.ownerid': options.sa_projectid,
  44. 'content.sa_projectid': options.sa_projectid
  45. });
  46. this.getList();
  47. },
  48. /* 默认添加 */
  49. created() {
  50. wx.redirectTo({
  51. url: '/packageA/project/modules/contacts/add/index?sa_projectid=' + this.data.content.sa_projectid,
  52. })
  53. },
  54. onClick(e) {
  55. const {
  56. item
  57. } = e.currentTarget.dataset;
  58. delete(item.tag1)
  59. wx.redirectTo({
  60. url: `/packageA/project/modules/contacts/add/index?sa_projectid=${this.data.content.sa_projectid}&data=${JSON.stringify(item)}`,
  61. })
  62. },
  63. onSearch({
  64. detail
  65. }) {
  66. this.setData({
  67. 'content.where.condition': detail ? detail : ""
  68. });
  69. this.getList(true);
  70. },
  71. onClear() {
  72. this.setData({
  73. 'content.where.condition': ""
  74. });
  75. this.getList(true);
  76. },
  77. onReachBottom() {
  78. this.getList();
  79. },
  80. })