shouye.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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|| data.hetongList.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. <!-- 合同 -->
  12. <hetongCardVue v-if="data.hetongList.length" :data="{...data.hetongList[0],iconsArr:data.iconsArr}"></hetongCardVue>
  13. </template>
  14. <view class="default-img-box" v-else>
  15. <icon :style="{ backgroundImage: 'url(' + data.defaultIndexImg + ')' }"></icon>
  16. <text>没有可培训的内容...</text>
  17. </view>
  18. <!-- 底部区域 -->
  19. <customTabbarClient :currentTab="0"></customTabbarClient>
  20. </view>
  21. </template>
  22. <script setup>
  23. import customNavbarVue from "@/components/custom-navbar/custom-navbar.vue";
  24. import kaoshiCardVue from '@/components/listCard/kaoshiCard.vue';
  25. import kechengCardVue from '@/components/listCard/kechengCard.vue';
  26. import lianxiCardVue from '@/components/listCard/lianxiCard.vue';
  27. import hetongCardVue from '@/components/listCard/hetongCard.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. hetongList: [],
  47. iconsArr: {
  48. timeIcon: '',
  49. numIcon: '',
  50. sumIcon: '',
  51. jgIcon: '',
  52. jzgsIcon: '',
  53. htJzIcon: '',
  54. htKhIcon: '',
  55. htTimeIcon: '',
  56. htZtIcon: '',
  57. },
  58. })
  59. function initPage() {
  60. httpApi.getAppIndexInfo().then(res => {
  61. const {
  62. kaoshiCount,
  63. kaoshiList,
  64. kechengCount,
  65. kechengList,
  66. lianxiCount,
  67. lianxiList,
  68. hetong
  69. } = res.data;
  70. data.kaoshiCount = kaoshiCount;
  71. data.kaoshiList = kaoshiList || [];
  72. data.kechengCount = kechengCount;
  73. data.kechengList = kechengList || [];
  74. data.lianxiCount = lianxiCount;
  75. data.lianxiList = lianxiList || [];
  76. data.hetongList = hetong ? [hetong] : [];
  77. console.log('data.hetongList',data.hetongList);
  78. })
  79. }
  80. onLoad(() => {
  81. const auth = cacheManager.get('auth');
  82. data.realName = auth.realName;
  83. data.defaultIndexImg = cacheManager.get('projectImg').index_default_img;
  84. data.iconsArr.timeIcon = cacheManager.get('projectImg').index_content_icon1;
  85. data.iconsArr.numIcon = cacheManager.get('projectImg').index_content_icon2;
  86. data.iconsArr.sumIcon = cacheManager.get('projectImg').index_content_icon3;
  87. data.iconsArr.jgIcon = cacheManager.get('projectImg').index_content_icon4;
  88. data.iconsArr.jzgsIcon = cacheManager.get('projectImg').jzgs_icon;
  89. data.iconsArr.htJzIcon = cacheManager.get('projectImg').user_green_icon;
  90. data.iconsArr.htKhIcon = cacheManager.get('projectImg').zymc_icon;
  91. data.iconsArr.htTimeIcon = cacheManager.get('projectImg').date_icon;
  92. data.iconsArr.htZtIcon = cacheManager.get('projectImg').htzt_icon;
  93. })
  94. onShow(() => {
  95. initPage();
  96. })
  97. </script>