aboutUs.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. switch5: function (e) {
  52. this.setData({
  53. currentTab: 5
  54. })
  55. },
  56. switch6: function (e) {
  57. this.setData({
  58. currentTab: 6
  59. })
  60. },
  61. switchend: function (e) {
  62. if (this.data.inviteCode == "" || this.data.publisherName == "" || this.data.publisherContact == "" ||
  63. this.data.publisherIntro == "" || this.data.publisherType == "" || this.data.publisherAvatar.length == 0) {
  64. wx.showToast({
  65. title: "请确认信息填写完整",
  66. icon: "none"
  67. })
  68. return
  69. }
  70. const db = wx.cloud.database()
  71. const _ = db.command
  72. db.collection("inviteCodeData").where({
  73. code: this.data.inviteCode,
  74. used: false
  75. }).get({
  76. success: function (code) {
  77. if (code.data.length == 0) {
  78. wx.showToast({
  79. title: "邀请码不存在",
  80. icon: "none"
  81. })
  82. return
  83. }
  84. db.collection("publisherInfoData").where({
  85. publisherName: this.data.publisherName
  86. }).get({
  87. success: function (res) {
  88. if (res.data.length != 0) {
  89. wx.showToast({
  90. title: "名称已使用",
  91. icon: "none"
  92. })
  93. return
  94. }
  95. wx.showLoading({
  96. title: "入驻中"
  97. })
  98. wx.cloud.uploadFile({
  99. cloudPath: "publisherAvater/" + this.data.publisherName + '.jpg',
  100. filePath: this.data.publisherAvatar[0],
  101. success: function (res) {
  102. db.collection("publisherInfoData").add({
  103. data: {
  104. publisherAttribute: [this.data.currentTab == 2 ? "组织" : "社团"],
  105. publisherAvatar: res.fileID,
  106. publisherContact: this.data.publisherContact,
  107. publisherIntro: this.data.publisherIntro,
  108. publisherName: this.data.publisherName,
  109. publisherType: this.data.publisherType
  110. },
  111. success: function (res) {
  112. db.collection("inviteCodeData").doc(code.data[0]._id).update({
  113. data: {
  114. used: true,
  115. publisherId: res._id
  116. },
  117. success: function () {
  118. db.collection("userInfoData").get({
  119. success: function (user) {
  120. db.collection("userInfoData").doc(user.data[0]._id).update({
  121. data: {
  122. publisherId: _.push(res._id)
  123. },
  124. success: function () {
  125. this.setData({
  126. currentTab: end
  127. })
  128. wx.hideLoading()
  129. }.bind(this)
  130. })
  131. }.bind(this)
  132. })
  133. }.bind(this)
  134. })
  135. }.bind(this)
  136. })
  137. }.bind(this)
  138. })
  139. }.bind(this)
  140. })
  141. }.bind(this)
  142. })
  143. },
  144. returnToUser: function (e) {
  145. wx.navigateBack()
  146. },
  147. /**
  148. * 生命周期函数--监听页面加载
  149. */
  150. onLoad: function (e) {
  151. wx.getSystemInfo({
  152. success: function (res) {
  153. this.setData({
  154. winWidth: res.windowWidth
  155. })
  156. this.setData({
  157. winHeight: res.windowHeight
  158. })
  159. }.bind(this),
  160. })
  161. },
  162. updatePage: function (e) {
  163. this.setData({
  164. currentTab: e.detail.current
  165. })
  166. }
  167. })