index.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. wx.showLoading({})
  18. this.nameText = decodeURIComponent(options.title || "详情");
  19. this.mediaType = options.mediaType || 'image';
  20. wx.setNavigationBarTitle({
  21. title: this.nameText
  22. })
  23. httpCloud({
  24. name: "server",
  25. type: "getMediaController",
  26. data: {
  27. typeMedia: this.mediaType
  28. },
  29. call(res) {
  30. _this.setData({
  31. mediaList: (res || []).map(v=>{
  32. const date = dateFormmat(v.date);
  33. return {
  34. ...v,
  35. date: [date.year, date.month, date.day].join("-"),
  36. mediaType: _this.mediaType,
  37. }
  38. })
  39. })
  40. }
  41. })
  42. },
  43. /**
  44. * 生命周期函数--监听页面初次渲染完成
  45. */
  46. onReady() {
  47. },
  48. /**
  49. * 生命周期函数--监听页面显示
  50. */
  51. onShow() {
  52. },
  53. /**
  54. * 生命周期函数--监听页面隐藏
  55. */
  56. onHide() {
  57. },
  58. /**
  59. * 生命周期函数--监听页面卸载
  60. */
  61. onUnload() {
  62. },
  63. /**
  64. * 页面相关事件处理函数--监听用户下拉动作
  65. */
  66. onPullDownRefresh() {
  67. },
  68. /**
  69. * 页面上拉触底事件的处理函数
  70. */
  71. onReachBottom() {
  72. },
  73. onShareAppMessage: function () {
  74. return {
  75. title: this.nameText, // 分享名称
  76. path: 'pages/detail/detail?title=' + this.nameText, // 点击分享后的链接要来到的页面的路径已经对应需要的参数
  77. }
  78. },
  79. })