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