HomePage.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. <template>
  2. <div class="home-container">
  3. <div class="box-1">
  4. <div class="inner-box left-box">
  5. <span>京华实验学校</span>
  6. <div class="dropdown-box">
  7. <!-- 下拉菜单 -->
  8. <el-dropdown v-model="selectedGrade">
  9. <el-button type="primary">
  10. {{ selectedGrade
  11. }}<el-icon class="el-icon--right"><arrow-down /></el-icon>
  12. </el-button>
  13. <template #dropdown>
  14. <el-dropdown-menu class="dropdown-menu">
  15. <el-dropdown-item>小学低年级</el-dropdown-item>
  16. <el-dropdown-item>小学高年级</el-dropdown-item>
  17. </el-dropdown-menu>
  18. </template>
  19. </el-dropdown>
  20. </div>
  21. </div>
  22. <div class="inner-box right-box">
  23. <div class="top-right-box">
  24. <el-button
  25. round
  26. class="top-right-btn"
  27. :class="{ 'is-active': selectedButton === 'AI通识课' }"
  28. @click="selectedButton = 'AI通识课'"
  29. >AI通识课</el-button
  30. >
  31. <el-button
  32. round
  33. class="top-right-btn"
  34. :class="{ 'is-active': selectedButton === 'AI写作课' }"
  35. @click="selectedButton = 'AI写作课'"
  36. >AI写作课</el-button
  37. >
  38. <el-button
  39. round
  40. class="top-right-btn"
  41. :class="{ 'is-active': selectedButton === 'AI艺术课' }"
  42. @click="selectedButton = 'AI艺术课'"
  43. >AI艺术课</el-button
  44. >
  45. </div>
  46. </div>
  47. </div>
  48. <div class="box-2">
  49. <div
  50. class="left-box-in-box2"
  51. @click="goToAIGeneralCourse('AI智能课')"
  52. :style="{ backgroundImage: `url(${indexImages[0]})` }"
  53. >
  54. <span>智能课</span>
  55. </div>
  56. <div
  57. class="center-box-in-box2"
  58. :style="{ backgroundImage: `url(${indexImages[1]})` }"
  59. >
  60. <span>AI实验室</span>
  61. </div>
  62. <div class="right-box-in-box2">
  63. <div
  64. class="top-sub-box"
  65. :style="{ backgroundImage: `url(${indexImages[2]})` }"
  66. >
  67. <span>能力测评</span>
  68. </div>
  69. <div
  70. class="bottom-sub-box"
  71. :style="{ backgroundImage: `url(${indexImages[3]})` }"
  72. >
  73. <span>个性化学习</span>
  74. </div>
  75. </div>
  76. </div>
  77. </div>
  78. </template>
  79. <script setup>
  80. import { ref } from 'vue'
  81. import { useRouter } from 'vue-router'
  82. // import { ClassList } from '@/api/class.js'
  83. import { ArrowDown, ArrowRightBold } from '@element-plus/icons-vue'
  84. import { Search, ArrowLeftBold } from '@element-plus/icons-vue'
  85. // 默认选中 AI 通识课
  86. const selectedButton = ref('AI通识课')
  87. // 获取当前路由对象
  88. const router = useRouter()
  89. // 添加图片路径
  90. const indexImages = ref([
  91. './src/assets/images/intelligence.png',
  92. './src/assets/images/room.png',
  93. './src/assets/images/test.png',
  94. './src/assets/images/study.png'
  95. ])
  96. const goToAIGeneralCourse = (title) => {
  97. router.push({ path: '/ai-general-course', query: { title } });
  98. };
  99. // 添加下拉菜单选中项
  100. const selectedGrade = ref('小学低年级')
  101. // 获取年级
  102. // ClassList().then(res=>{
  103. // console.log(res);
  104. // })
  105. </script>
  106. <style scoped lang="scss">
  107. @use 'sass:math';
  108. // 定义rpx转换函数
  109. @function rpx($px) {
  110. @return math.div($px, 750) * 100vw;
  111. }
  112. .home-container {
  113. position: fixed;
  114. top: 0;
  115. left: 0;
  116. right: 0;
  117. bottom: 0;
  118. background: linear-gradient(to bottom, #08105e, #8271c8);
  119. display: flex;
  120. flex-direction: column;
  121. gap: rpx(0);
  122. }
  123. .box-1 {
  124. width: 100%;
  125. flex: 0.3;
  126. display: flex;
  127. justify-content: center;
  128. align-items: center;
  129. box-sizing: border-box;
  130. font-size: rpx(16); // 默认字体大小
  131. }
  132. .box-2 {
  133. width: 100%;
  134. flex: 2;
  135. display: flex;
  136. justify-content: space-between;
  137. align-items: center;
  138. box-shadow: 0 4px 8px rgba(202, 52, 52, 0.1);
  139. box-sizing: border-box;
  140. padding: 0 rpx(20); // 添加左右内边距
  141. cursor: pointer; // 添加鼠标指针样式
  142. }
  143. .box-2 span {
  144. // 添加 padding,使文字距上边和左边留有间距
  145. padding: rpx(10) 0 0 rpx(10);
  146. font-size: rpx(12); // 默认字体大小
  147. color: white;
  148. }
  149. .left-box-in-box2,
  150. .center-box-in-box2 {
  151. background-color: rgba(133, 135, 176, 0.5);
  152. border-radius: rpx(20);
  153. flex: 1; // 让三个盒子平均分配空间
  154. margin: 0 rpx(10); // 添加左右间距
  155. height: 75%; // 高度占满容器
  156. display: flex;
  157. justify-content: flex-start;
  158. align-items: flex-start;
  159. }
  160. .left-box-in-box2:hover,
  161. .left-box-in-box2:active,
  162. .center-box-in-box2:hover,
  163. .center-box-in-box2:active {
  164. box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
  165. }
  166. .left-box-in-box2, .center-box-in-box2, .top-sub-box, .bottom-sub-box {
  167. background-repeat: no-repeat;
  168. background-size: cover;
  169. background-position: center;
  170. }
  171. .right-box-in-box2 {
  172. flex: 1; // 让三个盒子平均分配空间
  173. margin: 0 rpx(10); // 添加左右间距
  174. height: 75%; // 高度占满容器
  175. display: flex;
  176. // 确保两个子盒子上下排列
  177. flex-direction: column;
  178. justify-content: flex-start;
  179. align-items: flex-start;
  180. gap: rpx(10);
  181. }
  182. .top-sub-box,
  183. .bottom-sub-box {
  184. background-color: rgba(133, 135, 176, 0.5);
  185. flex: 1; // 让两个子盒子平均分配空间;
  186. display: flex;
  187. border-radius: rpx(20);
  188. width: 100%; // 宽度占满容器;
  189. }
  190. .top-sub-box:hover,
  191. .top-sub-box:active,
  192. .bottom-sub-box:hover,
  193. .bottom-sub-box:active {
  194. box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
  195. }
  196. .inner-box {
  197. height: 100%;
  198. display: flex;
  199. justify-content: center;
  200. align-items: center;
  201. font-size: rpx(16); // 默认字体大小
  202. }
  203. .left-box {
  204. position: relative;
  205. justify-content: space-between;
  206. align-items: flex-start;
  207. flex: 1; // 设置左侧盒子占比为 2
  208. // background-color: #fff;
  209. }
  210. .left-box span {
  211. position: absolute;
  212. margin-top: rpx(20); // 调整上边距离
  213. margin-left: rpx(25);
  214. font-size: rpx(11); // 默认字体大小
  215. color: white;
  216. }
  217. .right-box {
  218. flex: 2;
  219. position: relative; // 添加相对定位;
  220. }
  221. .top-right-box {
  222. position: absolute; // 添加绝对定位
  223. margin-right: rpx(35);
  224. width: 100%; // 设置盒子宽度,可按需调整
  225. height: 60px; // 设置盒子高度,可按需调整
  226. display: flex;
  227. justify-content: flex-end;
  228. cursor: pointer; // 添加鼠标指针样式
  229. }
  230. .top-right-btn {
  231. width: rpx(65); // 使用 rpx 函数设置按钮宽度
  232. height: rpx(15); // 使用 rpx 函数设置按钮高度
  233. margin: rpx(10) rpx(10) 0 0; // 使用 rpx 函数设置外边距
  234. background-color: #8587b0;
  235. color: white;
  236. border: none; // 移除默认边框
  237. font-size: rpx(7); // 使用 rpx 函数设置字体大小
  238. outline: none; // 移除默认的外边框
  239. }
  240. .top-right-btn.is-active,
  241. .top-right-btn:active,
  242. .top-right-btn:focus {
  243. background-color: white; // 点击选中后白色背景色
  244. color: black;
  245. border: none; // 移除点击时的边框
  246. outline: none; // 移除点击时的外边框
  247. box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
  248. }
  249. .dropdown-box {
  250. width: 100%;
  251. height: 100%;
  252. display: flex; // 添加 flex 布局;
  253. flex: 1;
  254. align-items: center; // 垂直居中;
  255. padding-left: rpx(25); // 添加右侧内边距;
  256. margin-top: rpx(25);
  257. }
  258. .dropdown-box .el-button {
  259. width: rpx(65); // 设置按钮宽度;
  260. height: rpx(15); // 设置按钮高度;
  261. background-color: white;
  262. color: black;
  263. border-radius: rpx(12);
  264. font-size: rpx(7); // 设置字体大小;
  265. }
  266. .dropdown-box .el-button:hover,
  267. .dropdown-box .el-button:focus,
  268. .dropdown-box .el-button:active {
  269. border: none; /* 移除悬停、聚焦、点击状态下的边框 */
  270. outline: none; /* 移除悬停、聚焦、点击状态下的轮廓线 el-scrollbar__view el-dropdown__list */
  271. }
  272. .dropdown-menu {
  273. width: rpx(100);
  274. height: rpx(50);
  275. border-radius: rpx(6);
  276. background-color: rgba(165, 209, 247, 0.5);
  277. box-shadow: 0 4px 8px rgba(202, 52, 52, 0.1);
  278. }
  279. // .el-dropdown__popper.el-popper
  280. .dropdown-menu ::v-deep(.el-dropdown-menu__item) {
  281. font-size: rpx(8);
  282. color: black;
  283. border-radius: rpx(6);
  284. width: rpx(78);
  285. height: rpx(15);
  286. margin-left: rpx(4);
  287. margin-bottom: rpx(8);
  288. }
  289. .dropdown-menu ::v-deep(.el-dropdown-menu__item:hover),
  290. .dropdown-menu ::v-deep(.el-dropdown-menu__item:focus),
  291. .dropdown-menu ::v-deep(.el-dropdown-menu__item:active) {
  292. background: linear-gradient(
  293. to bottom,
  294. #fee78a,
  295. #ffce1b
  296. ); /* 设置悬停、聚焦、点击状态下的背景色 */
  297. }
  298. </style>