question_report.vue 7.7 KB

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