aboutUs.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. Page({
  2. /**
  3. * 页面的初始数据
  4. */
  5. data: {
  6. currentTab: 0,
  7. winWidth: 0,
  8. winHeight: 0,
  9. inviteCode: "",
  10. publisherName: "",
  11. publisherContact: "",
  12. publisherIntro: "",
  13. publisherType: "",
  14. publisherAvatar: [],
  15. types: ["校级", "园级", "院级"],
  16. stars: ["一星级", "二星级", "三星级", "四星级", "五星级"],
  17. },
  18. stopTouchMove: function () {
  19. return false;
  20. },
  21. updateRadio: function (e) {
  22. this.setData({
  23. publisherType: e.detail.value
  24. })
  25. },
  26. updatePublishAvatar: function (e) {
  27. this.setData({
  28. publisherAvatar: e.detail.images
  29. })
  30. },
  31. switch1: function (e) {
  32. this.setData({
  33. currentTab: 1
  34. })
  35. },
  36. switch2: function (e) {
  37. this.setData({
  38. currentTab: 2
  39. })
  40. },
  41. switch3: function (e) {
  42. this.setData({
  43. currentTab: 3
  44. })
  45. },
  46. switch4: function (e) {
  47. this.setData({
  48. currentTab: 4
  49. })
  50. },
  51. switch4_1: function (e) {
  52. this.setData({
  53. currentTab: 41
  54. })
  55. },
  56. switchend: function (e) {
  57. if (this.data.inviteCode == "" || this.data.publisherName == "" || this.data.publisherContact == "" ||
  58. this.data.publisherIntro == "" || this.data.publisherType == "" || this.data.publisherAvatar.length == 0) {
  59. wx.showToast({
  60. title: "请确认信息填写完整",
  61. icon: "none"
  62. })
  63. return
  64. }
  65. const db = wx.cloud.database()
  66. const _ = db.command
  67. db.collection("inviteCodeData").where({
  68. code: this.data.inviteCode,
  69. used: false
  70. }).get({
  71. success: function (code) {
  72. if (code.data.length == 0) {
  73. wx.showToast({
  74. title: "邀请码不存在",
  75. icon: "none"
  76. })
  77. return
  78. }
  79. db.collection("publisherInfoData").where({
  80. publisherName: this.data.publisherName
  81. }).get({
  82. success: function (res) {
  83. if (res.data.length != 0) {
  84. wx.showToast({
  85. title: "名称已使用",
  86. icon: "none"
  87. })
  88. return
  89. }
  90. wx.showLoading({
  91. title: "入驻中"
  92. })
  93. wx.cloud.uploadFile({
  94. cloudPath: "publisherAvater/" + this.data.publisherName + '.jpg',
  95. filePath: this.data.publisherAvatar[0],
  96. success: function (res) {
  97. db.collection("publisherInfoData").add({
  98. data: {
  99. publisherAttribute: [this.data.currentTab == 2 ? "组织" : "社团"],
  100. publisherAvatar: res.fileID,
  101. publisherContact: this.data.publisherContact,
  102. publisherIntro: this.data.publisherIntro,
  103. publisherName: this.data.publisherName,
  104. publisherType: this.data.publisherType
  105. },
  106. success: function (res) {
  107. db.collection("inviteCodeData").doc(code.data[0]._id).update({
  108. data: {
  109. used: true,
  110. publisherId: res._id
  111. },
  112. success: function () {
  113. db.collection("userInfoData").get({
  114. success: function (user) {
  115. db.collection("userInfoData").doc(user.data[0]._id).update({
  116. data: {
  117. publisherId: _.push(res._id)
  118. },
  119. success: function () {
  120. this.setData({
  121. currentTab: end
  122. })
  123. wx.hideLoading()
  124. }.bind(this)
  125. })
  126. }.bind(this)
  127. })
  128. }.bind(this)
  129. })
  130. }.bind(this)
  131. })
  132. }.bind(this)
  133. })
  134. }.bind(this)
  135. })
  136. }.bind(this)
  137. })
  138. },
  139. returnToUser: function (e) {
  140. wx.navigateBack()
  141. },
  142. /**
  143. * 生命周期函数--监听页面加载
  144. */
  145. onLoad: function (e) {
  146. wx.getSystemInfo({
  147. success: function (res) {
  148. this.setData({
  149. winWidth: res.windowWidth
  150. })
  151. this.setData({
  152. winHeight: res.windowHeight
  153. })
  154. }.bind(this),
  155. })
  156. },
  157. updatePage: function (e) {
  158. this.setData({
  159. currentTab: e.detail.current
  160. })
  161. }
  162. })