liyongli 1 rok pred
rodič
commit
adcd86f517

+ 16 - 1
cloudfunctions/server/controller/article/index.js

@@ -2,7 +2,8 @@ const {
   formmat
 } = require("../../utils/http");
 const {
-  ArticleService
+  ArticleService,
+  ArticleListService
 } = require("../../service/index");
 async function getArticleController(data) {
   let article = {};
@@ -18,6 +19,19 @@ async function getArticleController(data) {
   return formmat(article, code, msg);
 }
 
+async function getArticleListController(data) {
+  let article = {};
+  let code = 0;
+  let msg = "ok";
+  try {
+    article = await ArticleListService(data);
+  } catch (err) {
+    console.log(err)
+    code = 500;
+    msg = "err";
+  }
+  return formmat(article, code, msg);
+}
 
 const {
   db,
@@ -57,5 +71,6 @@ async function test(data) {
 
 module.exports = {
   getArticleController,
+  getArticleListController,
   test
 }

+ 9 - 3
cloudfunctions/server/index.js

@@ -10,6 +10,7 @@ const {
   getScheduleController,
   getLiveController,
   getLiveListController,
+  getArticleListController,
   test
 } = require("./controller/index");
 cloud.init({
@@ -19,21 +20,26 @@ const { db, _ } = require("./utils/http");
 // 云函数入口函数
 exports.main = async (event, context) => {
   switch (event.type) {
-    case "getMediaController": {
+    case "getMedia": {
       delete event.type;
       return MediaController(event);
     }
 
-    case "getMediaOnceController": { // 1
+    case "getMediaOnce": {
       delete event.type
       return MediaOnceController(event)
     }
 
-    case "getArticle": { // 1
+    case "getArticle": {
       delete event.type;
       return getArticleController(event)
     }
 
+    case "getArticleList": {
+      delete event.type;
+      return getArticleListController(event)
+    }
+
     case "getSchedule": {
       delete event.type
       return getScheduleController(event)

+ 10 - 1
cloudfunctions/server/service/article/index.js

@@ -5,6 +5,15 @@ async function ArticleService(data) {
   return orilist.data || {}
 }
 
+async function ArticleListService(data) {
+  const orilist = await db.collection('article').where({
+    article_type: _.eq(data.articleType),
+    activity_name: _.eq(data.activityName)
+  }).get();
+  return orilist.data || []
+}
+
 module.exports = {
-  ArticleService
+  ArticleService,
+  ArticleListService
 }

+ 2 - 1
miniprogram/app.json

@@ -7,7 +7,8 @@
     "pages/schedule/index",
     "pages/live/live",
     "pages/livelist/index",
-    "pages/activityDetail/index"
+    "pages/activityDetail/index",
+    "pages/articleList/index"
   ],
   "window": {
     "backgroundColor": "#F6F6F6",

+ 6 - 20
miniprogram/app.wxss

@@ -1,24 +1,4 @@
 /**app.wxss**/
-.container {
-  display: flex;
-  flex-direction: column;
-  align-items: center;
-  box-sizing: border-box;
-} 
-
-button {
-  background: initial;
-}
-
-button:focus{
-  outline: 0;
-}
-
-button::after{
-  border: none;
-}
-
-
 page {
   background: #f6f6f6;
   display: flex;
@@ -167,3 +147,9 @@ page {
   margin-left: auto;
   border-radius: 22.5rpx;
 }
+
+.title {
+  white-space: nowrap;
+  overflow: hidden;
+  text-overflow: ellipsis;
+}

+ 4 - 0
miniprogram/pages/activityDetail/index.js

@@ -32,6 +32,10 @@ Page({
       case "schedule":
         url = '/pages/schedule/index' + parames + '&noToday=1';
         break;
+      case "article_china":
+      case "article_media":
+        url = '/pages/articleList/index' + parames + '&type=' + item.type;
+        break;
       default:
         url = '/pages/detail/detail' + parames + "&id=" + item.id;
         break;

+ 101 - 0
miniprogram/pages/articleList/index.js

@@ -0,0 +1,101 @@
+// pages/articleList/index.js
+import {
+  httpCloud
+} from "../../utils/httpFunc";
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    list: []
+  },
+  activity: '',
+  showBack(articleType) {
+    const _this = this;
+    httpCloud({
+      name: "server",
+      type: "getArticleList",
+      data: {
+        activityName: _this.activity,
+        articleType
+      },
+      call(res) {
+        console.log(res)
+        _this.setData({
+          list: res || []
+        })
+      }
+    })
+  },
+
+  toDetail(e) {
+    if (!e.currentTarget.dataset.id) return
+    wx.navigateTo({
+      url: '/pages/activityDetail/index?id=' + e.currentTarget.dataset.id + '&activityName=' + this.activity
+    })
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad(options) {
+    this.activity = decodeURIComponent(options.activity);
+    options.title && wx.setNavigationBarTitle({
+      title: decodeURIComponent(options.title)
+    })
+    this.showBack(options.type.split('_')[1]);
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload() {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh() {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom() {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+    return {
+      title: "", // 分享名称
+      path: 'pages/home/index', // 点击分享后的链接要来到的页面的路径已经对应需要的参数
+    }
+  }
+})

+ 3 - 0
miniprogram/pages/articleList/index.json

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

+ 5 - 0
miniprogram/pages/articleList/index.wxml

@@ -0,0 +1,5 @@
+<!--pages/articleList/index.wxml-->
+<view class="articleListlist" wx:for="{{list}}" wx:key="_id" data-id="{{item._id}}" bind:tap="toDetail">
+  <image class="image" wx:if="{{item.cover}}" src="{{item.cover}}" />
+  <view class="title">{{item.title}}</view>
+</view>

+ 13 - 0
miniprogram/pages/articleList/index.wxss

@@ -0,0 +1,13 @@
+/* pages/articleList/index.wxss */
+.articleListlist{
+  position: relative;
+}
+
+.image{
+  width: 750rpx;
+  height: 422rpx;
+}
+
+.title{
+  padding: 15rpx 10rpx;
+}

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

@@ -37,9 +37,6 @@ Page({
         })
       }
     })
-    wx.showShareMenu({
-      withShareTicket: true,
-    });
   },
   /**
    * 生命周期函数--监听页面初次渲染完成

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

@@ -19,9 +19,6 @@
 
 .title{
   padding: 15rpx 10rpx;
-  white-space: nowrap;
-  overflow: hidden;
-  text-overflow: ellipsis;
   font-size: 16px;
 }
 

+ 24 - 3
miniprogram/pages/live/live.js

@@ -11,10 +11,12 @@ Page({
     isLive: false,
     liveData: {},
     list: [],
-    type: '简介'
+    type: '简介',
+    userInfo: {}
   },
   activity: "",
   id: "",
+
   getDate() {
     const _this = this;
     httpCloud({
@@ -36,8 +38,17 @@ Page({
     })
   },
 
-  select(e){
-    console.log(e.currentTarget.dataset.type);
+  getUser(e) {
+    console.log(e.detail.userInfo.nickName, e.detail.userInfo.avatarUrl)
+    console.log(e.detail.rawData)
+    wx.setStorage({
+      key: "userInfo",
+      data: e.detail.rawData,
+      encrypt: true // 若开启加密存储,setStorage 和 getStorage 需要同时声明 encrypt 的值为 true
+    })
+  },
+
+  select(e) {
     this.setData({
       type: e.currentTarget.dataset.type
     })
@@ -60,6 +71,16 @@ Page({
     this.activity = decodeURIComponent(options.activityName);
     this.id = options.id;
     this.getDate();
+    const _this = this;
+    wx.getStorage({
+      key: "userInfo",
+      encrypt: true, // 若开启加密存储,setStorage 和 getStorage 需要同时声明 encrypt 的值为 true
+      success(res) {
+        _this.setData({
+          userInfo: JSON.parse(res.data || "{}")
+        })
+      }
+    })
   },
 
   /**

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

@@ -18,4 +18,7 @@
     </view>
   </view> -->
   <rich-text wx:if="{{type === '简介' && liveData.introduce}}" style="width:730rpx;margin: 10rpx auto;display:block" nodes="{{liveData.introduce}}" />
+  <!-- <view wx:if="{{type === '评论' && liveData.introduce}}">
+    <button type="primary" open-type="getUserInfo" 	bindgetuserinfo="getUser">获取用户信息</button>
+  </view> -->
 </view>

+ 1 - 1
miniprogram/pages/livelist/index.js

@@ -39,7 +39,7 @@ Page({
    * 生命周期函数--监听页面加载
    */
   onLoad(options) {
-    this.activity = options.activity;
+    this.activity = decodeURIComponent(options.activity);
     options.title && wx.setNavigationBarTitle({
       title: decodeURIComponent(options.title)
     })

+ 1 - 1
miniprogram/pages/mediaController/index.js

@@ -23,7 +23,7 @@ Page({
     const _this = this;
     httpCloud({
       name: "server",
-      type: "getMediaController",
+      type: "getMedia",
       data: {
         typeMedia: this.mediaType,
         page: this.page,

+ 1 - 1
miniprogram/pages/videoDetail/index.js

@@ -42,7 +42,7 @@ Page({
     this.activityName = decodeURIComponent(options.activityName);
     httpCloud({
       name: "server",
-      type: "getMediaOnceController",
+      type: "getMediaOnce",
       data: {
         typeMedia: options.type,
         id: options.id,

+ 2 - 2
project.private.config.json

@@ -8,8 +8,8 @@
       "list": [
         {
           "name": "",
-          "pathName": "pages/live/live",
-          "query": "id=AvrSA4TAEG1fz1sK&activityName=%E7%9B%9B%E4%B8%96%E4%B8%AD%E5%8D%8E%20%E4%BD%95%E4%BB%A5%E4%B8%AD%E5%9B%BD",
+          "pathName": "pages/articleList/index",
+          "query": "title=%E4%BD%95%E4%BB%A5%E4%B8%AD%E5%9B%BD&activity=%E7%9B%9B%E4%B8%96%E4%B8%AD%E5%8D%8E%20%E4%BD%95%E4%BB%A5%E4%B8%AD%E5%9B%BD&type=article_china",
           "launchMode": "default",
           "scene": null
         }