conference.js 5.0 KB

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