HomePage.vue 8.2 KB

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