question_report.vue 8.3 KB

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