Sfoglia il codice sorgente

格式

格式化代码,首页card添加tag,搜索框优化
RegMs If 4 anni fa
parent
commit
cbd0b5c8eb
36 ha cambiato i file con 444 aggiunte e 396 eliminazioni
  1. 2 11
      README.md
  2. 6 0
      cloudfunctions/listMessages/config.json
  3. 11 0
      cloudfunctions/listMessages/index.js
  4. 14 0
      cloudfunctions/listMessages/package.json
  5. 1 2
      miniprogram/app.json
  6. 60 19
      miniprogram/app.wxss
  7. 5 5
      miniprogram/components/imagePicker/imagePicker.js
  8. 7 4
      miniprogram/components/imagePicker/imagePicker.wxml
  9. 1 1
      miniprogram/components/itemCard/itemCard.js
  10. 17 11
      miniprogram/components/itemCard/itemCard.wxml
  11. 26 19
      miniprogram/components/itemCard/itemCard.wxss
  12. 1 1
      miniprogram/components/itemPublisher/itemPublisher.wxml
  13. 3 3
      miniprogram/components/itemmyNews/itemmyNews.wxml
  14. 13 43
      miniprogram/pages/activity/activity.js
  15. 7 7
      miniprogram/pages/activityPublish/activityPublish.wxml
  16. 39 58
      miniprogram/pages/main/main.js
  17. 1 1
      miniprogram/pages/main/main.json
  18. 24 7
      miniprogram/pages/main/main.wxml
  19. 3 3
      miniprogram/pages/main/main.wxss
  20. 1 1
      miniprogram/pages/myQuestion/myQuestion.wxml
  21. 26 26
      miniprogram/pages/opinion/opinion.wxml
  22. 8 36
      miniprogram/pages/publisher/publisher.js
  23. 1 1
      miniprogram/pages/publisher/publisher.wxml
  24. 6 6
      miniprogram/pages/publisherLogin/publisherLogin.wxml
  25. 1 1
      miniprogram/pages/receivedQuestion/receivedQuestion.wxml
  26. 42 52
      miniprogram/pages/search/search.js
  27. 1 1
      miniprogram/pages/search/search.json
  28. 21 14
      miniprogram/pages/search/search.wxml
  29. 7 9
      miniprogram/pages/search/search.wxss
  30. 8 8
      miniprogram/pages/setting/setting.js
  31. 32 32
      miniprogram/pages/setting/setting.wxml
  32. 1 1
      miniprogram/pages/setting/setting.wxss
  33. 7 7
      miniprogram/pages/user/user.js
  34. 6 4
      miniprogram/pages/user/user.wxml
  35. 34 2
      miniprogram/utils/util.js
  36. 1 0
      project.config.json

+ 2 - 11
README.md

@@ -1,12 +1,3 @@
-# 云开发 quickstart
-
-这是云开发的快速启动指引,其中演示了如何上手使用云开发的三大基础能力:
-
-- 数据库:一个既可在小程序前端操作,也能在云函数中读写的 JSON 文档型数据库
-- 文件存储:在小程序前端直接上传/下载云端文件,在云开发控制台可视化管理
-- 云函数:在云端运行的代码,微信私有协议天然鉴权,开发者只需编写业务逻辑代码
-
-## 参考文档
-
-- [云开发文档](https://developers.weixin.qq.com/miniprogram/dev/wxcloud/basis/getting-started.html)
+# 汇听
 
+校园信息汇总平台

+ 6 - 0
cloudfunctions/listMessages/config.json

@@ -0,0 +1,6 @@
+{
+  "permissions": {
+    "openapi": [
+    ]
+  }
+}

+ 11 - 0
cloudfunctions/listMessages/index.js

@@ -0,0 +1,11 @@
+// 云函数入口文件
+const cloud = require('wx-server-sdk')
+
+cloud.init()
+
+const db = cloud.database()
+
+// 云函数入口函数
+exports.main = async (event, context) => {
+
+}

+ 14 - 0
cloudfunctions/listMessages/package.json

@@ -0,0 +1,14 @@
+{
+  "name": "listMessages",
+  "version": "1.0.0",
+  "description": "",
+  "main": "index.js",
+  "scripts": {
+    "test": "echo \"Error: no test specified\" && exit 1"
+  },
+  "author": "",
+  "license": "ISC",
+  "dependencies": {
+    "wx-server-sdk": "~2.4.0"
+  }
+}

+ 1 - 2
miniprogram/app.json

@@ -34,8 +34,7 @@
     "backgroundColor": "#ffffff",
     "color": "#9E9E9E",
     "borderStyle": "white",
-    "list": [
-      {
+    "list": [{
         "pagePath": "pages/main/main",
         "text": "首页",
         "iconPath": "images/tabbar/1.1.png",

+ 60 - 19
miniprogram/app.wxss

@@ -7,25 +7,66 @@
   justify-content: space-between;
   padding: 200rpx 0;
   box-sizing: border-box;
-} 
-
-.dark-primary-color    { background: #303F9F; }
-.default-primary-color { background: #3F51B5; }
-.dark-primary-color-font { color: #303F9F; }
-.default-primary-color-font { color: #3F51B5; }
-.light-primary-color   { background: #C5CAE9; }
-.accent-color          { background: #FF4081; }
-.primary-text-color    { color: #212121; }
-.divider-color         { background: #BDBDBD; }
-.block-background-color{ background:#F0F0F0;}
-
-.primary-color-fg { color: #469298; }
-.primary-color-bg { background: #469298; }
-.secondary-text-color  { color: #707070; }
-.bg-color {background:#ededed}
-.text-primary-color    { color: #FFFFFF; }
+}
 
-page {
-  background: #ededed;
+.dark-primary-color {
+  background: #303F9F;
+}
+
+.default-primary-color {
+  background: #3F51B5;
+}
+
+.dark-primary-color-font {
+  color: #303F9F;
+}
+
+.default-primary-color-font {
+  color: #3F51B5;
+}
+
+.light-primary-color {
+  background: #C5CAE9;
+}
+
+.accent-color {
+  background: #FF4081;
+}
+
+.primary-text-color {
+  color: #212121;
+}
+
+.divider-color {
+  background: #BDBDBD;
+}
+
+.block-background-color {
+  background: #F0F0F0;
+}
+
+/* new color here */
+
+.primary-text-color {
+  color: #469298;
+}
+
+.primary-background-color {
+  background: #469298;
 }
 
+.secondary-text-color {
+  color: #707070;
+}
+
+.secondary-background-color {
+  background: #EDEDED
+}
+
+.white-text-color {
+  color: #FFFFFF;
+}
+
+page {
+  background: #EDEDED;
+}

+ 5 - 5
miniprogram/components/imagePicker/imagePicker.js

@@ -22,7 +22,7 @@ Component({
    * 组件的方法列表
    */
   methods: {
-    chooseImage: function(num, callback) {
+    chooseImage: function (num, callback) {
       wx.chooseImage({
         count: num,
         sizeType: ['original'],
@@ -32,14 +32,14 @@ Component({
         }.bind(this)
       })
     },
-  
+
     previewImage: function (e) {
       wx.previewImage({
         urls: this.data.images,
         current: e.currentTarget.dataset.url
       })
     },
-  
+
     removeImage: function (e) {
       for (var i = 0; i < this.properties.images.length; i++) {
         if (this.properties.images[i] == e.currentTarget.dataset.url) {
@@ -55,7 +55,7 @@ Component({
         }
       }
     },
-  
+
     addImage: function () {
       if (this.properties.images.length >= this.properties.max) {
         return
@@ -71,4 +71,4 @@ Component({
       })
     },
   }
-})
+})

+ 7 - 4
miniprogram/components/imagePicker/imagePicker.wxml

@@ -1,9 +1,12 @@
 <!--components/imagePicker/imagePicker.wxml-->
 <view style="text-align: center;">
   <label wx:for="{{images}}" wx:for-item="item" wx:key="*this">
-    <image class="image" style="position: relative; width: {{imageWidth}}rpx; height: {{imageHeight}}rpx;" src="{{item}}" mode="aspectFill" data-url="{{item}}" catchtap="previewImage">
-      <icon wx:if="{{!readonly}}" style="position: absolute; top: 0; left: 0;" type="cancel" size="20" data-url="{{item}}" catchtap="removeImage"></icon>
+    <image class="image" style="position: relative; width: {{imageWidth}}rpx; height: {{imageHeight}}rpx;"
+      src="{{item}}" mode="aspectFill" data-url="{{item}}" catchtap="previewImage">
+      <icon wx:if="{{!readonly}}" style="position: absolute; top: 0; left: 0;" type="cancel" size="20"
+        data-url="{{item}}" catchtap="removeImage"></icon>
     </image>
   </label>
-  <image wx:if="{{images.length < max && !readonly}}" class="image" style="width: 150rpx; height: 150rpx;" src="/images/add.png" mode="aspectFill" catchtap="addImage"></image>
-</view>
+  <image wx:if="{{images.length < max && !readonly}}" class="image" style="width: 150rpx; height: 150rpx;"
+    src="/images/add.png" mode="aspectFill" catchtap="addImage"></image>
+</view>

+ 1 - 1
miniprogram/components/itemCard/itemCard.js

@@ -40,4 +40,4 @@ Component({
       })
     }
   }
-})
+})

+ 17 - 11
miniprogram/components/itemCard/itemCard.wxml

@@ -5,21 +5,27 @@
       <image class="publisher-avatar" src="{{item.publisherAvatar}}" mode="aspectFill"></image>
       <view class="publisher-name">{{item.publisherName}}</view>
     </view>
-    <view class="activity-attribute primary-color-bg text-primary-color" catchtap="filterMsgType">{{item.attribute[0]}}</view>
+    <view class="activity-attribute primary-background-color white-text-color" catchtap="filterMsgType">{{item.attribute[0]}}
+    </view>
   </view>
   <view class="title-time">
     <view class="title">{{item.title}}</view>
-    <view class="time primary-color-fg">{{item.time}}</view>
+    <view class="time primary-text-color">{{item.time}}</view>
   </view>
   <view class="sub-title">{{item.subTitle}}</view>
-  <imagePicker wx:if="{{item.poster != ''}}" images="{{[item.poster]}}" max="1" image-width="700" image-height="365" readonly />
-  <imagePicker wx:if="{{item.poster == '' && item.photo.length != 0}}" images="{{item.photo}}" max="1" image-width="{{item.photo.length == 1 ? 700 : item.photo.length <= 4 ? 330 : 220}}" image-height="{{item.photo.length == 1 ? 700 : item.photo.length <= 4 ? 330 : 220}}" readonly />
+  <imagePicker wx:if="{{item.poster != ''}}" images="{{[item.poster]}}" max="1" image-width="690" image-height="365"
+    readonly />
+  <imagePicker wx:if="{{item.poster == '' && item.photo.length != 0}}" images="{{item.photo}}" max="1"
+    image-width="{{item.photo.length == 1 ? 690 : item.photo.length <= 4 ? 330 : 220}}"
+    image-height="{{item.photo.length == 1 ? 690 : item.photo.length <= 4 ? 330 : 220}}" readonly />
   <view class="bottom-line">
-  <view class="tags primary-color-fg"></view>
-  <view class="to-detail">
-    <text class="primary-color-fg" style="font-size:20rpx;">查看详情</text>
-    <image class="arrow" src="/images/hollow_arrow.png" mode="aspectFill"></image>
+    <view class="tags primary-text-color">
+      <text style="font-size: 25rpx; margin: 0rpx 30rpx;" wx:for="{{item.tag}}" wx:for-item="tag"
+        wx:key="_id">{{tag}}</text>
+    </view>
+    <view class="to-detail">
+      <text class="primary-text-color" style="font-size: 20rpx;">查看详情</text>
+      <image class="arrow" src="/images/hollow_arrow.png" mode="aspectFill"></image>
+    </view>
   </view>
-</view>
-</view>
-
+</view>

+ 26 - 19
miniprogram/components/itemCard/itemCard.wxss

@@ -1,19 +1,19 @@
-.card{
+.card {
   display: flex;
   flex-direction: column;
   width: 700rpx;
-  margin-top: 60rpx;
+  margin: 50rpx 0rpx;
   background-color: #ffffff;
   border-radius: 28rpx;
-  box-shadow: 5rpx 5rpx 8rpx 0rpx rgba(0,0,0,0.16);
+  box-shadow: 5rpx 5rpx 8rpx 0rpx rgba(0, 0, 0, 0.16);
 }
 
-.avatar-name{
+.avatar-name {
   display: flex;
   flex-direction: row;
 }
 
-.publisher-avatar{
+.publisher-avatar {
   width: 50rpx;
   height: 50rpx;
   border-radius: 30rpx;
@@ -25,7 +25,7 @@
   background-color: #ffffff;
 }
 
-.profile{
+.profile {
   display: flex;
   flex-direction: row;
   justify-content: space-between;
@@ -34,22 +34,22 @@
   margin-right: 10rpx;
 }
 
-.publisher-name{
+.publisher-name {
   font-size: 24rpx;
   align-self: center;
   background-color: #ffffff;
-  padding:5rpx 20rpx 5rpx 30rpx;
+  padding: 5rpx 20rpx 5rpx 30rpx;
   margin-left: -20rpx;
   border-radius: 22rpx;
-  box-shadow: 5rpx 5rpx 8rpx 0rpx rgba(0,0,0,0.16);
+  box-shadow: 5rpx 5rpx 8rpx 0rpx rgba(0, 0, 0, 0.16);
   z-index: 1;
 }
 
-.time{
+.time {
   font-size: 16rpx;
 }
 
-.activity-attribute{
+.activity-attribute {
   font-size: 24rpx;
   align-self: center;
   padding-top: 5rpx;
@@ -57,14 +57,14 @@
   padding-right: 20rpx;
   padding-left: 20rpx;
   border-radius: 28rpx;
-  box-shadow: 5rpx 5rpx 8rpx 0rpx rgba(0,0,0,0.16);
+  box-shadow: 5rpx 5rpx 8rpx 0rpx rgba(0, 0, 0, 0.16);
 }
 
-.title{
+.title {
   font-size: 28rpx;
 }
 
-.title-time{
+.title-time {
   margin-left: 50rpx;
   margin-right: 30rpx;
   margin-bottom: 20rpx;
@@ -74,28 +74,35 @@
   align-items: flex-end;
 }
 
-.sub-title{
+.sub-title {
   font-size: 24rpx;
   margin-left: 50rpx;
   margin-bottom: 20rpx;
   margin-right: 20rpx;
 }
 
-.bottom-line{
+.bottom-line {
   display: flex;
   flex-direction: row;
   justify-content: space-between;
+  align-items: center;
   margin: 10rpx 10rpx 30rpx 10rpx;
 }
 
-.to-detail{
+.tags {
   display: flex;
   flex-direction: row;
   align-items: center;
 }
 
-.arrow{
+.to-detail {
+  display: flex;
+  flex-direction: row;
+  align-items: center;
+}
+
+.arrow {
   height: 20rpx;
   width: 20rpx;
   margin: 0rpx 20rpx 0rpx 20rpx;
-}
+}

+ 1 - 1
miniprogram/components/itemPublisher/itemPublisher.wxml

@@ -6,7 +6,7 @@
       <view class="publisher-name dark-primary-color-font">{{item.publisherName}}</view>
       <view class="time">{{item.time}}</view>
     </view>
-    <view class="activity-attribute accent-color text-primary-color" catchtap="filterMsgType">{{item.attribute[0]}}</view>
+    <view class="activity-attribute accent-color white-text-color" catchtap="filterMsgType">{{item.attribute[0]}}</view>
   </view>
   <view class="title">{{item.title}}</view>
   <view class="sub-title">{{item.subTitle}}</view>

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

@@ -2,13 +2,13 @@
 <view class="card">
   <view class="top">
     <view class="profile" wx:if="{{item.publishType=='回复'}}">
-      <text class="publisher-name">{{item.publisherName}}</text><text class="primary-color-fg"
+      <text class="publisher-name">{{item.publisherName}}</text><text class="primary-text-color"
         style="font-size:24rpx;">对您的评论进行了回复</text>
     </view>
-    <text class="primary-color-fg detail">查看</text>
+    <text class="primary-text-color detail">查看</text>
   </view>
   <view class="bottom">
     <view class="title secondary-text-color">{{item.title}}</view>
-    <text class="primary-color-fg detail">回复</text>
+    <text class="primary-text-color detail">回复</text>
   </view>
 </view>

+ 13 - 43
miniprogram/pages/activity/activity.js

@@ -1,4 +1,5 @@
 const app = getApp()
+const util = require('../../utils/util.js')
 
 Page({
 
@@ -31,7 +32,7 @@ Page({
           type: "message",
           id: this.data.activityInfo._id
         },
-        success: function() {
+        success: function () {
           this.setData({
             like: 1,
             likeEnable: true
@@ -40,7 +41,7 @@ Page({
             title: "已收藏",
           })
         }.bind(this),
-        fail: function() {
+        fail: function () {
           wx.showToast({
             title: "网络错误",
             icon: "none"
@@ -52,7 +53,7 @@ Page({
         type: "message",
         id: this.data.activityInfo._id
       }).remove({
-        success: function() {
+        success: function () {
           this.setData({
             like: 0,
             likeEnable: true
@@ -61,7 +62,7 @@ Page({
             title: "已取消收藏",
           })
         }.bind(this),
-        fail: function() {
+        fail: function () {
           wx.showToast({
             title: "网络错误",
             icon: "none"
@@ -86,10 +87,10 @@ Page({
         success: function (res) {
           console.log(res)
           if (res.data.length >= 10) {
-           wx.showToast({
-             title: "为防止刷屏,每人每消息至多提问10条",
-             icon: "none"
-           })
+            wx.showToast({
+              title: "为防止刷屏,每人每消息至多提问10条",
+              icon: "none"
+            })
           } else {
             db.collection("qaData").add({
               data: {
@@ -116,37 +117,6 @@ Page({
     }
   },
 
-  // 计算时间差
-  handleDate: function(date) {
-    var now = new Date().getTime()
-    var diffValue = now - date.getTime()
-    if (diffValue < 0) {
-      console.log("时间不同步")
-      return "刚刚"
-    }
-    var result = ""
-    var minute = 1000 * 60
-    var hour = minute * 60
-    var day = hour * 24
-    var minC = diffValue / minute
-    var hourC = diffValue / hour
-    var dayC = diffValue / day
-    if (parseInt(dayC) > 30) {
-      result += date.getFullYear() + "/" + (date.getMonth() + 1) + "/" + date.getDate()
-    } else if (parseInt(dayC) > 1) {
-      result += parseInt(dayC) + "天前"
-    } else if (parseInt(dayC) == 1) {
-      result += "昨天"
-    } else if (hourC >= 1) {
-      result += parseInt(hourC) + "小时前"
-    } else if (minC >= 5) {
-      result += parseInt(minC) + "分钟前"
-    } else {
-      result += "刚刚"
-    }
-    return result
-  },
-
   /**
    * 生命周期函数--监听页面加载
    */
@@ -157,7 +127,7 @@ Page({
     const db = wx.cloud.database()
     const _ = db.command
     db.collection("mainData").doc(options.id).get({
-      success: function(res) {
+      success: function (res) {
         this.setData({
           activityInfo: res.data
         })
@@ -168,10 +138,10 @@ Page({
       activityId: options.id,
       answer: _.neq("")
     }).get({
-      success: function(res) {
+      success: function (res) {
         for (let i = 0; i < res.data.length; i++) {
           if (res.data[i].answerTime != "") {
-            res.data[i].time = this.handleDate(res.data[i].answerTime)
+            res.data[i].time = util.handleDate(res.data[i].answerTime)
           } else {
             res.data[i].time = ""
           }
@@ -185,7 +155,7 @@ Page({
       type: "message",
       id: options.id
     }).get({
-      success: function(res) {
+      success: function (res) {
         this.setData({
           like: res.data.length
         })

+ 7 - 7
miniprogram/pages/activityPublish/activityPublish.wxml

@@ -6,9 +6,9 @@
 <view wx:if="{{currentTab == 0}}" class="con">
   <view class="title2">信息发布类型</view>
   <view class="buttons">
-    <view><button class="button dark-primary-color text-primary-color" bindtap="switch1">活动</button></view>
-    <view><button class="button dark-primary-color text-primary-color" bindtap="switch2">纳新</button></view>
-    <view><button class="button dark-primary-color text-primary-color" bindtap="switch3">通知</button></view>
+    <view><button class="button dark-primary-color white-text-color" bindtap="switch1">活动</button></view>
+    <view><button class="button dark-primary-color white-text-color" bindtap="switch2">纳新</button></view>
+    <view><button class="button dark-primary-color white-text-color" bindtap="switch3">通知</button></view>
   </view>
 </view>
 
@@ -74,7 +74,7 @@
     <view class="cate">报名链接</view>:
     <input class="input block-background-color" model:value="{{activitySrc}}" placeholder="请输入报名链接" />
   </view>
-  <button class="button dark-primary-color text-primary-color" bindtap="switch4">提交</button>
+  <button class="button dark-primary-color white-text-color" bindtap="switch4">提交</button>
 </scroll-view>
 
 <scroll-view wx:if="{{currentTab == 2}}" scroll-y style="height: {{winHeight - 60}}px;">
@@ -127,7 +127,7 @@
     <view class="cate">报名链接</view>:
     <input class="input block-background-color" model:value="{{recruitSrc}}" placeholder="请输入报名链接" />
   </view>
-  <button class="button dark-primary-color text-primary-color" bindtap="switch4">提交</button>
+  <button class="button dark-primary-color white-text-color" bindtap="switch4">提交</button>
 </scroll-view>
 
 <scroll-view wx:if="{{currentTab == 3}}" scroll-y style="height: {{winHeight - 60}}px;">
@@ -164,12 +164,12 @@
     <view class="block22"><view class="cate">通知图片</view>:</view>
     <imagePicker images="{{notiPicture}}" max="9" image-width="145" image-height="145" bindchange="updateNotiPicture" />
   </view>
-  <button class="button dark-primary-color text-primary-color" bindtap="switch4">提交</button>
+  <button class="button dark-primary-color white-text-color" bindtap="switch4">提交</button>
 </scroll-view>
 
 <view wx:if="{{currentTab == 4}}" class="con">
   <view class="con1 dark-primary-color-font">发布成功!</view>
   <image  class="success-icon" src="../../images/finish.png" mode="aspectFill"/>
   <!-- <view class="con2"></view> -->
-  <button class="button dark-primary-color text-primary-color" bindtap="returnToUser" >返回</button>
+  <button class="button dark-primary-color white-text-color" bindtap="returnToUser" >返回</button>
 </view>

+ 39 - 58
miniprogram/pages/main/main.js

@@ -1,3 +1,5 @@
+const util = require('../../utils/util.js')
+
 Page({
 
   /**
@@ -8,28 +10,25 @@ Page({
     toggleEnable: true,
     filterList: 0,
     filterItem: ["", "", "", ""],
-    filterName: [
-      {},
+    filterName: [{},
       {
         type: "信息类型",
-        list: [
-          {
+        list: [{
             sub: "通知",
-            item : [
-              {
-                secondSub:"生活通知",
-                subitem:["水电通知", "缴费通知", "假期通知", "后勤通知", "图书馆通知"]            
+            item: [{
+                secondSub: "生活通知",
+                subitem: ["水电通知", "缴费通知", "假期通知", "后勤通知", "图书馆通知"]
               },
               {
-                secondSub:"学业通知",
-                subitem:["选课通知", "竞赛通知", "考试通知"]
+                secondSub: "学业通知",
+                subitem: ["选课通知", "竞赛通知", "考试通知"]
               },
               {
-                secondSub:"其他通知",
-                subitem:["其他通知"]
+                secondSub: "其他通知",
+                subitem: ["其他通知"]
               }
-        ]
-      },
+            ]
+          },
           {
             sub: "活动",
             item: ["志愿活动", "文艺活动", "体育活动", "学术活动", "素质拓展", "精品课程", "其他活动"]
@@ -59,13 +58,19 @@ Page({
     this.setData({
       filterList: id
     })
-    this.animate("#arrow" + id, [
-      { rotate: 0 },
-      { rotate: 180 },
+    this.animate("#arrow" + id, [{
+        rotate: 0
+      },
+      {
+        rotate: 180
+      },
     ], 150)
-    this.animate("#list" + id, [
-      { opacity: 0 },
-      { opacity: 1 },
+    this.animate("#list" + id, [{
+        opacity: 0
+      },
+      {
+        opacity: 1
+      },
     ], 150)
     setTimeout(function () {
       this.setData({
@@ -76,13 +81,19 @@ Page({
 
   hideList: function (id) {
     this.data.toggleEnable = false
-    this.animate("#arrow" + id, [
-      { rotate: 180 },
-      { rotate: 360 },
+    this.animate("#arrow" + id, [{
+        rotate: 180
+      },
+      {
+        rotate: 360
+      },
     ], 150)
-    this.animate("#list" + id, [
-      { opacity: 1 },
-      { opacity: 0 },
+    this.animate("#list" + id, [{
+        opacity: 1
+      },
+      {
+        opacity: 0
+      },
     ], 150, function () {
       this.setData({
         filterList: 0
@@ -133,46 +144,16 @@ Page({
     })
   },
 
-  // 计算时间差
-  handleDate: function(date) {
-    var now = new Date().getTime()
-    var diffValue = now - date.getTime()
-    if (diffValue < 0) {
-      console.log("时间不同步")
-      return "刚刚"
-    }
-    var result = ""
-    var minute = 1000 * 60
-    var hour = minute * 60
-    var day = hour * 24
-    var minC = diffValue / minute
-    var hourC = diffValue / hour
-    var dayC = diffValue / day
-    if (parseInt(dayC) > 30) {
-      result += date.getFullYear() + "/" + (date.getMonth() + 1) + "/" + date.getDate()
-    } else if (parseInt(dayC) > 1) {
-      result += parseInt(dayC) + "天前"
-    } else if (parseInt(dayC) == 1) {
-      result += "昨天"
-    } else if (hourC >= 1) {
-      result += parseInt(hourC) + "小时前"
-    } else if (minC >= 5) {
-      result += parseInt(minC) + "分钟前"
-    } else {
-      result += "刚刚"
-    }
-    return result
-  },
-
   processData: function (start, arr) {
     const db = wx.cloud.database()
     for (let i = start; i < arr.length; i++) {
-      arr[i].time = this.handleDate(arr[i].time)
+      arr[i].time = util.handleDate(arr[i].time)
       db.collection("publisherInfoData").where({
         publisherName: arr[i].publisherName
       }).get({
         success: function (res) {
           arr[i].publisherAttribute = res.data[0].publisherAttribute
+          arr[i].tag = ['紫金港', '管控', '保卫处']
           this.setData({
             mainDatas: arr
           })

+ 1 - 1
miniprogram/pages/main/main.json

@@ -1,6 +1,6 @@
 {
   "enablePullDownRefresh": true,
   "usingComponents": {
-    "itemCard":"/components/itemCard/itemCard"
+    "itemCard": "/components/itemCard/itemCard"
   }
 }

+ 24 - 7
miniprogram/pages/main/main.wxml

@@ -22,25 +22,42 @@
       <view wx:for="{{filterName[1].list}}" wx:for-item="item" wx:key="type">
         <view class="filter-list-title default-primary-color-font">{{item.sub}}</view>
         <view class="filter-list-subtitle default-primary-color-font">{{item.item[0].secondSub}}</view>
-        <view class="filter-list-item" wx:for="{{item.item[0].subitem}}" wx:for-item="name" wx:key="*this" data-filter-list="1" data-filter-item="{{name}}" bindtap="toggleFilterItem">{{name}}<view wx:if="{{filterItem[1] == name}}">✔</view></view>
+        <view class="filter-list-item" wx:for="{{item.item[0].subitem}}" wx:for-item="name" wx:key="*this"
+          data-filter-list="1" data-filter-item="{{name}}" bindtap="toggleFilterItem">{{name}}<view
+            wx:if="{{filterItem[1] == name}}">✔</view>
+        </view>
         <view class="filter-list-subtitle default-primary-color-font">{{item.item[1].secondSub}}</view>
-        <view class="filter-list-item" wx:for="{{item.item[1].subitem}}" wx:for-item="name" wx:key="*this" data-filter-list="1" data-filter-item="{{name}}" bindtap="toggleFilterItem">{{name}}<view wx:if="{{filterItem[1] == name}}">✔</view></view>
+        <view class="filter-list-item" wx:for="{{item.item[1].subitem}}" wx:for-item="name" wx:key="*this"
+          data-filter-list="1" data-filter-item="{{name}}" bindtap="toggleFilterItem">{{name}}<view
+            wx:if="{{filterItem[1] == name}}">✔</view>
+        </view>
         <view class="filter-list-subtitle default-primary-color-font">{{item.item[2].secondSub}}</view>
-        <view class="filter-list-item" wx:for="{{item.item[2].subitem}}" wx:for-item="name" wx:key="*this" data-filter-list="1" data-filter-item="{{name}}" bindtap="toggleFilterItem">{{name}}<view wx:if="{{filterItem[1] == name}}">✔</view></view>
+        <view class="filter-list-item" wx:for="{{item.item[2].subitem}}" wx:for-item="name" wx:key="*this"
+          data-filter-list="1" data-filter-item="{{name}}" bindtap="toggleFilterItem">{{name}}<view
+            wx:if="{{filterItem[1] == name}}">✔</view>
+        </view>
       </view>
     </view>
     <view class="filter-list"></view>
     <view wx:if="{{filterList == 2}}" class="filter-list" id="list2">
-      <view class="filter-list-item" wx:for="{{filterName[2].item}}" wx:for-item="name" wx:key="*this" data-filter-list="2" data-filter-item="{{name}}" bindtap="toggleFilterItem">{{name}}<view wx:if="{{filterItem[2] == name}}">✔</view></view>
+      <view class="filter-list-item" wx:for="{{filterName[2].item}}" wx:for-item="name" wx:key="*this"
+        data-filter-list="2" data-filter-item="{{name}}" bindtap="toggleFilterItem">{{name}}<view
+          wx:if="{{filterItem[2] == name}}">✔</view>
+      </view>
     </view>
     <view class="filter-list"></view>
     <view wx:if="{{filterList == 3}}" class="filter-list" id="list3">
-      <view class="filter-list-item" wx:for="{{filterName[3].item}}" wx:for-item="name" wx:key="*this" data-filter-list="3" data-filter-item="{{name}}" bindtap="toggleFilterItem">{{name}}<view wx:if="{{filterItem[3] == name}}">✔</view></view>
+      <view class="filter-list-item" wx:for="{{filterName[3].item}}" wx:for-item="name" wx:key="*this"
+        data-filter-list="3" data-filter-item="{{name}}" bindtap="toggleFilterItem">{{name}}<view
+          wx:if="{{filterItem[3] == name}}">✔</view>
+      </view>
     </view>
   </view>
   <view style="margin-top: 60rpx;">
     <view wx:for="{{mainDatas}}" wx:for-item="item" wx:for-index="index" wx:key="_id">
-      <itemCard wx:if="{{(filterItem[1] == '' || filterItem[1] == item.attribute[0]) && (filterItem[2] == '' || filterItem[2] == item.publisherAttribute[0]) && (filterItem[3] == '' || filterItem[3] == item.supply[0])}}" item="{{item}}" bindfiltermsgtype="filterMsgType"/>
+      <itemCard
+        wx:if="{{(filterItem[1] == '' || filterItem[1] == item.attribute[0]) && (filterItem[2] == '' || filterItem[2] == item.publisherAttribute[0]) && (filterItem[3] == '' || filterItem[3] == item.supply[0])}}"
+        item="{{item}}" bindfiltermsgtype="filterMsgType" />
     </view>
   </view>
-</view>
+</view>

+ 3 - 3
miniprogram/pages/main/main.wxss

@@ -15,7 +15,7 @@
   width: 100%;
   z-index: 100;
   background-color: #ffffff;
-  box-shadow: 0rpx 0rpx 15rpx 0rpx rgba(0,0,0,0.16);
+  box-shadow: 0rpx 0rpx 15rpx 0rpx rgba(0, 0, 0, 0.16);
 }
 
 .filter-item {
@@ -36,8 +36,8 @@
 .filter-line {
   height: 100%;
   width: 4rpx;
-  background-color: rgba(0,0,0,0.05);
-  box-shadow: 0rpx 0rpx 15rpx 0rpx rgba(0,0,0,0.16);
+  background-color: rgba(0, 0, 0, 0.05);
+  box-shadow: 0rpx 0rpx 15rpx 0rpx rgba(0, 0, 0, 0.16);
 }
 
 .filter-lists {

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

@@ -7,7 +7,7 @@
     <view class="question primary-text-color">提出的问题:{{item.question}}</view>
     <view class="question primary-text-color">收到的回复:{{item.answer}}</view>
     <textarea class="answer block-background-color" value="{{item.answer}}" placeholder="回复" data-index="{{index}}" bindinput="updateText"></textarea>
-    <view class="save-btn default-primary-color text-primary-color" data-id="{{item._id}}" data-answer="{{item.answer}}" bindtap="saveQuestion">保存</view>
+    <view class="save-btn default-primary-color white-text-color" data-id="{{item._id}}" data-answer="{{item.answer}}" bindtap="saveQuestion">保存</view>
     <icon style="position: absolute; top: 0; right: 0;" type="cancel" size="20" data-id="{{item._id}}" catchtap="removeQuestion"></icon>
   </view>
 </view>

+ 26 - 26
miniprogram/pages/opinion/opinion.wxml

@@ -6,15 +6,15 @@
 <view class="subTitle">向开发者反馈</view>
 <view class="con">
     <view class="buttons">
-      <view><button class="button dark-primary-color text-primary-color" bindtap="switch1">功能异常</button></view>
-      <view><button class="button dark-primary-color text-primary-color" bindtap="switch2">支付问题</button></view>
-      <view><button class="button dark-primary-color text-primary-color" bindtap="switch3">产品建议</button></view>
+      <view><button class="button dark-primary-color white-text-color" bindtap="switch1">功能异常</button></view>
+      <view><button class="button dark-primary-color white-text-color" bindtap="switch2">支付问题</button></view>
+      <view><button class="button dark-primary-color white-text-color" bindtap="switch3">产品建议</button></view>
     </view>
 </view>
 <view class="subTitle">向微信平台投诉</view>
 <view class="con">
     <view class="buttons">
-      <view><button class="button dark-primary-color text-primary-color" bindtap="switch4">违规举报</button></view>
+      <view><button class="button dark-primary-color white-text-color" bindtap="switch4">违规举报</button></view>
     </view>
 </view>
 
@@ -22,14 +22,14 @@
   <view class="con">
     <view class="title2">请选择反馈内容</view>
       <view class="buttons">
-        <view><button class="button dark-primary-color text-primary-color" bindtap="switch1_1">无法打开小程序</button></view>
-        <view><button class="button dark-primary-color text-primary-color" bindtap="switch1_2">小程序闪退</button></view>
-        <view><button class="button dark-primary-color text-primary-color" bindtap="switch1_3">卡顿</button></view>
-        <view><button class="button dark-primary-color text-primary-color" bindtap="switch1_4">黑屏白屏</button></view>
-        <view><button class="button dark-primary-color text-primary-color" bindtap="switch1_5">死机</button></view>
-        <view><button class="button dark-primary-color text-primary-color" bindtap="switch1_6">界面错位</button></view>
-        <view><button class="button dark-primary-color text-primary-color" bindtap="switch1_7">界面加载慢</button></view>
-        <view><button class="button dark-primary-color text-primary-color" bindtap="switch1_8">其他异常</button></view>
+        <view><button class="button dark-primary-color white-text-color" bindtap="switch1_1">无法打开小程序</button></view>
+        <view><button class="button dark-primary-color white-text-color" bindtap="switch1_2">小程序闪退</button></view>
+        <view><button class="button dark-primary-color white-text-color" bindtap="switch1_3">卡顿</button></view>
+        <view><button class="button dark-primary-color white-text-color" bindtap="switch1_4">黑屏白屏</button></view>
+        <view><button class="button dark-primary-color white-text-color" bindtap="switch1_5">死机</button></view>
+        <view><button class="button dark-primary-color white-text-color" bindtap="switch1_6">界面错位</button></view>
+        <view><button class="button dark-primary-color white-text-color" bindtap="switch1_7">界面加载慢</button></view>
+        <view><button class="button dark-primary-color white-text-color" bindtap="switch1_8">其他异常</button></view>
       </view>
   </view>
 </view>
@@ -38,10 +38,10 @@
   <view class="con">
     <view class="title2">请选择反馈内容</view>
       <view class="buttons">
-        <view><button class="button dark-primary-color text-primary-color" bindtap="switch2_1">支付失败</button></view>
-        <view><button class="button dark-primary-color text-primary-color" bindtap="switch2_2">支付成功未生效</button></view>
-        <view><button class="button dark-primary-color text-primary-color" bindtap="switch2_3">退款问题</button></view>
-        <view><button class="button dark-primary-color text-primary-color" bindtap="switch2_4">其他</button></view>
+        <view><button class="button dark-primary-color white-text-color" bindtap="switch2_1">支付失败</button></view>
+        <view><button class="button dark-primary-color white-text-color" bindtap="switch2_2">支付成功未生效</button></view>
+        <view><button class="button dark-primary-color white-text-color" bindtap="switch2_3">退款问题</button></view>
+        <view><button class="button dark-primary-color white-text-color" bindtap="switch2_4">其他</button></view>
       </view>
   </view>
 </view>
@@ -59,21 +59,21 @@
     <view class="cate">联系方式</view>:
     <input class="input block-background-color" placeholder="邮箱/手机号" model:value="{{publisherContact}}"/>
   </view>
-  <button class="button dark-primary-color text-primary-color" bindtap="switchend">提交</button>
+  <button class="button dark-primary-color white-text-color" bindtap="switchend">提交</button>
 </view>
 
 <view wx:if="{{currentTab == 4}}" scroll-y style="height: {{winHeight - 60}}px;">
   <view class="con">
     <view class="title2">请选择投诉原因</view>
       <view class="buttons">
-        <view><button class="button dark-primary-color text-primary-color" bindtap="switch4_1">新冠肺炎疫情相关</button></view>
-        <view><button class="button dark-primary-color text-primary-color" bindtap="switch4_2">se</button></view>
-        <view><button class="button dark-primary-color text-primary-color" bindtap="switch4_3">卡顿</button></view>
-        <view><button class="button dark-primary-color text-primary-color" bindtap="switch4_4">黑屏白屏</button></view>
-        <view><button class="button dark-primary-color text-primary-color" bindtap="switch4_5">死机</button></view>
-        <view><button class="button dark-primary-color text-primary-color" bindtap="switch4_6">界面错位</button></view>
-        <view><button class="button dark-primary-color text-primary-color" bindtap="switch4_7">界面加载慢</button></view>
-        <view><button class="button dark-primary-color text-primary-color" bindtap="switch4_8">其他异常</button></view>
+        <view><button class="button dark-primary-color white-text-color" bindtap="switch4_1">新冠肺炎疫情相关</button></view>
+        <view><button class="button dark-primary-color white-text-color" bindtap="switch4_2">se</button></view>
+        <view><button class="button dark-primary-color white-text-color" bindtap="switch4_3">卡顿</button></view>
+        <view><button class="button dark-primary-color white-text-color" bindtap="switch4_4">黑屏白屏</button></view>
+        <view><button class="button dark-primary-color white-text-color" bindtap="switch4_5">死机</button></view>
+        <view><button class="button dark-primary-color white-text-color" bindtap="switch4_6">界面错位</button></view>
+        <view><button class="button dark-primary-color white-text-color" bindtap="switch4_7">界面加载慢</button></view>
+        <view><button class="button dark-primary-color white-text-color" bindtap="switch4_8">其他异常</button></view>
       </view>
   </view>
 </view>
@@ -82,5 +82,5 @@
   <view class="con1 dark-primary-color-font">恭喜您完成填写!</view>
   <image  class="pic" src="../../images/finish.png" mode="aspectFill"/>
   <view class="con2">感谢您的入驻</view>
-  <button class="button dark-primary-color text-primary-color" bindtap="returnToUser">返回</button>
+  <button class="button dark-primary-color white-text-color" bindtap="returnToUser">返回</button>
 </view>

+ 8 - 36
miniprogram/pages/publisher/publisher.js

@@ -1,3 +1,5 @@
+const util = require('../../utils/util.js')
+
 Page({
 
   /**
@@ -10,39 +12,9 @@ Page({
     likeEnable: true
   },
 
-  handleDate: function(date) {
-    var now = new Date().getTime()
-    var diffValue = now - date.getTime()
-    if (diffValue < 0) {
-      console.log("时间不同步")
-      return "刚刚"
-    }
-    var result = ""
-    var minute = 1000 * 60
-    var hour = minute * 60
-    var day = hour * 24
-    var minC = diffValue / minute
-    var hourC = diffValue / hour
-    var dayC = diffValue / day
-    if (parseInt(dayC) > 30) {
-      result += date.getFullYear() + "/" + (date.getMonth() + 1) + "/" + date.getDate()
-    } else if (parseInt(dayC) > 1) {
-      result += parseInt(dayC) + "天前"
-    } else if (parseInt(dayC) == 1) {
-      result += "昨天"
-    } else if (hourC >= 1) {
-      result += parseInt(hourC) + "小时前"
-    } else if (minC >= 5) {
-      result += parseInt(minC) + "分钟前"
-    } else {
-      result += "刚刚"
-    }
-    return result
-  },
-
   processData: function (start, arr) {
     for (let i = start; i < arr.length; i++) {
-      arr[i].time = this.handleDate(arr[i].time)
+      arr[i].time = util.handleDate(arr[i].time)
     }
     this.setData({
       mainDatas: arr
@@ -62,7 +34,7 @@ Page({
           type: "publisher",
           id: this.data.publisherInfo._id
         },
-        success: function() {
+        success: function () {
           this.setData({
             like: 1,
             likeEnable: true
@@ -71,7 +43,7 @@ Page({
             title: "已关注",
           })
         }.bind(this),
-        fail: function() {
+        fail: function () {
           wx.showToast({
             title: "网络错误",
             icon: "none"
@@ -83,7 +55,7 @@ Page({
         type: "publisher",
         id: this.data.publisherInfo._id
       }).remove({
-        success: function() {
+        success: function () {
           this.setData({
             like: 0,
             likeEnable: true
@@ -92,7 +64,7 @@ Page({
             title: "已取消关注",
           })
         }.bind(this),
-        fail: function() {
+        fail: function () {
           wx.showToast({
             title: "网络错误",
             icon: "none"
@@ -128,7 +100,7 @@ Page({
       type: "publisher",
       id: options.id
     }).get({
-      success: function(res) {
+      success: function (res) {
         this.setData({
           like: res.data.length
         })

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

@@ -6,7 +6,7 @@
       <view class="brief-info-right">
         <view class="publisher-name default-primary-color-font">{{publisherInfo.publisherName}}</view>
         <view class="brief-info-right-below">
-          <view class="publisher-attribute accent-color text-primary-color">{{publisherInfo.publisherAttribute}}</view>
+          <view class="publisher-attribute accent-color white-text-color">{{publisherInfo.publisherAttribute}}</view>
           <image wx:if="{{like != -1}}" class="like" src="/images/like/{{like ? 'heart' : 'hollowheart'}}.png" bindtap="toggleLike"/>
         </view>
       </view>

+ 6 - 6
miniprogram/pages/publisherLogin/publisherLogin.wxml

@@ -21,14 +21,14 @@
   <view class="text">在纳新季确保同学们能够看到每一个社团/学生组织的纳新信息。</view>
   <view class="thirdTitle">4、与参加活动的同学私信交流</view>
   <view class="text">一键通知面试时间、面试结果、活动招募情况,再也不用手动发送信息了。</view>
-  <button class="button dark-primary-color text-primary-color" bindtap="switch1">一键入驻</button>
+  <button class="button dark-primary-color white-text-color" bindtap="switch1">一键入驻</button>
 </scroll-view>
 
 <view wx:if="{{currentTab == 1}}" class="con">
   <view class="title2">请问您入驻的类型是?</view>
     <view class="buttons">
-      <view><button class="button dark-primary-color text-primary-color" bindtap="switch2">组织</button></view>
-      <view><button class="button dark-primary-color text-primary-color" bindtap="switch3">社团</button></view>
+      <view><button class="button dark-primary-color white-text-color" bindtap="switch2">组织</button></view>
+      <view><button class="button dark-primary-color white-text-color" bindtap="switch3">社团</button></view>
     </view>
 </view>
 
@@ -62,7 +62,7 @@
     <view class="block22"><view class="cate">组织介绍</view>:</view>
     <textarea class="textarea block-background-color" placeholder="请输入组织介绍" model:value="{{publisherIntro}}"/>
   </view>
-  <button class="button dark-primary-color text-primary-color" bindtap="switch4">提交</button>
+  <button class="button dark-primary-color white-text-color" bindtap="switch4">提交</button>
 </scroll-view>
 
 <scroll-view wx:if="{{currentTab == 3}}" scroll-y style="height: {{winHeight - 60}}px;">
@@ -95,12 +95,12 @@
     <view class="block22"><view class="cate">社团介绍</view>:</view>
     <textarea class="textarea block-background-color" placeholder="请输入社团介绍" model:value="{{publisherIntro}}"/>
   </view>
-  <button class="button dark-primary-color text-primary-color" bindtap="switch4">提交</button>
+  <button class="button dark-primary-color white-text-color" bindtap="switch4">提交</button>
 </scroll-view>
 
 <view wx:if="{{currentTab == 4}}" class="con">
   <view class="con1 dark-primary-color-font">恭喜您完成填写!</view>
   <image  class="pic" src="../../images/finish.png" mode="aspectFill"/>
   <view class="con2">感谢您的入驻</view>
-  <button class="button dark-primary-color text-primary-color" bindtap="returnToUser">返回</button>
+  <button class="button dark-primary-color white-text-color" bindtap="returnToUser">返回</button>
 </view>

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

@@ -9,7 +9,7 @@
     <view class="title dark-primary-color-font">{{item.title}}</view>
     <view class="question primary-text-color">问:{{item.question}}</view>
     <textarea class="answer block-background-color" value="{{item.answer}}" placeholder="填写回答" data-index="{{index}}" bindinput="updateText"></textarea>
-    <view class="save-btn default-primary-color text-primary-color" data-id="{{item._id}}" data-answer="{{item.answer}}" bindtap="saveQuestion">保存</view>
+    <view class="save-btn default-primary-color white-text-color" data-id="{{item._id}}" data-answer="{{item.answer}}" bindtap="saveQuestion">保存</view>
     <icon style="position: absolute; top: 0; right: 0;" type="cancel" size="20" data-id="{{item._id}}" catchtap="removeQuestion"></icon>
   </view>
 </view>

+ 42 - 52
miniprogram/pages/search/search.js

@@ -1,5 +1,6 @@
-var hotTagData = require("../../data/hotTagData.js")
-var hotBarData = require("../../data/hotBarData.js")
+const hotTagData = require("../../data/hotTagData.js")
+const hotBarData = require("../../data/hotBarData.js")
+const util = require('../../utils/util.js')
 
 Page({
   options: {
@@ -29,7 +30,8 @@ Page({
     const db = wx.cloud.database()
     db.collection("searchData").orderBy("time", "desc").limit(20).get({
       success: function (res) {
-        var count = {}, hotTag = []
+        var count = {},
+          hotTag = []
         for (let j = 0; j < res.data.length; j++) {
           if (count[res.data[j].key] == undefined) {
             count[res.data[j].key] = 0
@@ -37,7 +39,9 @@ Page({
           count[res.data[j].key]++
         }
         for (let key in count) {
-          hotTag.push({tag: key})
+          hotTag.push({
+            tag: key
+          })
         }
         hotTag.sort(function (a, b) {
           return count[b] - count[a]
@@ -66,13 +70,19 @@ Page({
     this.setData({
       searchEnable: true
     })
-    this.animate('.cancel-button', [
-      { opacity: 0 },
-      { opacity: 1 },
+    this.animate('.cancel-button', [{
+        opacity: 0
+      },
+      {
+        opacity: 1
+      },
     ], 150)
-    this.animate('.search-block', [
-      { opacity: 0 },
-      { opacity: 1 },
+    this.animate('.search-block', [{
+        opacity: 0
+      },
+      {
+        opacity: 1
+      },
     ], 150)
     setTimeout(function () {
       this.setData({
@@ -86,37 +96,6 @@ Page({
     this.cancel()
   },
 
-  // 计算时间差
-  handleDate: function(date) {
-    var now = new Date().getTime()
-    var diffValue = now - date.getTime()
-    if (diffValue < 0) {
-      console.log("时间不同步")
-      return "刚刚"
-    }
-    var result = ""
-    var minute = 1000 * 60
-    var hour = minute * 60
-    var day = hour * 24
-    var minC = diffValue / minute
-    var hourC = diffValue / hour
-    var dayC = diffValue / day
-    if (parseInt(dayC) > 30) {
-      result += date.getFullYear() + "/" + (date.getMonth() + 1) + "/" + date.getDate()
-    } else if (parseInt(dayC) > 1) {
-      result += parseInt(dayC) + "天前"
-    } else if (parseInt(dayC) == 1) {
-      result += "昨天"
-    } else if (hourC >= 1) {
-      result += parseInt(hourC) + "小时前"
-    } else if (minC >= 5) {
-      result += parseInt(minC) + "分钟前"
-    } else {
-      result += "刚刚"
-    }
-    return result
-  },
-
   search: function () {
     var history = this.data.searchHistory
     if (history == undefined) history = []
@@ -150,15 +129,20 @@ Page({
       success: function () {
         var reg = new RegExp(this.data.searchText, "i")
         db.collection("mainData").where(
-          _.or([
-            {title: reg},
-            {subTitle: reg},
-            {details: reg}
+          _.or([{
+              title: reg
+            },
+            {
+              subTitle: reg
+            },
+            {
+              details: reg
+            }
           ])
         ).orderBy("time", "desc").limit(20).get({
           success: function (res) {
             for (let i = 0; i < res.data.length; i++) {
-              res.data[i].time = this.handleDate(res.data[i].time)
+              res.data[i].time = util.handleDate(res.data[i].time)
             }
             this.setData({
               searchResult: res.data
@@ -176,13 +160,19 @@ Page({
     this.setData({
       searchText: "",
     })
-    this.animate('.cancel-button', [
-      { opacity: 1 },
-      { opacity: 0 },
+    this.animate('.cancel-button', [{
+        opacity: 1
+      },
+      {
+        opacity: 0
+      },
     ], 150)
-    this.animate('.search-block', [
-      { opacity: 1 },
-      { opacity: 0 },
+    this.animate('.search-block', [{
+        opacity: 1
+      },
+      {
+        opacity: 0
+      },
     ], 150)
     setTimeout(function () {
       this.setData({

+ 1 - 1
miniprogram/pages/search/search.json

@@ -1,5 +1,5 @@
 {
   "usingComponents": {
-    "itemCard":"/components/itemCard/itemCard"
+    "itemCard": "/components/itemCard/itemCard"
   }
 }

+ 21 - 14
miniprogram/pages/search/search.wxml

@@ -1,43 +1,50 @@
 <!--为搜索页面-->
 <view class="search" style="background-color:#ffffff;">
-  <view class="search-inside bg-color" style="display: flex; align-items: center;">
+  <view class="search-inside secondary-background-color" style="display: flex; align-items: center;">
     <icon type="search" size="20"></icon>
-    <input class="search-input" style="width: {{searchEnable ? 550 : 650}}rpx;" value="{{searchText}}" placeholder="搜索" confirm-type="search" bindinput="update" bindfocus="focus" bindconfirm="search"></input>
+    <input class="search-input" style="width: {{searchEnable ? 550 : 650}}rpx;" value="{{searchText}}" placeholder="搜索"
+      confirm-type="search" bindinput="update" bindfocus="focus" bindconfirm="search"></input>
   </view>
   <view wx:if="{{searchEnable}}" class="cancel-button" bindtap="cancel">取消</view>
 </view>
 
-<scroll-view class="hot-block" scroll-y="true">
+<scroll-view class="hot-block" scroll-y>
   <view class="hot-tag-block">
-    <view class="hot-tag-title primary-color-fg">历史搜索</view>
+    <view class="hot-tag-title primary-text-color">历史搜索</view>
     <view class="hot-tags secondary-text-color">
-      <view class="hot-tag" wx:for="{{hotTagData}}" wx:key="tag" wx:for-item="item" data-search-tag="{{item.tag}}" bindtap="searchTag">{{item.tag}}</view>
+      <view class="hot-tag" wx:for="{{hotTagData}}" wx:key="tag" wx:for-item="item" data-search-tag="{{item.tag}}"
+        bindtap="searchTag">{{item.tag}}</view>
     </view>
   </view>
+
   <view class="hot-tag-block">
-    <view class="hot-tag-title primary-color-fg">热门搜索</view>
+    <view class="hot-tag-title primary-text-color">热门搜索</view>
     <view class="hot-tags secondary-text-color">
-      <view class="hot-tag" wx:for="{{hotTagData}}" wx:key="tag" wx:for-item="item" data-search-tag="{{item.tag}}" bindtap="searchTag">{{item.tag}}</view>
+      <view class="hot-tag" wx:for="{{hotTagData}}" wx:key="tag" wx:for-item="item" data-search-tag="{{item.tag}}"
+        bindtap="searchTag">{{item.tag}}</view>
     </view>
   </view>
 
   <view class="hot-bar-block">
-    <text class="hot-bar-title primary-color-bg text-primary-color">实时热点</text>
-    <view class="hot-bar" wx:for="{{hotBarData}}" wx:key="rank" wx:for-item="item" data-activity-id="{{item.id}}" bindtap="viewActivity">
+    <text class="hot-bar-title primary-background-color white-text-color">实时热点</text>
+    <view class="hot-bar" wx:for="{{hotBarData}}" wx:key="rank" wx:for-item="item" data-activity-id="{{item.id}}"
+      bindtap="viewActivity">
       <view>
-        <text class="primary-color-fg" space="nbsp">{{item.rank}}    </text><text class="secondary-text-color">{{item.title}} </text>
+        <text class="primary-text-color" space="nbsp">{{item.rank}}{{"   "}}</text><text
+          class="secondary-text-color">{{item.title}}</text>
       </view>
       <image class="more" src="/images/more.png" mode="aspectFill"></image>
     </view>
   </view>
 </scroll-view>
 
-<scroll-view wx:if="{{searchEnable}}" class="search-block" scroll-y="true" bindtap="blur">
+<scroll-view wx:if="{{searchEnable}}" class="search-block secondary-background-color" scroll-y bindtap="blur">
   <view class="result-bar" wx:for="{{searchResult}}" wx:key="_id">
-    <itemCard item="{{item}}"/>
+    <itemCard item="{{item}}" />
   </view>
-  <view wx:if="{{searchText == '' && searchResult.length == 0}}" wx:for="{{searchHistory}}" wx:for-item="item" wx:key="*this" class="search-history" data-history="{{item}}" catchtap="searchAgain">
+  <view wx:if="{{searchText == '' && searchResult.length == 0}}" wx:for="{{searchHistory}}" wx:for-item="item"
+    wx:key="*this" class="search-history" data-history="{{item}}" catchtap="searchAgain">
     <view>{{item}}</view>
     <view data-history="{{item}}" catchtap="removeHistory">×</view>
   </view>
-</scroll-view>
+</scroll-view>

+ 7 - 9
miniprogram/pages/search/search.wxss

@@ -9,13 +9,12 @@
   right: 0rpx;
 }
 
-.search-inside{
+.search-inside {
   border-radius: 20rpx;
-  background: #dadada;
 }
 
 .search-input {
-  font-size: 35rpx;
+  font-size: 30rpx;
 }
 
 .cancel-button {
@@ -28,7 +27,7 @@
 }
 
 .hot-tag-block {
-  display:flex;
+  display: flex;
   flex-direction: column;
   justify-content: flex-start;
   align-items: flex-start;
@@ -57,8 +56,8 @@
   background-color: #ffffff;
   border-radius: 24rpx;
   margin: 60rpx 40rpx 0rpx 40rpx;
-  box-shadow: 5rpx 5rpx 8rpx 0rpx rgba(0,0,0,0.16);
-  padding-bottom: 40rpx;
+  box-shadow: 5rpx 5rpx 8rpx 0rpx rgba(0, 0, 0, 0.16);
+  padding-bottom: 10rpx;
 }
 
 .hot-bar-title {
@@ -68,7 +67,7 @@
   top: -25rpx;
   margin: 20rpx 20rpx 0rpx 20rpx;
   padding: 8rpx 30rpx 8rpx 30rpx;
-  box-shadow: 5rpx 5rpx 8rpx 0rpx rgba(0,0,0,0.16);
+  box-shadow: 5rpx 5rpx 8rpx 0rpx rgba(0, 0, 0, 0.16);
 }
 
 .hot-bar {
@@ -92,7 +91,6 @@
   top: 80rpx;
   bottom: 0rpx;
   width: 100%;
-  background: white;
   opacity: 0;
 }
 
@@ -110,7 +108,7 @@
   padding: 25rpx 40rpx;
 }
 
-.more{
+.more {
   width: 30rpx;
   height: 30rpx;
 }

+ 8 - 8
miniprogram/pages/setting/setting.js

@@ -2,35 +2,35 @@
 const app = getApp()
 
 Page({
-  data:{
-    noticeIndex:0,
-    noticeForm:['数字','红点','不显示'],
+  data: {
+    noticeIndex: 0,
+    noticeForm: ['数字', '红点', '不显示'],
     vibrate: false
   },
 
-  myColor: function() {
+  myColor: function () {
     wx.navigateTo({
       url: '/pages/myColor/myColor'
     })
   },
 
-  noticeIndexChange: function(e) {
+  noticeIndexChange: function (e) {
     this.setData({
       noticeIndex: e.detail.value
     })
     app.globalData.noticeIndex = e.detail.value
   },
 
-  vibrateChange: function(e) {
+  vibrateChange: function (e) {
     this.setData({
       vibrate: e.detail.value
     })
     app.globalData.vibrate = e.detail.value
   },
 
-  onLoad: function() {
+  onLoad: function () {
     this.data.noticeIndex = app.globalData.noticeIndex
     this.data.vibrate = app.globalData.vibrate
   }
-  
+
 })

+ 32 - 32
miniprogram/pages/setting/setting.wxml

@@ -1,32 +1,32 @@
-  <view class="btn block-background-color" hover-class="btn-hover" bindtap="myColor">
-    <image class="btn-icon" mode="aspectFit" src="/images/user/follow.png"></image>
-    <view class="btn-text primary-text">主题颜色设置</view>
-    <view class="btn-arrow secondary-text">></view>
-  </view>
-
-  <view class="line"></view>
-
-  <picker class="btn block-background-color" hover-class="btn-hover" bindchange="noticeIndexChange" value="{{noticeIndex}}" range="{{noticeForm}}">
-    <image class="btn-icon" mode="aspectFit" src="/images/user/question.png"></image>
-    <view class="btn-text primary-text">消息通知形式</view>
-    <view class="btn-arrow secondary-text">{{noticeForm[noticeIndex]}}</view>
-  </picker>
-
-  <view class="gap"></view>
-
-  <view class="btn block-background-color" hover-class="btn-hover">
-    <image class="btn-icon" mode="aspectFit" src="/images/user/setting.png"></image>
-    <view class="btn-text primary-text">收到消息振动</view>
-    <switch class="btn-arrow secondary-text" checked="{{vibrate}}" bindchange="vibrateChange"/>
-  </view>
-
-  <view class="line"></view>
-
-  <view class="btn block-background-color" hover-class="btn-hover"  bindtap="opinion">
-    <image class="btn-icon" mode="aspectFit" src="/images/user/feedback.png"></image>
-    <view class="btn-text primary-text">退出登录</view>
-    <view class="btn-arrow secondary-text">></view>
-  </view>
-
-  <view class="gap"></view>
-
+<view class="btn block-background-color" hover-class="btn-hover" bindtap="myColor">
+  <image class="btn-icon" mode="aspectFit" src="/images/user/follow.png"></image>
+  <view class="btn-text primary-text">主题颜色设置</view>
+  <view class="btn-arrow secondary-text">></view>
+</view>
+
+<view class="line"></view>
+
+<picker class="btn block-background-color" hover-class="btn-hover" bindchange="noticeIndexChange"
+  value="{{noticeIndex}}" range="{{noticeForm}}">
+  <image class="btn-icon" mode="aspectFit" src="/images/user/question.png"></image>
+  <view class="btn-text primary-text">消息通知形式</view>
+  <view class="btn-arrow secondary-text">{{noticeForm[noticeIndex]}}</view>
+</picker>
+
+<view class="gap"></view>
+
+<view class="btn block-background-color" hover-class="btn-hover">
+  <image class="btn-icon" mode="aspectFit" src="/images/user/setting.png"></image>
+  <view class="btn-text primary-text">收到消息振动</view>
+  <switch class="btn-arrow secondary-text" checked="{{vibrate}}" bindchange="vibrateChange" />
+</view>
+
+<view class="line"></view>
+
+<view class="btn block-background-color" hover-class="btn-hover" bindtap="opinion">
+  <image class="btn-icon" mode="aspectFit" src="/images/user/feedback.png"></image>
+  <view class="btn-text primary-text">退出登录</view>
+  <view class="btn-arrow secondary-text">></view>
+</view>
+
+<view class="gap"></view>

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

@@ -66,4 +66,4 @@
   float: right;
   right: 40rpx;
   line-height: 100rpx;
-}
+}

+ 7 - 7
miniprogram/pages/user/user.js

@@ -30,37 +30,37 @@ Page({
     })
   },
 
-  myFollow:function(){
+  myFollow: function () {
     wx.navigateTo({
       url: '/pages/myFollow/myFollow',
     })
   },
 
-  myFavor:function(){
+  myFavor: function () {
     wx.navigateTo({
       url: '/pages/myFavor/myFavor',
     })
   },
 
-  setting:function(){
+  setting: function () {
     wx.navigateTo({
       url: '/pages/setting/setting',
     })
   },
 
-  myQuestion:function(){
+  myQuestion: function () {
     wx.navigateTo({
       url: '/pages/myQuestion/myQuestion',
     })
   },
 
-  aboutUs:function(){
+  aboutUs: function () {
     wx.navigateTo({
       url: '/pages/aboutUs/aboutUs',
     })
   },
 
-  opinion:function(){
+  opinion: function () {
     wx.navigateTo({
       url: '/pages/opinion/opinion',
     })
@@ -118,7 +118,7 @@ Page({
    * 生命周期函数--监听页面初次渲染完成
    */
   onReady: function () {
-    
+
   },
 
   /**

+ 6 - 4
miniprogram/pages/user/user.wxml

@@ -2,7 +2,8 @@
 <view class="card block-background-color">
   <cover-image class="avatar" src="{{hasUserInfo ? userInfo.avatarUrl : '/images/user/user.png'}}"></cover-image>
   <view wx:if="{{hasUserInfo}}" class="nickname primary-text">{{userInfo.nickName}}</view>
-  <view wx:else class="nickname"><button class="block-background-color" size="mini" open-type="getUserInfo" bindgetuserinfo="bindGetUserInfo">微信登录</button></view>
+  <view wx:else class="nickname"><button class="block-background-color" size="mini" open-type="getUserInfo"
+      bindgetuserinfo="bindGetUserInfo">微信登录</button></view>
   <view class="location secondary-text">{{publisherId.length == 0 ? '尚未加入任何社团组织' : publisherName}}</view>
 </view>
 
@@ -49,7 +50,7 @@
 
   <view class="line"></view>
 
-  <view class="btn block-background-color" hover-class="btn-hover"  bindtap="opinion">
+  <view class="btn block-background-color" hover-class="btn-hover" bindtap="opinion">
     <image class="btn-icon" mode="aspectFit" src="/images/user/feedback.png"></image>
     <view class="btn-text primary-text">意见反馈</view>
     <view class="btn-arrow secondary-text">></view>
@@ -57,7 +58,8 @@
 
   <view class="gap"></view>
 
-  <view wx:if="{{publisherId.length == 0}}" class="btn block-background-color" hover-class="btn-hover" bindtap="publisherLogin">
+  <view wx:if="{{publisherId.length == 0}}" class="btn block-background-color" hover-class="btn-hover"
+    bindtap="publisherLogin">
     <image class="btn-icon" mode="aspectFit" src="/images/user/settle.png"></image>
     <view class="btn-text primary-text">社团/组织入驻</view>
     <view class="btn-arrow secondary-text">></view>
@@ -67,4 +69,4 @@
     <view class="btn-text primary-text">社团/组织管理</view>
     <view class="btn-arrow secondary-text">></view>
   </view>
-</view>
+</view>

+ 34 - 2
miniprogram/utils/util.js

@@ -14,6 +14,38 @@ const formatNumber = n => {
   return n[1] ? n : '0' + n
 }
 
-module.exports = {
-  formatTime: formatTime
+// 计算时间差
+const handleDate = function (date) {
+  var now = new Date().getTime()
+  var diffValue = now - date.getTime()
+  if (diffValue < 0) {
+    console.log("时间不同步")
+    return "刚刚"
+  }
+  var result = ""
+  var minute = 1000 * 60
+  var hour = minute * 60
+  var day = hour * 24
+  var minC = diffValue / minute
+  var hourC = diffValue / hour
+  var dayC = diffValue / day
+  if (parseInt(dayC) > 30) {
+    result += date.getFullYear() + "/" + (date.getMonth() + 1) + "/" + date.getDate()
+  } else if (parseInt(dayC) > 1) {
+    result += parseInt(dayC) + "天前"
+  } else if (parseInt(dayC) == 1) {
+    result += "昨天"
+  } else if (hourC >= 1) {
+    result += parseInt(hourC) + "小时前"
+  } else if (minC >= 5) {
+    result += parseInt(minC) + "分钟前"
+  } else {
+    result += "刚刚"
+  }
+  return result
 }
+
+module.exports = {
+  formatTime: formatTime,
+  handleDate: handleDate
+}

+ 1 - 0
project.config.json

@@ -42,6 +42,7 @@
   "libVersion": "2.10.4",
   "simulatorType": "wechat",
   "simulatorPluginLibVersion": {},
+  "cloudfunctionTemplateRoot": "cloudfunctionTemplate",
   "condition": {
     "search": {
       "list": []