index.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. const app = getApp()
  2. Page({
  3. data: {
  4. spinShow: false,
  5. info: {}
  6. },
  7. onLoad: function(options) {
  8. this.loadUserInfo()
  9. },
  10. loadUserInfo() {
  11. let _this = this
  12. _this.setData({
  13. spinShow: true
  14. });
  15. app.formPost('/api/wx/student/user/current', null).then(res => {
  16. if (res.code == 1) {
  17. _this.setData({
  18. info: res.response
  19. });
  20. }
  21. _this.setData({
  22. spinShow: false
  23. });
  24. }).catch(e => {
  25. _this.setData({
  26. spinShow: false
  27. });
  28. app.message(e, 'error')
  29. })
  30. },
  31. logOut() {
  32. let _this = this
  33. _this.setData({
  34. spinShow: true
  35. });
  36. app.formPost('/api/wx/student/auth/unBind', null).then(res => {
  37. if (res.code == 1) {
  38. wx.setStorageSync('token', '')
  39. wx.reLaunch({
  40. url: '/pages/user/bind/index',
  41. });
  42. }
  43. _this.setData({
  44. spinShow: false
  45. });
  46. }).catch(e => {
  47. _this.setData({
  48. spinShow: false
  49. });
  50. app.message(e, 'error')
  51. })
  52. }
  53. })