viewPage.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. const getHeight = require("../../../../utils/getRheRemainingHeight");
  2. const _Http = getApp().globalData.http;
  3. Component({
  4. /**
  5. * 组件的属性列表
  6. */
  7. properties: {
  8. },
  9. lifetimes: {
  10. ready() {
  11. this.getList();
  12. getHeight.getHeight('.tabs', this).then(res => {
  13. this.setData({
  14. listHeight: res
  15. })
  16. });
  17. }
  18. },
  19. /**
  20. * 组件的初始数据
  21. */
  22. data: {
  23. listHeight: 0,
  24. tabActiveTitle: "列表",
  25. content: { //请求搜索条件
  26. "pageNumber": 1,
  27. "pageSize": 1,
  28. "parentid": 1,
  29. "pageTotal": 1,
  30. "where": {
  31. "condition": "", //搜索内容
  32. "sorttype": 2 //1:热门,2:最新,不传默认最新
  33. }
  34. },
  35. list: [], //文件列表
  36. inTotal: 0, //总计
  37. },
  38. /**
  39. * 组件的方法列表
  40. */
  41. methods: {
  42. /* 获得列表 */
  43. getList(init = false) {
  44. if (init.detail != undefined) init = init.detail;
  45. if (init) this.setData({
  46. ['content.pageNumber']: 1
  47. })
  48. if (this.data.content.pageNumber > this.data.content.pageTotal) return;
  49. _Http.basic({
  50. "classname": "saletool.salematerial.salematerial",
  51. "method": (this.data.tabActiveTitle == '列表') ? "selectList" : "selectMyList",
  52. "content": this.data.content
  53. }).then(res => {
  54. this.selectComponent('#ListBox').RefreshToComplete();
  55. if (res.msg != '成功') return wx.showToast({
  56. title: res.data,
  57. icon: "none"
  58. })
  59. this.setData({
  60. list: (res.pageNumber == 1) ? res.data : this.data.list.concat(res.data),
  61. ['content.pageNumber']: res.pageNumber + 1,
  62. ['content.pageTotal']: res.pageTotal,
  63. inTotal: res.total
  64. })
  65. // console.log((this.data.tabActiveTitle == '列表') ? "列表" : '营销物料', this.data.list)
  66. })
  67. },
  68. /* 搜索框输入 */
  69. searchInput({
  70. detail
  71. }) {
  72. this.setData({
  73. ['content.where.condition']: detail.trim()
  74. })
  75. this.getList(true)
  76. },
  77. /* 清除搜索输入 */
  78. searchClear() {
  79. this.setData({
  80. ['content.where.condition']: ""
  81. })
  82. },
  83. /* tab切换 */
  84. tabsChange({
  85. detail
  86. }) {
  87. this.setData({
  88. tabActiveTitle: detail.title
  89. })
  90. this.getList(true);
  91. },
  92. /* 开关切换 */
  93. changeSwitch({
  94. detail
  95. }) {
  96. this.setData({
  97. ["content.where.sorttype"]: detail == '最新' ? 2 : 1
  98. })
  99. this.getList(true);
  100. },
  101. /* 修改ID */
  102. changeParentid(id) {
  103. this.setData({
  104. ['content.parentid']: id
  105. })
  106. },
  107. }
  108. })