liyongli 2 ani în urmă
părinte
comite
a345252072

+ 2 - 1
miniprogram/app.json

@@ -1,6 +1,7 @@
 {
 {
   "pages": [
   "pages": [
     "pages/home/index",
     "pages/home/index",
+    "pages/detail/detail",
     "pages/mediaController/index",
     "pages/mediaController/index",
     "pages/videoDetail/index"
     "pages/videoDetail/index"
   ],
   ],
@@ -8,7 +9,7 @@
     "backgroundColor": "#F6F6F6",
     "backgroundColor": "#F6F6F6",
     "backgroundTextStyle": "light",
     "backgroundTextStyle": "light",
     "navigationBarBackgroundColor": "#F6F6F6",
     "navigationBarBackgroundColor": "#F6F6F6",
-    "navigationBarTitleText": "追寻红色记忆",
+    "navigationBarTitleText": "盛世中华 何以中国",
     "navigationBarTextStyle": "black"
     "navigationBarTextStyle": "black"
   },
   },
   "requiredBackgroundModes": [
   "requiredBackgroundModes": [

+ 102 - 0
miniprogram/pages/detail/detail.js

@@ -0,0 +1,102 @@
+// miniprogram/pages/detail/detail.js
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    detail: {}
+  },
+  nameText: "",
+  idText: "",
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: async function (options) {
+    this.nameText = decodeURIComponent(options.title || "详情");
+    this.idText = options.id || "";
+    wx.setNavigationBarTitle({
+      title:  this.nameText
+    })
+    // const db = wx.cloud.database();
+    // const _ = db.command;
+    // let list = await db.collection('data_news').where({
+    //   _id: _.eq(options.id)
+    // }).get();
+    
+    // let D = list.data[0] || {};
+    // D.content = D.content.replace(/style=\"([a-z|A-Z|-|:|;|0-9|\.]*)\"/g, "").replace(/width=\"([a-z|A-Z|-|:|;|0-9|\.]*)\"/g, "").replace(/height=\"([a-z|A-Z|-|:|;|0-9|\.]*)\"/g, "").replace(/<img/g, "<img style='width: 100%'").replace(/<p/gi, '<p style="text-indent: 2em;min-height: 1em"')
+    // if (D.creat_time) D.creat_time = this.format(D.creat_time);
+    // _this.setData({
+    //   detail: D,
+    // })
+    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);
+  },
+})

+ 3 - 0
miniprogram/pages/detail/detail.json

@@ -0,0 +1,3 @@
+{
+  "usingComponents": {}
+}

+ 9 - 0
miniprogram/pages/detail/detail.wxml

@@ -0,0 +1,9 @@
+<!--miniprogram/pages/detail/detail.wxml-->
+<import src="./template/sysDetail/index.wxml"></import>
+<import src="./template/pdfDetail/index.wxml"></import>
+<import src="./template/defaultDetail/index.wxml"></import>
+<view class="detail">
+  <template wx:if="{{detail.type === 0}}" is="sysDetail" data="{{...detail}}"></template>
+  <template wx:if="{{detail.type === 2}}" is="pdfDetail" data="{{...detail}}"></template>
+  <template wx:if="{{detail.type === 1}}" is="defaultDetail" data="{{...detail}}"></template>
+</view>

+ 8 - 0
miniprogram/pages/detail/detail.wxss

@@ -0,0 +1,8 @@
+/* miniprogram/pages/detail/detail.wxss */
+@import "./template/sysDetail/index.wxss";
+@import "./template/pdfDetail/index.wxss";
+@import "./template/defaultDetail/index.wxss";
+
+.detail{
+  width: 750rpx;
+}

+ 6 - 0
miniprogram/pages/detail/template/defaultDetail/index.wxml

@@ -0,0 +1,6 @@
+<!--miniprogram/pages/detail/template/pdfDetail/index.wxml-->
+<template name="defaultDetail">
+  <video custom-cache="{{false}}" class="video" wx:if="{{headUrl}}" src="{{headUrl}}"></video>
+  <view style="width:730rpx;margin: 10rpx auto;display:block" wx:if="{{creat_time}}"> 发表日期:{{creat_time}}</view>
+  <rich-text wx:if="{{content}}" style="width:730rpx;margin: 10rpx auto;display:block" nodes="{{content}}"></rich-text>
+</template>

+ 4 - 0
miniprogram/pages/detail/template/defaultDetail/index.wxss

@@ -0,0 +1,4 @@
+/* miniprogram/pages/detail/template/pdfDetail/index.wxss */
+.video{
+  width: 750rpx;
+}

+ 5 - 0
miniprogram/pages/detail/template/pdfDetail/index.wxml

@@ -0,0 +1,5 @@
+<!--miniprogram/pages/detail/template/pdfDetail/index.wxml-->
+<template name="pdfDetail">
+  <image class="headImg" mode="aspectFit" src="{{headUrl}}"></image>
+  <image class="bodyImg" mode="aspectFit" wx:for="{{content}}" src="{{item}}" wx:key="index"></image>
+</template>

+ 5 - 0
miniprogram/pages/detail/template/pdfDetail/index.wxss

@@ -0,0 +1,5 @@
+/* miniprogram/pages/detail/template/pdfDetail/index.wxss */
+.bodyImg{
+  width: 750rpx;
+  height: 1060rpx;
+}

+ 4 - 0
miniprogram/pages/detail/template/sysDetail/index.wxml

@@ -0,0 +1,4 @@
+<template name="sysDetail">
+  <image class="headImg" mode="aspectFit" wx:if="{{headUrl}}" src="{{headUrl}}"></image>
+  <rich-text wx:if="{{content}}" style="width:730rpx;margin: 10rpx auto;display:block" nodes="{{content}}"></rich-text>
+</template>

+ 1 - 0
miniprogram/pages/detail/template/sysDetail/index.wxss

@@ -0,0 +1 @@
+/* miniprogram/pages/detail/template/sysDetail/index.wxss */

+ 0 - 3
miniprogram/pages/home/index.js

@@ -31,9 +31,6 @@ Page({
    */
    */
   onLoad: function () {
   onLoad: function () {
     const _this = this;
     const _this = this;
-    wx.setNavigationBarTitle({
-      title: "盛世中华 何以中国"
-    })
     httpOrther({
     httpOrther({
       url: '/Applets/shengshizhongguo/json/shengshi.json',
       url: '/Applets/shengshizhongguo/json/shengshi.json',
       call(res) {
       call(res) {