index.vue 4.0 KB

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