|
@@ -1,3 +1,5 @@
|
|
|
|
|
+const util = require('../../utils/util.js')
|
|
|
|
|
+
|
|
|
Page({
|
|
Page({
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -7,101 +9,41 @@ Page({
|
|
|
currentTab: 0,
|
|
currentTab: 0,
|
|
|
winWidth: 0,
|
|
winWidth: 0,
|
|
|
winHeight: 0,
|
|
winHeight: 0,
|
|
|
- activityName: "",
|
|
|
|
|
- activitySubTitle: "",
|
|
|
|
|
- activityTime: "",
|
|
|
|
|
- activityPlace: "",
|
|
|
|
|
- activityContact: "",
|
|
|
|
|
- activityAim: "",
|
|
|
|
|
- activityDetail: "",
|
|
|
|
|
|
|
+ activityName: '',
|
|
|
|
|
+ activitySubTitle: '',
|
|
|
|
|
+ activityTime: '',
|
|
|
|
|
+ activityPlace: '',
|
|
|
|
|
+ activityContact: '',
|
|
|
|
|
+ activityAim: '',
|
|
|
|
|
+ activityDetail: '',
|
|
|
activityPoster: [],
|
|
activityPoster: [],
|
|
|
activityPicture: [],
|
|
activityPicture: [],
|
|
|
- activityProInfo: "",
|
|
|
|
|
- activitySrc: "",
|
|
|
|
|
|
|
+ activityProInfo: '',
|
|
|
|
|
+ activitySrc: '',
|
|
|
activityAttr: [],
|
|
activityAttr: [],
|
|
|
activitySupply: [],
|
|
activitySupply: [],
|
|
|
- recruitName: "",
|
|
|
|
|
- recruitSubTitle: "",
|
|
|
|
|
- recruitTime: "",
|
|
|
|
|
- recruitAttr: "",
|
|
|
|
|
- recruitContact: "",
|
|
|
|
|
- recruitAim: "",
|
|
|
|
|
- recruitDetail: "",
|
|
|
|
|
|
|
+ recruitName: '',
|
|
|
|
|
+ recruitSubTitle: '',
|
|
|
|
|
+ recruitTime: '',
|
|
|
|
|
+ recruitAttr: '',
|
|
|
|
|
+ recruitContact: '',
|
|
|
|
|
+ recruitAim: '',
|
|
|
|
|
+ recruitDetail: '',
|
|
|
recruitPoster: [],
|
|
recruitPoster: [],
|
|
|
recruitPicture: [],
|
|
recruitPicture: [],
|
|
|
- recruitProInfo: "",
|
|
|
|
|
- recruitSrc: "",
|
|
|
|
|
- notiName: "",
|
|
|
|
|
- notiSubTitle: "",
|
|
|
|
|
|
|
+ recruitProInfo: '',
|
|
|
|
|
+ recruitSrc: '',
|
|
|
|
|
+ notiName: '',
|
|
|
|
|
+ notiSubTitle: '',
|
|
|
notiAttr: [],
|
|
notiAttr: [],
|
|
|
- notiAim: "",
|
|
|
|
|
- notiDetail: "",
|
|
|
|
|
|
|
+ notiAim: '',
|
|
|
|
|
+ notiDetail: '',
|
|
|
notiPoster: [],
|
|
notiPoster: [],
|
|
|
notiPicture: [],
|
|
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) {
|
|
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({
|
|
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()
|
|
wx.navigateBack()
|
|
|
},
|
|
},
|
|
|
|
|
|
|
@@ -258,11 +252,5 @@ Page({
|
|
|
})
|
|
})
|
|
|
}.bind(this),
|
|
}.bind(this),
|
|
|
})
|
|
})
|
|
|
- },
|
|
|
|
|
-
|
|
|
|
|
- updatePage: function (e) {
|
|
|
|
|
- this.setData({
|
|
|
|
|
- currentTab: e.detail.current
|
|
|
|
|
- })
|
|
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|