question_report.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. <template>
  2. <view>
  3. <view :class="reportStatus == 0 ? 'redBtn' : reportStatus == 1 ? 'greenBtn' : 'disNone'">
  4. {{ reportStatus == 0 ? '测试未通过' : reportStatus == 1 ? '测试通过' : '' }}
  5. </view>
  6. <view class="top">
  7. <view class="box">
  8. <view class="left">
  9. <view>{{ ((rightQuestionNum / (rightQuestionNum + doWrongQuestionNum)) * 100).toFixed(0) }}%</view>
  10. <view>正确率</view>
  11. <view>不含简答/案例题</view>
  12. </view>
  13. <view class="right">
  14. <view class="flex up">
  15. <u-icon name="checkmark" color="#16D48B" size="48" style="margin-right: 14rpx;"></u-icon>
  16. <!-- <image src="/static/5-4_03.png" mode=""></image> -->
  17. <view class="text">正确题数</view>
  18. <text class="green">{{ rightQuestionNum }}</text>
  19. </view>
  20. <view class="flex down">
  21. <u-icon name="close" color="#FF3B30" size="38" style="margin-right: 26rpx;"></u-icon>
  22. <!-- <image src="/static/5-4_03.png" mode=""></image> -->
  23. <view class="text">错误题数</view>
  24. <text class="red">{{ doWrongQuestionNum }}</text>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. <view class="bottom">
  30. <view class="circle-wrap">
  31. <view class="circle-list">
  32. <view class="item" v-show="totalScore">
  33. <view class="title">
  34. 试卷得分
  35. <text>(不含简答和案例题)</text>
  36. </view>
  37. <canvas class="canvas" canvas-id="Canvas1"></canvas>
  38. </view>
  39. <view class="item" v-show="examTime">
  40. <view class="title">答题时长</view>
  41. <canvas canvas-id="Canvas2"></canvas>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. import { mapGetters } from 'vuex';
  50. export default {
  51. data() {
  52. return {
  53. id: '',
  54. hideBtns:false,
  55. examData:{},
  56. examId:'',
  57. context1: null,
  58. context2: null,
  59. rightQuestionNum:'',
  60. doWrongQuestionNum:'',
  61. score:'',
  62. totalScore:'',
  63. doTime:'',
  64. examTime:''
  65. };
  66. },
  67. onUnload() {},
  68. computed: { ...mapGetters(['userInfo']) },
  69. async onShow() {
  70. uni.getSystemInfo({
  71. success: res => {
  72. var winW = res.screenWidth;
  73. var winH = res.screenHeight;
  74. uni.createSelectorQuery()
  75. .in(this)
  76. .select('.canvas')
  77. .boundingClientRect()
  78. .exec(async newRes => {
  79. var width = newRes[0].width;
  80. var height = newRes[0].height;
  81. var caculateX = winW / 750;
  82. var caculateY = winH / 1334;
  83. console.log(caculateX);
  84. if(this.totalScore) {
  85. var context1 = uni.createCanvasContext('Canvas1');
  86. this.context1 = context1;
  87. context1.setStrokeStyle('#EEEEEE');
  88. context1.setLineWidth(caculateX * 20);
  89. context1.arc(caculateX * 90, caculateX * 90, caculateX * 80, 0, 2 * Math.PI, true);
  90. context1.stroke();
  91. context1.beginPath();
  92. context1.setStrokeStyle('#32D74B');
  93. context1.setFillStyle('#32D74B');
  94. context1.setTextAlign('center');
  95. context1.setTextBaseline('middle');
  96. context1.setLineCap('round');
  97. context1.setFontSize(caculateX * 64);
  98. context1.fillText(this.score, caculateX * 90, caculateX * 90, caculateX * 180);
  99. context1.setFillStyle('#999999');
  100. context1.setFontSize(caculateX * 20);
  101. context1.fillText(`满分${this.totalScore}`, caculateX * 90, caculateX * 130, caculateX * 180);
  102. context1.arc(caculateX * 90, caculateX * 90, caculateX * 80, -Math.PI/2, -Math.PI/2 + (this.score / this.totalScore) * 2 * Math.PI, false);
  103. context1.stroke();
  104. context1.draw();
  105. }
  106. if(this.examTime) {
  107. var context2 = uni.createCanvasContext('Canvas2');
  108. this.context2 = context2;
  109. context2.setStrokeStyle('#EEEEEE');
  110. context2.setLineWidth(caculateX * 20);
  111. context2.arc(caculateX * 90, caculateX * 90, caculateX * 80, 0, 2 * Math.PI, true);
  112. context2.stroke();
  113. context2.beginPath();
  114. context2.setStrokeStyle('#007AFF');
  115. context2.setFillStyle('#007AFF');
  116. context2.setTextAlign('center');
  117. context2.setTextBaseline('middle');
  118. context2.setLineCap('round');
  119. context2.setFontSize(caculateX * 64);
  120. context2.fillText(`${this.doTime}'`, caculateX * 90, caculateX * 90, caculateX * 180);
  121. context2.setFillStyle('#999999');
  122. context2.setFontSize(caculateX * 20);
  123. context2.fillText(`限时${this.examTime}'`, caculateX * 90, caculateX * 130, caculateX * 180);
  124. context2.arc(caculateX * 90, caculateX * 90, caculateX * 80, -Math.PI/2, -Math.PI/2 + (this.doTime / this.examTime) * 2 * Math.PI, false);
  125. context2.stroke();
  126. context2.draw();
  127. }
  128. });
  129. }
  130. });
  131. },
  132. async onLoad(option) {
  133. this.examTime = option.examTime;
  134. this.doTime = option.doTime;
  135. this.reportStatus = option.reportStatus;
  136. this.rightQuestionNum = +option.rightQuestionNum;
  137. this.doWrongQuestionNum = +option.rightQuestionNum;
  138. this.score = +option.score;
  139. this.totalScore = +option.totalScore;
  140. // this.hideBtns = Boolean(option.hideBtns);
  141. },
  142. methods: {
  143. }
  144. };
  145. </script>
  146. <style>
  147. page {
  148. background-color: #eaeef1;
  149. }
  150. </style>
  151. <style lang="scss" scope>
  152. .disNone {
  153. display: none;
  154. }
  155. .greenBtn {
  156. margin: 16rpx 16rpx 0;
  157. height: 80rpx;
  158. line-height: 80rpx;
  159. text-align: center;
  160. background-color: #f7fff8;
  161. border-radius: 16rpx;
  162. color: #34c759;
  163. font-weight: bold;
  164. font-size: 30rpx;
  165. }
  166. .redBtn {
  167. margin: 16rpx 16rpx 0;
  168. height: 80rpx;
  169. line-height: 80rpx;
  170. text-align: center;
  171. background-color: #FFF3F2;
  172. border-radius: 16rpx;
  173. color: #FF3B30;
  174. font-weight: bold;
  175. font-size: 30rpx;
  176. }
  177. .dis_fst {
  178. margin-top: 40rpx;
  179. display: flex;
  180. align-items: center;
  181. justify-content: space-around;
  182. }
  183. .btnACs {
  184. height: 48rpx;
  185. width: 160rpx;
  186. text-align: center;
  187. line-height: 48rpx;
  188. border: 1rpx solid #007aff;
  189. border-radius: 16rpx;
  190. color: #007aff;
  191. font-size: 24rpx;
  192. }
  193. .top {
  194. margin: 16rpx 16rpx 0;
  195. border-radius: 16rpx;
  196. padding: 40rpx 24rpx 16rpx;
  197. background: #fff;
  198. .title {
  199. font-size: 32rpx;
  200. font-weight: bold;
  201. color: #333333;
  202. }
  203. .desc {
  204. margin-top: 20rpx;
  205. font-size: 24rpx;
  206. color: #999999;
  207. }
  208. .box {
  209. margin-top: 30rpx;
  210. display: flex;
  211. .left {
  212. width: 250rpx;
  213. height: 176rpx;
  214. background: #f5f5f5;
  215. border-radius: 16rpx;
  216. display: flex;
  217. align-items: center;
  218. justify-content: center;
  219. flex-direction: column;
  220. margin-right: 16rpx;
  221. view {
  222. text-align: center;
  223. &:nth-of-type(1) {
  224. font-size: 60rpx;
  225. font-weight: bold;
  226. color: #007aff;
  227. }
  228. &:nth-of-type(2) {
  229. font-size: 32rpx;
  230. font-weight: bold;
  231. color: #333333;
  232. }
  233. &:nth-of-type(3) {
  234. font-size: 24rpx;
  235. color: #999999;
  236. }
  237. }
  238. }
  239. .right {
  240. flex: 1;
  241. display: flex;
  242. flex-direction: column;
  243. justify-content: space-between;
  244. .flex {
  245. background: #f5f5f5;
  246. display: flex;
  247. height: 80rpx;
  248. align-items: center;
  249. padding: 0 40rpx;
  250. border-radius: 16rpx;
  251. image {
  252. width: 30rpx;
  253. height: 30rpx;
  254. margin-right: 28rpx;
  255. }
  256. .text {
  257. flex: 1;
  258. font-size: 30rpx;
  259. color: #666666;
  260. }
  261. text {
  262. font-size: 48rpx;
  263. color: #e12626;
  264. &.red {
  265. color: red;
  266. }
  267. &.green {
  268. color: green;
  269. }
  270. }
  271. }
  272. }
  273. }
  274. }
  275. .bottom {
  276. .circle-wrap {
  277. .circle-list {
  278. display: flex;
  279. .item {
  280. padding: 20rpx;
  281. border-radius: 16rpx;
  282. background: #fff;
  283. margin: 16rpx;
  284. flex: 1;
  285. .title {
  286. font-weight: bold;
  287. font-size: 30rpx;
  288. line-height: 24rpx;
  289. color: #333333;
  290. text {
  291. font-size: 20rpx;
  292. color: #999999;
  293. }
  294. }
  295. canvas {
  296. margin: 36rpx auto 0;
  297. width: 180rpx;
  298. height: 180rpx;
  299. }
  300. .text {
  301. text-align: center;
  302. margin-top: 16rpx;
  303. font-size: 24rpx;
  304. color: #333333;
  305. }
  306. }
  307. }
  308. }
  309. }
  310. </style>