shouye.vue 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <template>
  2. <view class="client-shouye-page">
  3. <customNavbarVue title="首页"></customNavbarVue>
  4. <template v-if="data.kaoshiList.length||data.lianxiList.length||data.kechengList.length">
  5. <!-- 考试 -->
  6. <kaoshiCardVue v-if="data.kaoshiList.length" :data="{ count: data.kaoshiCount, ...data.kaoshiList[0],iconsArr:data.iconsArr}"></kaoshiCardVue>
  7. <!-- 练习 -->
  8. <lianxiCardVue v-if="data.lianxiList.length" :data="{ count: data.lianxiCount,...data.lianxiList[0],iconsArr:data.iconsArr}"></lianxiCardVue>
  9. <!-- 课程 -->
  10. <kechengCardVue v-if="data.kechengList.length" :data="{ count: data.kechengCount,...data.kechengList[0],iconsArr:data.iconsArr}"></kechengCardVue>
  11. </template>
  12. <view class="default-img-box" v-else>
  13. <icon :style="{ backgroundImage: 'url(' + data.defaultIndexImg + ')' }"></icon>
  14. <text>没有可培训的内容...</text>
  15. </view>
  16. <!-- 底部区域 -->
  17. <customTabbarClient :currentTab="0"></customTabbarClient>
  18. </view>
  19. </template>
  20. <script setup>
  21. import customNavbarVue from "@/components/custom-navbar/custom-navbar.vue";
  22. import kaoshiCardVue from '@/components/listCard/kaoshiCard.vue';
  23. import kechengCardVue from '@/components/listCard/kechengCard.vue';
  24. import lianxiCardVue from '@/components/listCard/lianxiCard.vue';
  25. import customTabbarClient from "@/components/custom-tabbar/custom-tabbar-client.vue"
  26. import * as httpApi from "@/api/shouye.js"
  27. import {
  28. onLoad, onShow
  29. } from "@dcloudio/uni-app"
  30. import {
  31. reactive
  32. } from "vue"
  33. import cacheManager from '@/utils/cacheManager.js'
  34. const data = reactive({
  35. kaoshiCount: 0,
  36. kaoshiList: [],
  37. kechengCount: 0,
  38. kechengList: [],
  39. lianxiCount: 0,
  40. lianxiList: [],
  41. realName: '',
  42. defaultIndexImg: '',
  43. iconsArr: {
  44. timeIcon: '',
  45. numIcon: '',
  46. sumIcon: '',
  47. jgIcon: '',
  48. },
  49. })
  50. function initPage() {
  51. httpApi.getAppIndexInfo().then(res => {
  52. const {
  53. kaoshiCount,
  54. kaoshiList,
  55. kechengCount,
  56. kechengList,
  57. lianxiCount,
  58. lianxiList
  59. } = res.data;
  60. data.kaoshiCount = kaoshiCount;
  61. data.kaoshiList = kaoshiList || [];
  62. data.kechengCount = kechengCount;
  63. data.kechengList = kechengList || [];
  64. data.lianxiCount = lianxiCount;
  65. data.lianxiList = lianxiList || [];
  66. })
  67. }
  68. onLoad(() => {
  69. const auth = cacheManager.get('auth');
  70. data.realName = auth.realName;
  71. data.defaultIndexImg = cacheManager.get('projectImg').index_default_img;
  72. data.iconsArr.timeIcon = cacheManager.get('projectImg').index_content_icon1;
  73. data.iconsArr.numIcon = cacheManager.get('projectImg').index_content_icon2;
  74. data.iconsArr.sumIcon = cacheManager.get('projectImg').index_content_icon3;
  75. data.iconsArr.jgIcon = cacheManager.get('projectImg').index_content_icon4;
  76. })
  77. onShow(() => {
  78. initPage();
  79. })
  80. </script>