quickly.js 2.7 KB

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