index.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //index.js
  2. //获取应用实例
  3. const app = getApp()
  4. Page({
  5. data: {
  6. spinShow: false,
  7. fixedPaper: [],
  8. pushPaper: [],
  9. timeLimitPaper: [],
  10. taskList: []
  11. },
  12. onLoad: function() {
  13. this.setData({
  14. spinShow: true
  15. });
  16. this.indexLoad()
  17. },
  18. onPullDownRefresh() {
  19. this.setData({
  20. spinShow: true
  21. });
  22. if (!this.loading) {
  23. this.indexLoad()
  24. }
  25. },
  26. indexLoad: function() {
  27. let _this = this
  28. app.formPost('/api/wx/student/dashboard/index', null).then(res => {
  29. _this.setData({
  30. spinShow: false
  31. });
  32. wx.stopPullDownRefresh()
  33. if (res.code === 1) {
  34. _this.setData({
  35. fixedPaper: res.response.fixedPaper,
  36. timeLimitPaper: res.response.timeLimitPaper,
  37. pushPaper: res.response.pushPaper
  38. });
  39. }
  40. }).catch(e => {
  41. _this.setData({
  42. spinShow: false
  43. });
  44. app.message(e, 'error')
  45. })
  46. app.formPost('/api/wx/student/dashboard/task', null).then(res => {
  47. _this.setData({
  48. spinShow: false
  49. });
  50. wx.stopPullDownRefresh()
  51. if (res.code === 1) {
  52. _this.setData({
  53. taskList: res.response,
  54. });
  55. }
  56. }).catch(e => {
  57. _this.setData({
  58. spinShow: false
  59. });
  60. app.message(e, 'error')
  61. })
  62. }
  63. })