index.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <template>
  2. <view class="random_practice">
  3. <nav-bar title="随机练习"></nav-bar>
  4. <view class="contents">
  5. <view class="exam_si">试卷情况</view>
  6. <image src="/pages2/static/random/exam_situ.png" class="examSitu"></image>
  7. <view class="nums">
  8. <view class="n_item">
  9. <text class="do_num">{{ questionNum.doNum || 0 }}</text>
  10. <text class="word">已完成题数</text>
  11. </view>
  12. <view class="n_item">
  13. <text class="do_num">{{ questionNum.totalNum || 0 }}</text>
  14. <text class="word">总题数</text>
  15. </view>
  16. <view class="n_item">
  17. <text class="do_num">{{ accuracy }}</text>
  18. <text class="word">正确率</text>
  19. </view>
  20. </view>
  21. <view class="number_crad">
  22. <view class="title">选择做题数量</view>
  23. <view class="crads">
  24. <view v-for="(item, index) in numberLists" :key="index" class="items"
  25. :class="{nactive: item == number}" @click="changeNum(item)">
  26. {{item}}
  27. </view>
  28. </view>
  29. <view class="starts" @click="startPractice()">
  30. 开始做题
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. export default {
  38. data() {
  39. return {
  40. goodsId: '',
  41. orderGoodsId: '',
  42. numberLists: [5, 10, 15, 20, 50, 100],
  43. number: 5,
  44. questionNum: {}
  45. }
  46. },
  47. onLoad(option) {
  48. this.goodsId = option.goodsId
  49. this.orderGoodsId = option.orderGoodsId
  50. },
  51. onShow() {
  52. this.getQuestionTempNum()
  53. },
  54. computed: {
  55. accuracy() {
  56. if (this.questionNum.rightNum >= this.questionNum.totalNum) {
  57. return '100%'
  58. } else {
  59. let value = (this.questionNum.rightNum / this.questionNum.totalNum ) * 100
  60. return value.toFixed(2) + '%'
  61. }
  62. }
  63. },
  64. methods: {
  65. changeNum(item) {
  66. this.number = item
  67. },
  68. getQuestionTempNum() {
  69. this.$http({
  70. url: `/goods/bank/questionTempNum/${this.orderGoodsId}`,
  71. method: 'get',
  72. }).then((res) => {
  73. if (res.data.code == 200) {
  74. this.questionNum = res.data.data || {}
  75. }
  76. })
  77. },
  78. startPractice() {
  79. this.$http({
  80. url: '/bank/exam/temp',
  81. method: 'post',
  82. data: {
  83. goodsId: this.goodsId,
  84. orderGoodsId: this.orderGoodsId,
  85. number: this.number
  86. }
  87. }).then((res) => {
  88. if(res.data.code == 200) {
  89. uni.navigateTo({
  90. url:'/pages2/bank/questionBank?orderGoodsId='+ this.orderGoodsId + '&id=""' + '&goodsid=' + this.goodsId
  91. +'&moduleId=0' + '&chapterId=0' + '&entryType=random' + '&bankNum=' + this.number
  92. })
  93. } else {
  94. this.$u.toast(res.data.msg)
  95. }
  96. })
  97. }
  98. },
  99. }
  100. </script>
  101. <style lang="scss">
  102. .random_practice {
  103. width: 100%;
  104. padding: 24rpx 26rpx;
  105. background: #FAFAFA;
  106. }
  107. .contents {
  108. width: 100%;
  109. height: 100%;
  110. display: flex;
  111. flex-direction: column;
  112. align-items: center;
  113. .examSitu {
  114. width: 200rpx;
  115. height: 200rpx;
  116. margin-bottom: 56rpx;
  117. }
  118. .exam_si {
  119. color: #222222;
  120. font-size: 32rpx;
  121. font-weight: bold;
  122. margin: 80rpx 0rpx 40rpx 0rpx;
  123. }
  124. .nums {
  125. width: 100%;
  126. display: flex;
  127. align-items: center;
  128. justify-content: space-around;
  129. margin-bottom: 132rpx;
  130. .n_item {
  131. display: flex;
  132. flex-direction: column;
  133. align-items: center;
  134. .do_num {
  135. font-size: 48rpx;
  136. font-family: DIN-Medium, DIN;
  137. font-weight: 500;
  138. color: #222222;
  139. margin-bottom: 8rpx;
  140. }
  141. .word {
  142. font-size: 24rpx;
  143. font-family: PingFang SC-Medium, PingFang SC;
  144. font-weight: 500;
  145. color: #808DA4;
  146. }
  147. }
  148. }
  149. }
  150. .number_crad {
  151. width: 100%;
  152. padding: 0rpx 26rpx;
  153. text-align: center;
  154. background-color: #fff;
  155. margin-bottom: 178rpx;
  156. border-radius: 24rpx;
  157. .title {
  158. font-size: 36rpx;
  159. font-family: PingFang SC-Medium, PingFang SC;
  160. font-weight: 500;
  161. color: #222222;
  162. margin: 56rpx 0rpx;
  163. }
  164. .crads {
  165. display: flex;
  166. flex-wrap: wrap;
  167. justify-content: space-between;
  168. .items {
  169. width: 204rpx;
  170. height: 96rpx;
  171. line-height: 96rpx;
  172. text-align: center;
  173. background: #F8F8FA;
  174. border-radius: 24rpx;
  175. margin-bottom: 28rpx;
  176. font-size: 48rpx;
  177. font-family: DIN Alternate-Bold, DIN Alternate;
  178. font-weight: bold;
  179. color: #222222;
  180. &.nactive {
  181. background: #E8F6FF;
  182. color: #3577E8;
  183. }
  184. }
  185. }
  186. .starts {
  187. width: 646rpx;
  188. height: 96rpx;
  189. line-height: 96rpx;
  190. text-align: center;
  191. color: #fff;
  192. font-size: 32rpx;
  193. font-weight: bold;
  194. background: #3577E8;
  195. border-radius: 24rpx;
  196. margin: 52rpx 0rpx 40rpx 0rpx;
  197. }
  198. }
  199. </style>