detail.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. // miniprogram/pages/detail/detail.js
  2. const app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. detail: {},
  9. name: "",
  10. id: ""
  11. },
  12. /**
  13. * 生命周期函数--监听页面加载
  14. */
  15. onLoad: async function (options) {
  16. wx.setNavigationBarTitle({
  17. title: decodeURIComponent(options.title) || "详情"
  18. })
  19. wx.showShareMenu({
  20. withShareTicket: true,
  21. });
  22. this.setData({
  23. detail: {
  24. type: options.type,
  25. content: app.globalData.origin[options.key] || ""
  26. }
  27. })
  28. },
  29. /**
  30. * 生命周期函数--监听页面初次渲染完成
  31. */
  32. onReady: function () {
  33. },
  34. /**
  35. * 生命周期函数--监听页面显示
  36. */
  37. onShow: function () {
  38. },
  39. /**
  40. * 生命周期函数--监听页面隐藏
  41. */
  42. onHide: function () {
  43. },
  44. /**
  45. * 生命周期函数--监听页面卸载
  46. */
  47. onUnload: function () {
  48. },
  49. /**
  50. * 页面相关事件处理函数--监听用户下拉动作
  51. */
  52. onPullDownRefresh: function () {
  53. },
  54. /**
  55. * 页面上拉触底事件的处理函数
  56. */
  57. onReachBottom: function () {
  58. },
  59. /**
  60. * 用户点击右上角分享
  61. */
  62. onShareAppMessage: function () {
  63. return {
  64. title: this.data.name, // 分享名称
  65. path: 'pages/detail/detail?title=' + this.data.name + '&id=' + this.data.id, // 点击分享后的链接要来到的页面的路径已经对应需要的参数
  66. }
  67. },
  68. format: function (res) {
  69. if (!res) return "";
  70. let num = (res || 0) - 0;
  71. let T = new Date(num);
  72. let year = T.getFullYear();
  73. let month = T.getMonth() + 1;
  74. let day = T.getDate();
  75. let hour = T.getHours();
  76. let min = T.getMinutes() + 1;
  77. let sec = T.getSeconds();
  78. return year + "-" + (month > 9 ? month : "0" + month) + "-" + day + " " + (hour > 9 ? hour : '0' + hour) + ":" + (min > 9 ? min : '0' + min) + ":" + (sec > 9 ? sec : '0' + sec);
  79. },
  80. })