shouye.vue 2.8 KB

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