index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. <template>
  2. <Container
  3. class="body-content"
  4. title="首页"
  5. bgColor="#F8F8F8"
  6. :showBack="false"
  7. >
  8. <view class="home">
  9. <!-- 倒计时 -->
  10. <view class="time">
  11. <view>倒计时</view>
  12. <view class="tiem-item">1</view>
  13. <view class="tiem-item">0</view>
  14. <view class="tiem-item">0</view>
  15. <view>天</view>
  16. </view>
  17. <!-- 轮播图 -->
  18. <swiper class="swiper" circular autoplay>
  19. <swiper-item v-for="(item, index) in banner_list" :key="index">
  20. <view class="swiper-item"
  21. ><image
  22. class="swiper-item-image"
  23. :src="item.image_url"
  24. mode="aspectFill"
  25. @load="onImageLoad($event, item, index)"
  26. ></image
  27. ></view>
  28. </swiper-item>
  29. </swiper>
  30. <!-- 公告 -->
  31. <view class="notice" v-if="notice_list != '' && notice_list != null">
  32. <view class="title-lable">公告</view>
  33. <view class="notice-title">{{ notice_list[0]["title"] }}</view>
  34. <navigator url="/pages/notice/list">
  35. <view class="notice-more">{{ "更多 >" }}</view>
  36. </navigator>
  37. </view>
  38. <!-- 2025新大纲 -->
  39. <view class="new_outline">
  40. <uni-section title="基础用法" type="line">
  41. <view class="p-20">
  42. <uni-segmented-control
  43. :flex="false"
  44. :current="current"
  45. :values="list.map((item) => item.name)"
  46. style-type="text"
  47. @clickItem="(e) => (current = e.currentIndex)"
  48. />
  49. <!-- 执业药师 -->
  50. <template v-for="(item, index) in list" :key="item.id">
  51. <view v-if="current === index" class="grid">
  52. <view
  53. v-for="i in item?.children"
  54. class="flex"
  55. @click="clickClass(i)"
  56. >
  57. <image :src="i.chapter_image_url" class="img_small"></image>
  58. <view>{{ i.name }}</view>
  59. </view>
  60. </view>
  61. </template>
  62. </view>
  63. </uni-section>
  64. </view>
  65. <view class="p-20">
  66. <uni-section title="往年真题" type="line">
  67. <!-- 往年真题 -->
  68. <view class="grid-3">
  69. <view
  70. v-for="item in 7"
  71. class="flex"
  72. @click="
  73. toReal({
  74. title: '2025真题',
  75. })
  76. "
  77. >
  78. <view class="bg-red">
  79. <view class="text">执业药师{{ item }}</view>
  80. </view>
  81. </view>
  82. </view>
  83. </uni-section>
  84. </view>
  85. </view>
  86. </Container>
  87. </template>
  88. <script setup>
  89. import { ref, onMounted } from "vue";
  90. import Container from "../../components/Container/Container.vue";
  91. import { router } from "../../utils/router";
  92. import { request } from "../../utils/request";
  93. import { arrayToTree } from "../../utils";
  94. const current = ref(0);
  95. const list = ref([]);
  96. const banner_list = ref([]);
  97. const notice_list = ref([]);
  98. const imgHeight = ref("auto"); // 初始高度
  99. const clickClass = ({ id }) => {
  100. router.push({
  101. url: "/pages/regulations/index",
  102. params: {
  103. id,
  104. },
  105. });
  106. };
  107. const toReal = (item) => {
  108. router.push({
  109. url: "/pages/real/index",
  110. params: item,
  111. });
  112. };
  113. const onImageLoad = (e, item, index) => {
  114. const { width, height } = e.detail;
  115. const ratio = height / width;
  116. const systemInfo = uni.getSystemInfoSync();
  117. const imgHeightValue = systemInfo.windowWidth * ratio;
  118. imgHeight.value = imgHeightValue + "px";
  119. };
  120. onMounted(async () => {
  121. const res = await request(
  122. "api/question_bank/question_reception/chapter/get",
  123. {},
  124. "POST"
  125. );
  126. list.value = arrayToTree({
  127. list: res.data,
  128. });
  129. console.log(list.value);
  130. // 首页轮播
  131. const banner_res = await request(
  132. "api/question_bank/question_reception/banner/list",
  133. { page: 1, limit: 10 },
  134. "POST"
  135. );
  136. banner_list.value = banner_res.data.data;
  137. //系统公告
  138. const notice_res = await request(
  139. "api/question_bank/question_reception/notice/list",
  140. { page: 1, limit: 1 },
  141. "POST"
  142. );
  143. notice_list.value = notice_res.data.data;
  144. console.log(notice_list);
  145. });
  146. </script>
  147. <style scoped lang="scss">
  148. @import "@/uni.scss";
  149. .img_small {
  150. width: 112rpx;
  151. height: 112rpx;
  152. }
  153. .body-content {
  154. background: #f8f8f8;
  155. border-radius: 0rpx 0rpx 0rpx 0rpx;
  156. }
  157. .home {
  158. display: flex;
  159. flex-direction: column;
  160. gap: 20rpx;
  161. .time {
  162. display: flex;
  163. align-items: center;
  164. justify-content: center;
  165. font-family: PingFang SC, PingFang SC;
  166. font-weight: 500;
  167. font-size: 24rpx;
  168. color: #333333;
  169. gap: 8rpx;
  170. .tiem-item {
  171. width: 24rpx;
  172. height: 34rpx;
  173. background: #ff3c3c;
  174. border-radius: 2rpx 2rpx 2rpx 2rpx;
  175. font-family: PingFang SC, PingFang SC;
  176. font-weight: 500;
  177. font-size: 24rpx;
  178. color: #ffffff;
  179. display: flex;
  180. align-items: center;
  181. justify-content: center;
  182. }
  183. }
  184. .swiper {
  185. width: 100%;
  186. height: v-bind(imgHeight);
  187. /* 关键修复样式 */
  188. overflow: hidden;
  189. transform-style: preserve-3d;
  190. .swiper-item {
  191. width: 100%;
  192. height: 100%;
  193. overflow: hidden;
  194. border-radius: 30rpx;
  195. /* 确保变换不影响子元素 */
  196. transform: translateZ(0);
  197. .swiper-item-image {
  198. width: 100%;
  199. height: 100%;
  200. display: block;
  201. border-radius: 30rpx;
  202. /* 防止图片变形 */
  203. object-fit: cover;
  204. /* 确保层级 */
  205. position: relative;
  206. }
  207. }
  208. }
  209. .notice {
  210. display: flex;
  211. align-items: center;
  212. gap: 20rpx;
  213. padding-left: 26rpx;
  214. height: 72rpx;
  215. background: #ffffff;
  216. border-radius: 500rpx 500rpx 500rpx 500rpx;
  217. border: 1rpx solid #f8f8f8;
  218. .title-lable {
  219. padding: 5rpx 15rpx;
  220. border-radius: 8rpx 8rpx 8rpx 8rpx;
  221. border: 1rpx solid #3f75ff;
  222. font-weight: 500;
  223. font-size: 26rpx;
  224. color: #3f75ff;
  225. line-height: 32rpx;
  226. text-align: center;
  227. font-style: normal;
  228. text-transform: none;
  229. }
  230. .notice-title {
  231. width: calc(100% - 225rpx);
  232. color: #333;
  233. font-size: 26rpx;
  234. display: -webkit-box;
  235. -webkit-box-orient: vertical;
  236. -webkit-line-clamp: 1;
  237. overflow: hidden;
  238. text-overflow: ellipsis;
  239. }
  240. .notice-more {
  241. font-size: 26rpx;
  242. }
  243. }
  244. }
  245. .title {
  246. font-family: "PingFang SC, PingFang SC";
  247. font-weight: 700;
  248. font-size: 32rpx;
  249. color: #000000;
  250. }
  251. .p-20 {
  252. display: flex;
  253. flex-direction: column;
  254. gap: 20rpx;
  255. }
  256. .grid {
  257. display: grid;
  258. grid-template-columns: repeat(4, 1fr);
  259. background-color: #ffffff;
  260. padding: 24rpx;
  261. gap: 16rpx;
  262. border-radius: 16rpx;
  263. }
  264. .grid-3 {
  265. display: grid;
  266. grid-template-columns: repeat(3, 1fr);
  267. background-color: #ffffff;
  268. padding: 24rpx;
  269. gap: 16rpx;
  270. border-radius: 16rpx;
  271. height: 100%;
  272. }
  273. .flex {
  274. display: flex;
  275. flex-direction: column;
  276. gap: 20rpx;
  277. align-items: center;
  278. justify-content: center;
  279. }
  280. .bg-red {
  281. width: 191.07rpx;
  282. height: 179.61rpx;
  283. background: url("https://openwork-oss.oss-cn-shenzhen.aliyuncs.com/uploads/question/2025/05/WmhlbORF2q8A62Ytg1RVac8AYSGPkf7F2pEY6jQP.png")
  284. no-repeat;
  285. background-size: cover;
  286. display: flex;
  287. justify-content: center;
  288. .text {
  289. font-family: jiangxizhuokai, jiangxizhuokai;
  290. font-weight: bold;
  291. font-size: 27rpx;
  292. color: #3f75ff;
  293. text-shadow: 0px 2px 4px #bdcfff;
  294. text-align: left;
  295. font-style: normal;
  296. text-transform: none;
  297. margin-top: 16rpx;
  298. width: 95rpx;
  299. height: 70rpx;
  300. }
  301. }
  302. </style>