quickly.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. content: {
  5. loading: false,
  6. sa_contractid: "",
  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: 20240923153304,
  24. content
  25. }).then(res => {
  26. console.log("通讯录列表", res)
  27. if (res.code != '1') return wx.showToast({
  28. title: res.msg,
  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.id) this.setData({
  42. 'content.sa_contractid': options.id
  43. });
  44. this.getList();
  45. getApp().globalData.Language.getLanguagePackage(this, '选择联系人');
  46. },
  47. onClick(e) {
  48. if (this.data.loading) return;
  49. const {
  50. item
  51. } = e.currentTarget.dataset,
  52. sa_contractid = this.data.content.sa_contractid;
  53. this.data.loading = true;
  54. _Http.basic({
  55. "id": "20240923153004",
  56. "content": {
  57. sa_contractid,
  58. "sys_phonebookid": item.sys_phonebookid
  59. }
  60. }).then(res => {
  61. console.log("添加合同联系人", res)
  62. this.data.loading = false;
  63. wx.showToast({
  64. title: getApp().globalData.Language.getMapText(res.code != '1' ? res.msg : '添加成功'),
  65. icon: "none",
  66. mask: res.code == '1'
  67. })
  68. if (res.code == '1') setTimeout(() => {
  69. wx.navigateBack()
  70. getCurrentPages().forEach(v => {
  71. if (v.__route__ == 'packageA/contract/detail') {
  72. let page = v.selectComponent("#Contacts");
  73. page.getList(sa_contractid, true)
  74. }
  75. });
  76. }, 500)
  77. })
  78. },
  79. onSearch({
  80. detail
  81. }) {
  82. this.setData({
  83. 'content.where.condition': detail ? detail : ""
  84. });
  85. this.getList(true);
  86. },
  87. onClear() {
  88. this.setData({
  89. 'content.where.condition': ""
  90. });
  91. this.getList(true);
  92. },
  93. onReachBottom() {
  94. this.getList();
  95. },
  96. })