Selaa lähdekoodia

ADD

添加信息修改功能
RegMs If 4 vuotta sitten
vanhempi
commit
8c2e170309

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

@@ -38,7 +38,7 @@ Component({
 
     filterMsgType: function (e) {
       this.triggerEvent('filtermsgtype', {
-        type: this.data.item.type
+        type: this.data.item.type[0]
       })
     },
 

+ 5 - 5
miniprogram/components/itemCard/itemCard.wxml

@@ -6,7 +6,7 @@
       <view class="publisher-name">{{item.publisher[0].name}}</view>
     </view>
     <view class="activity-attribute primary-background-color white-text-color" catchtap="filterMsgType">
-      {{item.type}}
+      {{item.type[0]}}
     </view>
   </view>
   <view class="title-time">
@@ -14,15 +14,15 @@
     <view class="time primary-text-color">{{item.publish_time}}</view>
   </view>
   <view class="sub-title">{{item.brief}}</view>
-  <imagePicker wx:if="{{item.poster !== ''}}" value="{{[item.poster]}}" max="1" image-width="698" image-height="330"
+  <imagePicker wx:if="{{item.poster.length}}" value="{{item.poster}}" max="1" image-width="698" image-height="330"
     readonly />
-  <imagePicker wx:if="{{item.poster === '' && item.photo.length !== 0}}" value="{{item.photo}}" max="1"
+  <imagePicker wx:if="{{!item.poster.length && item.photo.length}}" value="{{item.photo}}" max="1"
     image-width="{{item.photo.length === 1 ? 698 : item.photo.length <= 4 ? 330 : 220}}"
     image-height="{{item.photo.length === 1 ? 698 : item.photo.length <= 4 ? 330 : 220}}" readonly />
   <view class="bottom-line">
     <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"
-        data-tag="{{tag}}" catchtap="filterTag">{{tag}}</text>
+      <text class="tag" wx:for="{{item.tag}}" wx:for-item="tag" wx:key="_id" data-tag="{{tag}}"
+        catchtap="filterTag">{{tag}}</text>
     </view>
     <view class="to-detail">
       <text class="primary-text-color" style="font-size: 20rpx;">查看详情</text>

+ 6 - 0
miniprogram/components/itemCard/itemCard.wxss

@@ -90,6 +90,12 @@
   align-items: center;
 }
 
+.tag {
+  margin: 0rpx 20rpx;
+  font-size: 22rpx;
+  white-space: nowrap;
+}
+
 .to-detail {
   display: flex;
   align-items: center;

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

@@ -11,20 +11,19 @@ Page({
     activityComment: [],
     like: -1,
     likeEnable: true,
-    commentText: ""
+    commentText: ''
   },
 
-  // getPublisherInfo: function () {
-  //   wx.navigateTo({
-  //     url: "/pages/publisher/publisher?id=" + this.data.activityInfo.publisherId
-  //   })
-  // },
-
-  // components/itemCard.js
-
   getPublisherInfo: function () {
     wx.navigateTo({
-      url: "/pages/publisher/publisher?id=" + this.data.activityInfo.pub_id
+      url: '/pages/publisher/publisher?id=' + this.data.activityInfo.pub_id
+    })
+  },
+
+  editActivity: function () {
+    wx.navigateTo({
+      url: '/pages/activityPublish/activityPublish?id=' + this.data.activityInfo.pub_id +
+        '&msg_id=' + this.data.activityInfo._id
     })
   },
 
@@ -35,9 +34,9 @@ Page({
     })
     const db = wx.cloud.database()
     if (this.data.like == 0) {
-      db.collection("likeData").add({
+      db.collection('likeData').add({
         data: {
-          type: "message",
+          type: 'message',
           id: this.data.activityInfo._id
         },
         success: function () {
@@ -46,19 +45,19 @@ Page({
             likeEnable: true
           })
           wx.showToast({
-            title: "已收藏",
+            title: '已收藏',
           })
         }.bind(this),
         fail: function () {
           wx.showToast({
-            title: "网络错误",
-            icon: "none"
+            title: '网络错误',
+            icon: 'none'
           })
         }
       })
     } else {
-      db.collection("likeData").where({
-        type: "message",
+      db.collection('likeData').where({
+        type: 'message',
         id: this.data.activityInfo._id
       }).remove({
         success: function () {
@@ -67,13 +66,13 @@ Page({
             likeEnable: true
           })
           wx.showToast({
-            title: "已取消收藏",
+            title: '已取消收藏',
           })
         }.bind(this),
         fail: function () {
           wx.showToast({
-            title: "网络错误",
-            icon: "none"
+            title: '网络错误',
+            icon: 'none'
           })
         }
       })
@@ -83,12 +82,12 @@ Page({
   comment: function () {
     if (this.data.commentText.length < 5) {
       wx.showToast({
-        title: "提问字数至少为5",
-        icon: "none"
+        title: '提问字数至少为5',
+        icon: 'none'
       })
     } else {
       wx.showLoading({
-        title: '发送中',
+        title: '发送中'
       })
       wx.cloud.callFunction({
         name: 'createQuestion',
@@ -108,7 +107,7 @@ Page({
       })
 
       // const db = wx.cloud.database()
-      // db.collection("qaData").where({
+      // db.collection('qaData').where({
       //   _openid: app.globalData.openId,
       //   activityId: this.data.activityInfo._id
       // }).get({
@@ -116,26 +115,26 @@ Page({
       //     console.log(res)
       //     if (res.data.length >= 10) {
       //       wx.showToast({
-      //         title: "为防止刷屏,每人每消息至多提问10条",
-      //         icon: "none"
+      //         title: '为防止刷屏,每人每消息至多提问10条',
+      //         icon: 'none'
       //       })
       //     } else {
-      //       db.collection("qaData").add({
+      //       db.collection('qaData').add({
       //         data: {
       //           activityId: this.data.activityInfo._id,
       //           publisherId: this.data.activityInfo.publisherId,
-      //           answer: "",
-      //           answerTime: "",
+      //           answer: '',
+      //           answerTime: '',
       //           question: this.data.commentText,
       //           questionTime: new Date(),
-      //           rank: ""
+      //           rank: ''
       //         },
       //         success: function () {
       //           this.setData({
-      //             commentText: ""
+      //             commentText: ''
       //           })
       //           wx.showToast({
-      //             title: "提问成功"
+      //             title: '提问成功'
       //           })
       //         }.bind(this)
       //       })
@@ -150,7 +149,7 @@ Page({
    */
   onLoad: function (options) {
     wx.showLoading({
-      title: "加载中",
+      title: '加载中'
     })
     wx.cloud.callFunction({
       name: 'getMessage',
@@ -159,9 +158,7 @@ Page({
       }
     }).then(res => {
       wx.hideLoading()
-      res.result.list[0].photo = res.result.list[0].photo.split(',')
-      res.result.list[0].tag = res.result.list[0].tag.split(',')
-      res.result.list[0].publish_time = util.handleDate(res.result.list[0].publish_time)
+      res.result.list[0] = util.dbToMsg(res.result.list[0])
       this.setData({
         activityInfo: res.result.list[0]
       })
@@ -169,7 +166,7 @@ Page({
 
     // const db = wx.cloud.database()
     // const _ = db.command
-    // db.collection("mainData").doc(options.id).get({
+    // db.collection('mainData').doc(options.id).get({
     //   success: function (res) {
     //     res.data.time = util.handleDate(res.data.time)
     //     this.setData({
@@ -178,16 +175,16 @@ Page({
     //     wx.hideLoading()
     //   }.bind(this)
     // })
-    // db.collection("qaData").where({
+    // db.collection('qaData').where({
     //   activityId: options.id,
-    //   answer: _.neq("")
+    //   answer: _.neq('')
     // }).get({
     //   success: function (res) {
     //     for (let i = 0; i < res.data.length; i++) {
-    //       if (res.data[i].answerTime !== "") {
+    //       if (res.data[i].answerTime !== '') {
     //         res.data[i].time = util.handleDate(res.data[i].answerTime)
     //       } else {
-    //         res.data[i].time = ""
+    //         res.data[i].time = ''
     //       }
     //     }
     //     this.setData({
@@ -195,8 +192,8 @@ Page({
     //     })
     //   }.bind(this)
     // })
-    // db.collection("likeData").where({
-    //   type: "message",
+    // db.collection('likeData').where({
+    //   type: 'message',
     //   id: options.id
     // }).get({
     //   success: function (res) {

+ 9 - 15
miniprogram/pages/activity/activity.wxml

@@ -1,22 +1,22 @@
 <!--为首页-信息详情页面-->
 <view class="page">
   <view class="card">
-    <image wx:if="{{activityInfo.poster}}" class="activity-poster" src="{{activityInfo.poster}}" mode="aspectFill" />
+    <image wx:if="{{activityInfo.poster.length}}" class="activity-poster" src="{{activityInfo.poster[0]}}" mode="aspectFill" />
     <view>
       <view class="profile">
-        <view class="avatar-name" catchtap="getPublisherInfo">
+        <view class="avatar-name" bindtap="getPublisherInfo">
           <image class="publisher-avatar" src="{{activityInfo.publisher[0].avatar}}"></image>
           <view class="publisher-name">{{activityInfo.publisher[0].name}}</view>
         </view>
-        <view class="activity-attribute primary-background-color white-text-color" catchtap="filterMsgType">
+        <view class="activity-attribute primary-background-color white-text-color">
           {{activityInfo.type}}
         </view>
       </view>
+
       <view class="title-time">
         <view class="title">{{activityInfo.name}}</view>
         <view class="time primary-text-color">{{activityInfo.publish_time}}</view>
       </view>
-
       <view wx:if="{{activityInfo.detail}}" class="text">
         <text>{{activityInfo.detail}}</text>
       </view>
@@ -24,24 +24,20 @@
       <view class="line primary-background-color"></view>
 
       <view wx:if="{{activityInfo.time}}" class="text">时间:{{activityInfo.time}}</view>
-
       <view wx:if="{{activityInfo.place}}" class="text">地点:{{activityInfo.place}}</view>
-
       <view wx:if="{{activityInfo.tag[0]}}" class="text">活动提供:<text wx:for="{{activityInfo.tag}}" wx:for-item="tag"
           wx:key="tag">{{tag}} </text></view>
-
       <view wx:if="{{activityInfo.orient}}" class="text">面向对象:{{activityInfo.orient}}</view>
-
       <view wx:if="{{activityInfo.contact}}" class="text">联系方式:{{activityInfo.contact}}</view>
-
       <view wx:if="{{activityInfo.orient}}" class="text">链接:{{activityInfo.link}}</view>
 
-      <imagePicker wx:if="{{activityInfo.photo.length != 0}}" value="{{activityInfo.photo}}" max="1"
-        image-width="{{activityInfo.photo.length == 1 ? 698 : activityInfo.photo.length <= 4 ? 330 : 220}}"
-        image-height="{{activityInfo.photo.length == 1 ? 698 : activityInfo.photo.length <= 4 ? 330 : 220}}" readonly />
+      <imagePicker wx:if="{{activityInfo.photo.length}}" value="{{activityInfo.photo}}" max="1"
+        image-width="{{activityInfo.photo.length === 1 ? 698 : activityInfo.photo.length <= 4 ? 330 : 220}}"
+        image-height="{{activityInfo.photo.length === 1 ? 698 : activityInfo.photo.length <= 4 ? 330 : 220}}"
+        readonly />
     </view>
 
-    <view class="btn primary-background-color">
+    <view class="btn primary-background-color" bindtap="editActivity">
       <image class="btn-icon primary-background-color" mode="aspectFit" src="/images/publisher/publish2.png"></image>
       <view class=" white-text-color">编辑内容</view>
     </view>
@@ -56,8 +52,6 @@
     </view>
   </view>
 
-  <text>\n</text>
-
   <view class="comment secondary-background-color">
     <view class="comment-inside" style="display: flex; align-items: center;">
       <icon type="info" size="20" color="#B0B0B0"></icon>

+ 113 - 46
miniprogram/pages/activityPublish/activityPublish.js

@@ -6,44 +6,81 @@ Page({
    * 页面的初始数据
    */
   data: {
-    currentTab: 0,
     winWidth: 0,
     winHeight: 0,
-    activityName: '',
-    activitySubTitle: '',
-    activityTime: '',
-    activityPlace: '',
-    activityContact: '',
-    activityAim: '',
-    activityDetail: '',
-    activityPoster: [],
-    activityPicture: [],
-    activityProInfo: '',
-    activitySrc: '',
-    activityAttr: [],
-    activitySupply: [],
-    recruitName: '',
-    recruitSubTitle: '',
-    recruitTime: '',
-    recruitAttr: '',
-    recruitContact: '',
-    recruitAim: '',
-    recruitDetail: '',
-    recruitPoster: [],
-    recruitPicture: [],
-    recruitProInfo: '',
-    recruitSrc: '',
-    notiName: '',
-    notiSubTitle: '',
-    notiAttr: [],
-    notiAim: '',
-    notiDetail: '',
-    notiPoster: [],
-    notiPicture: [],
-    types1: ['志愿活动', '文艺活动', '体育活动', '学术活动', '素质拓展', '精品课程', '其他活动'],
-    types2: ['二课分', '三课分', '四课分', '勤工助学', '志愿者小时数', '综素/活动纪实'],
-    types3: ['水电通知', '缴费通知', '假期通知', '后勤通知', '图书馆通知', '选课通知', '竞赛通知', '考试通知', '其他通知'],
-    publisherId: ''
+    types1: [{
+      value: '志愿活动',
+      checked: false
+    }, {
+      value: '文艺活动',
+      checked: false
+    }, {
+      value: '体育活动',
+      checked: false
+    }, {
+      value: '学术活动',
+      checked: false
+    }, {
+      value: '素质拓展',
+      checked: false
+    }, {
+      value: '精品课程',
+      checked: false
+    }, {
+      value: '其他活动',
+      checked: false
+    }],
+    types2: [{
+      value: '二课分',
+      checked: false
+    }, {
+      value: '三课分',
+      checked: false
+    }, {
+      value: '四课分',
+      checked: false
+    }, {
+      value: '勤工助学',
+      checked: false
+    }, {
+      value: '志愿者小时数',
+      checked: false
+    }, {
+      value: '综素',
+      checked: false
+    }],
+    types3: [{
+      value: '水电通知',
+      checked: false
+    }, {
+      value: '缴费通知',
+      checked: false
+    }, {
+      value: '假期通知',
+      checked: false
+    }, {
+      value: '后勤通知',
+      checked: false
+    }, {
+      value: '图书馆通知',
+      checked: false
+    }, {
+      value: '选课通知',
+      checked: false
+    }, {
+      value: '竞赛通知',
+      checked: false
+    }, {
+      value: '考试通知',
+      checked: false
+    }, {
+      value: '其他通知',
+      checked: false
+    }],
+    publisherId: '',
+    messageId: '',
+    currentTab: 0,
+    activityInfo: {}
   },
 
   switch1: function (e) {
@@ -68,10 +105,10 @@ Page({
     const value = e.detail.value
 
     if (this.data.currentTab === 2) {
-      value.type = '纳新'
+      value.type = ['纳新']
     }
 
-    if (value.name === '' || value.type === '' || this.data.detail === '') {
+    if (value.name === '' || value.type.length === 0 || this.data.detail === '') {
       wx.showToast({
         title: '请确认信息填写完整',
         icon: 'none'
@@ -98,22 +135,17 @@ Page({
     Promise.all(arr).then(res => {
       wx.hideLoading()
       wx.showLoading({
-        title: '正在发布',
+        title: '正在发布'
       })
       value.pub_id = this.data.publisherId
       if (value.poster.length !== 0) {
-        value.poster = res[0].fileID
+        value.poster[0] = res[0].fileID
         res.splice(0, 1)
-      } else {
-        value.poster = ''
       }
       for (let i = 0; i < value.photo.length; i++) {
         value.photo[i] = res[i].fileID
       }
-      value.photo = value.photo.join()
-      if (value.tag) {
-        value.tag = value.tag.join()
-      }
+      value = util.msgToDb(value)
       return wx.cloud.callFunction({
         name: 'createMessage',
         data: value
@@ -144,6 +176,41 @@ Page({
     this.setData({
       publisherId: options.id
     })
+    if (options.msg_id) {
+      this.setData({
+        messageId: options.msg_id,
+        currentTab: -1
+      })
+      wx.showLoading({
+        title: '加载中'
+      })
+      wx.cloud.callFunction({
+        name: 'getMessage',
+        data: {
+          msg_id: options.msg_id
+        }
+      }).then(res => {
+        wx.hideLoading()
+        res.result.list[0] = util.dbToMsg(res.result.list[0])
+        const type = res.result.list[0].type[0].substr(res.result.list[0].type[0].length - 2)
+        for (let i = 0; i < this.data.types1.length; i++) {
+          this.data.types1[i].checked = res.result.list[0].type.indexOf(this.data.types1[i].value) !== -1
+        }
+        for (let i = 0; i < this.data.types2.length; i++) {
+          this.data.types2[i].checked = res.result.list[0].tag.indexOf(this.data.types2[i].value) !== -1
+        }
+        for (let i = 0; i < this.data.types3.length; i++) {
+          this.data.types3[i].checked = res.result.list[0].type.indexOf(this.data.types3[i].value) !== -1
+        }
+        this.setData({
+          types1: this.data.types1,
+          types2: this.data.types2,
+          types3: this.data.types3,
+          currentTab: type === '通知' ? 3 : type === '纳新' ? 2 : 1,
+          activityInfo: res.result.list[0]
+        })
+      })
+    }
     wx.getSystemInfo({
       success: function (res) {
         this.setData({

+ 56 - 47
miniprogram/pages/activityPublish/activityPublish.wxml

@@ -1,7 +1,7 @@
 <!--为我的-信息发布页面-->
 <!-- 修改:信息发布页面移到首页-->
 
-<view class="title primary-text-color">信息发布</view>
+<view class="title primary-text-color">信息{{messageId ? '修改' : '发布'}}</view>
 
 <view wx:if="{{currentTab === 0}}" class="con">
   <view class="title2">信息发布类型</view>
@@ -13,161 +13,170 @@
 </view>
 
 <scroll-view wx:if="{{currentTab === 1}}" scroll-y style="height: {{winHeight - 60}}px;">
-  <view class="sub-title">活动发布</view>
+  <view class="sub-title">活动{{messageId ? '修改' : '发布'}}</view>
   <form bindsubmit="switch4">
     <view class="block">
       <view class="cate">活动名称<span style="color: #FF0000">*</span></view>
-      <input class="input" placeholder="请填写" name="name" />
+      <input class="input" placeholder="请填写" name="name" value="{{activityInfo.name}}" />
     </view>
     <view class="block">
       <view class="cate" style="align-self: flex-start;">活动类型<span style="color: #FF0000">*</span></view>
-      <radio-group class="radio-group" name="type">
-        <label wx:for="{{types1}}" wx:for-item="item" wx:key="*this">
-          <radio class="radio" value="{{item}}" color="#469298">{{item}}</radio>
+      <checkbox-group class="checkbox-group" name="type">
+        <label wx:for="{{types1}}" wx:for-item="item" wx:key="item.value">
+          <checkbox class="checkbox" value="{{item.value}}" checked="{{item.checked}}" color="#469298">{{item.value}}
+          </checkbox>
         </label>
-      </radio-group>
+      </checkbox-group>
     </view>
     <view class="block">
       <view class="cate" style="align-self: flex-start;">活动简介</view>
-      <textarea class="input" style="height: 100rpx;" placeholder="请填写" name="brief"></textarea>
+      <textarea class="input" style="height: 100rpx;" placeholder="请填写" name="brief"
+        value="{{activityInfo.brief}}"></textarea>
     </view>
     <view class="block" style="margin-bottom: 20rpx;">
       <view class="cate" style="align-self: flex-start;">活动详情<span style="color: #FF0000">*</span></view>
-      <textarea class="input" style="height: 200rpx;" placeholder="请填写" name="detail"></textarea>
+      <textarea class="input" style="height: 200rpx;" placeholder="请填写" name="detail"
+        value="{{activityInfo.detail}}"></textarea>
     </view>
     <view class="block">
       <view class="cate" style="align-self: flex-start;">活动封图</view>
-      <imagePicker name="poster" max="1" image-width="450" image-height="215" />
+      <imagePicker name="poster" max="1" image-width="450" image-height="215" value="{{activityInfo.poster}}" />
     </view>
     <view class="block" style="margin-bottom: 20rpx;">
       <view class="cate" style="align-self: flex-start;">活动图片</view>
-      <imagePicker name="photo" max="9" image-width="145" image-height="145" />
+      <imagePicker name="photo" max="9" image-width="145" image-height="145" value="{{activityInfo.photo}}" />
     </view>
     <view class="block">
       <view class="cate" style="align-self: flex-start;">活动提供</view>
-      <checkbox-group class="radio-group" name="tag">
-        <label wx:for="{{types2}}" wx:for-item="item" wx:key="*this">
-          <checkbox class="radio" value="{{item}}" color="#469298">{{item}}</checkbox>
+      <checkbox-group class="checkbox-group" name="tag">
+        <label wx:for="{{types2}}" wx:for-item="item" wx:key="item.value">
+          <checkbox class="checkbox" value="{{item.value}}" checked="{{item.checked}}" color="#469298">
+            {{item.value}}</checkbox>
         </label>
       </checkbox-group>
     </view>
     <view class="block">
       <view class="cate">面向对象</view>
-      <input class="input" placeholder="请填写" name="orient" />
+      <input class="input" placeholder="请填写" name="orient" value="{{activityInfo.orient}}" />
     </view>
     <view class="block">
       <view class="cate">活动时间</view>
-      <input class="input" placeholder="请填写" name="time" />
+      <input class="input" placeholder="请填写" name="time" value="{{activityInfo.time}}" />
     </view>
     <view class="block">
       <view class="cate">活动地点</view>
-      <input class="input" placeholder="请填写" name="place" />
+      <input class="input" placeholder="请填写" name="place" value="{{activityInfo.place}}" />
     </view>
     <view class="block">
       <view class="cate">联系方式</view>
-      <input class="input" placeholder="请填写" name="contact" />
+      <input class="input" placeholder="请填写" name="contact" value="{{activityInfo.contact}}" />
     </view>
     <view class="block">
       <view class="cate">链接</view>
-      <input class="input" placeholder="请填写" name="link" />
+      <input class="input" placeholder="请填写" name="link" value="{{activityInfo.link}}" />
     </view>
-    <view class="block" style="margin-top: 20rpx;">
+    <view wx:if="{{messageId}}" class="block" style="margin-top: 20rpx;">
       <view class="cate primary-text-color" style="align-self: flex-start;">消息通知</view>
-      <textarea class="input" style="height: 200rpx;" placeholder="提交后会以消息的形式通知关注者" name="noti"></textarea>
+      <textarea class="input" style="height: 200rpx;" placeholder="提交后会以消息的形式通知关注者" name="notify"></textarea>
     </view>
     <myButton class="button" type="primary">提交</myButton>
   </form>
 </scroll-view>
 
 <scroll-view wx:if="{{currentTab === 2}}" scroll-y style="height: {{winHeight - 60}}px;">
-  <view class="sub-title">纳新发布</view>
+  <view class="sub-title">纳新{{messageId ? '修改' : '发布'}}</view>
   <form bindsubmit="switch4">
     <view class="block">
       <view class="cate">纳新标题<span style="color: #FF0000">*</span></view>
-      <input class="input" placeholder="请填写" name="name" />
+      <input class="input" placeholder="请填写" name="name" value="{{activityInfo.name}}" />
     </view>
     <view class="block">
       <view class="cate" style="align-self: flex-start;">纳新简介</view>
-      <textarea class="input" style="height: 100rpx;" placeholder="请填写" name="brief"></textarea>
+      <textarea class="input" style="height: 100rpx;" placeholder="请填写" name="brief"
+        value="{{activityInfo.brief}}"></textarea>
     </view>
     <view class="block" style="margin-bottom: 20rpx;">
       <view class="cate" style="align-self: flex-start;">纳新详情<span style="color: #FF0000">*</span></view>
-      <textarea class="input" style="height: 200rpx;" placeholder="请填写" name="detail"></textarea>
+      <textarea class="input" style="height: 200rpx;" placeholder="请填写" name="detail"
+        value="{{activityInfo.detail}}"></textarea>
     </view>
     <view class="block">
       <view class="cate" style="align-self: flex-start;">纳新封图</view>
-      <imagePicker name="poster" max="1" image-width="450" image-height="215" />
+      <imagePicker name="poster" max="1" image-width="450" image-height="215" value="{{activityInfo.poster}}" />
     </view>
     <view class="block" style="margin-bottom: 20rpx;">
       <view class="cate" style="align-self: flex-start;">纳新图片</view>
-      <imagePicker name="photo" max="9" image-width="145" image-height="145" />
+      <imagePicker name="photo" max="9" image-width="145" image-height="145" value="{{activityInfo.photo}}" />
     </view>
     <view class="block">
       <view class="cate">面向对象</view>
-      <input class="input" placeholder="请填写" name="orient" />
+      <input class="input" placeholder="请填写" name="orient" value="{{activityInfo.orient}}" />
     </view>
     <view class="block">
       <view class="cate">纳新时间</view>
-      <input class="input" placeholder="请填写" name="time" />
+      <input class="input" placeholder="请填写" name="time" value="{{activityInfo.time}}" />
     </view>
     <view class="block">
       <view class="cate">现宣信息</view>
-      <input class="input" placeholder="请填写" name="place" />
+      <input class="input" placeholder="请填写" name="place" value="{{activityInfo.place}}" />
     </view>
     <view class="block">
       <view class="cate">联系方式</view>
-      <input class="input" placeholder="请填写" name="contact" />
+      <input class="input" placeholder="请填写" name="contact" value="{{activityInfo.contact}}" />
     </view>
     <view class="block">
       <view class="cate">链接</view>
-      <input class="input" placeholder="请填写" name="link" />
+      <input class="input" placeholder="请填写" name="link" value="{{activityInfo.link}}" />
     </view>
-    <view class="block" style="margin-top: 20rpx;">
+    <view wx:if="{{messageId}}" class="block" style="margin-top: 20rpx;">
       <view class="cate primary-text-color" style="align-self: flex-start;">消息通知</view>
-      <textarea class="input" style="height: 200rpx;" placeholder="提交后会以消息的形式通知关注者" name="noti"></textarea>
+      <textarea class="input" style="height: 200rpx;" placeholder="提交后会以消息的形式通知关注者" name="notify"></textarea>
     </view>
     <myButton class="button" type="primary">提交</myButton>
   </form>
 </scroll-view>
 
 <scroll-view wx:if="{{currentTab === 3}}" scroll-y style="height: {{winHeight - 60}}px;">
-  <view class="sub-title">通知发布</view>
+  <view class="sub-title">通知{{messageId ? '修改' : '发布'}}</view>
   <form bindsubmit="switch4">
     <view class="block">
       <view class="cate">通知标题<span style="color: #FF0000">*</span></view>
-      <input class="input" placeholder="请填写" name="name" />
+      <input class="input" placeholder="请填写" name="name" value="{{activityInfo.name}}" />
     </view>
     <view class="block">
       <view class="cate" style="align-self: flex-start;">通知类型<span style="color: #FF0000">*</span></view>
-      <radio-group class="radio-group" name="type">
-        <label wx:for="{{types3}}" wx:for-item="item" wx:key="*this">
-          <radio class="radio" value="{{item}}" color="#469298">{{item}}</radio>
+      <checkbox-group class="checkbox-group" name="type">
+        <label wx:for="{{types3}}" wx:for-item="item" wx:key="item.value">
+          <checkbox class="checkbox" value="{{item.value}}" checked="{{item.checked}}" color="#469298">{{item.value}}
+          </checkbox>
         </label>
-      </radio-group>
+      </checkbox-group>
     </view>
     <view class="block">
       <view class="cate" style="align-self: flex-start;">通知简介</view>
-      <textarea class="input" style="height: 100rpx;" placeholder="请填写" name="brief"></textarea>
+      <textarea class="input" style="height: 100rpx;" placeholder="请填写" name="brief"
+        value="{{activityInfo.brief}}"></textarea>
     </view>
     <view class="block" style="margin-bottom: 20rpx;">
       <view class="cate" style="align-self: flex-start;">通知详情<span style="color: #FF0000">*</span></view>
-      <textarea class="input" style="height: 200rpx;" placeholder="请填写" name="detail"></textarea>
+      <textarea class="input" style="height: 200rpx;" placeholder="请填写" name="detail"
+        value="{{activityInfo.detail}}"></textarea>
     </view>
     <view class="block">
       <view class="cate" style="align-self: flex-start;">通知封图</view>
-      <imagePicker name="poster" max="1" image-width="450" image-height="215" />
+      <imagePicker name="poster" max="1" image-width="450" image-height="215" value="{{activityInfo.poster}}" />
     </view>
     <view class="block" style="margin-bottom: 20rpx;">
       <view class="cate" style="align-self: flex-start;">通知图片</view>
-      <imagePicker name="photo" max="9" image-width="145" image-height="145" />
+      <imagePicker name="photo" max="9" image-width="145" image-height="145" value="{{activityInfo.photo}}" />
     </view>
     <view class="block">
       <view class="cate">链接</view>
-      <input class="input" placeholder="请填写" name="link" />
+      <input class="input" placeholder="请填写" name="link" value="{{activityInfo.link}}" />
     </view>
-    <view class="block" style="margin-top: 20rpx;">
+    <view wx:if="{{messageId}}" class="block" style="margin-top: 20rpx;">
       <view class="cate primary-text-color" style="align-self: flex-start;">消息通知</view>
-      <textarea class="input" style="height: 200rpx;" placeholder="提交后会以消息的形式通知关注者" name="noti"></textarea>
+      <textarea class="input" style="height: 200rpx;" placeholder="提交后会以消息的形式通知关注者" name="notify"></textarea>
     </view>
     <myButton class="button" type="primary">提交</myButton>
   </form>

+ 2 - 2
miniprogram/pages/activityPublish/activityPublish.wxss

@@ -11,12 +11,12 @@
   margin: 20rpx 40rpx;
 }
 
-.radio {
+.checkbox {
   transform: scale(0.8);
   margin-left: 10rpx;
 }
 
-.radio-group {
+.checkbox-group {
   width: 500rpx;
 }
 

+ 3 - 5
miniprogram/pages/main/main.js

@@ -46,14 +46,14 @@ Page({
       },
       {
         title: '我的需求',
-        children: ['二课分', '三课分', '四课分', '勤工助学', '志愿者小时数', '综素/活动纪实']
+        children: ['二课分', '三课分', '四课分', '勤工助学', '志愿者小时数', '综素']
       }
     ]
   },
 
   updateData: function () {
     for (let i = 0; i < this.data.mainDatas.length; i++) {
-      this.data.mainDatas[i].show = (this.data.filterItem[1] === '' || this.data.filterItem[1] === this.data.mainDatas[i].type) &&
+      this.data.mainDatas[i].show = (this.data.filterItem[1] === '' || this.data.mainDatas[i].type.indexOf(this.data.filterItem[1]) !== -1) &&
         (this.data.filterItem[2] === '' || this.data.filterItem[2] === this.data.mainDatas[i].publisher[0].type) &&
         (this.data.filterItem[3] === '' || this.data.mainDatas[i].tag.indexOf(this.data.filterItem[3]) !== -1)
     }
@@ -198,9 +198,7 @@ Page({
     }).then(res => {
       wx.hideNavigationBarLoading()
       for (let i = 0; i < res.result.list.length; i++) {
-        res.result.list[i].photo = res.result.list[i].photo.split(',')
-        res.result.list[i].tag = res.result.list[i].tag.split(',')
-        res.result.list[i].publish_time = util.handleDate(res.result.list[i].publish_time)
+        res.result.list[i] = util.dbToMsg(res.result.list[i])
       }
       this.setData({
         mainDatas: this.data.mainDatas.concat(res.result.list),

+ 1 - 1
miniprogram/pages/myFavor/myFavor.js

@@ -6,7 +6,7 @@ Component({
   lifetimes: {
     ready: function() {
       wx.showLoading({
-        title: "加载中",
+        title: "加载中"
       })
       const db = wx.cloud.database()
       db.collection("likeData").where({

+ 0 - 41
miniprogram/pages/publisherDetail/publisherDetail.js

@@ -6,47 +6,6 @@ Page({
     publisherInfo: {},
   },
 
-  // processData: function (start, arr) {
-  //   for (let i = start; i < arr.length; i++) {
-  //     arr[i].time = util.handleDate(arr[i].time)
-  //   }
-  //   this.setData({
-  //     mainDatas: arr
-  //   })
-  //   wx.hideLoading()
-  // },
-
-  // onLoad: function (options) {
-  //   wx.showLoading({
-  //     title: "加载中"
-  //   })
-  //   const db = wx.cloud.database()
-  //   db.collection("publisherInfoData").doc(options.id).get({
-  //     success: function (res) {
-  //       this.setData({
-  //         publisherInfo: res.data
-  //       })
-  //       db.collection("mainData").where({
-  //         publisherName: this.data.publisherInfo.publisherName
-  //       }).orderBy("time", "desc").limit(20).get({
-  //         success: function (res) {
-  //           this.processData(0, res.data)
-  //         }.bind(this)
-  //       })
-  //     }.bind(this)
-  //   })
-  //   db.collection("likeData").where({
-  //     type: "publisher",
-  //     id: options.id
-  //   }).get({
-  //     success: function (res) {
-  //       this.setData({
-  //         like: res.data.length
-  //       })
-  //     }.bind(this)
-  //   })
-  // },
-
   /**
    * 生命周期函数--监听页面加载
    */

+ 1 - 1
miniprogram/pages/publisherLogin/publisherLogin.js

@@ -67,7 +67,7 @@ Page({
     }).then(res => {
       wx.hideLoading()
       wx.showLoading({
-        title: '正在入驻',
+        title: '正在入驻'
       })
       value.type = this.data.currentTab === 2 ? '组织' : this.data.currentTab === 3 ? '社团' : '学校部门'
       value.avatar = res.fileID

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

@@ -117,7 +117,7 @@ Page({
       data: history
     })
     wx.showLoading({
-      title: "搜索中",
+      title: "搜索中"
     })
     const db = wx.cloud.database()
     const _ = db.command

+ 33 - 1
miniprogram/utils/util.js

@@ -56,8 +56,40 @@ const randomString = len => {
   return str
 }
 
+const msgToDb = function (item) {
+  item.type = item.type.join()
+  item.poster = item.poster.join()
+  item.photo = item.photo.join()
+  if (item.tag) {
+    item.tag = item.tag.join()
+  }
+}
+
+const dbToMsg = function (item) {
+  item.type = item.type.split(',')
+  if (item.poster !== '') {
+    item.poster = item.poster.split(',')
+  } else {
+    item.poster = []
+  }
+  if (item.photo !== '') {
+    item.photo = item.photo.split(',')
+  } else {
+    item.poster = []
+  }
+  if (item.tag !== '') {
+    item.tag = item.tag.split(',')
+  } else {
+    item.tag = []
+  }
+  item.publish_time = handleDate(item.publish_time)
+  return item
+}
+
 module.exports = {
   formatTime: formatTime,
   handleDate: handleDate,
-  randomString: randomString
+  randomString: randomString,
+  msgToDb: msgToDb,
+  dbToMsg: dbToMsg
 }