index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <template>
  2. <Container title="首页" :showBack="false">
  3. <view class="home">
  4. <!-- 倒计时 -->
  5. <view class="time">
  6. <view>倒计时</view>
  7. <view>151天</view>
  8. </view>
  9. <!-- 轮播图 -->
  10. <swiper class="swiper" circular autoplay>
  11. <swiper-item v-for="(item, index) in banner_list" :key="index">
  12. <view class="swiper-item"><image class="swiper-item-image" :src="item.image_url" mode="aspectFill"></image></view>
  13. </swiper-item>
  14. </swiper>
  15. <!-- 公告 -->
  16. <view class="notice">
  17. <view class="title">公告</view>
  18. <view>这是公告</view>
  19. </view>
  20. <!-- 2025新大纲 -->
  21. <view class="new_outline">
  22. <uni-section title="基础用法" type="line">
  23. <view class="p-20">
  24. <uni-segmented-control
  25. :flex="false"
  26. :current="current"
  27. :values="items"
  28. style-type="text"
  29. @clickItem="(e) => (current = e.currentIndex)"
  30. />
  31. <!-- 执业药师 -->
  32. <template v-for="(item, index) in list" :key="item.id">
  33. <view v-if="current === index" class="grid">
  34. <view
  35. v-for="i in item?.children"
  36. class="flex"
  37. @click="clickClass(i)"
  38. >
  39. <view class="bg-red"></view>
  40. <view> {{ i.name }} </view>
  41. </view>
  42. </view>
  43. </template>
  44. </view>
  45. </uni-section>
  46. </view>
  47. </view>
  48. <uni-section title="往年真题" type="line">
  49. <!-- 往年真题 -->
  50. <view class="grid-3">
  51. <view
  52. v-for="item in 7"
  53. class="flex"
  54. @click="
  55. toReal({
  56. title: '2025真题',
  57. })
  58. "
  59. >
  60. <view class="bg-red"></view>
  61. <view> 执业药师{{ item }} </view>
  62. </view>
  63. </view>
  64. </uni-section>
  65. </Container>
  66. </template>
  67. <script setup>
  68. import { ref, onMounted } from "vue";
  69. import Container from "../../components/Container/Container.vue";
  70. import { router } from "../../utils/router";
  71. import { request } from "../../utils/request";
  72. import { arrayToTree } from "../../utils";
  73. const current = ref(0);
  74. const items = ref(["", "标签2"]);
  75. const list = ref([]);
  76. const banner_list=ref([]);
  77. const clickClass = ({ id }) => {
  78. router.push({
  79. url: "/pages/regulations/index",
  80. params: {
  81. id,
  82. },
  83. });
  84. };
  85. const toReal = (item) => {
  86. router.push({
  87. url: "/pages/real/index",
  88. params: item,
  89. });
  90. };
  91. onMounted(async () => {
  92. const res = await request(
  93. "api/question_bank/question_reception/chapter/get",
  94. {},
  95. "POST"
  96. );
  97. list.value = arrayToTree({
  98. list: res.data,
  99. });
  100. items.value[0] = list.value[0].name;
  101. // 首页轮播
  102. const banner_res = await request(
  103. "api/question_bank/question_reception/banner/list",
  104. {},
  105. "POST"
  106. );
  107. banner_list.value = banner_res.data.data;
  108. });
  109. </script>
  110. <style scoped lang="scss">
  111. .home {
  112. display: flex;
  113. flex-direction: column;
  114. gap: 20rpx;
  115. .time {
  116. display: flex;
  117. align-items: center;
  118. justify-content: center;
  119. gap: 80rpx;
  120. }
  121. .swiper {
  122. height: 320rpx;
  123. // border: 1rpx solid #000000;
  124. width: 100%;
  125. .swiper-item {
  126. display: block;
  127. height: 320rpx;
  128. line-height: 320rpx;
  129. text-align: center;
  130. // background-color: red;
  131. border-radius: 30rpx;
  132. .swiper-item-image{
  133. // border-radius: 5%;
  134. width: 100%;
  135. }
  136. }
  137. }
  138. .notice {
  139. display: flex;
  140. align-items: center;
  141. gap: 20rpx;
  142. padding-left: 26rpx;
  143. }
  144. .new_outline {
  145. border: 1rpx solid #000000;
  146. }
  147. }
  148. .title {
  149. font-family: "PingFang SC, PingFang SC";
  150. font-weight: 700;
  151. font-size: 32rpx;
  152. color: #000000;
  153. }
  154. .p-20 {
  155. padding: 0 30rpx 30rpx;
  156. display: flex;
  157. flex-direction: column;
  158. gap: 20rpx;
  159. }
  160. .grid {
  161. display: grid;
  162. grid-template-columns: repeat(4, 1fr);
  163. gap: 20rpx;
  164. }
  165. .grid-3 {
  166. display: grid;
  167. grid-template-columns: repeat(3, 1fr);
  168. gap: 20rpx;
  169. height: 100%;
  170. }
  171. .flex {
  172. display: flex;
  173. flex-direction: column;
  174. gap: 20rpx;
  175. align-items: center;
  176. justify-content: center;
  177. }
  178. .bg-red {
  179. width: 149rpx;
  180. height: 80rpx;
  181. background: #d9d9d9;
  182. }
  183. </style>