question_report.vue 7.7 KB

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