liyongli 3 years ago
parent
commit
79300b1137

+ 0 - 1
miniprogram/app.json

@@ -1,7 +1,6 @@
 {
   "pages": [
     "pages/home/index",
-    "pages/index/index",
     "pages/interList/interList",
     "pages/detail/detail",
     "pages/marvellous/index"

+ 3 - 3
miniprogram/components/chatroom/chatroom.wxml

@@ -26,7 +26,7 @@
       <image 
         class="avatar"
         src="{{item.avatar}}"
-        mode="scaleToFill"
+        mode="aspectFit"
       ></image> 
       <view class="main">
         <view class="nickname">{{item.nickName}}</view>
@@ -38,7 +38,7 @@
               data-fileid="{{item.tempFilePath || item.imgFileID}}" 
               class="image-content" 
               style="{{item.imgStyle}}"
-              mode="scallToFill" 
+              mode="aspectFit" 
               bindtap="onMessageImageTap"></image>
           </view>
         </block>
@@ -67,7 +67,7 @@
       <image 
         src="./photo.png" 
         class="btn-send-image" 
-        mode="scaleToFill"
+        mode="aspectFit"
         bindtap="onChooseImage"
       ></image>
     </view>

+ 2 - 5
miniprogram/pages/detail/detail.js

@@ -26,16 +26,13 @@ Page({
       icon: "error"
     })
     let D = list.data[0] || {};
-    if (D.type !== 2 && D.content) {
-      D.content = D.content.replace(/<p>/gi, '<p style="text-indent: 2em">').replace(/<img/gi, "<img style='width:100%'")
-    }
+    console.log(D.content.match(/style=\"([a-z|A-Z|-|:|;|0-9]*)\"/g))
+    D.content = D.content.replace(/<p/gi, '<p style="text-indent: 2em"').replace(/style=\"([a-z|A-Z|-|:|;|0-9|\.]*)\"/g, "").replace(/width=\"([a-z|A-Z|-|:|;|0-9|\.]*)\"/g, "").replace(/height=\"([a-z|A-Z|-|:|;|0-9|\.]*)\"/g, "").replace(/<img/g, "<img style='width: 100%'")
     if (D.creat_time) D.creat_time = this.format(D.creat_time);
-    console.log(D)
     _this.setData({
       detail: D
     })
   },
-
   /**
    * 生命周期函数--监听页面初次渲染完成
    */

+ 1 - 1
miniprogram/pages/detail/detail.wxss

@@ -4,5 +4,5 @@
 @import "./template/defaultDetail/index.wxss";
 
 .detail{
-  padding: 10rpx;
+  width: 750rpx;
 }

+ 2 - 2
miniprogram/pages/detail/template/defaultDetail/index.wxml

@@ -1,6 +1,6 @@
 <!--miniprogram/pages/detail/template/pdfDetail/index.wxml-->
 <template name="defaultDetail">
   <video class="video" wx:if="{{headUrl}}" src="{{headUrl}}"></video>
-  <view wx:if="{{creat_time}}"> 发表日期:{{creat_time}}</view>
-  <rich-text wx:if="{{content}}" nodes="{{content}}"></rich-text>
+  <view style="width:730rpx;margin: 10rpx auto;display:block" wx:if="{{creat_time}}"> 发表日期:{{creat_time}}</view>
+  <rich-text wx:if="{{content}}" style="width:730rpx;margin: 10rpx auto;display:block" nodes="{{content}}"></rich-text>
 </template>

+ 2 - 2
miniprogram/pages/detail/template/pdfDetail/index.wxml

@@ -1,5 +1,5 @@
 <!--miniprogram/pages/detail/template/pdfDetail/index.wxml-->
 <template name="pdfDetail">
-  <image class="headImg" src="{{headUrl}}"></image>
-  <image class="bodyImg" wx:for="{{content}}" src="{{item}}" wx:key="index"></image>
+  <image class="headImg" mode="aspectFit" src="{{headUrl}}"></image>
+  <image class="bodyImg" mode="aspectFit" wx:for="{{content}}" src="{{item}}" wx:key="index"></image>
 </template>

+ 2 - 2
miniprogram/pages/detail/template/sysDetail/index.wxml

@@ -1,4 +1,4 @@
 <template name="sysDetail">
-  <image class="headImg" src="{{headUrl}}"></image>
-  <rich-text nodes="{{content}}"></rich-text>
+  <image class="headImg" style="width:730rpx;margin: 10rpx auto;display:block" mode="aspectFit" wx:if="{{headUrl}}" src="{{headUrl}}"></image>
+  <rich-text wx:if="{{content}}" style="width:730rpx;margin: 10rpx auto;display:block" nodes="{{content}}"></rich-text>
 </template>

+ 24 - 3
miniprogram/pages/home/index.js

@@ -18,9 +18,18 @@ Page({
       hot: 1,
       type: 1
     }).get();
+    let video = await db.collection("data_asset").where({
+      type: "video"
+    }).get();
+    list.data = list.data.concat(video.data);
+    list.data = list.data.sort((a,b)=>{
+      return b.create_time - a.create_time
+    })
+    console.log(list)
+
     for (let i = 0; i < list.data.length; i++) {
       const v = list.data[i];
-      v.creat_time = this.format(v.creat_time || 0)
+      v.create_time = this.format(v.create_time || 0)
     }
     this.setData({
       newList: list.data || []
@@ -76,6 +85,19 @@ Page({
 
   },
 
+  play: function (e) {
+    var that = this;
+    var id = e.currentTarget.id;
+    for (var i = 0; i < that.data.newList.length; i++) {
+      if (id !== 'newsVideo' + i && that.data.newList[i].type == 'video') {
+        //console.log('暂停其他正在播放的视频');
+        var videoContext = wx.createVideoContext("newsVideo" + i, that);
+        videoContext.pause();
+      }else{
+        continue
+      }
+    }
+  },
   format: function (res) {
     if (!res) return ""
     let T = new Date(res || 0);
@@ -85,8 +107,7 @@ Page({
     let hour = T.getHours();
     let min = T.getMinutes() + 1;
     let sec = T.getSeconds();
-
-    return year + "-" + (month > 9 ? month : "0" + month) + "-" + day + " " + (hour > 9 ? hour : '0' + hour) + ":" + (min > 9 ? min : '0' + min) + ":" + (sec > 9 ? sec : '0' + sec);
+    return year + "-" + (month > 9 ? month : "0" + month) + "-" + (day > 9 ? day : "0" + day) + " " + (hour > 9 ? hour : '0' + hour) + ":" + (min > 9 ? min : '0' + min) + ":" + (sec > 9 ? sec : '0' + sec);
   },
   toDetail: function (e) {
     let title = e.currentTarget.dataset.title, id = e.currentTarget.dataset.id;

+ 22 - 15
miniprogram/pages/home/index.wxml

@@ -1,17 +1,18 @@
 <!--miniprogram/pages/home/index.wxml-->
 <view class="home">
-  <image class="headImg" src="cloud://cloud1-6gbxfp9x33ff3b7c.636c-cloud1-6gbxfp9x33ff3b7c-1306051304/head.jpeg"></image>
+  <image class="headImg " mode="aspectFit"
+    src="cloud://cloud1-6gbxfp9x33ff3b7c.636c-cloud1-6gbxfp9x33ff3b7c-1306051304/homeTop.jpeg"></image>
   <view class="title">
-    畅行中国•庆祝建党100周年“追寻红色记忆”主题——“红色文物会说话、红色遗址会发声”融媒传播发布仪式
+    畅行中国·庆祝建党100周年“追寻红色记忆”主题——“重访红色声音故里”融媒传播暨 “党性教育基地”揭牌仪式定于2021年6月16日-19日在陕西延安举行。
   </view>
-  <view class="subTitle">
-    2021年5月15日至16日
+  <view class="subTitle" style="height: 20rpx">
+    <!-- 2021年6月16日至19日 -->
   </view>
 
   <view class="icon_container">
     <view class="icon_item_cell">
       <view class="icon_content" data-title="活动简介" data-id="79550af260b0394f1aea63d27b6f2ae9" bindtap="toDetail">
-        <image class="img" src="../../images/0.png"></image>
+        <image mode="aspectFit" class="img" src="../../images/0.png"></image>
         <view class="icon_title">
           活动简介
         </view>
@@ -19,7 +20,7 @@
     </view>
     <view class="icon_item_cell">
       <view class="icon_content" data-title="日程会务" data-id="cbddf0af60b041bd0c3e871a1a8f5a7e" bindtap="toDetail">
-        <image class="img" src="../../images/1.png"></image>
+        <image mode="aspectFit" class="img" src="../../images/1.png"></image>
         <view class="icon_title">
           日程会务
         </view>
@@ -27,7 +28,7 @@
     </view>
     <view class="icon_item_cell">
       <view class="icon_content" data-title="精彩瞬间" data-type="img" bindtap="toMarvellous">
-        <image class="img" src="../../images/3.png"></image>
+        <image mode="aspectFit" class="img" src="../../images/3.png"></image>
         <view class="icon_title">
           精彩瞬间
         </view>
@@ -35,7 +36,7 @@
     </view>
     <view class="icon_item_cell">
       <view class="icon_content" data-title="红色声音" data-type="video" bindtap="toMarvellous">
-        <image class="img" src="../../images/4.png"></image>
+        <image mode="aspectFit" class="img" src="../../images/4.png"></image>
         <view class="icon_title">
           红色声音
         </view>
@@ -51,7 +52,7 @@
     </view>
     <view class="icon_item_cell">
       <view class="icon_content" data-title="疫情防控" data-id="cbddf0af60b042750c3ebf6b09f3e165" bindtap="toDetail">
-        <image class="img" src="../../images/2.png"></image>
+        <image mode="aspectFit" class="img" src="../../images/2.png"></image>
         <view class="icon_title">
           疫情防控
         </view>
@@ -61,12 +62,18 @@
 
   <mp-cell link hover value="新闻动态" footer="查看更多" url="/pages/interList/interList?type=news">
   </mp-cell>
-  <view class="newList" wx:key="_id" wx:for="{{newList}}" data-id="{{item._id}}" data-title="{{item.title}}" bindtap="toDetail">
-    <image class="newsImg" src="{{item.cover}}"></image>
-    <view class="newsTitle">
-      <text class="top">{{item.title}}</text>
-      <text class="subTitle">发布日期 2021-05-15 11:25:00</text>
+  <view wx:key="_id" wx:for="{{newList}}">
+    <view wx:if="{{item.type != 'video'}}" data-id="{{item._id}}" data-title="{{item.title}}" class="newList"
+      bindtap="toDetail">
+      <image mode="aspectFit" class="newsImg" src="{{item.cover}}"></image>
+      <view class="newsTitle">
+        <text class="top">{{item.title}}</text>
+        <text class="subTitle">发布日期 {{item.create_time}}</text>
+      </view>
+    </view>
+    <view wx:if="{{item.type == 'video'}}">
+      <video id="newsVideo{{index}}" data-index="{{index}}" bindplay="play" style="width: 100%" src="{{item.url}}"></video>
     </view>
+    <view class="br"></view>
   </view>
-  <view class="br"></view>
 </view>

+ 0 - 124
miniprogram/pages/index/index.js

@@ -1,124 +0,0 @@
-//index.js
-const app = getApp()
-
-Page({
-  data: {
-    avatarUrl: './user-unlogin.png',
-    userInfo: {},
-    hasUserInfo: false,
-    logged: false,
-    takeSession: false,
-    requestResult: '',
-    canIUseGetUserProfile: false,
-    canIUseOpenData: wx.canIUse('open-data.type.userAvatarUrl') // 如需尝试获取用户信息可改为false
-  },
-
-  onLoad: function() {
-    if (!wx.cloud) {
-      wx.redirectTo({
-        url: '../chooseLib/chooseLib',
-      })
-      return
-    }
-    if (wx.getUserProfile) {
-      this.setData({
-        canIUseGetUserProfile: true,
-      })
-    }
-  },
-
-  getUserProfile() {
-    // 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认,开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
-    wx.getUserProfile({
-      desc: '展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
-      success: (res) => {
-        this.setData({
-          avatarUrl: res.userInfo.avatarUrl,
-          userInfo: res.userInfo,
-          hasUserInfo: true,
-        })
-      }
-    })
-  },
-
-  onGetUserInfo: function(e) {
-    if (!this.data.logged && e.detail.userInfo) {
-      this.setData({
-        logged: true,
-        avatarUrl: e.detail.userInfo.avatarUrl,
-        userInfo: e.detail.userInfo,
-        hasUserInfo: true,
-      })
-    }
-  },
-
-  onGetOpenid: function() {
-    // 调用云函数
-    wx.cloud.callFunction({
-      name: 'login',
-      data: {},
-      success: res => {
-        console.log('[云函数] [login] user openid: ', res.result.openid)
-        app.globalData.openid = res.result.openid
-        wx.navigateTo({
-          url: '../userConsole/userConsole',
-        })
-      },
-      fail: err => {
-        console.error('[云函数] [login] 调用失败', err)
-        wx.navigateTo({
-          url: '../deployFunctions/deployFunctions',
-        })
-      }
-    })
-  },
-
-  // 上传图片
-  doUpload: function () {
-    // 选择图片
-    wx.chooseImage({
-      count: 1,
-      sizeType: ['compressed'],
-      sourceType: ['album', 'camera'],
-      success: function (res) {
-        wx.showLoading({
-          title: '上传中',
-        })
-
-        const filePath = res.tempFilePaths[0]
-        
-        // 上传图片
-        const cloudPath = `my-image${filePath.match(/\.[^.]+?$/)[0]}`
-        wx.cloud.uploadFile({
-          cloudPath,
-          filePath,
-          success: res => {
-            console.log('[上传文件] 成功:', res)
-
-            app.globalData.fileID = res.fileID
-            app.globalData.cloudPath = cloudPath
-            app.globalData.imagePath = filePath
-            
-            wx.navigateTo({
-              url: '../storageConsole/storageConsole'
-            })
-          },
-          fail: e => {
-            console.error('[上传文件] 失败:', e)
-            wx.showToast({
-              icon: 'none',
-              title: '上传失败',
-            })
-          },
-          complete: () => {
-            wx.hideLoading()
-          }
-        })
-      },
-      fail: e => {
-        console.error(e)
-      }
-    })
-  },
-
-})

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

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

+ 0 - 77
miniprogram/pages/index/index.wxml

@@ -1,77 +0,0 @@
-<!--index.wxml-->
-<view class="container">
-
-  <!-- 用户 openid -->
-  <view class="userinfo">
-    <block wx:if="{{canIUseOpenData}}" class="userinfo-opendata">
-      <view class="userinfo-block-avatar" bindtap="bindViewTap">
-        <open-data type="userAvatarUrl"></open-data>
-      </view>
-    </block>
-    <block wx:elif="{{!hasUserInfo}}">
-      <button 
-        wx:if="{{canIUseGetUserProfile}}" 
-        bindtap="getUserProfile"
-        class="userinfo-avatar"
-        style="background-image: url({{avatarUrl}})"
-        size="default"
-      ></button>
-      <button
-        wx:else
-        open-type="getUserInfo" 
-        bindgetuserinfo="onGetUserInfo"
-        class="userinfo-avatar"
-        style="background-image: url({{avatarUrl}})"
-        size="default"
-      ></button>
-    </block>
-    <block wx:else>
-      <image bindtap="bindViewTap" class="userinfo-block-avatar" src="{{avatarUrl}}" mode="cover"></image>
-    </block>
-    <view class="userinfo-nickname-wrapper">
-      <button class="userinfo-nickname" bindtap="onGetOpenid">点击获取 openid</button>
-    </view>
-  </view>
-
-
-  <!-- 上传图片 -->
-  <view class="uploader">
-    <view class="uploader-text" bindtap="doUpload">
-      <text>上传图片</text>
-    </view>
-    <view class="uploader-container" wx:if="{{imgUrl}}">
-      <image class="uploader-image" src="{{imgUrl}}" mode="aspectFit" bindtap="previewImg"></image>
-    </view>
-  </view>
-
-
-  <!-- 操作数据库 -->
-  <view class="uploader">
-    <navigator url="../databaseGuide/databaseGuide" open-type="navigate" class="uploader-text">
-      <text>前端操作数据库</text>
-    </navigator>
-  </view>
-
-  <!-- 即时通信 -->
-  <view class="uploader">
-    <navigator url="../im/im" open-type="navigate" class="uploader-text">
-      <text>即时通信 Demo</text>
-    </navigator>
-  </view>
-
-  <!-- 新建云函数 -->
-  <view class="uploader">
-    <navigator url="../addFunction/addFunction" open-type="navigate" class="uploader-text">
-      <text>快速新建云函数</text>
-    </navigator>
-  </view>
-
-  <!-- 云调用 -->
-  <view class="uploader">
-    <navigator url="../openapi/openapi" open-type="navigate" class="uploader-text">
-      <text>云调用</text>
-    </navigator>
-  </view>
-
-
-</view>

+ 0 - 161
miniprogram/pages/index/index.wxss

@@ -1,161 +0,0 @@
-/**index.wxss**/
-
-page {
-  background: #f6f6f6;
-  display: flex;
-  flex-direction: column;
-  justify-content: flex-start;
-}
-
-.userinfo, .uploader, .tunnel {
-  margin-top: 40rpx;
-  height: 140rpx;
-  width: 100%;
-  background: #fff;
-  border: 1px solid rgba(0, 0, 0, 0.1);
-  border-left: none;
-  border-right: none;
-  display: flex;
-  flex-direction: row;
-  align-items: center;
-  transition: all 300ms ease;
-}
-
-.userinfo {
-  padding-left: 120rpx;
-}
-
-.userinfo-avatar {
-  width: 100rpx;
-  height: 100rpx;
-  margin: 20rpx;
-  border-radius: 50%;
-  background-size: cover;
-  background-color: white;
-}
-
-.userinfo-block-avatar {
-  width: 100rpx;
-  height: 100rpx;
-  margin: 20rpx;
-  border-radius: 50%;
-  overflow: hidden;
-}
-
-.userinfo-avatar[size] {
-  width: 100rpx;
-}
-
-
-.userinfo-avatar:after {
-  border: none;
-}
-
-.userinfo-nickname {
-  font-size: 32rpx;
-  color: #007aff;
-  background-color: white;
-  background-size: cover;
-  text-align: left;
-  padding-left: 0;
-  margin-left: 10px;
-}
-
-.userinfo-nickname::after {
-  border: none;
-}
-
-.userinfo-nickname-wrapper {
-  flex: 1;
-}
-
-.uploader, .tunnel {
-  height: auto;
-  padding: 0 0 0 40rpx;
-  flex-direction: column;
-  align-items: flex-start;
-  box-sizing: border-box;
-}
-
-.uploader-text, .tunnel-text {
-  width: 100%;
-  line-height: 52px;
-  font-size: 34rpx;
-  color: #007aff;
-}
-
-.uploader-container {
-  width: 100%;
-  height: 400rpx;
-  padding: 20rpx 20rpx 20rpx 0;
-  display: flex;
-  align-content: center;
-  justify-content: center;
-  box-sizing: border-box;
-  border-top: 1px solid rgba(0, 0, 0, 0.1);
-}
-
-.uploader-image {
-  width: 100%;
-  height: 360rpx;
-}
-
-.tunnel {
-  padding: 0 0 0 40rpx;
-}
-
-.tunnel-text {
-  position: relative;
-  color: #222;
-  display: flex;
-  flex-direction: row;
-  align-content: center;
-  justify-content: space-between;
-  box-sizing: border-box;
-  border-top: 1px solid rgba(0, 0, 0, 0.1);
-}
-
-.tunnel-text:first-child {
-  border-top: none;
-}
-
-.tunnel-switch {
-  position: absolute;
-  right: 20rpx;
-  top: -2rpx;
-}
-
-.disable {
-  color: #888;
-}
-
-.service {
-  position: fixed;
-  right: 40rpx;
-  bottom: 40rpx;
-  width: 140rpx;
-  height: 140rpx;
-  border-radius: 50%;
-  background: linear-gradient(#007aff, #0063ce);
-  box-shadow: 0 5px 10px rgba(0, 0, 0, 0.3);
-  display: flex;
-  align-content: center;
-  justify-content: center;
-  transition: all 300ms ease;
-}
-
-.service-button {
-  position: absolute;
-  top: 40rpx;
-}
-
-.service:active {
-  box-shadow: none;
-}
-
-.request-text {
-  padding: 20rpx 0;
-  font-size: 24rpx;
-  line-height: 36rpx;
-  word-break: break-all;
-}

BIN
miniprogram/pages/index/user-unlogin.png


+ 1 - 1
miniprogram/pages/interList/interList.wxml

@@ -9,7 +9,7 @@
     </view>
     <view wx:if="{{!item.headUrl}}" bindtap="toDetail"  data-id="{{item._id}}" data-title="{{item.title}}">
       <view class="newList">
-        <image class="newsImg" src="{{item.cover}}" wx:if="{{item.cover}}"></image>
+        <image mode="aspectFit" class="newsImg" src="{{item.cover}}" wx:if="{{item.cover}}"></image>
         <view class="newsTitle">
           <text wx:if="{{item.title}}" class="top">{{item.title}}</text>
           <text wx:if="{{item.creat_time}}" class="subTitle">发布日期 {{item.creat_time}}</text>

+ 5 - 0
miniprogram/pages/marvellous/index.js

@@ -31,12 +31,17 @@ Page({
     let list = await db.collection('data_asset').where({
       type: _.eq(options.type || "img")
     }).get();
+
     wx.hideLoading();
     if (!list.data.length) return wx.showToast({
       title: '暂无数据',
       icon: "none"
     })
+    list.data.sort((a, b) => {
+      return b.create_time - a.create_time
+    })
     let li = list.data || [];
+    console.log(list, options.type)
     for (let i = 0; i < li.length; i++) {
       const v = li[i];
       v.index = i;

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

@@ -10,7 +10,9 @@
           data-index="{{v.index}}" data-key="{{index}}" data-o="{{o}}" data-url="{{v.url}}" bindtap="showImg"
           bindlongtap="longtap">
           <cover-view wx:if="{{showSelect}}" class="btnClose {{ v.select ? 'act': '' }}" size="{{20}}">√</cover-view>
-          <image wx:if="{{pageType === 'img'}}" class="img" src="{{v.url}}"></image>
+          <image style="background-color: #000" mode="aspectFit" wx:if="{{pageType === 'img'}}" class="img"
+            src="{{v.url}}" lazy-load="{{true}}">
+          </image>
           <video show-progress="{{false}}" show-fullscreen-btn="{{false}}" show-play-btn="{{false}}"
             show-center-play-btn="{{false}}" bindlongtap="longtap" wx:if="{{pageType === 'video'}}" class="video {{}}"
             src="{{v.url}}"></video>