index.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. 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: this.data.active == 0 ? 20221219161202 : 20221219201402,
  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. onChange(e) {
  41. this.setData({
  42. active: e.detail.index
  43. });
  44. this.getList(true);
  45. },
  46. onLoad(options) {
  47. if (options.sa_projectid) this.setData({
  48. 'content.ownertable': "sa_project",
  49. 'content.ownerid': options.sa_projectid,
  50. 'content.sa_projectid': options.sa_projectid
  51. });
  52. this.getList();
  53. },
  54. /* 默认添加 */
  55. created() {
  56. wx.redirectTo({
  57. url: '/packageA/project/modules/contacts/add/index?sa_projectid=' + this.data.content.sa_projectid,
  58. })
  59. },
  60. onClick(e) {
  61. const {
  62. item
  63. } = e.currentTarget.dataset;
  64. delete(item.tag1)
  65. wx.redirectTo({
  66. url: `/packageA/project/modules/contacts/add/index?sa_projectid=${this.data.content.sa_projectid}&data=${JSON.stringify(item)}`,
  67. })
  68. },
  69. onSearch({
  70. detail
  71. }) {
  72. this.setData({
  73. 'content.where.condition': detail ? detail : ""
  74. });
  75. this.getList(true);
  76. },
  77. onClear() {
  78. this.setData({
  79. 'content.where.condition': ""
  80. });
  81. this.getList(true);
  82. },
  83. onReachBottom() {
  84. this.getList();
  85. },
  86. })