liyongli преди 1 година
родител
ревизия
aefeb50caf

+ 17 - 2
cloudfunctions/server/controller/live/index.js

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

+ 7 - 1
cloudfunctions/server/index.js

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

+ 9 - 1
cloudfunctions/server/service/live/index.js

@@ -3,10 +3,18 @@ const {
   _
 } = require("../../utils/http");
 async function LiveService(data) {
-  const orilist = await db.collection('live').doc('AvrSA4TAEG1fz1sK').get();
+  const orilist = await db.collection('live').where({
+    live_type: _.eq('live'),
+  }).get();
+  return orilist.data[0] || {}
+}
+
+async function LiveServiceList() {
+  const orilist = await db.collection('live').get();
   return orilist.data
 }
 
 module.exports = {
   LiveService,
+  LiveServiceList
 }

+ 36 - 4
miniprogram/pages/live/live.js

@@ -9,7 +9,8 @@ Page({
    */
   data: {
     isLive: false,
-    liveData: {}
+    liveData: {},
+    list: []
   },
 
   getDate() {
@@ -17,7 +18,7 @@ Page({
     httpCloud({
       name: "server",
       type: "getLiveData",
-      data: { },
+      data: {},
       call(res) {
         const obj = res || {};
         _this.setData({
@@ -27,11 +28,41 @@ Page({
     })
   },
 
-  liveing(){
+  liveing() {
     this.setData({
       isLive: true
     })
   },
+  liveerr() {
+    this.setData({
+      isLive: false
+    })
+  },
+  showBack() {
+    const _this = this;
+    httpCloud({
+      name: "server",
+      type: "getLiveListData",
+      data: {},
+      call(res) {
+        const r = res || [];
+        for (let i = 0; i < r.length; i++) {
+          const v = r[i];
+          v.titleShow = v.live_type === 'back' ? '回看-' + v.title : '直播-' + v.title;
+        }
+        _this.setData({
+          list: r,
+        })
+      }
+    })
+  },
+  bindPickerChange(e) {
+    const d = this.data.list[e.detail.value] || {}
+    this.setData({
+      liveData: d,
+      isLive : d.backUrl ? true : false
+    })
+  },
   /**
    * 生命周期函数--监听页面加载
    */
@@ -39,7 +70,8 @@ Page({
     wx.setNavigationBarTitle({
       title: decodeURIComponent(options.title || "盛世中华 何以中国")
     })
-    this.getDate()
+    this.getDate();
+    this.showBack();
   },
 
   /**

+ 5 - 2
miniprogram/pages/live/live.wxml

@@ -1,7 +1,10 @@
 <!--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 />
+  <video class="video" enable-play-gesture="{{true}}" enable-progress-gesture="{{false}}" play-btn-position="center" show-progress="{{false}}" src="{{liveData.liveUrl || liveData.backUrl}}" binderror="liveerr" bindplay="liveing" autoplay />
 </view>
+<picker bindchange="bindPickerChange" range-key="title" range="{{list}}">
+<mp-cell title="查看回放" link link></mp-cell>
+</picker>
 <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>
+<rich-text wx:if="{{liveData.introduce}}" style="width:730rpx;margin: 10rpx auto;display:block" nodes="{{liveData.introduce}}"></rich-text>

+ 2 - 3
miniprogram/pages/live/live.wxss

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

+ 2 - 1
project.config.json

@@ -36,7 +36,8 @@
     "showES6CompileOption": false,
     "ignoreUploadUnusedFiles": true,
     "condition": false,
-    "skylineRenderEnable": false
+    "skylineRenderEnable": false,
+    "minifyWXML": true
   },
   "appid": "wxcbc23a7780c48db2",
   "projectname": "miniprogram-1",