mockPractice.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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+'%;'"></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+'%;'"></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. uni.navigateTo({
  63. url: '/pages_safetyEducationExamination/views/practice/index',
  64. });
  65. },
  66. async examUserPracticeSummary() {
  67. try {
  68. const { data } = await examUserPracticeSummary();
  69. if (data.code === 200){
  70. this.$set(this,'newData',data.data);
  71. this.$set(this,'num',this.completedPercentage(data.data));
  72. }
  73. } catch (e) { console.error('模拟练习数据错误', e); }
  74. },
  75. // 计算完成百分比
  76. completedPercentage(data) {
  77. if (data.totalCount === 0) {
  78. return 0;
  79. }
  80. const percentage = (data.completedCount / data.totalCount) * 100;
  81. return parseFloat(percentage.toFixed(2));
  82. }
  83. },
  84. }
  85. </script>
  86. <style lang="stylus" scoped>
  87. .mockPractice-component {
  88. margin: 0 32rpx 32rpx;
  89. .card {
  90. background: #fff;
  91. border-radius: 24rpx;
  92. overflow: hidden;
  93. margin-bottom: 24rpx;
  94. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.03);
  95. border: 1px solid #dde3ed;
  96. }
  97. .card-header {
  98. padding: 20rpx 28rpx;
  99. display: flex;
  100. justify-content: space-between;
  101. align-items: center;
  102. .card-title {
  103. font-size: 28rpx;
  104. color: #333;
  105. }
  106. .header-subtitle{
  107. margin-top:10rpx;
  108. font-size:22rpx;
  109. color:#8896a7;
  110. }
  111. .header-link {
  112. font-size: 24rpx;
  113. color: #1857d4;
  114. border:1rpx solid #1857d4;
  115. padding:10rpx 20rpx;
  116. border-radius:50rpx;
  117. background-color: #f5f8ff;
  118. }
  119. }
  120. .card-body{
  121. display: flex;
  122. padding:0 36rpx 36rpx;
  123. .card-left-bxo{
  124. flex:1;
  125. text-align: center;
  126. padding: 10rpx 6rpx;
  127. background: #f6f8ff;
  128. border-radius: 10rpx;
  129. margin-right: 16rpx;
  130. .card-top-text-box{
  131. margin-top:20rpx;
  132. display: flex;
  133. view:nth-child(1){
  134. font-size: 44rpx;
  135. line-height:44rpx;
  136. font-weight: 700;
  137. color: #1677ff;
  138. flex:1;
  139. text-align: right;
  140. }
  141. view:nth-child(2){
  142. margin-top:10rpx;
  143. font-size:26rpx;
  144. line-height:26rpx;
  145. width:30rpx;
  146. }
  147. view:nth-child(3){
  148. margin-top:10rpx;
  149. font-size:26rpx;
  150. line-height:26rpx;
  151. flex:1;
  152. text-align: left;
  153. }
  154. }
  155. .card-name-box{
  156. font-size: 22rpx;
  157. margin-top:8rpx;
  158. color:#8896a7;
  159. }
  160. .card-num-box{
  161. margin:16rpx 10rpx;
  162. height: 10rpx;
  163. border-radius: 12rpx;
  164. background: #e8eaf6;
  165. overflow: hidden;
  166. view{
  167. border-radius: 12rpx;
  168. height: 10rpx;
  169. background: linear-gradient(90deg, #1677ff, #69b1ff);
  170. }
  171. }
  172. }
  173. .card-right-bxo{
  174. flex:1;
  175. text-align: center;
  176. padding: 10rpx 6rpx;
  177. background: #f6ffed;
  178. border-radius: 10rpx;
  179. .card-top-text-box{
  180. margin-top:20rpx;
  181. font-size: 44rpx;
  182. line-height:44rpx;
  183. font-weight: 700;
  184. color: #52c41a;
  185. }
  186. .card-name-box{
  187. font-size: 22rpx;
  188. margin-top:8rpx;
  189. color:#8896a7;
  190. }
  191. .card-num-box{
  192. margin:16rpx 10rpx;
  193. height: 10rpx;
  194. border-radius: 12rpx;
  195. background: #e8eaf6;
  196. overflow: hidden;
  197. view{
  198. border-radius: 12rpx;
  199. height: 10rpx;
  200. background: linear-gradient(90deg, #52c41a, #95de64);
  201. }
  202. }
  203. }
  204. }
  205. }
  206. </style>