index.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. sys_enterpriseid: "",
  5. parems: {
  6. id: '20221102110003',
  7. content: {
  8. nocache: true,
  9. pageNumber: 1,
  10. pageSize: 20,
  11. pageTotal: 1,
  12. total: 0,
  13. where: {
  14. "condition": "",
  15. }
  16. }
  17. },
  18. list: [],
  19. radio: "",
  20. acitonItem: {},
  21. },
  22. onLoad(options) {
  23. if (options.sys_enterpriseid) this.setData({
  24. sys_enterpriseid: options.sys_enterpriseid
  25. });
  26. this.getList();
  27. },
  28. /* 默认添加 */
  29. created() {
  30. wx.redirectTo({
  31. url: '/packageA/setclient/modules/contacts/add/index?sys_enterpriseid=' + this.data.sys_enterpriseid,
  32. })
  33. },
  34. /* 快速添加 */
  35. quickly() {
  36. console.log(this.data.acitonItem)
  37. wx.redirectTo({
  38. url: `/packageA/setclient/modules/contacts/add/index?sys_enterpriseid=${this.data.sys_enterpriseid}&data=${JSON.stringify(this.data.acitonItem)}`,
  39. })
  40. },
  41. onClick(e) {
  42. const {
  43. item
  44. } = e.currentTarget.dataset;
  45. delete(item.tag1)
  46. this.setData({
  47. radio: item.sys_phonebookid,
  48. acitonItem: item
  49. })
  50. },
  51. onSearch({
  52. detail
  53. }) {
  54. this.setData({
  55. 'parems.content.where.condition': detail ? detail : ""
  56. });
  57. this.getList(true);
  58. },
  59. onClear() {
  60. this.setData({
  61. 'parems.content.where.condition': ""
  62. });
  63. this.getList(true);
  64. },
  65. getList(init = false) {
  66. const parems = this.data.parems;
  67. if (init) parems.content.pageNumber = 1;
  68. if (parems.content.pageNumber > parems.content.pageTotal) return;
  69. _Http.basic(parems).then(res => {
  70. console.log("通讯录列表", res)
  71. if (res.msg != '成功') return wx.showToast({
  72. title: res.data,
  73. icon: "none"
  74. });
  75. parems.content.pageNumber = res.pageNumber + 1;
  76. parems.content.pageTotal = res.pageTotal;
  77. parems.content.total = res.total;
  78. this.setData({
  79. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  80. parems
  81. })
  82. })
  83. },
  84. onReachBottom() {
  85. this.getList();
  86. },
  87. })