mockPractice.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <!-- 模拟练习 -->
  2. <template>
  3. <view class="mockPractice-component">
  4. <view class="card">
  5. <view class="card-header">
  6. <view class="header-left">
  7. <view class="card-title">📝 模拟练习</view>
  8. <view class="header-subtitle">刷题提高正确率</view>
  9. </view>
  10. <text class="header-link" @click="goToPage()">去练习 ›</text>
  11. </view>
  12. <view class="card-body">
  13. <view class="card-left-bxo">
  14. <view class="card-top-text-box">
  15. <view>{{newData.completedCount}}</view>
  16. <view>/</view>
  17. <view>{{newData.totalCount}}</view>
  18. </view>
  19. <view class="card-name-box">已完成 / 总题数</view>
  20. <view class="card-num-box">
  21. <view :style="'width:'+num+'rpx;'"></view>
  22. </view>
  23. </view>
  24. <view class="card-right-bxo">
  25. <view class="card-top-text-box">
  26. {{newData.correctRate}}%
  27. </view>
  28. <view class="card-name-box">模拟正确率</view>
  29. <view class="card-num-box">
  30. <view :style="'width:'+newData.correctRate+'rpx;'"></view>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. import {
  39. examUserPracticeSummary,
  40. } from '@/pages_safetyEducationExamination/api/index.js'
  41. export default {
  42. // components: {
  43. // workbench,
  44. // },
  45. data() {
  46. return {
  47. newData:{
  48. completedCount: 0,
  49. correctRate: 0,
  50. totalCount: 0,
  51. },
  52. num:0,
  53. }
  54. },
  55. created() {
  56. },
  57. mounted() {
  58. this.examUserPracticeSummary();
  59. },
  60. methods: {
  61. goToPage(){
  62. },
  63. async examUserPracticeSummary() {
  64. try {
  65. const { data } = await examUserPracticeSummary();
  66. if (data.code === 200){
  67. data.data={
  68. completedCount: 50,
  69. correctRate: 50,
  70. totalCount: 100,
  71. }
  72. this.$set(this,'newData',data.data);
  73. this.$set(this,'num',this.completedPercentage(data.data));
  74. }
  75. } catch (e) { console.error('模拟练习数据错误', e); }
  76. },
  77. // 计算完成百分比
  78. completedPercentage(data) {
  79. if (data.totalCount === 0) {
  80. return 0;
  81. }
  82. const percentage = (data.completedCount / data.totalCount) * 100;
  83. return parseFloat(percentage.toFixed(2));
  84. }
  85. },
  86. }
  87. </script>
  88. <style lang="stylus" scoped>
  89. .mockPractice-component {
  90. margin: 0 32rpx 32rpx;
  91. .card {
  92. background: #fff;
  93. border-radius: 24rpx;
  94. overflow: hidden;
  95. margin-bottom: 24rpx;
  96. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.03);
  97. border: 1px solid #dde3ed;
  98. }
  99. .card-header {
  100. padding: 20rpx 28rpx;
  101. display: flex;
  102. justify-content: space-between;
  103. align-items: center;
  104. .card-title {
  105. font-size: 28rpx;
  106. color: #333;
  107. }
  108. .header-subtitle{
  109. margin-top:10rpx;
  110. font-size:22rpx;
  111. color:#8896a7;
  112. }
  113. .header-link {
  114. font-size: 24rpx;
  115. color: #1857d4;
  116. border:1rpx solid #1857d4;
  117. padding:10rpx 20rpx;
  118. border-radius:50rpx;
  119. background-color: #f5f8ff;
  120. }
  121. }
  122. .card-body{
  123. display: flex;
  124. padding:0 36rpx 36rpx;
  125. .card-left-bxo{
  126. flex:1;
  127. text-align: center;
  128. padding: 10rpx 6rpx;
  129. background: #f6f8ff;
  130. border-radius: 10rpx;
  131. margin-right: 16rpx;
  132. .card-top-text-box{
  133. margin-top:20rpx;
  134. display: flex;
  135. view:nth-child(1){
  136. font-size: 44rpx;
  137. line-height:44rpx;
  138. font-weight: 700;
  139. color: #1677ff;
  140. flex:1;
  141. text-align: right;
  142. }
  143. view:nth-child(2){
  144. margin-top:10rpx;
  145. font-size:26rpx;
  146. line-height:26rpx;
  147. width:30rpx;
  148. }
  149. view:nth-child(3){
  150. margin-top:10rpx;
  151. font-size:26rpx;
  152. line-height:26rpx;
  153. flex:1;
  154. text-align: left;
  155. }
  156. }
  157. .card-name-box{
  158. font-size: 22rpx;
  159. margin-top:8rpx;
  160. color:#8896a7;
  161. }
  162. .card-num-box{
  163. margin:16rpx 10rpx;
  164. height: 10rpx;
  165. border-radius: 12rpx;
  166. background: #e8eaf6;
  167. overflow: hidden;
  168. view{
  169. border-radius: 12rpx;
  170. height: 10rpx;
  171. background: linear-gradient(90deg, #1677ff, #69b1ff);
  172. }
  173. }
  174. }
  175. .card-right-bxo{
  176. flex:1;
  177. text-align: center;
  178. padding: 10rpx 6rpx;
  179. background: #f6ffed;
  180. border-radius: 10rpx;
  181. .card-top-text-box{
  182. margin-top:20rpx;
  183. font-size: 44rpx;
  184. line-height:44rpx;
  185. font-weight: 700;
  186. color: #52c41a;
  187. }
  188. .card-name-box{
  189. font-size: 22rpx;
  190. margin-top:8rpx;
  191. color:#8896a7;
  192. }
  193. .card-num-box{
  194. margin:16rpx 10rpx;
  195. height: 10rpx;
  196. border-radius: 12rpx;
  197. background: #e8eaf6;
  198. overflow: hidden;
  199. view{
  200. border-radius: 12rpx;
  201. height: 10rpx;
  202. background: linear-gradient(90deg, #52c41a, #95de64);
  203. }
  204. }
  205. }
  206. }
  207. }
  208. </style>