index.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. const app = getApp()
  2. Page({
  3. data: {
  4. levelIndex: 0
  5. },
  6. bindLevelChange: function (e) {
  7. this.setData({
  8. levelIndex: e.detail.value
  9. })
  10. },
  11. formSubmit: function(e) {
  12. let _this = this;
  13. let form = e.detail.value
  14. if (form.userName == null || form.userName == '') {
  15. app.message('用户名不能为空', 'error');
  16. return;
  17. }
  18. if (form.password == null || form.password == '') {
  19. app.message('密码不能为空', 'error');
  20. return;
  21. }
  22. if (form.userLevel == null || form.userLevel == '') {
  23. app.message('年级不能为空', 'error');
  24. return;
  25. }
  26. _this.setData({
  27. spinShow: true
  28. });
  29. app.formPost('/api/wx/student/user/register', form)
  30. .then(res => {
  31. _this.setData({
  32. spinShow: false
  33. });
  34. if (res.code == 1) {
  35. wx.reLaunch({
  36. url: '/pages/user/bind/index',
  37. });
  38. } else {
  39. app.message(res.message, 'error')
  40. }
  41. }).catch(e => {
  42. _this.setData({
  43. spinShow: false
  44. });
  45. app.message(e, 'error')
  46. })
  47. }
  48. })