index.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. loading: true,
  5. "content": {
  6. "version": 1,
  7. nocache: true,
  8. "pageNumber": 1,
  9. "pageTotal": 1,
  10. "where": {
  11. "condition": ""
  12. },
  13. sort: []
  14. }
  15. },
  16. onLoad(options) {
  17. this.getList()
  18. },
  19. /* 处理筛选 */
  20. handleFilter({
  21. detail
  22. }) {
  23. console.log(detail)
  24. },
  25. getList(init = false) {
  26. if (init.detail != undefined) init = init.detail;
  27. let content = this.data.content;
  28. if (init) content.pageNumber = 1;
  29. if (content.pageNumber > content.pageTotal) return;
  30. _Http.basic({
  31. "id": 20231025144003,
  32. content
  33. }).then(res => {
  34. console.log("活动列表", res)
  35. this.selectComponent('#ListBox').RefreshToComplete();
  36. let list = res.data.map(v => {
  37. v.surplus = Date.parse(new Date(v.enddate)) - Date.parse(new Date())
  38. return v
  39. });
  40. this.setData({
  41. list: res.pageNumber == 1 ? list : this.data.list.concat(list),
  42. "content.pageNumber": res.pageNumber + 1,
  43. "content.pageTotal": res.pageTotal,
  44. "content.sort": res.sort,
  45. loading: false
  46. })
  47. })
  48. },
  49. /* intervalTime(startTime, endTime) {
  50. var timestamp = ,
  51. startTamp = Date.parse(new Date(startTime)),
  52. endTamp = Date.parse(new Date(endTime));
  53. return endTamp - timestamp
  54. }, */
  55. /* 搜索 */
  56. onSearch({
  57. detail
  58. }) {
  59. this.setData({
  60. "content.where.condition": detail
  61. });
  62. this.getList(true)
  63. },
  64. onReady() {
  65. this.setListHeight()
  66. },
  67. /* 设置页面高度 */
  68. setListHeight() {
  69. this.selectComponent("#ListBox").setHeight(".division", this);
  70. },
  71. })