template.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <view class="app-page flex flex-col">
  3. <view v-if="loading != 'success'" class="loading-wrap">
  4. <block v-if="loading == 'loading'">
  5. <tm-skeleton model="card"></tm-skeleton>
  6. <tm-skeleton model="cardActions"></tm-skeleton>
  7. <tm-skeleton model="list"></tm-skeleton>
  8. <tm-skeleton model="listAvatr"></tm-skeleton>
  9. <tm-skeleton model="listAvatr"></tm-skeleton>
  10. <tm-skeleton model="listAvatr"></tm-skeleton>
  11. </block>
  12. <view v-else-if="loading == 'error'" class="loading-error flex flex-col flex-center">
  13. <tm-empty icon="icon-wind-cry" label="加载失败"><tm-button theme="light-blue" size="m" @click="fnGetData()">重新加载</tm-button></tm-empty>
  14. </view>
  15. </view>
  16. <block v-else><!-- 内容区域 --></block>
  17. </view>
  18. </template>
  19. <script>
  20. import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
  21. import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue';
  22. import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
  23. export default {
  24. components: {
  25. tmSkeleton,
  26. tmButton,
  27. tmEmpty
  28. },
  29. data() {
  30. return {
  31. loading: 'loading',
  32. queryParams: {
  33. size: 10,
  34. page: 0
  35. },
  36. result: null
  37. };
  38. },
  39. onLoad() {
  40. this.fnSetPageTitle();
  41. },
  42. created() {
  43. this.fnGetData();
  44. },
  45. onPullDownRefresh() {
  46. this.fnGetData();
  47. },
  48. methods: {
  49. fnGetData() {
  50. this.loading = 'loading';
  51. uni.showLoading({
  52. mask: true,
  53. title: '加载中...'
  54. });
  55. this.$httpApi.admin
  56. .getAttachmentsByPage(this.queryParams)
  57. .then(res => {
  58. console.log('请求结果:');
  59. console.log(res);
  60. // this.result = res.data.xxx;
  61. setTimeout(() => {
  62. this.loading = 'success';
  63. }, 500);
  64. })
  65. .catch(err => {
  66. console.error(err);
  67. this.loading = 'error';
  68. })
  69. .finally(() => {
  70. setTimeout(() => {
  71. uni.hideLoading();
  72. uni.stopPullDownRefresh();
  73. }, 500);
  74. });
  75. }
  76. }
  77. };
  78. </script>
  79. <style lang="scss" scoped>
  80. .app-page {
  81. width: 100vw;
  82. min-height: 100vh;
  83. }
  84. .loading-wrap {
  85. padding: 24rpx;
  86. .loading-error {
  87. height: 65vh;
  88. }
  89. }
  90. </style>