search.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. const _Http = getApp().globalData.http,
  2. getHeight = require("../../../../utils/getRheRemainingHeight");
  3. Page({
  4. data: {
  5. content: null
  6. },
  7. onLoad(options) {
  8. this.setData({
  9. content: JSON.parse(options.data)
  10. });
  11. this.getList(true);
  12. },
  13. /* 获取地址列表 */
  14. getList(init) {
  15. if (init.detail != undefined) init = init.detail;
  16. let content = this.data.content;
  17. if (init) content.pageNumber = 1
  18. if (content.pageNumber > content.pageTotal) return;
  19. _Http.basic({
  20. "id": "20221027143702",
  21. content
  22. }).then(res => {
  23. console.log("关联客户列表", res)
  24. if (res.msg != '成功') return wx.showToast({
  25. title: res.data,
  26. icon: "none"
  27. })
  28. this.getTags(res.data.map(v => v.sa_customersid));
  29. this.setData({
  30. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  31. "content.pageNumber": res.pageNumber + 1,
  32. "content.pageSize": res.pageSize,
  33. "content.pageTotal": res.pageTotal,
  34. "content.total": res.total
  35. })
  36. })
  37. },
  38. /* 开始搜索 */
  39. startSearch({
  40. detail
  41. }) {
  42. if (detail == this.data.content.where.condition) return;
  43. this.setData({
  44. 'content.where.condition': detail
  45. });
  46. this.getList(true);
  47. },
  48. /* 取消搜索 */
  49. onClear() {
  50. this.setData({
  51. 'content.where.condition': ""
  52. });
  53. this.getList(true);
  54. },
  55. /* 获取列表标签 */
  56. getTags(ownerids = []) {
  57. _Http.basic({
  58. "id": 20221018102001,
  59. "content": {
  60. "ownertable": "sa_customers",
  61. ownerids
  62. }
  63. }).then(res => {
  64. console.log("标签", res)
  65. let list = this.data.list;
  66. for (let key in res.data) {
  67. let index = list.findIndex(v => v.sa_customersid == key);
  68. list[index].tags = res.data[key]
  69. };
  70. this.setData({
  71. list
  72. })
  73. })
  74. },
  75. onReady() {
  76. getHeight.getHeight('.search', this).then(res => this.setData({
  77. listHeight: res
  78. }));
  79. },
  80. })