index.vue 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <template>
  2. <view>
  3. <!-- 答题组件 -->
  4. <kz-question mode="TRAINING" title="收藏试题" :questions="list" v-show="!showNodata"></kz-question>
  5. <!-- 暂无数据 -->
  6. <tui-no-data imgUrl="/static/img/img_noorder_3x.png" v-if="showNodata">暂无数据</tui-no-data>
  7. <login ref="login" v-on:succ="ajax"></login>
  8. </view>
  9. </template>
  10. <script>
  11. export default {
  12. data() {
  13. return {
  14. list: [],
  15. total: 0,
  16. page: 1,
  17. over: 0,
  18. showNodata: false,
  19. }
  20. },
  21. onLoad() {
  22. this.ajax()
  23. },
  24. methods: {
  25. ajax() {
  26. this.http('question/collectList', {page:this.page}, 'get').then(res => {
  27. this.total = res.data.total;
  28. // this.choice[2] = res.data.total;
  29. var list = res.data.list.data;
  30. for (var i in list) {
  31. list[i]['log_id'] = list[i]['id']
  32. list[i]['collected'] = true
  33. // list[i]['code2'] = false;
  34. // list[i] = list[i].concat(list[i]['question'])
  35. list[i] = Object.assign(list[i], list[i]['question']);
  36. }
  37. this.list = this.list || [];
  38. this.list = this.list.concat(list);
  39. this.page++;
  40. if (!res.data.list.has_more) {
  41. this.over = 1;
  42. }
  43. this.showNodata = this.list.length == 0
  44. console.log('collect list', this.list)
  45. });
  46. },
  47. }
  48. }
  49. </script>
  50. <style>
  51. </style>