| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- currentTab:0,
- winWidth:0,
- winHeight:0,
- inviteCode:"",
- publisherName:"",
- publisherContact:"",
- publisherIntro:"",
- publisherType:"",
- publisherAvatar:[],
- types:["校级", "园级", "院级"],
- stars:["一星级", "二星级", "三星级", "四星级", "五星级"],
- },
- stopTouchMove:function(){
- return false;
- },
- updateRadio:function(e){
- this.setData({publisherType: e.detail.value})
- },
- updatePublishAvatar:function(e){
- this.setData({publisherAvatar: e.detail.images})
- },
- switch1:function(e){
- this.setData({currentTab:1})
- },
- switch2:function(e){
- this.setData({currentTab:2})
- },
- switch3:function(e){
- this.setData({currentTab:3})
- },
- switch4:function(e){
- this.setData({currentTab:4})
- },
- switchend:function(e){
- if (this.data.inviteCode == "" || this.data.publisherName == "" || this.data.publisherContact == "" ||
- this.data.publisherIntro == "" || this.data.publisherType == "" || this.data.publisherAvatar.length == 0) {
- wx.showToast({
- title: "请确认信息填写完整",
- icon: "none"
- })
- 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:end})
- wx.hideLoading()
- }.bind(this)
- })
- }.bind(this)
- })
- }.bind(this)
- })
- }.bind(this)
- })
- }.bind(this)
- })
- }.bind(this)
- })
- }.bind(this)
- })
- },
- returnToUser:function(e){
- wx.navigateBack()
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (e) {
- wx.getSystemInfo({
- success: function (res) {
- this.setData({winWidth:res.windowWidth})
- this.setData({winHeight:res.windowHeight})
- }.bind(this),
- })
- },
-
- updatePage: function(e) {
- this.setData({
- currentTab: e.detail.current
- })
- }
- })
|