liyongli 1 年間 前
コミット
f5fd5befde

+ 3 - 5
cloudfunctions/server/controller/article/index.js

@@ -1,5 +1,7 @@
 const {
-  formmat
+  formmat,
+  db,
+  _
 } = require("../../utils/http");
 const {
   ArticleService,
@@ -33,10 +35,6 @@ async function getArticleListController(data) {
   return formmat(article, code, msg);
 }
 
-const {
-  db,
-  _
-} = require("../../utils/http");
 async function test(data) {
   try {
     await db.collection('article').where({

+ 21 - 0
cloudfunctions/server/controller/home/index.js

@@ -0,0 +1,21 @@
+const { formmat } = require("../../utils/http");
+const {
+  HomeListService
+} = require("../../service/index");
+async function getHomeListController(data) {
+  let article = {};
+  let code = 0;
+  let msg = "ok";
+  try {
+    article = await HomeListService(data);
+  } catch (err) {
+    console.log(err)
+    code = 500;
+    msg = "err";
+  }
+  return formmat(article, code, msg);
+}
+
+module.exports = {
+  getHomeListController
+}

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

@@ -2,10 +2,12 @@ const media = require("./media/index");
 const article = require("./article/index");
 const schedule = require("./schedule/index");
 const live = require("./live/index");
+const home = require("./home/index");
 
 module.exports = {
   ...media,
   ...schedule,
   ...article,
-  ...live
+  ...live,
+  ...home
 }

+ 7 - 1
cloudfunctions/server/index.js

@@ -11,7 +11,8 @@ const {
   getLiveController,
   getLiveListController,
   getArticleListController,
-  test
+  test,
+  getHomeListController
 } = require("./controller/index");
 cloud.init({
   env: 'medium-4gx7s66sd1698f5a'
@@ -55,6 +56,11 @@ exports.main = async (event, context) => {
       return getLiveListController(event);
     }
 
+    case "getHome": {
+      delete event.type
+      return getHomeListController(event);
+    }
+
     case 'test': {
       return test()
     }

+ 14 - 0
cloudfunctions/server/service/home/index.js

@@ -0,0 +1,14 @@
+const {
+  db,
+  _
+} = require("../../utils/http");
+
+async function HomeListService(data) {
+  const skip = (data.page - 1) * data.size;
+  const orilist = await db.collection('event_managemen').skip(skip).limit(data.size || 100).get();
+  return orilist.data || []
+}
+
+module.exports = {
+  HomeListService
+}

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

@@ -2,10 +2,12 @@ const media = require("./media/index");
 const article = require("./article/index");
 const schedule = require("./schedule/index");
 const live = require("./live/index");
+const home = require("./home/index");
 
 module.exports = {
   ...media,
   ...article,
   ...schedule,
-  ...live
+  ...live,
+  ...home
 }

+ 34 - 12
miniprogram/pages/activityDetail/index.js

@@ -11,7 +11,37 @@ Page({
    * 页面的初始数据
    */
   data: {
-    iconList: [],
+    iconList: [{
+        "text": "何以中国",
+        "url": "https://cxzx.smcic.net/topic/Applets/shengshizhongguo/0.png",
+        "type": "article_china",
+      },
+      {
+        "text": "日程安排",
+        "url": "https://cxzx.smcic.net/topic/Applets/shengshizhongguo/1.png",
+        "type": "schedule",
+      },
+      {
+        "text": "图片集锦",
+        "url": "https://cxzx.smcic.net/topic/Applets/shengshizhongguo/3.png",
+        "type": "image"
+      },
+      {
+        "text": "精彩视频",
+        "url": "https://cxzx.smcic.net/topic/Applets/shengshizhongguo/4.png",
+        "type": "video"
+      },
+      {
+        "text": "媒体聚焦",
+        "url": "https://cxzx.smcic.net/topic/Applets/shengshizhongguo/5.png",
+        "type": "article_media",
+      },
+      {
+        "text": "蓝直播",
+        "url": "https://cxzx.smcic.net/topic/Applets/shengshizhongguo/2.png",
+        "type": "live"
+      }
+    ],
     headTitle: ""
   },
   activity: "",
@@ -55,17 +85,9 @@ Page({
         title: this.activity
       });
     }
-
-    const _this = this;
-    httpOrther({
-      url: `/Applets/shengshizhongguo/json/${(options.url || 'shengshi') + globalData.miniProgram.envVersion}.json?${Date.now()}`,
-      call(res) {
-        _this.setData({
-          iconList: res.list || [],
-          headTitle: res.headTitle || '',
-          headImage: res.headImage || ''
-        })
-      }
+    this.setData({
+      headTitle: options.introduction || '',
+      headImage: options.theme || ''
     })
   },
 

+ 19 - 10
miniprogram/pages/home/index.js

@@ -3,7 +3,8 @@ const {
   globalData
 } = getApp();
 import {
-  httpOrther
+  httpOrther,
+  httpCloud
 } from "../../utils/httpFunc";
 Page({
 
@@ -12,31 +13,39 @@ Page({
    */
   data: {
     list: [],
-    // heights: []
   },
   title: '',
   showBack() {
     const _this = this;
-    httpOrther({
-      url: `/Applets/shengshizhongguo/json/list${globalData.miniProgram.envVersion}.json?${Date.now()}`,
+    
+    httpCloud({
+      name: "server",
+      type: "getHome",
+      data: {
+        page: 1,
+        size: 100
+      },
       call(res) {
-        const defaultItem = (res.list || [])[0]
-        if (!res.showList) {
+        const list = res || [];
+        for (let i = 0; i < list.length; i++) {
+          const v = list[i];
+          if(!v.isDefaultOpen) continue;
           wx.redirectTo({
-            url: `/pages/activityDetail/index?url=${defaultItem.fileName}&title=${defaultItem.title}`
+            url: `/pages/activityDetail/index?theme=${v.theme}&title=${v.title}&introduction=${v.introduction}`
           })
-          return
+          break
         }
         _this.setData({
-          list: res.list || []
+          list
         })
       }
     })
   },
 
   toDetail(e) {
+    const data = e.currentTarget.dataset || {};
     wx.navigateTo({
-      url: '/pages/activityDetail/index?url=' + e.currentTarget.dataset.file + '&title=' + e.currentTarget.dataset.title
+      url: `/pages/activityDetail/index?theme=${data.theme}&title=${data.title}&introduction=${data.introduction}`
     })
   },
 

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

@@ -1,6 +1,6 @@
 <!--pages/home/index.wxml-->
 <view style="padding-top: 10rpx;font-size: 0;">
-  <view class="homelist" wx:for="{{list}}" wx:key="index" data-file="{{item.fileName}}" data-title="{{item.title}}" bind:tap="toDetail">
+  <view class="homelist" wx:for="{{list}}" wx:key="index" data-introduction="{{item.introduction}}" data-theme="{{item.theme}}" data-title="{{item.title}}" bind:tap="toDetail">
     <image bindload="imageload" data-index="{{index}}" class="image" wx:if="{{item.cover}}" src="{{item.cover}}" />
     <view class="title">{{item.title}}</view>
   </view>

+ 4 - 3
miniprogram/pages/home/index.wxss

@@ -1,7 +1,7 @@
 /* pages/home/index.wxss */
 .homelist{
   display: inline-block;
-  width: 345rpx;
+  width: 700rpx;
   margin: 10rpx 10rpx 10rpx 20rpx;
   border-radius: 15rpx;
   box-shadow: #ccc 0  0  20rpx;
@@ -12,14 +12,15 @@
 }
 
 .image{
-  height: 270rpx;
-  width: 345rpx;
+  height: 350rpx;
+  width: 700rpx;
   display: block;
 }
 
 .title{
   padding: 15rpx 10rpx;
   font-size: 16px;
+  background-color: #f7f7f7;
 }
 
 .tag{