index.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. content: {
  5. loading: false,
  6. "ownertable": "sa_project",
  7. sa_projectid: "",
  8. nocache: true,
  9. pageNumber: 1,
  10. pageSize: 20,
  11. pageTotal: 1,
  12. total: 0,
  13. where: {
  14. "condition": "",
  15. }
  16. },
  17. list: [],
  18. },
  19. getList(init = false) {
  20. const content = this.data.content;
  21. if (init) content.pageNumber = 1;
  22. if (content.pageNumber > content.pageTotal) return;
  23. _Http.basic({
  24. id: 20240531152004,
  25. content
  26. }).then(res => {
  27. console.log("通讯录列表", res)
  28. if (res.msg != '成功') return wx.showToast({
  29. title: res.data,
  30. icon: "none"
  31. });
  32. content.pageNumber = res.pageNumber + 1;
  33. content.pageTotal = res.pageTotal;
  34. content.total = res.total;
  35. this.setData({
  36. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  37. content
  38. })
  39. })
  40. },
  41. onLoad(options) {
  42. if (options.sa_projectid) this.setData({
  43. 'content.ownertable': "sa_project",
  44. 'content.ownerid': options.sa_projectid,
  45. 'content.sa_projectid': options.sa_projectid
  46. });
  47. this.getList();
  48. },
  49. /* 默认添加 */
  50. created() {
  51. wx.redirectTo({
  52. url: '/packageA/project/modules/contacts/add/index?sa_projectid=' + this.data.content.sa_projectid,
  53. })
  54. },
  55. onClick(e) {
  56. if (this.data.loading) return;
  57. const {
  58. item
  59. } = e.currentTarget.dataset;
  60. delete(item.tag1)
  61. item.sa_project_contactsid = 0;
  62. item.sa_projectid = this.data.content.sa_projectid;
  63. item.ownertable = "sa_project";
  64. item.ownerid = item.sa_projectid;
  65. this.data.loading = true;
  66. _Http.basic({
  67. "id": "20221219135502",
  68. "content": item
  69. }).then(res => {
  70. console.log("添加项目联系人", res)
  71. this.data.loading = false;
  72. wx.showToast({
  73. title: res.msg != '成功' ? res.msg : '添加成功',
  74. icon: "none",
  75. mask: true
  76. })
  77. if (res.msg == '成功') setTimeout(() => {
  78. wx.navigateBack()
  79. getCurrentPages().forEach(v => {
  80. if (v.__route__ == 'packageA/project/detail') {
  81. let page = v.selectComponent("#Contacts");
  82. page.getList(item.sa_projectid, true)
  83. }
  84. });
  85. }, 500)
  86. })
  87. return
  88. wx.redirectTo({
  89. url: `/packageA/project/modules/contacts/add/index?sa_projectid=${this.data.content.sa_projectid}&data=${JSON.stringify(item)}`,
  90. })
  91. },
  92. onSearch({
  93. detail
  94. }) {
  95. this.setData({
  96. 'content.where.condition': detail ? detail : ""
  97. });
  98. this.getList(true);
  99. },
  100. onClear() {
  101. this.setData({
  102. 'content.where.condition': ""
  103. });
  104. this.getList(true);
  105. },
  106. onReachBottom() {
  107. this.getList();
  108. },
  109. })