question_report.vue 8.3 KB

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