register.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. import {
  2. iactivity
  3. } from '../../../api/api.js'
  4. const app = getApp()
  5. Page({
  6. data: {
  7. gender: 1,
  8. age_range: ''
  9. },
  10. clickRegister() {
  11. if (!this.data.realname) {
  12. return wx.showToast({
  13. icon: 'loading',
  14. title: '请填写姓名!'
  15. })
  16. }
  17. if (!this.data.age_range) {
  18. return wx.showToast({
  19. icon: 'loading',
  20. title: '请选择年龄段!'
  21. })
  22. }
  23. if (!this.data.mobile || this.data.mobile.length != 11) {
  24. return wx.showToast({
  25. icon: 'loading',
  26. title: '请正确填写手机号!'
  27. })
  28. }
  29. if (!this.data.address) {
  30. return wx.showToast({
  31. icon: 'loading',
  32. title: '请填写地址!'
  33. })
  34. }
  35. // iactivity.loadJoinin(this.data, r => {
  36. // app.data.nav.joininActivityInfo = r.info
  37. // wx.navigateTo({
  38. // url: '../registerDone/registerDone'
  39. // })
  40. // })
  41. // console.log(this.data);
  42. let {event_id,address,age_range,mobile,gender,realname} = this.data
  43. iactivity.loadSaveApply({
  44. reqdata: {
  45. activityId: event_id-0,
  46. address: address,
  47. generation: age_range,
  48. phone: mobile,
  49. sex: gender,
  50. userId: wx.getStorageSync('id'),
  51. username: realname
  52. }
  53. }, r => {
  54. wx.reLaunch({
  55. url: '/pages/home/home',
  56. success: () => {
  57. wx.showToast({
  58. title: '参加活动成功!',
  59. icon: 'none'
  60. })
  61. }
  62. })
  63. })
  64. },
  65. clickRadio(e) {
  66. this.setData({
  67. gender: e.currentTarget.dataset.v
  68. })
  69. },
  70. clickAgegroup(e) {
  71. this.setData({
  72. showAgegroupModal: true
  73. })
  74. },
  75. clickAgegroupModalCancel() {
  76. this.setData({
  77. showAgegroupModal: false
  78. })
  79. },
  80. clickAgegroupItem(e) {
  81. this.setData({
  82. age_range: e.currentTarget.dataset.agegroup,
  83. showAgegroupModal: false
  84. })
  85. },
  86. inputName(e) {
  87. this.setData({
  88. realname: e.detail.value
  89. })
  90. },
  91. inputPhoneno(e) {
  92. this.setData({
  93. mobile: e.detail.value
  94. })
  95. },
  96. inputAddress(e) {
  97. this.setData({
  98. address: e.detail.value
  99. })
  100. },
  101. onLoad(opts) {
  102. this.setData({
  103. event_id: opts.id
  104. })
  105. }
  106. })