question_report.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. <template>
  2. <view>
  3. <view class="top">
  4. <view class="title">{{reportdata.examName}}</view>
  5. <view class="desc">交卷时间:{{$method.timestampToTime(reportdata.updateTime,false)}}</view>
  6. <view class="box">
  7. <view class="left">
  8. <view>{{(reportdata.rightQuestionNum / reportdata.totalQuestionNum * 100).toFixed(0)}}%</view>
  9. <view>正确率</view>
  10. <view>不含简答/案例题</view>
  11. </view>
  12. <view class="right">
  13. <view class="flex up">
  14. <image src="/static/5-4_03.png" mode=""></image>
  15. <view class="text">正确题数</view>
  16. <text class="red">{{reportdata.rightQuestionNum}}</text>
  17. </view>
  18. <view class="flex down">
  19. <image src="/static/5-4_03.png" mode=""></image>
  20. <view class="text">错误题数</view>
  21. <text class="green">{{reportdata.totalQuestionNum - reportdata.rightQuestionNum}}</text>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. <view class="bottom">
  27. <view class="circle-wrap">
  28. <view class="circle-list">
  29. <view class="item">
  30. <view class="title">
  31. 试卷得分
  32. <text>(不含简答和案例题)</text>
  33. </view>
  34. <canvas class="canvas" canvas-id="Canvas1"></canvas>
  35. </view>
  36. <view class="item">
  37. <view class="title">
  38. 答题时长
  39. </view>
  40. <canvas canvas-id="Canvas2"></canvas>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. </template>
  47. <script>
  48. import { mapGetters } from 'vuex';
  49. export default {
  50. data() {
  51. return {
  52. id:'',
  53. reportdata:{},
  54. context1:null,
  55. context2:null,
  56. };
  57. },
  58. onUnload() {
  59. },
  60. computed: { ...mapGetters(['userInfo']) },
  61. onLoad(option) {
  62. this.id = option.id;
  63. this.examReport();
  64. },
  65. onShow() {
  66. uni.getSystemInfo({
  67. success:(res) => {
  68. var winW = res.screenWidth;
  69. var winH = res.screenHeight;
  70. uni.createSelectorQuery().in(this).select('.canvas').boundingClientRect().exec((newRes)=>{
  71. var width = newRes[0].width;
  72. var height = newRes[0].height;
  73. var caculateX = winW/750;
  74. var caculateY = winH/1334;
  75. console.log(caculateX)
  76. var context1 = uni.createCanvasContext('Canvas1')
  77. this.context1 = context1;
  78. context1.setStrokeStyle("#EEEEEE")
  79. context1.setLineWidth(caculateX * 20)
  80. context1.arc(caculateX * 90, caculateX * 90, caculateX * 80, 0, 2 * Math.PI, true)
  81. // context1.arc(caculateX * 90, caculateX * 90, caculateX * 80, 0, (this.reportdata.performance / this.reportdata.goodsId) * 2 * Math.PI, false);
  82. context1.stroke()
  83. context1.beginPath()
  84. context1.setStrokeStyle("#32D74B")
  85. context1.setFillStyle('#32D74B')
  86. context1.setTextAlign('center')
  87. context1.setTextBaseline('middle')
  88. context1.setLineCap('round')
  89. context1.setFontSize(caculateX * 64)
  90. context1.fillText(this.reportdata.performance, caculateX * 90, caculateX * 90, caculateX * 180)
  91. context1.setFillStyle('#999999')
  92. context1.setFontSize(caculateX * 20)
  93. context1.fillText('满分100', caculateX * 90, caculateX * 130, caculateX * 180)
  94. context1.arc(caculateX * 90, caculateX * 90, caculateX * 80, 0, (this.reportdata.performance / 100) * 2 * Math.PI, false)
  95. context1.stroke()
  96. context1.draw()
  97. var context2 = uni.createCanvasContext('Canvas2')
  98. this.context2 = context2;
  99. context2.setStrokeStyle("#EEEEEE")
  100. context2.setLineWidth(caculateX * 20)
  101. context2.arc(caculateX * 90, caculateX * 90, caculateX * 80, 0, 2 * Math.PI, true)
  102. context2.stroke()
  103. context2.beginPath()
  104. context2.setStrokeStyle("#007AFF")
  105. context2.setFillStyle("#007AFF")
  106. context2.setTextAlign('center')
  107. context1.setTextBaseline('middle')
  108. context2.setLineCap('round')
  109. context2.setFontSize(caculateX * 64)
  110. context2.fillText("12'", caculateX * 90, caculateX * 90, caculateX * 180)
  111. context2.setFillStyle('#999999')
  112. context2.setFontSize(caculateX * 20)
  113. context2.fillText("限时120'", caculateX * 90, caculateX * 130, caculateX * 180)
  114. context2.arc(caculateX * 90, caculateX * 90, caculateX * 80, 0, Math.PI, true)
  115. context2.stroke()
  116. context2.draw()
  117. })
  118. }
  119. })
  120. },
  121. methods: {
  122. examReport() {
  123. this.$api.examReport(this.id).then(res => {
  124. this.reportdata = res.data.data;
  125. })
  126. }
  127. }
  128. };
  129. </script>
  130. <style >
  131. page{
  132. background-color: #EAEEF1;
  133. }
  134. </style>
  135. <style lang="scss" scope>
  136. .top {
  137. margin:16rpx 16rpx 0;
  138. border-radius: 16rpx;
  139. padding:40rpx 24rpx 16rpx;
  140. background:#fff;
  141. .title {
  142. font-size: 32rpx;
  143. font-weight: bold;
  144. color: #333333;
  145. }
  146. .desc {
  147. margin-top:20rpx;
  148. font-size: 24rpx;
  149. color: #999999;
  150. }
  151. .box {
  152. margin-top:30rpx;
  153. display: flex;
  154. .left {
  155. width: 250rpx;
  156. height: 176rpx;
  157. background: #F5F5F5;
  158. border-radius: 16rpx;
  159. display: flex;
  160. align-items: center;
  161. justify-content: center;
  162. flex-direction: column;
  163. margin-right:16rpx;
  164. view {
  165. text-align: center;
  166. &:nth-of-type(1) {
  167. font-size: 60rpx;
  168. font-weight: bold;
  169. color: #007AFF;
  170. }
  171. &:nth-of-type(2) {
  172. font-size: 32rpx;
  173. font-weight: bold;
  174. color: #333333;
  175. }
  176. &:nth-of-type(3) {
  177. font-size: 24rpx;
  178. color: #999999;
  179. }
  180. }
  181. }
  182. .right{
  183. flex:1;
  184. display: flex;
  185. flex-direction: column;
  186. justify-content: space-between;
  187. .flex {
  188. background:#F5F5F5;
  189. display: flex;
  190. height: 80rpx;
  191. align-items: center;
  192. padding:0 40rpx;
  193. border-radius: 16rpx;
  194. image {
  195. width: 30rpx;
  196. height: 30rpx;
  197. margin-right:28rpx;
  198. }
  199. .text {
  200. flex:1;
  201. font-size: 30rpx;
  202. color: #666666;
  203. }
  204. text {
  205. font-size: 48rpx;
  206. color: #E12626;
  207. &.red {
  208. color:red;
  209. }
  210. &.green {
  211. color:green;
  212. }
  213. }
  214. }
  215. }
  216. }
  217. }
  218. .bottom {
  219. .circle-wrap {
  220. .circle-list {
  221. display: flex;
  222. .item {
  223. padding:20rpx;
  224. border-radius: 16rpx;
  225. background:#fff;
  226. margin:16rpx;
  227. flex:1;
  228. .title {
  229. font-weight: bold;
  230. font-size: 30rpx;
  231. line-height: 24rpx;
  232. color: #333333;
  233. text {
  234. font-size: 20rpx;
  235. color: #999999;
  236. }
  237. }
  238. canvas {
  239. margin:36rpx auto 0;
  240. width:180rpx;
  241. height:180rpx;
  242. }
  243. .text {
  244. text-align: center;
  245. margin-top:16rpx;
  246. font-size: 24rpx;
  247. color: #333333;
  248. }
  249. }
  250. }
  251. }
  252. }
  253. </style>