index.js 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. sa_customersid: 0
  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: this.data.active == 0 ? 20221219161202 : 20221219193002,
  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. onChange(e) {
  42. this.setData({
  43. active: e.detail.index
  44. });
  45. this.getList(true);
  46. },
  47. onLoad(options) {
  48. console.log(options)
  49. if (options.sys_enterpriseid) this.setData({
  50. 'content.sys_enterpriseid': options.sys_enterpriseid,
  51. 'content.ownertable': 'sa_customers',
  52. 'content.ownerid': options.sa_customersid,
  53. enterprisename: options.enterprisename,
  54. sa_customersid: options.sa_customersid
  55. });
  56. this.getList();
  57. },
  58. /* 默认添加 */
  59. created() {
  60. wx.redirectTo({
  61. url: '/packageA/setclient/modules/contacts/add/index?sys_enterpriseid=' + this.data.content.sys_enterpriseid + "&enterprisename=" + this.data.enterprisename + "&sa_customersid=" + this.data.sa_customersid,
  62. })
  63. },
  64. onClick(e) {
  65. const {
  66. item
  67. } = e.currentTarget.dataset;
  68. delete(item.tag1)
  69. wx.redirectTo({
  70. url: `/packageA/setclient/modules/contacts/add/index?sys_enterpriseid=${this.data.content.sys_enterpriseid}&enterprisename=${this.data.enterprisename}&sa_customersid=${this.data.sa_customersid}&data=${JSON.stringify(item)}`,
  71. })
  72. },
  73. onSearch({
  74. detail
  75. }) {
  76. this.setData({
  77. 'parems.content.where.condition': detail ? detail : ""
  78. });
  79. this.getList(true);
  80. },
  81. onClear() {
  82. this.setData({
  83. 'parems.content.where.condition': ""
  84. });
  85. this.getList(true);
  86. },
  87. onReachBottom() {
  88. this.getList();
  89. },
  90. })