index.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. define([
  2. 'api/auth',
  3. 'text!components/my/course/index.html',
  4. 'css!components/my/course/index.css'
  5. ], function(authApi, html) {
  6. return {
  7. props: {
  8. isLogin: {
  9. type: Boolean,
  10. default: false
  11. }
  12. },
  13. data: function () {
  14. return {
  15. page: 1,
  16. limit: 16,
  17. count: 0,
  18. specialList: [],
  19. finished: false
  20. };
  21. },
  22. watch: {
  23. isLogin: function (value) {
  24. if (value) {
  25. this.my_special_list();
  26. }
  27. }
  28. },
  29. methods: {
  30. // 课程列表
  31. my_special_list: function () {
  32. var vm = this;
  33. authApi.my_special_list({
  34. page: this.page,
  35. limit: this.limit
  36. }).then(function (res) {
  37. var data = res.data;
  38. vm.count = data.count;
  39. vm.specialList = data.list;
  40. vm.finished = vm.limit > data.list.length;
  41. }).catch(function (err) {
  42. vm.$message.error(err.msg);
  43. });
  44. }
  45. },
  46. template: html
  47. };
  48. });