index.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. // pages/imgController/index.js
  2. import {
  3. httpCloud
  4. } from "../../utils/httpFunc";
  5. import {
  6. dateFormmat
  7. } from "../../utils/tool"
  8. Page({
  9. /**
  10. * 页面的初始数据
  11. */
  12. data: {
  13. mediaList: [],
  14. activityName: '',
  15. },
  16. nameText: "",
  17. page: 0,
  18. limit: 100,
  19. getDate() {
  20. const _this = this;
  21. httpCloud({
  22. name: "server",
  23. type: "getMediaController",
  24. data: {
  25. typeMedia: this.mediaType,
  26. page: this.page,
  27. limit: this.limit,
  28. activityName: this.data.activityName
  29. },
  30. call(res) {
  31. if (!res.length) {
  32. this.page = -1;
  33. return
  34. }
  35. _this.setData({
  36. mediaList: (res || []).map(v => {
  37. const date = dateFormmat(v.date);
  38. return {
  39. ...v,
  40. date: [date.year, date.month, date.day].join("-"),
  41. mediaType: _this.mediaType,
  42. }
  43. })
  44. })
  45. }
  46. })
  47. },
  48. /**
  49. * 生命周期函数--监听页面加载
  50. */
  51. onLoad(options) {
  52. this.nameText = decodeURIComponent(options.title || "详情");
  53. this.mediaType = options.mediaType || 'image';
  54. this.setData({
  55. activityName: options.activity,
  56. })
  57. wx.setNavigationBarTitle({
  58. title: this.nameText
  59. })
  60. this.page = 0;
  61. this.getDate()
  62. },
  63. /**
  64. * 生命周期函数--监听页面初次渲染完成
  65. */
  66. onReady() {},
  67. /**
  68. * 生命周期函数--监听页面显示
  69. */
  70. onShow() {},
  71. /**
  72. * 生命周期函数--监听页面隐藏
  73. */
  74. onHide() {},
  75. /**
  76. * 生命周期函数--监听页面卸载
  77. */
  78. onUnload() {},
  79. /**
  80. * 页面相关事件处理函数--监听用户下拉动作
  81. */
  82. onPullDownRefresh() {},
  83. /**
  84. * 页面上拉触底事件的处理函数
  85. */
  86. onReachBottom() {
  87. if (this.page === -1) return;
  88. this.page += 1;
  89. this.getDate();
  90. },
  91. onShareAppMessage: function () {
  92. return {
  93. title: "", // 分享名称
  94. path: 'pages/home/index', // 点击分享后的链接要来到的页面的路径已经对应需要的参数
  95. }
  96. },
  97. })