Jelajahi Sumber

更新

完成信息发布后端
RegMs If 4 tahun lalu
induk
melakukan
70d041d61a

+ 18 - 12
cloudfunctions/createMessage/index.js

@@ -25,20 +25,26 @@ exports.main = async (event, context) => {
     }
   }
 
+  if (!event.type) {
+    const publisher = await db.collection('publisher').doc(event.pub_id).get()
+    event.type = publisher.data.type + '纳新'
+  }
+
   const message = await db.collection('message').add({
     data: {
-      pub_id: '',
-      name: '',
-      type: '',
-      brief: '',
-      poster: '',
-      photo: '',
-      tag: '',
-      orient: '',
-      time: '',
-      place: '',
-      contact: '',
-      detail: '',
+      pub_id: event.pub_id,
+      user_id: OPENID,
+      name: event.name,
+      type: event.type,
+      brief: event.brief,
+      poster: event.poster,
+      photo: event.photo,
+      tag: event.tag,
+      orient: event.orient,
+      time: event.time,
+      place: event.place,
+      contact: event.contact,
+      detail: event.detail,
       publish_time: new Date()
     }
   })

+ 1 - 38
miniprogram/app.js

@@ -12,44 +12,6 @@ App({
     //     // 发送 res.code 到后台换取 openId, sessionKey, unionId
     //   }
     // })
-    // // 获取用户信息
-    // wx.getSetting({
-    //   success: res => {
-    //     if (res.authSetting['scope.userInfo']) {
-    //       // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
-    //       wx.getUserInfo({
-    //         success: res => {
-    //           // 可以将 res 发送给后台解码出 unionId
-    //           this.globalData.userInfo = res.userInfo
-    //           console.log(this.globalData.userInfo)
-    //           const db = wx.cloud.database()
-    //           db.collection("userInfoData").get({
-    //             success: function (user) {
-    //               if (user.data.length == 0) {
-    //                 db.collection("userInfoData").add({
-    //                   data: {
-    //                     publisherId: []
-    //                   },
-    //                   success: function () {
-    //                     this.globalData.publisherId = []
-    //                     if (this.userInfoReadyCallback) {
-    //                       this.userInfoReadyCallback(res)
-    //                     }
-    //                   }.bind(this)
-    //                 })
-    //               } else {
-    //                 this.globalData.publisherId = user.data[0].publisherId
-    //                 if (this.userInfoReadyCallback) {
-    //                   this.userInfoReadyCallback(res)
-    //                 }
-    //               }
-    //             }.bind(this)
-    //           })
-    //         }
-    //       })
-    //     }
-    //   }
-    // })
 
     if (!wx.cloud) {
       console.error('请使用 2.2.3 或以上的基础库以使用云能力')
@@ -86,6 +48,7 @@ App({
       })
     }
   },
+
   globalData: {
     userInfo: null,
     hasUserInfo: false,

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

@@ -16,7 +16,7 @@
   <view class="sub-title">{{item.subTitle}}</view>
   <imagePicker wx:if="{{item.poster != ''}}" images="{{[item.poster]}}" max="1" image-width="700" image-height="350"
     readonly />
-  <imagePicker wx:if="{{item.poster == '' && item.photo.length != 0}}" images="{{item.photo}}" max="1"
+  <imagePicker wx:if="{{item.poster == '' && item.photo.length != 0}}" value="{{item.photo}}" max="1"
     image-width="{{item.photo.length == 1 ? 696 : item.photo.length <= 4 ? 330 : 220}}"
     image-height="{{item.photo.length == 1 ? 696 : item.photo.length <= 4 ? 330 : 220}}" readonly />
   <view class="bottom-line">

+ 185 - 197
miniprogram/pages/activityPublish/activityPublish.js

@@ -1,3 +1,5 @@
+const util = require('../../utils/util.js')
+
 Page({
 
   /**
@@ -7,101 +9,41 @@ Page({
     currentTab: 0,
     winWidth: 0,
     winHeight: 0,
-    activityName: "",
-    activitySubTitle: "",
-    activityTime: "",
-    activityPlace: "",
-    activityContact: "",
-    activityAim: "",
-    activityDetail: "",
+    activityName: '',
+    activitySubTitle: '',
+    activityTime: '',
+    activityPlace: '',
+    activityContact: '',
+    activityAim: '',
+    activityDetail: '',
     activityPoster: [],
     activityPicture: [],
-    activityProInfo: "",
-    activitySrc: "",
+    activityProInfo: '',
+    activitySrc: '',
     activityAttr: [],
     activitySupply: [],
-    recruitName: "",
-    recruitSubTitle: "",
-    recruitTime: "",
-    recruitAttr: "",
-    recruitContact: "",
-    recruitAim: "",
-    recruitDetail: "",
+    recruitName: '',
+    recruitSubTitle: '',
+    recruitTime: '',
+    recruitAttr: '',
+    recruitContact: '',
+    recruitAim: '',
+    recruitDetail: '',
     recruitPoster: [],
     recruitPicture: [],
-    recruitProInfo: "",
-    recruitSrc: "",
-    notiName: "",
-    notiSubTitle: "",
+    recruitProInfo: '',
+    recruitSrc: '',
+    notiName: '',
+    notiSubTitle: '',
     notiAttr: [],
-    notiAim: "",
-    notiDetail: "",
+    notiAim: '',
+    notiDetail: '',
     notiPoster: [],
     notiPicture: [],
-    types1: ["志愿活动", "文艺活动", "体育活动", "学术活动", "素质拓展", "精品课程", "其他活动"],
-    types2: ["二课分", "三课分", "四课分", "勤工助学", "志愿者小时数", "综素/活动纪实"],
-    types3: ["水电通知", "缴费通知", "假期通知", "后勤通知", "图书馆通知", "选课通知", "竞赛通知", "考试通知", "其他通知"],
-    publisherId: ""
-  },
-
-  activityAttrUpdate: function (e) {
-    this.setData({
-      activityAttr: e.detail.value
-    })
-  },
-
-  activitySupplyUpdate: function (e) {
-    this.setData({
-      activitySupply: e.detail.value
-    })
-  },
-
-  recruitAttrUpdate: function (e) {
-    this.setData({
-      recruitAttr: e.detail.value
-    })
-  },
-
-  notiAttrUpdate: function (e) {
-    this.setData({
-      notiAttr: e.detail.value
-    })
-  },
-
-  updateActivityPoster: function (e) {
-    this.setData({
-      activityPoster: e.detail.images
-    })
-  },
-
-  updateActivityPicture: function (e) {
-    this.setData({
-      activityPicture: e.detail.images
-    })
-  },
-
-  updateRecruitPoster: function (e) {
-    this.setData({
-      recruitPoster: e.detail.images
-    })
-  },
-
-  updateRecruitPicture: function (e) {
-    this.setData({
-      recruitPicture: e.detail.images
-    })
-  },
-
-  updateNotiPoster: function (e) {
-    this.setData({
-      notiPoster: e.detail.images
-    })
-  },
-
-  updateNotiPicture: function (e) {
-    this.setData({
-      notiPicture: e.detail.images
-    })
+    types1: ['志愿活动', '文艺活动', '体育活动', '学术活动', '素质拓展', '精品课程', '其他活动'],
+    types2: ['二课分', '三课分', '四课分', '勤工助学', '志愿者小时数', '综素/活动纪实'],
+    types3: ['水电通知', '缴费通知', '假期通知', '后勤通知', '图书馆通知', '选课通知', '竞赛通知', '考试通知', '其他通知'],
+    publisherId: ''
   },
 
   switch1: function (e) {
@@ -122,122 +64,174 @@ Page({
     })
   },
 
-  randomString: function () {
-    var char = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
-    var str = ""
-    for (var i = 0; i < 16; i++) {
-      str += char[Math.floor(Math.random() * char.length)]
+  switch4: function (e) {
+    // var obj = {}
+    // if (this.data.currentTab == 1) {
+    //   if (this.data.activityName == '' || this.data.activityTime == '' || this.data.activityPlace == '' ||
+    //     this.data.activityAttr.length == 0 || this.data.activityContact == '' || this.data.activityDetail == '') {
+    //     wx.showToast({
+    //       title: '请确认信息填写完整',
+    //       icon: 'none'
+    //     })
+    //     return
+    //   }
+    //   obj = {
+    //     title: this.data.activityName,
+    //     subTitle: this.data.activitySubTitle,
+    //     activityTime: this.data.activityTime,
+    //     place: this.data.activityPlace,
+    //     attribute: this.data.activityAttr,
+    //     supply: this.data.activitySupply,
+    //     contactDetails: this.data.activityContact,
+    //     objectOriented: this.data.activityAim,
+    //     details: this.data.activityDetail,
+    //     poster: this.data.activityPoster.length == 0 ? '' : this.data.activityPoster[0],
+    //     photo: this.data.activityPicture,
+    //     publicity: this.data.activityProInfo,
+    //     registrationLink: this.data.activitySrc
+    //   }
+    // } else if (this.data.currentTab == 2) {
+    //   if (this.data.recruitName == '' || this.data.recruitTime == '' || this.data.recruitAttr == '' ||
+    //     this.data.recruitContact == '' || this.data.recruitDetail == '') {
+    //     wx.showToast({
+    //       title: '请确认信息填写完整',
+    //       icon: 'none'
+    //     })
+    //     return
+    //   }
+    //   obj = {
+    //     title: this.data.recruitName,
+    //     subTitle: this.data.recruitSubTitle,
+    //     activityTime: this.data.recruitTime,
+    //     attribute: this.data.recruitAttr,
+    //     contactDetails: this.data.recruitContact,
+    //     objectOriented: this.data.recruitAim,
+    //     details: this.data.recruitDetail,
+    //     poster: this.data.recruitPoster.length == 0 ? '' : this.data.recruitPoster[0],
+    //     photo: this.data.recruitPicture,
+    //     publicity: this.data.recruitProInfo,
+    //     registrationLink: this.data.recruitSrc
+    //   }
+    // } else {
+    //   if (this.data.notiName == '' || this.data.notiAttr.length == 0 || this.data.notiDetail == '') {
+    //     wx.showToast({
+    //       title: '请确认信息填写完整',
+    //       icon: 'none'
+    //     })
+    //     return
+    //   }
+    //   obj = {
+    //     title: this.data.notiName,
+    //     subTitle: this.data.notiSubTitle,
+    //     attribute: this.data.notiAttr,
+    //     objectOriented: this.data.notiAim,
+    //     details: this.data.notiDetail,
+    //     poster: this.data.notiPoster.length == 0 ? '' : this.data.notiPoster[0],
+    //     photo: this.data.notiPicture
+    //   }
+    // }
+    // obj.time = new Date()
+    // obj.publisherId = this.data.publisherId
+    // wx.showLoading({
+    //   title: '发布中'
+    // })
+    // const db = wx.cloud.database()
+    // db.collection('publisherInfoData').doc(this.data.publisherId).get({
+    //   success: async function (res) {
+    //     obj.publisherAvatar = res.data.publisherAvatar
+    //     obj.publisherName = res.data.publisherName
+    //     if (obj.poster != '') {
+    //       obj.poster = (await wx.cloud.uploadFile({
+    //         cloudPath: 'activityPoster/' + this.randomString() + '.jpg',
+    //         filePath: obj.poster
+    //       })).fileID
+    //     }
+    //     var arr = []
+    //     for (let i = 0; i < obj.photo.length; i++) {
+    //       arr.push(wx.cloud.uploadFile({
+    //         cloudPath: 'informPhoto/' + this.randomString() + '.jpg',
+    //         filePath: obj.photo[i]
+    //       }))
+    //     }
+    //     arr = await Promise.all(arr)
+    //     for (let i = 0; i < obj.photo.length; i++) {
+    //       obj.photo[i] = arr[i].fileID
+    //     }
+    //     db.collection('mainData').add({
+    //       data: obj,
+    //       success: function () {
+    //         this.setData({
+    //           currentTab: 4
+    //         })
+    //         wx.hideLoading()
+    //       }.bind(this)
+    //     })
+    //   }.bind(this)
+    // })
+
+    const value = e.detail.value
+
+    if (value.name === '' || this.data.currentTab !== 2 && value.type === '' || this.data.detail === '') {
+      wx.showToast({
+        title: '请确认信息填写完整',
+        icon: 'none'
+      })
+      return
     }
-    return str
-  },
 
-  switch4: function (e) {
-    var obj = {}
-    if (this.data.currentTab == 1) {
-      if (this.data.activityName == "" || this.data.activityTime == "" || this.data.activityPlace == "" ||
-        this.data.activityAttr.length == 0 || this.data.activityContact == "" || this.data.activityDetail == "") {
-        wx.showToast({
-          title: "请确认信息填写完整",
-          icon: "none"
-        })
-        return
-      }
-      obj = {
-        title: this.data.activityName,
-        subTitle: this.data.activitySubTitle,
-        activityTime: this.data.activityTime,
-        place: this.data.activityPlace,
-        attribute: this.data.activityAttr,
-        supply: this.data.activitySupply,
-        contactDetails: this.data.activityContact,
-        objectOriented: this.data.activityAim,
-        details: this.data.activityDetail,
-        poster: this.data.activityPoster.length == 0 ? "" : this.data.activityPoster[0],
-        photo: this.data.activityPicture,
-        publicity: this.data.activityProInfo,
-        registrationLink: this.data.activitySrc
+    wx.showLoading({
+      title: '上传图片'
+    })
+    const arr = []
+    if (value.poster.length !== 0) {
+      arr.push(wx.cloud.uploadFile({
+        cloudPath: `messagePoster/${util.randomString(16)}.jpg`,
+        filePath: value.poster[0]
+      }))
+    }
+    for (let i = 0; i < value.photo.length; i++) {
+      arr.push(wx.cloud.uploadFile({
+        cloudPath: `messagePhoto/${util.randomString(16)}.jpg`,
+        filePath: value.photo[i]
+      }))
+    }
+    Promise.all(arr).then(res => {
+      wx.hideLoading()
+      wx.showLoading({
+        title: '正在发布',
+      })
+      value.pub_id = this.data.publisherId
+      if (value.poster.length !== 0) {
+        value.poster = res[0].fileID
+        res.splice(0, 1)
       }
-    } else if (this.data.currentTab == 2) {
-      if (this.data.recruitName == "" || this.data.recruitTime == "" || this.data.recruitAttr == "" ||
-        this.data.recruitContact == "" || this.data.recruitDetail == "") {
-        wx.showToast({
-          title: "请确认信息填写完整",
-          icon: "none"
-        })
-        return
+      for (let i = 0; i < value.photo.length; i++) {
+        value.photo[i] = res[i].fileID
       }
-      obj = {
-        title: this.data.recruitName,
-        subTitle: this.data.recruitSubTitle,
-        activityTime: this.data.recruitTime,
-        attribute: this.data.recruitAttr,
-        contactDetails: this.data.recruitContact,
-        objectOriented: this.data.recruitAim,
-        details: this.data.recruitDetail,
-        poster: this.data.recruitPoster.length == 0 ? "" : this.data.recruitPoster[0],
-        photo: this.data.recruitPicture,
-        publicity: this.data.recruitProInfo,
-        registrationLink: this.data.recruitSrc
+      value.photo = value.photo.join()
+      if (value.tag) {
+        value.tag = value.tag.join()
       }
-    } else {
-      if (this.data.notiName == "" || this.data.notiAttr.length == 0 || this.data.notiDetail == "") {
+      return wx.cloud.callFunction({
+        name: 'createMessage',
+        data: value
+      })
+    }).then(res => {
+      wx.hideLoading()
+      if (res.result._id !== undefined) {
+        this.setData({
+          currentTab: 4
+        })
+      } else {
         wx.showToast({
-          title: "请确认信息填写完整",
-          icon: "none"
+          title: res.result.errMsg,
+          icon: 'none'
         })
-        return
-      }
-      obj = {
-        title: this.data.notiName,
-        subTitle: this.data.notiSubTitle,
-        attribute: this.data.notiAttr,
-        objectOriented: this.data.notiAim,
-        details: this.data.notiDetail,
-        poster: this.data.notiPoster.length == 0 ? "" : this.data.notiPoster[0],
-        photo: this.data.notiPicture
       }
-    }
-    obj.time = new Date()
-    obj.publisherId = this.data.publisherId
-    wx.showLoading({
-      title: "发布中"
-    })
-    const db = wx.cloud.database()
-    db.collection("publisherInfoData").doc(this.data.publisherId).get({
-      success: async function (res) {
-        obj.publisherAvatar = res.data.publisherAvatar
-        obj.publisherName = res.data.publisherName
-        if (obj.poster != "") {
-          obj.poster = (await wx.cloud.uploadFile({
-            cloudPath: "activityPoster/" + this.randomString() + ".jpg",
-            filePath: obj.poster
-          })).fileID
-        }
-        var arr = []
-        for (let i = 0; i < obj.photo.length; i++) {
-          arr.push(wx.cloud.uploadFile({
-            cloudPath: "informPhoto/" + this.randomString() + ".jpg",
-            filePath: obj.photo[i]
-          }))
-        }
-        arr = await Promise.all(arr)
-        for (let i = 0; i < obj.photo.length; i++) {
-          obj.photo[i] = arr[i].fileID
-        }
-        db.collection("mainData").add({
-          data: obj,
-          success: function () {
-            this.setData({
-              currentTab: 4
-            })
-            wx.hideLoading()
-          }.bind(this)
-        })
-      }.bind(this)
     })
   },
 
-  returnToUser: function (e) {
+  returnToPublisher: function (e) {
     wx.navigateBack()
   },
 
@@ -258,11 +252,5 @@ Page({
         })
       }.bind(this),
     })
-  },
-
-  updatePage: function (e) {
-    this.setData({
-      currentTab: e.detail.current
-    })
   }
 })

+ 13 - 19
miniprogram/pages/activityPublish/activityPublish.wxml

@@ -6,15 +6,9 @@
 <view wx:if="{{currentTab == 0}}" class="con">
   <view class="title2">信息发布类型</view>
   <view class="buttons">
-    <view>
-      <myButton class="button" type="primary" bindtap="switch1">活动</myButton>
-    </view>
-    <view>
-      <myButton class="button" type="primary" bindtap="switch2">纳新</myButton>
-    </view>
-    <view>
-      <myButton class="button" type="primary" bindtap="switch3">通知</myButton>
-    </view>
+    <myButton class="button" type="primary" bindtap="switch1">活动</myButton>
+    <myButton class="button" type="primary" bindtap="switch2">纳新</myButton>
+    <myButton class="button" type="primary" bindtap="switch3">通知</myButton>
   </view>
 </view>
 
@@ -34,7 +28,7 @@
       </radio-group>
     </view>
     <view class="block">
-      <view class="cate" style="align-self: flex-start;">活动简介<span style="color: #FF0000">*</span></view>
+      <view class="cate" style="align-self: flex-start;">活动简介</view>
       <textarea class="input" style="height: 100rpx;" placeholder="请填写" name="brief"></textarea>
     </view>
     <view class="block" style="margin-bottom: 20rpx;">
@@ -51,11 +45,11 @@
     </view>
     <view class="block">
       <view class="cate" style="align-self: flex-start;">活动提供</view>
-      <radio-group class="radio-group" name="type">
+      <checkbox-group class="radio-group" name="tag">
         <label wx:for="{{types2}}" wx:for-item="item" wx:key="*this">
-          <radio class="radio" value="{{item}}" color="#469298">{{item}}</radio>
+          <checkbox class="radio" value="{{item}}" color="#469298">{{item}}</checkbox>
         </label>
-      </radio-group>
+      </checkbox-group>
     </view>
     <view class="block" style="margin-bottom: 20rpx;">
       <view class="cate">面向对象</view>
@@ -77,7 +71,7 @@
       <view class="cate">报名链接</view>
       <input class="input" placeholder="请填写" name="link" />
     </view>
-    <myButton class="button" type="primary" bindtap="switch4">提交</myButton>
+    <myButton class="button" type="primary">提交</myButton>
   </form>
 </scroll-view>
 
@@ -89,7 +83,7 @@
       <input class="input" placeholder="请填写" name="name" />
     </view>
     <view class="block">
-      <view class="cate" style="align-self: flex-start;">纳新简介<span style="color: #FF0000">*</span></view>
+      <view class="cate" style="align-self: flex-start;">纳新简介</view>
       <textarea class="input" style="height: 100rpx;" placeholder="请填写" name="brief"></textarea>
     </view>
     <view class="block" style="margin-bottom: 20rpx;">
@@ -124,7 +118,7 @@
       <view class="cate">报名链接</view>
       <input class="input" placeholder="请填写" name="link" />
     </view>
-    <myButton class="button" type="primary" bindtap="switch4">提交</myButton>
+    <myButton class="button" type="primary">提交</myButton>
   </form>
 </scroll-view>
 
@@ -144,7 +138,7 @@
       </radio-group>
     </view>
     <view class="block">
-      <view class="cate" style="align-self: flex-start;">通知简介<span style="color: #FF0000">*</span></view>
+      <view class="cate" style="align-self: flex-start;">通知简介</view>
       <textarea class="input" style="height: 100rpx;" placeholder="请填写" name="brief"></textarea>
     </view>
     <view class="block" style="margin-bottom: 20rpx;">
@@ -163,7 +157,7 @@
       <view class="cate">通知链接</view>
       <input class="input" placeholder="请填写" name="link" />
     </view>
-    <myButton class="button" type="primary" bindtap="switch4">提交</myButton>
+    <myButton class="button" type="primary">提交</myButton>
   </form>
 </scroll-view>
 
@@ -171,5 +165,5 @@
   <view class="con1 primary-text-color">发布成功!</view>
   <image class="success-icon" src="../../images/finish.png" mode="aspectFill" />
   <!-- <view class="con2"></view> -->
-  <myButton class="button" type="primary" bindtap="returnToUser">返回</myButton>
+  <myButton class="button" type="primary" bindtap="returnToPublisher">返回</myButton>
 </view>

+ 6 - 1
miniprogram/pages/activityPublish/activityPublish.wxss

@@ -26,8 +26,13 @@
   margin: 10rpx 40rpx;
 }
 
+.buttons {
+  display: flex;
+  flex-direction: column;
+}
+
 .button {
-  margin: 10rpx;
+  margin: 20rpx;
 }
 
 .title2 {

+ 6 - 97
miniprogram/pages/publisherLogin/publisherLogin.js

@@ -19,22 +19,6 @@ Page({
     stars: ['一星级', '二星级', '三星级', '四星级', '五星级'],
   },
 
-  stopTouchMove: function () {
-    return false
-  },
-
-  bindLevelChange: function (e) {
-    this.setData({
-      publisherType: e.detail.value
-    })
-  },
-
-  bindAvatarChange: function (e) {
-    this.setData({
-      publisherAvatar: e.detail.value
-    })
-  },
-
   switch1: function (e) {
     this.setData({
       currentTab: 1
@@ -64,87 +48,18 @@ Page({
       return
     }
 
-    // const db = wx.cloud.database()
-    // const _ = db.command
-    // db.collection('inviteCodeData').where({
-    //   code: this.data.inviteCode,
-    //   used: false
-    // }).get({
-    //   success: function (code) {
-    //     if (code.data.length == 0) {
-    //       wx.showToast({
-    //         title: '邀请码不存在',
-    //         icon: 'none'
-    //       })
-    //       return
-    //     }
-    //     db.collection('publisherInfoData').where({
-    //       publisherName: this.data.publisherName
-    //     }).get({
-    //       success: function (res) {
-    //         if (res.data.length != 0) {
-    //           wx.showToast({
-    //             title: '名称已使用',
-    //             icon: 'none'
-    //           })
-    //           return
-    //         }
-    //         wx.showLoading({
-    //           title: '入驻中'
-    //         })
-    //         wx.cloud.uploadFile({
-    //           cloudPath: 'publisherAvater/' + this.data.publisherName + '.jpg',
-    //           filePath: this.data.publisherAvatar[0],
-    //           success: function (res) {
-    //             db.collection('publisherInfoData').add({
-    //               data: {
-    //                 publisherAttribute: [this.data.currentTab == 2 ? '组织' : '社团'],
-    //                 publisherAvatar: res.fileID,
-    //                 publisherContact: this.data.publisherContact,
-    //                 publisherIntro: this.data.publisherIntro,
-    //                 publisherName: this.data.publisherName,
-    //                 publisherType: this.data.publisherType
-    //               },
-    //               success: function (res) {
-    //                 db.collection('inviteCodeData').doc(code.data[0]._id).update({
-    //                   data: {
-    //                     used: true,
-    //                     publisherId: res._id
-    //                   },
-    //                   success: function () {
-    //                     db.collection('userInfoData').get({
-    //                       success: function (user) {
-    //                         db.collection('userInfoData').doc(user.data[0]._id).update({
-    //                           data: {
-    //                             publisherId: _.push(res._id)
-    //                           },
-    //                           success: function () {
-    //                             this.setData({
-    //                               currentTab: 4
-    //                             })
-    //                             wx.hideLoading()
-    //                           }.bind(this)
-    //                         })
-    //                       }.bind(this)
-    //                     })
-    //                   }.bind(this)
-    //                 })
-    //               }.bind(this)
-    //             })
-    //           }.bind(this)
-    //         })
-    //       }.bind(this)
-    //     })
-    //   }.bind(this)
-    // })
-
     wx.showLoading({
-      title: '入驻中'
+      title: '上传图片'
     })
     wx.cloud.uploadFile({
       cloudPath: `publisherAvater/${util.randomString(16)}.jpg`,
       filePath: value.avatar[0]
     }).then(res => {
+      wx.hideLoading()
+      wx.showLoading({
+        title: '正在入驻',
+      })
+      value.type = this.data.currentTab === 2 ? '组织' : '社团'
       value.avatar = res.fileID
       return wx.cloud.callFunction({
         name: 'createPublisher',
@@ -183,11 +98,5 @@ Page({
         })
       }.bind(this),
     })
-  },
-
-  updatePage: function (e) {
-    this.setData({
-      currentTab: e.detail.current
-    })
   }
 })

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

@@ -27,12 +27,8 @@
 <view wx:if="{{currentTab == 1}}" class="con">
   <view class="title2">请问您入驻的类型是?</view>
   <view class="buttons">
-    <view>
-      <myButton class="button" type="primary" bindtap="switch2">组织</myButton>
-    </view>
-    <view>
-      <myButton class="button" type="primary" bindtap="switch3">社团</myButton>
-    </view>
+    <myButton class="button" type="primary" bindtap="switch2">组织</myButton>
+    <myButton class="button" type="primary" bindtap="switch3">社团</myButton>
   </view>
 </view>
 

+ 6 - 1
miniprogram/pages/publisherLogin/publisherLogin.wxss

@@ -32,8 +32,13 @@
   margin: 10rpx 40rpx;
 }
 
+.buttons {
+  display: flex;
+  flex-direction: column;
+}
+
 .button {
-  margin: 10rpx;
+  margin: 20rpx;
 }
 
 .title2 {

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

@@ -9,7 +9,7 @@
 
 <view class="btn block-background-color" hover-class="btn-hover" bindtap="publishInfo">
   <image class="btn-icon" mode="aspectFit" src="/images/user/publish1.png"></image>
-  <view class="btn-text primary-text">发布息</view>
+  <view class="btn-text primary-text">发布息</view>
   <view class="btn-arrow secondary-text">></view>
 </view>
 

+ 1 - 84
miniprogram/pages/user/user.js

@@ -12,11 +12,6 @@ Page({
     pubInfo: []
   },
 
-  // bindGetUserInfo: function (e) {
-  //   app.globalData.userInfo = e.detail.userInfo
-  //   this.onShow()
-  // },
-
   setUserInfo: function () {
     this.setData({
       userInfo: app.globalData.userInfo,
@@ -111,48 +106,7 @@ Page({
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
-    // wx.showNavigationBarLoading()
-    // if (app.globalData.userInfo && app.globalData.publisherId) {
-    //   this.setData({
-    //     userInfo: app.globalData.userInfo,
-    //     hasUserInfo: true,
-    //     publisherId: app.globalData.publisherId
-    //   })
-    //   if (this.data.publisherId.length != 0) {
-    //     const db = wx.cloud.database()
-    //     db.collection("publisherInfoData").doc(this.data.publisherId[0]).get({
-    //       success: function (res) {
-    //         this.setData({
-    //           publisherName: res.data.publisherName
-    //         })
-    //         wx.hideNavigationBarLoading()
-    //       }.bind(this)
-    //     })
-    //   } else {
-    //     wx.hideNavigationBarLoading()
-    //   }
-    // } else {
-    //   app.userInfoReadyCallback = res => {
-    //     this.setData({
-    //       userInfo: res.userInfo,
-    //       hasUserInfo: true,
-    //       publisherId: app.globalData.publisherId
-    //     })
-    //     if (this.data.publisherId.length != 0) {
-    //       const db = wx.cloud.database()
-    //       db.collection("publisherInfoData").doc(this.data.publisherId[0]).get({
-    //         success: function (res) {
-    //           this.setData({
-    //             publisherName: res.data.publisherName
-    //           })
-    //           wx.hideNavigationBarLoading()
-    //         }.bind(this)
-    //       })
-    //     } else {
-    //       wx.hideNavigationBarLoading()
-    //     }
-    //   }
-    // }
+
   },
 
   /**
@@ -166,43 +120,6 @@ Page({
    * 生命周期函数--监听页面显示
    */
   onShow: function () {
-    // const db = wx.cloud.database()
-    // db.collection("userInfoData").get({
-    //   success: function (res) {
-    //     if (res.data.length == 0) {
-    //       db.collection("userInfoData").add({
-    //         data: {
-    //           publisherId: []
-    //         },
-    //         success: function (res) {
-    //           app.globalData.publisherId = []
-    //           this.setData({
-    //             userInfo: app.globalData.userInfo,
-    //             hasUserInfo: true,
-    //             publisherId: app.globalData.publisherId
-    //           })
-    //         }.bind(this)
-    //       })
-    //     } else {
-    //       app.globalData.publisherId = res.data[0].publisherId
-    //       this.setData({
-    //         userInfo: app.globalData.userInfo,
-    //         hasUserInfo: true,
-    //         publisherId: app.globalData.publisherId
-    //       })
-    //       if (this.data.publisherId.length != 0) {
-    //         db.collection("publisherInfoData").doc(this.data.publisherId[0]).get({
-    //           success: function (res) {
-    //             this.setData({
-    //               publisherName: res.data.publisherName
-    //             })
-    //           }.bind(this)
-    //         })
-    //       }
-    //     }
-    //   }.bind(this)
-    // })
-
     if (app.globalData.hasUserInfo) {
       this.setUserInfo()
     } else {