index.js 1.6 KB

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