question_report.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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>100%</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.stroke()
  82. context1.beginPath()
  83. context1.setStrokeStyle("#32D74B")
  84. context1.setFillStyle('#32D74B')
  85. context1.setTextAlign('center')
  86. context1.setTextBaseline('middle')
  87. context1.setLineCap('round')
  88. context1.setFontSize(caculateX * 64)
  89. context1.fillText('60', caculateX * 90, caculateX * 90, caculateX * 180)
  90. context1.setFillStyle('#999999')
  91. context1.setFontSize(caculateX * 20)
  92. context1.fillText('满分100', caculateX * 90, caculateX * 130, caculateX * 180)
  93. context1.arc(caculateX * 90, caculateX * 90, caculateX * 80, 0, Math.PI, true)
  94. context1.stroke()
  95. context1.draw()
  96. var context2 = uni.createCanvasContext('Canvas2')
  97. this.context2 = context2;
  98. context2.setStrokeStyle("#EEEEEE")
  99. context2.setLineWidth(caculateX * 20)
  100. context2.arc(caculateX * 90, caculateX * 90, caculateX * 80, 0, 2 * Math.PI, true)
  101. context2.stroke()
  102. context2.beginPath()
  103. context2.setStrokeStyle("#007AFF")
  104. context2.setFillStyle("#007AFF")
  105. context2.setTextAlign('center')
  106. context1.setTextBaseline('middle')
  107. context2.setLineCap('round')
  108. context2.setFontSize(caculateX * 64)
  109. context2.fillText("12'", caculateX * 90, caculateX * 90, caculateX * 180)
  110. context2.setFillStyle('#999999')
  111. context2.setFontSize(caculateX * 20)
  112. context2.fillText("限时120'", caculateX * 90, caculateX * 130, caculateX * 180)
  113. context2.arc(caculateX * 90, caculateX * 90, caculateX * 80, 0, Math.PI, true)
  114. context2.stroke()
  115. context2.draw()
  116. })
  117. }
  118. })
  119. },
  120. methods: {
  121. examReport() {
  122. this.$api.examReport(this.id).then(res => {
  123. this.reportdata = res.data.data;
  124. })
  125. }
  126. }
  127. };
  128. </script>
  129. <style >
  130. page{
  131. background-color: #EAEEF1;
  132. }
  133. </style>
  134. <style lang="scss" scope>
  135. .top {
  136. margin:16rpx 16rpx 0;
  137. border-radius: 16rpx;
  138. padding:40rpx 24rpx 16rpx;
  139. background:#fff;
  140. .title {
  141. font-size: 32rpx;
  142. font-weight: bold;
  143. color: #333333;
  144. }
  145. .desc {
  146. margin-top:20rpx;
  147. font-size: 24rpx;
  148. color: #999999;
  149. }
  150. .box {
  151. margin-top:30rpx;
  152. display: flex;
  153. .left {
  154. width: 250rpx;
  155. height: 176rpx;
  156. background: #F5F5F5;
  157. border-radius: 16rpx;
  158. display: flex;
  159. align-items: center;
  160. justify-content: center;
  161. flex-direction: column;
  162. margin-right:16rpx;
  163. view {
  164. text-align: center;
  165. &:nth-of-type(1) {
  166. font-size: 60rpx;
  167. font-weight: bold;
  168. color: #007AFF;
  169. }
  170. &:nth-of-type(2) {
  171. font-size: 32rpx;
  172. font-weight: bold;
  173. color: #333333;
  174. }
  175. &:nth-of-type(3) {
  176. font-size: 24rpx;
  177. color: #999999;
  178. }
  179. }
  180. }
  181. .right{
  182. flex:1;
  183. display: flex;
  184. flex-direction: column;
  185. justify-content: space-between;
  186. .flex {
  187. background:#F5F5F5;
  188. display: flex;
  189. height: 80rpx;
  190. align-items: center;
  191. padding:0 40rpx;
  192. border-radius: 16rpx;
  193. image {
  194. width: 30rpx;
  195. height: 30rpx;
  196. margin-right:28rpx;
  197. }
  198. .text {
  199. flex:1;
  200. font-size: 30rpx;
  201. color: #666666;
  202. }
  203. text {
  204. font-size: 48rpx;
  205. color: #E12626;
  206. &.red {
  207. color:red;
  208. }
  209. &.green {
  210. color:green;
  211. }
  212. }
  213. }
  214. }
  215. }
  216. }
  217. .bottom {
  218. .circle-wrap {
  219. .circle-list {
  220. display: flex;
  221. .item {
  222. padding:20rpx;
  223. border-radius: 16rpx;
  224. background:#fff;
  225. margin:16rpx;
  226. flex:1;
  227. .title {
  228. font-weight: bold;
  229. font-size: 30rpx;
  230. line-height: 24rpx;
  231. color: #333333;
  232. text {
  233. font-size: 20rpx;
  234. color: #999999;
  235. }
  236. }
  237. canvas {
  238. margin:36rpx auto 0;
  239. width:180rpx;
  240. height:180rpx;
  241. }
  242. .text {
  243. text-align: center;
  244. margin-top:16rpx;
  245. font-size: 24rpx;
  246. color: #333333;
  247. }
  248. }
  249. }
  250. }
  251. }
  252. </style>