123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- // miniprogram/pages/detail/detail.js
- import { httpCloud } from "../../utils/httpFunc";
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- detail: {}
- },
- nameText: "",
- idText: "",
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: async function (options) {
- const _this = this;
- this.nameText = decodeURIComponent(options.title || "详情");
- this.idText = options.id || "";
- wx.setNavigationBarTitle({
- title: this.nameText
- })
- httpCloud({
- name: "server",
- type: "getArticle",
- data: {
- id: options.id,
- },
- call(res) {
- console.log(res)
- _this.setData({
- detail: res || {}
- })
- }
- })
- wx.showShareMenu({
- withShareTicket: true,
- });
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- return {
- title: this.nameText, // 分享名称
- path: 'pages/detail/detail?title=' + this.nameText + '&id=' + this.data.id, // 点击分享后的链接要来到的页面的路径已经对应需要的参数
- }
- },
- format: function (res) {
- if (!res) return "";
- let num = (res || 0) - 0;
- let T = new Date(num);
- let year = T.getFullYear();
- let month = T.getMonth() + 1;
- let day = T.getDate();
- let hour = T.getHours();
- let min = T.getMinutes() + 1;
- let sec = T.getSeconds();
- return year + "-" + (month > 9 ? month : "0" + month) + "-" + day + " " + (hour > 9 ? hour : '0' + hour) + ":" + (min > 9 ? min : '0' + min) + ":" + (sec > 9 ? sec : '0' + sec);
- },
- })
|