index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  1. <template>
  2. <template>
  3. <Container
  4. class="body-content"
  5. title="首页"
  6. bgColor="#F8F8F8"
  7. :showBack="false"
  8. >
  9. <view class="home">
  10. <!-- 倒计时 -->
  11. <view class="time" v-if="(splitDays != '') & (splitDays != null)">
  12. <view>距离2025年考试倒计时</view>
  13. <!-- 将天数拆分为单个数字显示 -->
  14. <view
  15. class="exam-countdown-tiem-item"
  16. v-for="(digit, index) in splitDays"
  17. :key="index"
  18. >{{ digit }}</view
  19. >
  20. <view>天</view>
  21. </view>
  22. <!-- 轮播图 -->
  23. <swiper
  24. class="swiper"
  25. :style="{
  26. height: imgHeight,
  27. }"
  28. circular
  29. autoplay
  30. >
  31. <swiper-item v-for="(item, index) in banner_list" :key="index">
  32. <view class="swiper-item"
  33. ><image
  34. class="swiper-item-image"
  35. :src="item.image_url"
  36. mode="aspectFill"
  37. @load="onImageLoad($event, item, index)"
  38. @click="goto_notice_list(item.link_url)"
  39. ></image
  40. ></view>
  41. </swiper-item>
  42. </swiper>
  43. <!-- 公告 -->
  44. <view class="notice" v-if="notice_list != '' && notice_list != null">
  45. <view class="title-lable">公告</view>
  46. <view class="notice-title">{{ notice_list[0]["title"] }}</view>
  47. <navigator url="/pages/notice/list">
  48. <view class="notice-more">{{ "更多 >" }}</view>
  49. </navigator>
  50. </view>
  51. <div class="qiandao">
  52. <div class="left">
  53. <span class="text-16" style="font-weight: bold">每日一练</span>
  54. <span class="text-12 text-t9"
  55. >今日已有<span class="text-primary">48</span>人打卡</span
  56. >
  57. </div>
  58. <div
  59. class="bt"
  60. :style="{
  61. backgroundColor: !success ? '#FF6666' : '#3FCCFF',
  62. }"
  63. @click="onClickToPunch"
  64. >
  65. {{ !success ? "今日未打卡" : "今日已打卡" }}
  66. </div>
  67. </div>
  68. <!-- 2025新大纲 -->
  69. <view class="new_outline">
  70. <uni-section title="执业药师章节练习" type="line">
  71. <template v-for="(item, index) in list" :key="item.id">
  72. <view v-if="current === index" class="grid">
  73. <view
  74. v-for="i in item?.children"
  75. :key="i.id"
  76. class="flex"
  77. @click="clickClass(i)"
  78. >
  79. <image :src="i.chapter_image_url" class="img_small"></image>
  80. <view>{{ i.name }}</view>
  81. </view>
  82. </view>
  83. </template>
  84. </uni-section>
  85. </view>
  86. <div class="flex-box">
  87. <div
  88. class="children lishi"
  89. @click="
  90. router.push({
  91. url: '/pages/index/yearExam',
  92. })
  93. "
  94. >
  95. <div>往年真题</div>
  96. <div class="te">10年真题卷</div>
  97. <div class="cricle">{{ ">" }}</div>
  98. </div>
  99. <div class="children gaopin">
  100. <div>高频考点</div>
  101. <div class="te">经典拿分题</div>
  102. <div class="cricle">{{ ">" }}</div>
  103. </div>
  104. </div>
  105. <!-- #ifdef MP-WEIXIN -->
  106. <official-account @load="onload"></official-account>
  107. <!-- #endif -->
  108. </view>
  109. </Container>
  110. <view class="service">
  111. <CustomerService>联系客服</CustomerService>
  112. </view>
  113. </template>
  114. <Modal title="ces" :footer="false" v-model:open="showModal">
  115. <template #custom>
  116. <view class="mo">
  117. <uni-icons
  118. type="closeempty"
  119. class="icons"
  120. color="#fff"
  121. @click="showModal = false"
  122. ></uni-icons>
  123. <div class="bgt">
  124. <span>恭喜您获得7天会员</span>
  125. <span>可以免费学习所有课程以及练习题库</span>
  126. <span style="margin-top: 71rpx">戳下方还可以</span>
  127. <span>添加专属助教老师为您答疑解惑</span>
  128. <span>限时领取《药品速记口诀》</span>
  129. <span class="fixed" @click="receive"></span>
  130. </div>
  131. </view>
  132. </template>
  133. </Modal>
  134. </template>
  135. <script setup>
  136. import { ref, onMounted, computed, onBeforeUnmount } from "vue";
  137. import Container from "../../components/Container/Container.vue";
  138. import CustomerService from "../../components/CustomerService/CustomerService.vue";
  139. import Modal from "../../components/Modal/Modal.vue";
  140. import { router, getRoute } from "../../utils/router";
  141. import { request } from "../../utils/request";
  142. import { arrayToTree } from "../../utils";
  143. const current = ref(0);
  144. const list = ref([]);
  145. const banner_list = ref([]);
  146. const notice_list = ref([]);
  147. const imgHeight = ref("auto"); // 初始高度
  148. const showModal = ref(false);
  149. const success = ref(false);
  150. const onClickToPunch = () => {
  151. router.push({
  152. url: "/pages/learn/dayPractice",
  153. params: {
  154. title: "每日一练",
  155. },
  156. });
  157. };
  158. const days = ref("000"); // 默认值设为100,确保有3位数
  159. let timer = null;
  160. const exam_time = ref(""); //考试时间
  161. const isLogin = () => {
  162. const userInfo = uni.getStorageSync("userLogin");
  163. return !!userInfo?.is_register;
  164. };
  165. const receive = () => {
  166. if (!isLogin()) {
  167. router.push("/pages/login/index");
  168. return;
  169. }
  170. showModal.value = false;
  171. setTimeout(() => {
  172. router.push("/pages/contant/sub");
  173. }, 0);
  174. };
  175. // 将天数拆分为单个数字数组
  176. const splitDays = computed(() => {
  177. // 将数字转为字符串,然后拆分为字符数组
  178. const str = days.value.toString();
  179. // 如果不足3位数,前面补0(例如5变成["0","0","5"])
  180. return str.padStart(3, "0").split("");
  181. });
  182. const onload = (e) => {
  183. console.log(e);
  184. };
  185. const calculateDays = () => {
  186. // const targetDate = new Date('2025-12-31');
  187. const targetDate = new Date(Number(exam_time.value * 1000));
  188. const currentDate = new Date();
  189. const diffTime = targetDate - currentDate;
  190. const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
  191. days.value = diffDays > 0 ? diffDays : 0;
  192. };
  193. const clickClass = ({ id, name }) => {
  194. router.push({
  195. url: "/pages/regulations/index",
  196. params: {
  197. id,
  198. title: name,
  199. },
  200. });
  201. };
  202. const onImageLoad = (e, item, index) => {
  203. const { width, height } = e.detail;
  204. const ratio = height / width;
  205. const systemInfo = uni.getSystemInfoSync();
  206. const imgHeightValue = systemInfo.windowWidth * ratio;
  207. imgHeight.value = imgHeightValue + "px";
  208. };
  209. onBeforeUnmount(() => {
  210. if (timer) clearInterval(timer);
  211. });
  212. const goto_notice_list = (link_url) => {
  213. uni.navigateTo({
  214. url: link_url,
  215. });
  216. };
  217. onMounted(async () => {
  218. const params = getRoute().params;
  219. if (params.scene) {
  220. const p = params.scene.split("=");
  221. const value = p[1];
  222. uni.setStorageSync("share_uid", value);
  223. }
  224. const res = await request(
  225. "api/question_bank/question_reception/chapter/get",
  226. {},
  227. "POST"
  228. );
  229. list.value = arrayToTree({
  230. list: res.data,
  231. });
  232. // 首页轮播
  233. const banner_res = await request(
  234. "api/question_bank/question_reception/banner/list",
  235. { page: 1, limit: 10 },
  236. "POST"
  237. );
  238. banner_list.value = banner_res.data.data;
  239. //系统公告
  240. const notice_res = await request(
  241. "api/question_bank/question_reception/notice/list",
  242. { page: 1, limit: 1 },
  243. "POST"
  244. );
  245. notice_list.value = notice_res.data.data;
  246. //获取考试倒计时
  247. const examination_res = await request(
  248. "api/question_bank/question_reception/common_config/detail",
  249. { content_code: "examination_countdown" },
  250. "POST"
  251. );
  252. exam_time.value =
  253. examination_res != "" ? examination_res.data.content_detail : "";
  254. if (!isLogin()) {
  255. showModal.value = true;
  256. }
  257. calculateDays();
  258. timer = setInterval(() => {
  259. calculateDays();
  260. }, 24 * 60 * 60 * 1000);
  261. return {
  262. days,
  263. splitDays,
  264. };
  265. });
  266. </script>
  267. <style scoped lang="scss">
  268. // https://openwork-oss.oss-cn-shenzhen.aliyuncs.com/uploads/question/2025/06/kPFuCa2RDyoUXbiCzj0MOwcCm7XowJcWqNqs18oB.png 往年真题
  269. // https://openwork-oss.oss-cn-shenzhen.aliyuncs.com/uploads/question/2025/06/WsEF9w5bs7Gknnf3vUV3EMR0WxqleESpYSVxZtkn.png 高频考点
  270. @import "@/uni.scss";
  271. .flex-box {
  272. display: flex;
  273. align-items: center;
  274. gap: 10rpx;
  275. .children {
  276. flex: 1;
  277. height: 173rpx;
  278. width: 100%;
  279. padding: 24rpx 12rpx;
  280. box-sizing: border-box;
  281. color: #333333;
  282. }
  283. @mixin text($bg) {
  284. .te {
  285. color: $bg;
  286. font-weight: 400;
  287. font-size: 24rpx;
  288. }
  289. .cricle {
  290. width: 32rpx;
  291. height: 32rpx;
  292. background: $bg;
  293. display: flex;
  294. align-items: center;
  295. justify-content: center;
  296. color: #fff;
  297. border-radius: 50%;
  298. font-size: 20rpx;
  299. margin: 14rpx 0 0 8rpx;
  300. }
  301. }
  302. .lishi {
  303. background: url(https://openwork-oss.oss-cn-shenzhen.aliyuncs.com/uploads/question/2025/06/kPFuCa2RDyoUXbiCzj0MOwcCm7XowJcWqNqs18oB.png);
  304. background-size: 100% 100%;
  305. @include text(#00a3ff);
  306. }
  307. .gaopin {
  308. background: url(https://openwork-oss.oss-cn-shenzhen.aliyuncs.com/uploads/question/2025/06/WsEF9w5bs7Gknnf3vUV3EMR0WxqleESpYSVxZtkn.png);
  309. background-size: 100% 100%;
  310. @include text(#ff6a00);
  311. }
  312. }
  313. .qiandao {
  314. background: url(https://openwork-oss.oss-cn-shenzhen.aliyuncs.com/uploads/question/2025/06/hASs5yhNTWUMTAGdod21hDIcibFNFSDTbiGpEMd0.png)
  315. no-repeat;
  316. background-size: 100% 100%;
  317. width: 100%;
  318. height: 104rpx;
  319. display: flex;
  320. justify-content: space-between;
  321. box-sizing: border-box;
  322. padding: 10rpx 16rpx;
  323. align-items: center;
  324. .left {
  325. display: flex;
  326. flex-direction: column;
  327. gap: 4rpx;
  328. }
  329. .bt {
  330. width: 188rpx;
  331. height: 55rpx;
  332. background: #ff6666;
  333. border-radius: 200rpx 200rpx 200rpx 200rpx;
  334. font-weight: 400;
  335. font-size: 28rpx;
  336. color: #ffffff;
  337. display: flex;
  338. align-items: center;
  339. justify-content: center;
  340. }
  341. }
  342. .mo {
  343. display: flex;
  344. flex-direction: column;
  345. align-items: flex-end;
  346. width: 658rpx;
  347. .icons {
  348. background: #8a8a8b;
  349. width: 48rpx;
  350. height: 48rpx;
  351. border-radius: 50%;
  352. display: flex;
  353. align-items: center;
  354. justify-content: center;
  355. }
  356. .bgt {
  357. width: 658rpx;
  358. height: 766rpx;
  359. position: relative;
  360. background: url(https://openwork-oss.oss-cn-shenzhen.aliyuncs.com/uploads/question/2025/06/p3qrAPK10tNFOfwy27yryTtwEOsE8x40V0wFvbOW.png);
  361. background-size: 100% 100%;
  362. display: flex;
  363. flex-direction: column;
  364. align-items: center;
  365. font-weight: 600;
  366. font-size: 32rpx;
  367. color: #8b3700;
  368. gap: 16rpx;
  369. box-sizing: border-box;
  370. padding-top: 161rpx;
  371. }
  372. .fixed {
  373. position: absolute;
  374. width: 348rpx;
  375. height: 86rpx;
  376. bottom: 30rpx;
  377. }
  378. }
  379. .service {
  380. position: absolute;
  381. bottom: 20%;
  382. right: 5%;
  383. color: $uni-primary;
  384. font-size: 28rpx;
  385. margin-bottom: 40rpx;
  386. text-align: right;
  387. }
  388. .img_small {
  389. width: 112rpx;
  390. height: 112rpx;
  391. }
  392. .body-content {
  393. background: #f8f8f8;
  394. border-radius: 0rpx 0rpx 0rpx 0rpx;
  395. }
  396. .exam-countdown-tiem-item {
  397. width: 24rpx;
  398. height: 34rpx;
  399. background: #ff3c3c;
  400. border-radius: 2rpx 2rpx 2rpx 2rpx;
  401. font-family: PingFang SC, PingFang SC;
  402. font-weight: 500;
  403. font-size: 24rpx;
  404. color: #ffffff;
  405. display: flex;
  406. align-items: center;
  407. justify-content: center;
  408. }
  409. .home {
  410. display: flex;
  411. flex-direction: column;
  412. gap: 20rpx;
  413. .time {
  414. display: flex;
  415. align-items: center;
  416. justify-content: center;
  417. font-family: PingFang SC, PingFang SC;
  418. font-weight: 500;
  419. font-size: 24rpx;
  420. color: #333333;
  421. gap: 8rpx;
  422. .tiem-item {
  423. width: 24rpx;
  424. height: 34rpx;
  425. background: #ff3c3c;
  426. border-radius: 2rpx 2rpx 2rpx 2rpx;
  427. font-family: PingFang SC, PingFang SC;
  428. font-weight: 500;
  429. font-size: 24rpx;
  430. color: #ffffff;
  431. display: flex;
  432. align-items: center;
  433. justify-content: center;
  434. }
  435. }
  436. .swiper {
  437. width: 100%;
  438. /* 关键修复样式 */
  439. overflow: hidden;
  440. transform-style: preserve-3d;
  441. .swiper-item {
  442. width: 100%;
  443. height: 100%;
  444. overflow: hidden;
  445. border-radius: 30rpx;
  446. /* 确保变换不影响子元素 */
  447. transform: translateZ(0);
  448. .swiper-item-image {
  449. width: 100%;
  450. height: 100%;
  451. display: block;
  452. border-radius: 30rpx;
  453. /* 防止图片变形 */
  454. object-fit: cover;
  455. /* 确保层级 */
  456. position: relative;
  457. }
  458. }
  459. }
  460. .notice {
  461. display: flex;
  462. align-items: center;
  463. gap: 20rpx;
  464. padding-left: 26rpx;
  465. height: 72rpx;
  466. background: #ffffff;
  467. border-radius: 500rpx 500rpx 500rpx 500rpx;
  468. border: 1rpx solid #f8f8f8;
  469. .title-lable {
  470. padding: 5rpx 15rpx;
  471. border-radius: 8rpx 8rpx 8rpx 8rpx;
  472. border: 1rpx solid #3f75ff;
  473. font-weight: 500;
  474. font-size: 26rpx;
  475. color: #3f75ff;
  476. line-height: 32rpx;
  477. text-align: center;
  478. font-style: normal;
  479. text-transform: none;
  480. }
  481. .notice-title {
  482. width: calc(100% - 225rpx);
  483. color: #333;
  484. font-size: 26rpx;
  485. display: -webkit-box;
  486. -webkit-box-orient: vertical;
  487. -webkit-line-clamp: 1;
  488. overflow: hidden;
  489. text-overflow: ellipsis;
  490. }
  491. .notice-more {
  492. font-size: 26rpx;
  493. }
  494. }
  495. }
  496. .title {
  497. font-family: "PingFang SC, PingFang SC";
  498. font-weight: 700;
  499. font-size: 32rpx;
  500. color: #000000;
  501. }
  502. .p-20 {
  503. display: flex;
  504. flex-direction: column;
  505. gap: 20rpx;
  506. }
  507. .grid {
  508. display: grid;
  509. grid-template-columns: repeat(4, 1fr);
  510. background-color: #ffffff;
  511. padding: 24rpx;
  512. gap: 16rpx;
  513. border-radius: 16rpx;
  514. }
  515. .grid-3 {
  516. display: grid;
  517. grid-template-columns: repeat(3, 1fr);
  518. background-color: #ffffff;
  519. padding: 24rpx;
  520. gap: 16rpx;
  521. border-radius: 16rpx;
  522. height: 100%;
  523. margin-bottom: 20rpx;
  524. }
  525. .flex {
  526. display: flex;
  527. flex-direction: column;
  528. gap: 20rpx;
  529. align-items: center;
  530. justify-content: center;
  531. }
  532. .bg-red {
  533. width: 191.07rpx;
  534. height: 179.61rpx;
  535. background: url("https://openwork-oss.oss-cn-shenzhen.aliyuncs.com/uploads/question/2025/05/WmhlbORF2q8A62Ytg1RVac8AYSGPkf7F2pEY6jQP.png")
  536. no-repeat;
  537. background-size: cover;
  538. display: flex;
  539. justify-content: center;
  540. .text {
  541. font-family: jiangxizhuokai, jiangxizhuokai;
  542. font-weight: bold;
  543. font-size: 27rpx;
  544. color: #3f75ff;
  545. text-shadow: 0px 2px 4px #bdcfff;
  546. text-align: left;
  547. font-style: normal;
  548. text-transform: none;
  549. margin-top: 16rpx;
  550. width: 95rpx;
  551. height: 70rpx;
  552. }
  553. }
  554. </style>