index.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. define([
  2. 'api/auth',
  3. 'text!./index.html',
  4. 'css!./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. total: 0,
  18. materialList: [],
  19. finished: false
  20. };
  21. },
  22. watch: {
  23. isLogin: function (value) {
  24. if (value) {
  25. this.my_material_list();
  26. }
  27. }
  28. },
  29. methods: {
  30. // 资料列表
  31. my_material_list: function () {
  32. var vm = this;
  33. authApi.my_material_list({
  34. page: this.page,
  35. limit: this.limit
  36. }).then(function (res) {
  37. var data = res.data;
  38. vm.total = data.count;
  39. vm.materialList = data.data;
  40. vm.finished = vm.limit > data.data.length;
  41. });
  42. }
  43. },
  44. template: html
  45. };
  46. });