index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <template>
  2. <Container class="body-content" 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" @load="onImageLoad($event, item, index)"></image></view>
  13. </swiper-item>
  14. </swiper>
  15. <!-- 公告 -->
  16. <view class="notice" v-if="notice_list !='' && notice_list != null">
  17. <view class="title-lable">公告</view>
  18. <view class="notice-title">{{notice_list[0]['title']}}</view>
  19. <navigator url="/pages/notice/list">
  20. <view class="notice-more">{{'更多 >'}}</view>
  21. </navigator>
  22. </view>
  23. <!-- 2025新大纲 -->
  24. <view class="new_outline">
  25. <uni-section title="基础用法" type="line">
  26. <view class="p-20">
  27. <uni-segmented-control :flex="false" :current="current" :values="items" style-type="text" @clickItem="(e) => (current = e.currentIndex)" />
  28. <!-- 执业药师 -->
  29. <template v-for="(item, index) in list" :key="item.id">
  30. <view v-if="current === index" class="grid">
  31. <view v-for="i in item?.children" class="flex" @click="clickClass(i)">
  32. <view class="bg-red"></view>
  33. <view>{{ i.name }}</view>
  34. </view>
  35. </view>
  36. </template>
  37. </view>
  38. </uni-section>
  39. </view>
  40. </view>
  41. <uni-section title="往年真题" type="line">
  42. <!-- 往年真题 -->
  43. <view class="grid-3">
  44. <view
  45. v-for="item in 7"
  46. class="flex"
  47. @click="
  48. toReal({
  49. title: '2025真题'
  50. })
  51. "
  52. >
  53. <view class="bg-red"></view>
  54. <view>执业药师{{ item }}</view>
  55. </view>
  56. </view>
  57. </uni-section>
  58. </Container>
  59. </template>
  60. <script setup>
  61. import { ref, onMounted } from 'vue';
  62. import Container from '../../components/Container/Container.vue';
  63. import { router } from '../../utils/router';
  64. import { request } from '../../utils/request';
  65. import { arrayToTree } from '../../utils';
  66. const current = ref(0);
  67. const items = ref(['', '标签2']);
  68. const list = ref([]);
  69. const banner_list = ref([]);
  70. const notice_list=ref([]);
  71. const imgHeight= ref('auto'); // 初始高度
  72. const clickClass = ({ id }) => {
  73. router.push({
  74. url: '/pages/regulations/index',
  75. params: {
  76. id
  77. }
  78. });
  79. };
  80. const toReal = (item) => {
  81. router.push({
  82. url: '/pages/real/index',
  83. params: item
  84. });
  85. };
  86. const onImageLoad = (e, item, index) => {
  87. const { width, height } = e.detail;
  88. const ratio = height / width;
  89. const systemInfo = uni.getSystemInfoSync();
  90. const imgHeightValue = systemInfo.windowWidth * ratio;
  91. imgHeight.value = imgHeightValue + 'px';
  92. };
  93. onMounted(async () => {
  94. const res = await request('api/question_bank/question_reception/chapter/get', {}, 'POST');
  95. list.value = arrayToTree({
  96. list: res.data
  97. });
  98. items.value[0] = list.value[0].name;
  99. // 首页轮播
  100. const banner_res = await request('api/question_bank/question_reception/banner/list', {page:1,limit:10}, 'POST');
  101. banner_list.value = banner_res.data.data;
  102. //系统公告
  103. const notice_res = await request('api/question_bank/question_reception/notice/list', {page:1,limit:1}, 'POST');
  104. notice_list.value = notice_res.data.data;
  105. console.log(notice_list);
  106. });
  107. </script>
  108. <style scoped lang="scss">
  109. .body-content {
  110. background: #f8f8f8;
  111. border-radius: 0rpx 0rpx 0rpx 0rpx;
  112. }
  113. .home {
  114. display: flex;
  115. flex-direction: column;
  116. gap: 20rpx;
  117. .time {
  118. display: flex;
  119. align-items: center;
  120. justify-content: center;
  121. gap: 80rpx;
  122. }
  123. .swiper {
  124. width: 100%;
  125. height: v-bind(imgHeight);
  126. /* 关键修复样式 */
  127. overflow: hidden;
  128. transform-style: preserve-3d;
  129. .swiper-item {
  130. width: 100%;
  131. height: 100%;
  132. overflow: hidden;
  133. border-radius: 30rpx;
  134. /* 确保变换不影响子元素 */
  135. transform: translateZ(0);
  136. .swiper-item-image {
  137. width: 100%;
  138. height: 100%;
  139. display: block;
  140. border-radius: 30rpx;
  141. /* 防止图片变形 */
  142. object-fit: cover;
  143. /* 确保层级 */
  144. position: relative;
  145. }
  146. }
  147. }
  148. .notice {
  149. display: flex;
  150. align-items: center;
  151. gap: 20rpx;
  152. padding-left: 26rpx;
  153. height: 72rpx;
  154. background: #ffffff;
  155. border-radius: 500rpx 500rpx 500rpx 500rpx;
  156. border:1rpx solid #f8f8f8;
  157. .title-lable {
  158. padding: 5rpx 15rpx;
  159. border-radius: 8rpx 8rpx 8rpx 8rpx;
  160. border: 1rpx solid #3f75ff;
  161. font-weight: 500;
  162. font-size: 26rpx;
  163. color: #3f75ff;
  164. line-height: 32rpx;
  165. text-align: center;
  166. font-style: normal;
  167. text-transform: none;
  168. }
  169. .notice-title{
  170. width: calc(100% - 225rpx);
  171. color: #333;
  172. font-size: 26rpx;
  173. display: -webkit-box;
  174. -webkit-box-orient: vertical;
  175. -webkit-line-clamp: 1;
  176. overflow: hidden;
  177. text-overflow: ellipsis;
  178. }
  179. .notice-more{
  180. font-size: 26rpx;
  181. }
  182. }
  183. .new_outline {
  184. border: 1rpx solid #000000;
  185. }
  186. }
  187. .title {
  188. font-family: 'PingFang SC, PingFang SC';
  189. font-weight: 700;
  190. font-size: 32rpx;
  191. color: #000000;
  192. }
  193. .p-20 {
  194. padding: 0 30rpx 30rpx;
  195. display: flex;
  196. flex-direction: column;
  197. gap: 20rpx;
  198. }
  199. .grid {
  200. display: grid;
  201. grid-template-columns: repeat(4, 1fr);
  202. gap: 20rpx;
  203. }
  204. .grid-3 {
  205. display: grid;
  206. grid-template-columns: repeat(3, 1fr);
  207. gap: 20rpx;
  208. height: 100%;
  209. }
  210. .flex {
  211. display: flex;
  212. flex-direction: column;
  213. gap: 20rpx;
  214. align-items: center;
  215. justify-content: center;
  216. }
  217. .bg-red {
  218. width: 149rpx;
  219. height: 80rpx;
  220. background: #d9d9d9;
  221. }
  222. </style>