index.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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. timer: null,
  46. }
  47. },
  48. onLoad(option) {
  49. this.goodsId = option.goodsId
  50. this.orderGoodsId = option.orderGoodsId
  51. this.getLock()
  52. this.timer = setInterval(this.getLock, 10000)
  53. },
  54. onShow() {
  55. this.getQuestionTempNum()
  56. },
  57. onUnload() {
  58. clearInterval(this.timer)
  59. this.$api.lockDelLock({
  60. action: 'bank',
  61. uuid: this.$method.getUuid()
  62. }).then(res => {
  63. })
  64. },
  65. computed: {
  66. accuracy() {
  67. if (this.questionNum.rightNum >= this.questionNum.totalNum) {
  68. return '100%'
  69. } else {
  70. let value = (this.questionNum.rightNum / this.questionNum.totalNum ) * 100
  71. return value.toFixed(2) + '%'
  72. }
  73. }
  74. },
  75. methods: {
  76. getLock() {
  77. this.$api.lockLockAction({
  78. action: 'bank',
  79. uuid: this.$method.getUuid()
  80. }).then(res => {
  81. })
  82. },
  83. changeNum(item) {
  84. this.number = item
  85. },
  86. getQuestionTempNum() {
  87. this.$http({
  88. url: `/goods/bank/questionTempNum/${this.orderGoodsId}`,
  89. method: 'get',
  90. }).then((res) => {
  91. if (res.data.code == 200) {
  92. this.questionNum = res.data.data || {}
  93. }
  94. })
  95. },
  96. startPractice() {
  97. this.$http({
  98. url: '/bank/exam/temp',
  99. method: 'post',
  100. data: {
  101. goodsId: this.goodsId,
  102. orderGoodsId: this.orderGoodsId,
  103. number: this.number
  104. }
  105. }).then((res) => {
  106. if(res.data.code == 200) {
  107. uni.navigateTo({
  108. url:'/pages2/bank/questionBank?orderGoodsId='+ this.orderGoodsId + '&id=""' + '&goodsid=' + this.goodsId
  109. +'&moduleId=0' + '&chapterId=0' + '&entryType=random' + '&bankNum=' + this.number
  110. })
  111. } else {
  112. this.$u.toast(res.data.msg)
  113. }
  114. })
  115. }
  116. },
  117. }
  118. </script>
  119. <style lang="scss">
  120. .random_practice {
  121. width: 100%;
  122. padding: 24rpx 26rpx;
  123. background: #FAFAFA;
  124. }
  125. .contents {
  126. width: 100%;
  127. height: 100%;
  128. display: flex;
  129. flex-direction: column;
  130. align-items: center;
  131. .examSitu {
  132. width: 200rpx;
  133. height: 200rpx;
  134. margin-bottom: 56rpx;
  135. }
  136. .exam_si {
  137. color: #222222;
  138. font-size: 32rpx;
  139. font-weight: bold;
  140. margin: 80rpx 0rpx 40rpx 0rpx;
  141. }
  142. .nums {
  143. width: 100%;
  144. display: flex;
  145. align-items: center;
  146. justify-content: space-around;
  147. margin-bottom: 132rpx;
  148. .n_item {
  149. display: flex;
  150. flex-direction: column;
  151. align-items: center;
  152. .do_num {
  153. font-size: 48rpx;
  154. font-family: DIN-Medium, DIN;
  155. font-weight: 500;
  156. color: #222222;
  157. margin-bottom: 8rpx;
  158. }
  159. .word {
  160. font-size: 24rpx;
  161. font-family: PingFang SC-Medium, PingFang SC;
  162. font-weight: 500;
  163. color: #808DA4;
  164. }
  165. }
  166. }
  167. }
  168. .number_crad {
  169. width: 100%;
  170. padding: 0rpx 26rpx;
  171. text-align: center;
  172. background-color: #fff;
  173. margin-bottom: 178rpx;
  174. border-radius: 24rpx;
  175. .title {
  176. font-size: 36rpx;
  177. font-family: PingFang SC-Medium, PingFang SC;
  178. font-weight: 500;
  179. color: #222222;
  180. margin: 56rpx 0rpx;
  181. }
  182. .crads {
  183. display: flex;
  184. flex-wrap: wrap;
  185. justify-content: space-between;
  186. .items {
  187. width: 204rpx;
  188. height: 96rpx;
  189. line-height: 96rpx;
  190. text-align: center;
  191. background: #F8F8FA;
  192. border-radius: 24rpx;
  193. margin-bottom: 28rpx;
  194. font-size: 48rpx;
  195. font-family: DIN Alternate-Bold, DIN Alternate;
  196. font-weight: bold;
  197. color: #222222;
  198. &.nactive {
  199. background: #E8F6FF;
  200. color: #3577E8;
  201. }
  202. }
  203. }
  204. .starts {
  205. width: 646rpx;
  206. height: 96rpx;
  207. line-height: 96rpx;
  208. text-align: center;
  209. color: #fff;
  210. font-size: 32rpx;
  211. font-weight: bold;
  212. background: #3577E8;
  213. border-radius: 24rpx;
  214. margin: 52rpx 0rpx 40rpx 0rpx;
  215. }
  216. }
  217. </style>