index.vue 15 KB

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