index.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <template>
  2. <Container :title="title">
  3. <view class="p-20">
  4. <view class="center"
  5. ><uni-segmented-control
  6. :flex="false"
  7. :current="current"
  8. :values="list.map((i) => i.name)"
  9. style-type="text"
  10. @clickItem="(e) => (current = e.currentIndex)"
  11. /></view>
  12. <!-- 执业药师 -->
  13. <template v-for="(item, index) in list" :key="item.id">
  14. <view v-if="current === index" class="grid">
  15. <view v-for="i in item?.children" class="flex">
  16. <view class="bg-red">
  17. <view class="text">{{ i.name }}</view>
  18. <view class="button" @click="clickClass(i)">开始考试</view>
  19. </view>
  20. </view>
  21. </view>
  22. </template>
  23. </view>
  24. </Container>
  25. </template>
  26. <script setup name="real">
  27. import { ref, onMounted } from "vue";
  28. import Container from "../../components/Container/Container.vue";
  29. import { getRoute, router } from "../../utils/router";
  30. import { arrayToTree } from "../../utils";
  31. import { request } from "../../utils/request";
  32. const title = ref("");
  33. const list = ref([]);
  34. const current = ref(0);
  35. const clickClass = (item) => {
  36. router.push({
  37. url: "/pages/real/history",
  38. params: {
  39. id: item.id,
  40. title: item.name,
  41. },
  42. });
  43. };
  44. onMounted(async () => {
  45. const params = getRoute().params;
  46. title.value = params.title;
  47. const res = await request(
  48. "api/question_bank/question_reception/chapter/get",
  49. {},
  50. "POST"
  51. );
  52. list.value = arrayToTree({
  53. list: res.data,
  54. });
  55. });
  56. </script>
  57. <style scoped lang="scss">
  58. @import "@/uni.scss";
  59. .title {
  60. font-family: "PingFang SC, PingFang SC";
  61. font-weight: 700;
  62. font-size: 32rpx;
  63. color: #000000;
  64. }
  65. .center {
  66. display: flex;
  67. align-items: center;
  68. justify-content: center;
  69. }
  70. .p-20 {
  71. padding: 0 30rpx 30rpx;
  72. display: flex;
  73. flex-direction: column;
  74. gap: 20rpx;
  75. }
  76. .grid {
  77. display: grid;
  78. grid-template-columns: repeat(3, 1fr);
  79. gap: 20rpx;
  80. }
  81. .grid-3 {
  82. display: grid;
  83. grid-template-columns: repeat(3, 1fr);
  84. gap: 20rpx;
  85. height: 100%;
  86. }
  87. .flex {
  88. display: flex;
  89. flex-direction: column;
  90. gap: 22rpx;
  91. align-items: center;
  92. justify-content: center;
  93. }
  94. .bg-red {
  95. font-family: PingFang SC, PingFang SC;
  96. font-weight: 500;
  97. font-size: 28rpx;
  98. color: #333333;
  99. display: flex;
  100. flex-direction: column;
  101. width: 214rpx;
  102. height: 282rpx;
  103. background: url("https://openwork-oss.oss-cn-shenzhen.aliyuncs.com/uploads/question/2025/05/mrgkegM1h3pgz5taDRfQv5r1DX4DfONhIJtgJXEv.png");
  104. .text {
  105. margin-top: 32rpx;
  106. margin-left: 54rpx;
  107. margin-bottom: 126rpx;
  108. }
  109. .button {
  110. padding: 10rpx 0;
  111. width: 152rpx;
  112. border-radius: 24rpx;
  113. font-family: PingFang SC, PingFang SC;
  114. font-weight: 500;
  115. font-size: 26rpx;
  116. margin: 0 auto;
  117. }
  118. .btn-plain {
  119. color: $primary;
  120. border: 1rpx solid #3f75ff;
  121. background: transparent;
  122. border-radius: 24rpx;
  123. }
  124. }
  125. </style>