liyongli 1 tahun lalu
induk
melakukan
157fa2f409

+ 3 - 1
cloudfunctions/server/controller/index.js

@@ -1,9 +1,11 @@
 const media = require("./media/index");
 const article = require("./article/index");
 const schedule = require("./schedule/index");
+const live = require("./live/index");
 
 module.exports = {
   ...media,
   ...schedule,
-  ...article
+  ...article,
+  ...live
 }

+ 19 - 0
cloudfunctions/server/controller/live/index.js

@@ -0,0 +1,19 @@
+const { formmat } = require("../../utils/http");
+const { LiveService } = require("../../service/index");
+async function getLiveController(data) {
+  let list = [];
+  let code = 0;
+  let msg = "ok";
+  try{
+    list = await LiveService(data);
+  }catch(err){
+    console.log(err)
+    code = 500;
+    msg = "err";
+  }
+  return formmat(list, code, msg);
+}
+
+module.exports = {
+  getLiveController
+}

+ 0 - 1
cloudfunctions/server/controller/media/index.js

@@ -27,7 +27,6 @@ async function MediaOnceController(data) {
   return formmat(list, code, msg);
 }
 
-
 module.exports = {
   MediaController,
   MediaOnceController

+ 7 - 1
cloudfunctions/server/index.js

@@ -7,7 +7,8 @@ const {
   MediaController,
   MediaOnceController,
   getArticleController,
-  getScheduleController
+  getScheduleController,
+  getLiveController
 } = require("./controller/index");
 cloud.init({
   env: 'shengshi-5gwo482xaec28676'
@@ -35,6 +36,11 @@ exports.main = async (event, context) => {
       return getScheduleController(event)
     }
 
+    case "getLiveData":{
+      delete event.type;
+      return getLiveController(event);
+    }
+
     default: {
       return {}
     }

+ 3 - 1
cloudfunctions/server/service/index.js

@@ -1,9 +1,11 @@
 const media = require("./media/index");
 const article = require("./article/index");
 const schedule = require("./schedule/index");
+const live = require("./live/index");
 
 module.exports = {
   ...media,
   ...article,
-  ...schedule
+  ...schedule,
+  ...live
 }

+ 12 - 0
cloudfunctions/server/service/live/index.js

@@ -0,0 +1,12 @@
+const {
+  db,
+  _
+} = require("../../utils/http");
+async function LiveService(data) {
+  const orilist = await db.collection('live').doc('AvrSA4TAEG1fz1sK').get();
+  return orilist.data
+}
+
+module.exports = {
+  LiveService,
+}

+ 2 - 1
miniprogram/app.json

@@ -4,7 +4,8 @@
     "pages/detail/detail",
     "pages/mediaController/index",
     "pages/videoDetail/index",
-    "pages/schedule/index"
+    "pages/schedule/index",
+    "pages/live/live"
   ],
   "window": {
     "backgroundColor": "#F6F6F6",

TEMPAT SAMPAH
miniprogram/assets/image/None-1.png


TEMPAT SAMPAH
miniprogram/assets/image/nolive.jpg


+ 16 - 8
miniprogram/pages/home/index.js

@@ -1,4 +1,6 @@
-import { httpOrther } from "../../utils/httpFunc";
+import {
+  httpOrther
+} from "../../utils/httpFunc";
 // miniprogram/pages/home/index.js
 Page({
 
@@ -6,7 +8,8 @@ Page({
    * 页面的初始数据
    */
   data: {
-    iconList: []
+    iconList: [],
+    headTitle: ""
   },
 
   clickFunc(data) {
@@ -15,9 +18,11 @@ Page({
     let url = ""
     if (!item.type) return
     switch (item.type) {
+      case 'live':
+        url = '/pages/live/live?title=' + item.text + "&mediaType=" + item.type;
+        break;
       case 'image':
       case 'video':
-      case 'live':
         url = '/pages/mediaController/index?title=' + item.text + "&mediaType=" + item.type;
         break;
       case "schedule":
@@ -27,7 +32,9 @@ Page({
         url = '/pages/detail/detail?title=' + item.text + "&id=" + item.id;
         break;
     }
-    wx.navigateTo({ url })
+    wx.navigateTo({
+      url
+    })
   },
 
   /**
@@ -36,10 +43,12 @@ Page({
   onLoad: function () {
     const _this = this;
     httpOrther({
-      url: '/Applets/shengshizhongguo/json/shengshi.json',
+      url: '/Applets/shengshizhongguo/json/shengshi.json?' + Date.now(),
       call(res) {
         _this.setData({
-          iconList: res || []
+          iconList: res.list || [],
+          headTitle: res.headTitle || '',
+          headImage: res.headImage || ''
         })
       }
     })
@@ -94,5 +103,4 @@ Page({
 
   }
 
-})
-
+})

+ 2 - 2
miniprogram/pages/home/index.wxml

@@ -1,8 +1,8 @@
 <!--miniprogram/pages/home/index.wxml-->
 <view class="home">
-  <image class="headImg"	lazy-load mode="scaleToFill" src="https://djweb.smcic.net/img/302306190.jpg"></image>
+  <image class="headImg"	lazy-load mode="scaleToFill" src="{{headImage}}"></image>
   <view class="title">
-    由中央网信办、国家文物局、人民日报社、陕西省委网信委指导,中央网信办网络传播局、国家文物局相关司局、陕西省委网信办、人民网等单位主办的“盛世中华 何以中国”网上主题宣传活动即将拉开帷幕!我们将通过互联网平台,向您展现中国历史文化的辉煌、传承中国文化的精髓,让您感受中国文化的独特性和无穷魅力。
+    {{headTitle}}
   </view>
   <view class="subTitle" style="height: 20rpx">
     <!-- 2021年6月16日至19日 -->

+ 93 - 0
miniprogram/pages/live/live.js

@@ -0,0 +1,93 @@
+// pages/live/live.js
+import {
+  httpCloud
+} from "../../utils/httpFunc";
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    isLive: false,
+    liveData: {}
+  },
+
+  getDate() {
+    const _this = this;
+    httpCloud({
+      name: "server",
+      type: "getLiveData",
+      data: { },
+      call(res) {
+        const obj = res || {};
+        _this.setData({
+          liveData: obj
+        })
+      }
+    })
+  },
+
+  liveing(){
+    this.setData({
+      isLive: true
+    })
+  },
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad(options) {
+    wx.setNavigationBarTitle({
+      title: decodeURIComponent(options.title || "盛世中华 何以中国")
+    })
+    this.getDate()
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload() {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh() {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom() {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage() {
+
+  }
+})

+ 5 - 0
miniprogram/pages/live/live.json

@@ -0,0 +1,5 @@
+{
+  "usingComponents": {
+    "mp-cell": "weui-miniprogram/cell/cell"
+  }
+}

+ 7 - 0
miniprogram/pages/live/live.wxml

@@ -0,0 +1,7 @@
+<!--pages/live/live.wxml-->
+<view class="liveBg">
+  <image wx:if="{{!isLive}}" class="image" src="../../assets/image/nolive.jpg" mode="aspectFill" />
+  <video class="video" enable-play-gesture="{{true}}" enable-progress-gesture="{{false}}" play-btn-position="center" show-progress="{{false}}" src="{{liveData.liveUrl}}" 	bindplay="liveing" autoplay />
+</view>
+<mp-cell title="{{liveData.title}}"></mp-cell>
+<rich-text wx:if="{{liveData.introduce}}" style="width:730rpx;margin: 10rpx auto;display:block" nodes="{{liveData.introduce}}"></rich-text>

+ 13 - 0
miniprogram/pages/live/live.wxss

@@ -0,0 +1,13 @@
+/* pages/live/live.wxss */
+.video,
+.image {
+  width: 750rpx;
+  height: 422rpx;
+}
+
+.liveBg{
+  overflow: hidden;
+  font-size: 0;
+  width: 750rpx;
+  height: 422rpx;
+}

+ 13 - 1
project.private.config.json

@@ -3,7 +3,19 @@
     "compileHotReLoad": true,
     "urlCheck": true
   },
-  "condition": {},
+  "condition": {
+    "miniprogram": {
+      "list": [
+        {
+          "name": "",
+          "pathName": "pages/live/live",
+          "query": "title=%E8%93%9D%E7%9B%B4%E6%92%AD&mediaType=live",
+          "launchMode": "default",
+          "scene": null
+        }
+      ]
+    }
+  },
   "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
   "libVersion": "2.14.1",
   "projectname": "%E7%9B%9B%E4%B8%96%E4%B8%AD%E5%8D%8E%EF%BC%8C%E4%BD%95%E4%BB%A5%E4%B8%AD%E5%9B%BD"