conference.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. // pages/conference/conference.js
  2. const app = getApp()
  3. var host = app.globalData.host;
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. info:{},
  10. labels: {
  11. company: '单位', name: '姓名', tax_company: '发票单位', idcard: '身份证号',
  12. email: '邮箱', sex: '性别', age: '年龄', title: '职称',
  13. remark1: '备注1', remark2: '备注2', remark3: '备注3', phone:'手机号'
  14. },
  15. sex_array: ['男', '女'],
  16. sex: -1,
  17. phone:'',
  18. show:0
  19. },
  20. /**
  21. * 生命周期函数--监听页面加载
  22. */
  23. onLoad: function (options) {
  24. var that = this;
  25. wx.showNavigationBarLoading()
  26. var that = this;
  27. wx.getStorage({
  28. key: 'uid',
  29. success: res => {
  30. if (res.data) {
  31. this.setData({
  32. user_id: res.data
  33. })
  34. wx.request({
  35. url: host + '/api/detail',
  36. method: 'GET',
  37. data: {
  38. type: 'activity',
  39. id: options.id,
  40. uid: res.data
  41. },
  42. success: function (res) {
  43. wx.hideNavigationBarLoading();
  44. if(res.data.code != 0){
  45. wx.showToast({
  46. title: '服务器开小差啦!',
  47. icon: 'none'
  48. })
  49. return
  50. }
  51. const info = res.data.data
  52. if (info.sign_note) { info.sign_note = info.sign_note.replace(/\\n/, '\n') }
  53. that.setData({
  54. info: info
  55. })
  56. },
  57. fail: function () {
  58. wx.hideLoading();
  59. wx.showToast({
  60. title: '服务器开小差啦!',
  61. icon: 'none'
  62. })
  63. }
  64. })
  65. }
  66. },
  67. })
  68. },
  69. close: function () {
  70. this.setData({
  71. show: 0
  72. })
  73. },
  74. open: function () {
  75. this.setData({
  76. show: 1
  77. })
  78. },
  79. phoneChange: function (e) {
  80. this.setData({
  81. phone: e.detail.value
  82. })
  83. },
  84. sendcode: function () {
  85. if (this.data.phone.length < 11) {
  86. wx.showToast({
  87. title: '请输入正确的手机号',
  88. icon: 'none'
  89. })
  90. return;
  91. }
  92. wx.request({
  93. url: host + '/api/phcode',
  94. method: 'POST',
  95. data: { phone: this.data.phone },
  96. success: function (res) {
  97. if (res.data.code == 0) {
  98. wx.showToast({
  99. title: '验证码已发送',
  100. })
  101. } else {
  102. wx.showToast({
  103. title: '发送失败',
  104. icon: 'none'
  105. })
  106. }
  107. },
  108. })
  109. },
  110. bindSexChange: function (e) {
  111. this.setData({
  112. sex: e.detail.value
  113. })
  114. },
  115. //提交报名信息
  116. submit: function (e) {
  117. var form = e.detail.value;
  118. var list = this.data.list, index = this.data.index;
  119. if (this.data.info.signup_fields.indexOf('sex') >= 0) {
  120. form.sex = this.data.sex > -1 ? this.data.sex:''
  121. }
  122. form.uid = this.data.user_id;
  123. form.conference_id = this.data.info.id;
  124. form.conference_name = this.data.info.name;
  125. form.type ='activity';
  126. console.log(form)
  127. var fields = this.data.info.signup_fields;
  128. for(let i=0;i<fields.length;i++){
  129. if (!form[fields[i]]){
  130. wx.showToast({
  131. title: '请输入' + this.data.labels[fields[i]]+'!',
  132. icon: 'none'
  133. })
  134. return;
  135. }
  136. }
  137. if (!form.code) {
  138. wx.showToast({
  139. title: '请输入验证码!',
  140. icon: 'none'
  141. })
  142. return;
  143. }
  144. wx.showLoading({
  145. title: '正在提交',
  146. })
  147. wx.request({
  148. url: host + '/api/user/signup',
  149. method: 'POST',
  150. data: form,
  151. success: (res => {
  152. if (res.data.code == 0) {
  153. wx.hideLoading()
  154. this.setData({
  155. show: 0
  156. })
  157. wx.redirectTo({
  158. url: '../order/order',
  159. })
  160. } else {
  161. wx.showToast({
  162. title: '提交失败',
  163. icon: 'none'
  164. })
  165. }
  166. })
  167. })
  168. },
  169. /**
  170. * 生命周期函数--监听页面初次渲染完成
  171. */
  172. onReady: function () {
  173. },
  174. /**
  175. * 生命周期函数--监听页面显示
  176. */
  177. onShow: function () {
  178. },
  179. /**
  180. * 生命周期函数--监听页面隐藏
  181. */
  182. onHide: function () {
  183. },
  184. /**
  185. * 生命周期函数--监听页面卸载
  186. */
  187. onUnload: function () {
  188. },
  189. /**
  190. * 页面相关事件处理函数--监听用户下拉动作
  191. */
  192. onPullDownRefresh: function () {
  193. },
  194. /**
  195. * 页面上拉触底事件的处理函数
  196. */
  197. onReachBottom: function () {
  198. },
  199. /**
  200. * 用户点击右上角分享
  201. */
  202. onShareAppMessage: function () {
  203. }
  204. })