index.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. active: 0,
  5. content: {
  6. sys_enterpriseid: "",
  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: this.data.active == 0 ? 20221219161202 : 20221219193002,
  24. content
  25. }).then(res => {
  26. console.log("通讯录列表", res)
  27. if (res.msg != '成功') return wx.showToast({
  28. title: res.data,
  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. onChange(e) {
  41. this.setData({
  42. active: e.detail.index
  43. });
  44. this.getList(true);
  45. },
  46. onLoad(options) {
  47. console.log(options)
  48. if (options.sys_enterpriseid) this.setData({
  49. 'content.sys_enterpriseid': options.sys_enterpriseid,
  50. 'content.ownertable': 'sa_customers',
  51. 'content.ownerid': options.sys_enterpriseid,
  52. enterprisename: options.enterprisename
  53. });
  54. this.getList();
  55. },
  56. /* 默认添加 */
  57. created() {
  58. wx.redirectTo({
  59. url: '/packageA/setclient/modules/contacts/add/index?sys_enterpriseid=' + this.data.content.sys_enterpriseid + "&enterprisename=" + this.data.enterprisename,
  60. })
  61. },
  62. onClick(e) {
  63. const {
  64. item
  65. } = e.currentTarget.dataset;
  66. delete(item.tag1)
  67. wx.redirectTo({
  68. url: `/packageA/setclient/modules/contacts/add/index?sys_enterpriseid=${this.data.content.sys_enterpriseid}&enterprisename=${this.data.enterprisename}&data=${JSON.stringify(item)}`,
  69. })
  70. },
  71. onSearch({
  72. detail
  73. }) {
  74. this.setData({
  75. 'parems.content.where.condition': detail ? detail : ""
  76. });
  77. this.getList(true);
  78. },
  79. onClear() {
  80. this.setData({
  81. 'parems.content.where.condition': ""
  82. });
  83. this.getList(true);
  84. },
  85. onReachBottom() {
  86. this.getList();
  87. },
  88. })