HomePage.vue 8.4 KB

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