liyongli 1 an în urmă
părinte
comite
ff10289265

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

@@ -6,7 +6,8 @@ async function MediaController(data) {
   let msg = "ok";
   try{
     list = await MediaService(data);
-  }catch{
+  }catch(err){
+    console.log(err)
     code = 500;
     msg = "err";
   }

+ 7 - 3
cloudfunctions/server/index.js

@@ -3,13 +3,17 @@
  * 初始化数据库
  */
 const cloud = require('wx-server-sdk');
-const { MediaController, MediaOnceController, getArticleController, getScheduleController } = require("./controller/index");
+const {
+  MediaController,
+  MediaOnceController,
+  getArticleController,
+  getScheduleController
+} = require("./controller/index");
 cloud.init({
-  env: 'serverless-env-7gkaeuji38488831'
+  env: 'shengshi-5gwo482xaec28676'
 })
 // 云函数入口函数
 exports.main = async (event, context) => {
-  console.log(event)
   switch (event.type) {
     case "getMediaController": {
       delete event.type;

+ 20 - 18
cloudfunctions/server/service/media/index.js

@@ -1,10 +1,14 @@
-const { db, _ } = require("../../utils/http");
+const {
+  db,
+  _
+} = require("../../utils/http");
 async function MediaService(data) {
   const list = [];
   const orilist = await db.collection('AudioAndVideo').where({
     type: _.eq(data.typeMedia)
   }).get();
   const keysOir = {};
+
   for (let i = 0; i < orilist.data.length; i++) {
     const v = orilist.data[i];
     if (keysOir[v.localtion] !== undefined) {
@@ -13,7 +17,8 @@ async function MediaService(data) {
         url: v.url,
         title: v.title,
         cover: v.cover,
-        id: v._id
+        id: v._id,
+        type: v.type
       })
     } else {
       // push
@@ -22,14 +27,13 @@ async function MediaService(data) {
         location: v.localtion,
         date: v.uptime,
         id: v._id,
-        child: [
-          {
-            url: v.url,
-            title: v.title,
-            cover: v.cover,
-            id: v._id
-          }
-        ]
+        child: [{
+          url: v.url,
+          title: v.title,
+          cover: v.cover,
+          id: v._id,
+          type: v.type
+        }]
       })
     }
   }
@@ -60,14 +64,12 @@ async function MediaOnceService(data) {
         location: v.localtion,
         date: v.uptime,
         id: v._id,
-        child: [
-          {
-            url: v.url,
-            title: v.title,
-            cover: v.cover,
-            id: v._id
-          }
-        ]
+        child: [{
+          url: v.url,
+          title: v.title,
+          cover: v.cover,
+          id: v._id
+        }]
       })
     }
   }

+ 1 - 1
cloudfunctions/server/utils/http.js

@@ -1,6 +1,6 @@
 const cloud = require('wx-server-sdk')
 cloud.init({
-  env: 'serverless-env-5gliqq5230ac465d'
+  env: 'shengshi-5gwo482xaec28676'
 })
 const db = cloud.database();
 

+ 1 - 1
miniprogram/app.js

@@ -10,7 +10,7 @@ App({
         //   env 参数决定接下来小程序发起的云开发调用(wx.cloud.xxx)会默认请求到哪个云环境的资源
         //   此处请填入环境 ID, 环境 ID 可打开云控制台查看
         //   如不填则使用默认环境(第一个创建的环境)
-        env: 'serverless-env-5gliqq5230ac465d',
+        env: 'shengshi-5gwo482xaec28676',
         traceUser: true,
       })
     }

+ 1 - 1
miniprogram/components/dayList/index.js

@@ -48,7 +48,7 @@ Component({
         return
       }
       wx.navigateTo({
-        url: "/pages/videoDetail/index?id=" + item.id + '&group=' + row.location
+        url: "/pages/videoDetail/index?id=" + item.id + '&group=' + row.location + '&type=' + item.type
       })
     }
   }

+ 1 - 3
miniprogram/pages/schedule/index.wxml

@@ -2,7 +2,5 @@
 <template wx:if="{{!list || !list.length }}" is="none"></template>
 <view wx:for="{{list}}" wx:key="index">
   <mp-cell title="{{item.date}}" footer="{{item.location}}"></mp-cell>
-  <view class="text" wx:for="{{item.child}}" wx:for-index="i" wx:for-item="v" wx:key="i">
-    {{v.content}}
-  </view>
+  <view class="text" wx:for="{{item.child}}" wx:for-index="i" wx:for-item="v" wx:key="i">{{v.content}}</view>
 </view>

+ 1 - 1
miniprogram/pages/schedule/index.wxss

@@ -8,7 +8,7 @@
 }
 
 .text {
-  padding-left: 1em;
+  margin-left: 1em;
   font-size: 14px;
   font-weight: 400;
   color: #00000080;

+ 13 - 6
miniprogram/pages/videoDetail/index.js

@@ -1,5 +1,7 @@
 // pages/videoDetail/index.js
-import { httpCloud } from "../../utils/httpFunc";
+import {
+  httpCloud
+} from "../../utils/httpFunc";
 const app = getApp()
 Page({
 
@@ -14,14 +16,17 @@ Page({
   },
 
   toNext(e) {
-    const item =this.data.media.child[e.currentTarget.dataset.index];
+    const item = this.data.media.child[e.currentTarget.dataset.index];
     wx.redirectTo({
-      url:  "/pages/videoDetail/index?id=" + item.id + '&group=' + this.data.media.location
+      url: "/pages/videoDetail/index?id=" + item.id + '&group=' + this.data.media.location
     })
   },
 
   loadedmetadata(e) {
-    const { width, height } = e.detail || {};
+    const {
+      width,
+      height
+    } = e.detail || {};
     this.setData({
       videoWidth: app.globalData.client.windowWidth,
       videoHeight: app.globalData.client.windowWidth / width * height
@@ -37,12 +42,14 @@ Page({
       name: "server",
       type: "getMediaOnceController",
       data: {
-        typeMedia: 'video',
+        typeMedia: options.type,
         id: options.id,
         group: options.group
       },
       call(res) {
-        const ori = res[0] || { child: [] };
+        const ori = res[0] || {
+          child: []
+        };
         let indexItem = {};
         for (let i = 0; i < ori.child.length; i++) {
           const v = ori.child[i];