index.js 2.4 KB

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