index.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. return wx.redirectTo({
  62. url: `/packageA/project/modules/contacts/add/index?sa_projectid=${this.data.content.sa_projectid}&data=${JSON.stringify(item)}&sys_phonebookid=${item.sys_phonebookid}`,
  63. })
  64. item.sa_project_contactsid = 0;
  65. item.sa_projectid = this.data.content.sa_projectid;
  66. item.ownertable = "sa_project";
  67. item.ownerid = item.sa_projectid;
  68. this.data.loading = true;
  69. _Http.basic({
  70. "id": "20221219135502",
  71. "content": item
  72. }).then(res => {
  73. console.log("添加项目联系人", res)
  74. this.data.loading = false;
  75. wx.showToast({
  76. title: res.msg != '成功' ? res.msg : '添加成功',
  77. icon: "none",
  78. mask: true
  79. })
  80. if (res.msg == '成功') setTimeout(() => {
  81. wx.navigateBack()
  82. getCurrentPages().forEach(v => {
  83. if (v.__route__ == 'packageA/project/detail') {
  84. let page = v.selectComponent("#Contacts");
  85. page.getList(item.sa_projectid, true)
  86. }
  87. });
  88. }, 500)
  89. })
  90. },
  91. onSearch({
  92. detail
  93. }) {
  94. this.setData({
  95. 'content.where.condition': detail ? detail : ""
  96. });
  97. this.getList(true);
  98. },
  99. onClear() {
  100. this.setData({
  101. 'content.where.condition': ""
  102. });
  103. this.getList(true);
  104. },
  105. onReachBottom() {
  106. this.getList();
  107. },
  108. })