home.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <view class="home">
  3. <view class="empty" v-if="domesticList.length == 0"></view>
  4. <view class="full" v-else>
  5. <listContent :main='domesticList'></listContent>
  6. <listContent :main='varietyList'></listContent>
  7. <listContent :main='americanList'></listContent>
  8. </view>
  9. </view>
  10. </template>
  11. <script>
  12. import listContent from "../../components/listContent.vue";
  13. import {
  14. Domestic,
  15. Variety,
  16. American
  17. } from '../../api/home.js';
  18. export default {
  19. onLoad() {
  20. uni.showLoading({
  21. title: '加载中',
  22. })
  23. this.getMain()
  24. },
  25. data() {
  26. return {
  27. domesticList: [],
  28. varietyList: [],
  29. americanList: []
  30. }
  31. },
  32. components: {
  33. listContent
  34. },
  35. methods: {
  36. async getMain() {
  37. let newList = [this.getList1(), this.getList2(), this.getList3()];
  38. let [data1, data2, data3] = await Promise.allSettled(newList);
  39. this.domesticList = data1;
  40. this.varietyList = data2;
  41. this.americanList = data3;
  42. uni.hideLoading();
  43. },
  44. async getList1() {
  45. return await Domestic({
  46. start: 0,
  47. count: 8
  48. })
  49. },
  50. async getList2() {
  51. return await Variety({
  52. start: 0,
  53. count: 8
  54. })
  55. },
  56. async getList3() {
  57. return await American({
  58. start: 0,
  59. count: 8
  60. })
  61. },
  62. }
  63. }
  64. </script>
  65. <style lang="scss">
  66. .home {
  67. padding: 20rpx;
  68. }
  69. </style>