homePage.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. <!--
  2. * @FileDescription: 首页
  3. * @Author: 黄琪勇
  4. * @Date:2024-03-29 17:20:39
  5. -->
  6. <template>
  7. <navContainer class="homePageNav" :headImg="headImg" :navs="navs">
  8. <div class="homePage">
  9. <ElScrollbar class="elScrollbar">
  10. <div class="classTypes">
  11. <div class="classType" v-for="item in classTypeObj[userStoreHook.roles!]" :key="item.name" @click="handleRouter(item.url)">
  12. <img :src="item.img" />
  13. <div>{{ item.name }}</div>
  14. </div>
  15. </div>
  16. <div class="courseBoard" :class="{ isEmpty: isEmptyClassData && !classDataLoading }">
  17. <div class="details">
  18. <div class="head">
  19. <div class="leftCon">
  20. <div class="line"></div>
  21. <div class="title">下次课程</div>
  22. </div>
  23. <img v-if="userStoreHook.roles !== 'KLX'" class="rightRouter" @click="handleRouterCurriculum" src="@/img/homePage/back.png" />
  24. </div>
  25. <el-skeleton class="elSkeleton" :loading="classDataLoading">
  26. <template #template>
  27. <el-skeleton-item class="elSkeletonItem" variant="p" />
  28. <el-skeleton-item class="elSkeletonItem" variant="p" />
  29. <el-skeleton-item class="elSkeletonItem" variant="h1" />
  30. <el-skeleton-item class="elSkeletonItem" variant="h1" />
  31. <div class="elSkeletonBtnCon">
  32. <el-skeleton-item class="elSkeletonItem" variant="button" />
  33. <el-skeleton-item class="elSkeletonItem" variant="button" />
  34. </div>
  35. <el-skeleton-item class="elSkeletonItem" variant="button" />
  36. </template>
  37. <template #default>
  38. <component
  39. v-if="!isEmptyClassData"
  40. :classData="classData"
  41. :is="userStoreHook.roles === 'GYM' ? curriculum_gym : curriculum_gyt"
  42. @update="handleClassData"
  43. />
  44. <el-empty v-else class="empty" :image="require('@/img/layout/empty1.png')" description="您还没有待上课程哦~" />
  45. </template>
  46. </el-skeleton>
  47. </div>
  48. </div>
  49. </ElScrollbar>
  50. </div>
  51. </navContainer>
  52. </template>
  53. <script setup lang="ts">
  54. import navContainer from "@/businessComponents/navContainer"
  55. import { useRouter } from "vue-router"
  56. import { ref, computed } from "vue"
  57. import useDialogConfirm from "@/hooks/useDialogConfirm"
  58. import userStore from "@/store/modules/user"
  59. import curriculum_gym from "./components/curriculum/curriculum_gym.vue"
  60. import curriculum_gyt from "./components/curriculum/curriculum_gyt.vue"
  61. import { getRemind_gyt, getRecentCourseSchedule_gym } from "@/api/homePage.api"
  62. import { httpAjax } from "@/plugin/httpAjax"
  63. import { format } from "@/libs/tools"
  64. const userStoreHook = userStore()
  65. const router = useRouter()
  66. const headImg = {
  67. img: require("@/img/homePage/home.png")
  68. }
  69. const navs = [
  70. {
  71. name: "主页"
  72. }
  73. ]
  74. const classTypes_gym = [
  75. {
  76. img: require("@/img/homePage/kb.png"),
  77. name: "课表",
  78. url: "/curriculum"
  79. },
  80. {
  81. img: require("@/img/homePage/xl.png"),
  82. name: "训练",
  83. url: ""
  84. },
  85. {
  86. img: require("@/img/homePage/jdcp.png"),
  87. name: "进度测评",
  88. url: ""
  89. },
  90. {
  91. img: require("@/img/homePage/xltj.png"),
  92. name: "训练统计",
  93. url: ""
  94. },
  95. {
  96. img: require("@/img/homePage/yjl.png"),
  97. name: "云练习",
  98. url: "/cloudPractice"
  99. },
  100. {
  101. img: require("@/img/homePage/yjc.png"),
  102. name: "云课堂",
  103. url: "/cloudTextbooks"
  104. }
  105. ]
  106. const classTypes_gyt = [
  107. {
  108. img: require("@/img/homePage/kb.png"),
  109. name: "课表",
  110. url: "/curriculum"
  111. },
  112. {
  113. img: require("@/img/homePage/xl.png"),
  114. name: "课后作业",
  115. url: ""
  116. },
  117. {
  118. img: require("@/img/homePage/jdzc.png"),
  119. name: "阶段自测",
  120. url: ""
  121. },
  122. {
  123. img: require("@/img/homePage/xltj.png"),
  124. name: "练习情况",
  125. url: ""
  126. },
  127. {
  128. img: require("@/img/homePage/yjl.png"),
  129. name: "云练习",
  130. url: "/cloudPractice"
  131. },
  132. {
  133. img: require("@/img/homePage/yjc.png"),
  134. name: "云课堂",
  135. url: "/cloudTextbooks"
  136. }
  137. ]
  138. const classTypes_klx = [
  139. {
  140. img: require("@/img/homePage/kb.png"),
  141. name: "课表",
  142. url: ""
  143. },
  144. {
  145. img: require("@/img/homePage/xl.png"),
  146. name: "训练",
  147. url: ""
  148. },
  149. {
  150. img: require("@/img/homePage/jdcp.png"),
  151. name: "进度测评",
  152. url: ""
  153. },
  154. {
  155. img: require("@/img/homePage/xltj.png"),
  156. name: "训练统计",
  157. url: ""
  158. },
  159. {
  160. img: require("@/img/homePage/yjl.png"),
  161. name: "云练习",
  162. url: "/cloudPractice"
  163. },
  164. {
  165. img: require("@/img/homePage/yjc.png"),
  166. name: "云课堂",
  167. url: "/cloudTextbooks"
  168. }
  169. ]
  170. const classTypeObj = {
  171. GYT: classTypes_gyt,
  172. GYM: classTypes_gym,
  173. KLX: classTypes_klx
  174. }
  175. /* 下次课程信息 */
  176. const classData = ref<Record<string, any>>({})
  177. const classDataLoading = ref(true)
  178. const isEmptyClassData = computed(() => {
  179. return !Object.keys(classData.value).length
  180. })
  181. // 现在酷乐秀没有课表功能
  182. if (userStoreHook.roles !== "KLX") {
  183. handleClassData()
  184. } else {
  185. classDataLoading.value = false
  186. }
  187. function handleClassData() {
  188. if (userStoreHook.roles === "GYM") {
  189. classDataLoading.value = true
  190. httpAjax(getRecentCourseSchedule_gym).then(res => {
  191. classDataLoading.value = false
  192. if (res.code === 200) {
  193. classData.value = res.data || {}
  194. }
  195. })
  196. } else {
  197. classDataLoading.value = true
  198. httpAjax(getRemind_gyt).then(res => {
  199. classDataLoading.value = false
  200. if (res.code === 200) {
  201. classData.value = res.data || {}
  202. }
  203. })
  204. }
  205. }
  206. function handleRouter(url?: string) {
  207. url
  208. ? router.push(url)
  209. : useDialogConfirm({
  210. headImg: require("@/img/homePage/ts.png"),
  211. text: "该功能暂未开放,敬请期待哦~",
  212. btnShow: [true]
  213. })
  214. }
  215. function handleRouterCurriculum() {
  216. router.push({
  217. path: "/curriculum",
  218. query: {
  219. date: classData.value.classDate ? format(classData.value.classDate) : ""
  220. }
  221. })
  222. }
  223. </script>
  224. <style lang="scss" scoped>
  225. .homePageNav.navContainer {
  226. &:deep(.navCon) {
  227. .navImg {
  228. margin-left: 50px;
  229. > img {
  230. width: 91px;
  231. height: 92px;
  232. top: 70%;
  233. }
  234. }
  235. .nav {
  236. font-size: 28px;
  237. font-family: AlimamaFangYuanTiVF, AlimamaFangYuanTiVF;
  238. &:last-child {
  239. margin-right: 30px;
  240. }
  241. }
  242. }
  243. }
  244. .homePage {
  245. width: 100%;
  246. height: 100%;
  247. & > :deep(.elScrollbar) {
  248. .el-scrollbar__view {
  249. width: 100%;
  250. display: flex;
  251. padding: 50px 50px 0;
  252. }
  253. .el-scrollbar__wrap {
  254. overflow-x: hidden;
  255. }
  256. }
  257. .classTypes {
  258. flex-grow: 1;
  259. display: flex;
  260. flex-wrap: wrap;
  261. justify-content: space-between;
  262. height: 729px;
  263. align-content: space-between;
  264. .classType {
  265. background: #feffff;
  266. box-shadow: 0px 2px 14px 0 #f1e3cc;
  267. border-radius: 34px;
  268. width: 360px;
  269. height: 350px;
  270. display: flex;
  271. justify-content: center;
  272. align-items: center;
  273. flex-direction: column;
  274. cursor: pointer;
  275. padding: 44px 53px;
  276. &:hover {
  277. transform: scale(1.02);
  278. box-shadow: 0px 2px 14px 0px #e4d7c2;
  279. }
  280. > div {
  281. margin-top: 10px;
  282. font-family: AlimamaFangYuanTiVF, AlimamaFangYuanTiVF;
  283. font-weight: bold;
  284. font-size: 28px;
  285. color: #393939;
  286. }
  287. > img {
  288. width: 100%;
  289. }
  290. }
  291. }
  292. .courseBoard {
  293. flex-shrink: 0;
  294. margin-left: 50px;
  295. margin-top: -35px;
  296. width: 572px;
  297. height: 764px;
  298. background: url("@/img/homePage/bg1.png") no-repeat;
  299. background-size: 100% 100%;
  300. position: relative;
  301. &.isEmpty {
  302. background: url("@/img/homePage/bg.png") no-repeat;
  303. background-size: 100% 100%;
  304. }
  305. .details {
  306. width: 100%;
  307. position: absolute;
  308. top: 88px;
  309. left: 0;
  310. padding: 0 30px;
  311. .head {
  312. height: 81px;
  313. display: flex;
  314. justify-content: space-between;
  315. align-items: center;
  316. padding: 0 30px;
  317. .leftCon {
  318. display: flex;
  319. align-items: center;
  320. .line {
  321. width: 8px;
  322. height: 28px;
  323. background: linear-gradient(180deg, #ffcb35 0%, #fea60a 100%), #ff6a67;
  324. border-radius: 7px;
  325. }
  326. .title {
  327. margin-left: 12px;
  328. font-family: AlimamaFangYuanTiVF, AlimamaFangYuanTiVF;
  329. font-weight: bold;
  330. font-size: 28px;
  331. color: #994d1c;
  332. }
  333. }
  334. .rightRouter {
  335. width: 38px;
  336. height: 38px;
  337. cursor: pointer;
  338. &:hover {
  339. opacity: $opacity-hover;
  340. }
  341. }
  342. }
  343. .elSkeleton {
  344. padding: 0 30px;
  345. display: flex;
  346. flex-direction: column;
  347. align-items: center;
  348. > .elSkeletonItem {
  349. &:nth-child(1) {
  350. margin-top: 25px;
  351. height: 34px;
  352. }
  353. &:nth-child(2) {
  354. width: 50%;
  355. margin-top: 58px;
  356. height: 60px;
  357. }
  358. &:nth-child(3) {
  359. margin-top: 34px;
  360. }
  361. &:nth-child(4) {
  362. margin-top: 34px;
  363. }
  364. &:nth-child(6) {
  365. width: 100%;
  366. height: 74px;
  367. margin-top: 58px;
  368. }
  369. }
  370. .elSkeletonBtnCon {
  371. width: 100%;
  372. margin-top: 76px;
  373. display: flex;
  374. justify-content: space-between;
  375. > .elSkeletonItem {
  376. width: 216px;
  377. height: 65px;
  378. }
  379. }
  380. }
  381. :deep(.empty) {
  382. margin-top: 114px;
  383. padding: 0;
  384. .el-empty__image {
  385. width: 360px;
  386. }
  387. }
  388. }
  389. }
  390. }
  391. </style>