question_report.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  1. <template>
  2. <view>
  3. <view :class="reportdata.reportStatus === 0 ? 'redBtn' : reportdata.reportStatus === 1 ? 'greenBtn' : 'disNone'" v-if="examData.doType == 2 && reportdata.reportStatus !== null">
  4. {{ reportdata.reportStatus === 0 ? '测试未通过' : reportdata.reportStatus === 1 ? '测试通过' : '' }}
  5. </view>
  6. <view class="top">
  7. <view class="title">{{ reportdata.examName }}</view>
  8. <view class="desc">交卷时间:{{ $method.timestampToTime(reportdata.updateTime, false) }}</view>
  9. <view class="box">
  10. <view class="left">
  11. <view>{{ (((reportdata.rightQuestionNum / (reportdata.rightQuestionNum + wrongRecordWrongNum)) || 0) * 100).toFixed(0)}}%</view>
  12. <view>正确率</view>
  13. <view>不含简答/案例题</view>
  14. </view>
  15. <view class="right">
  16. <view class="flex up">
  17. <u-icon name="checkmark" color="#16D48B" size="48" style="margin-right: 14rpx;"></u-icon>
  18. <!-- <image src="/static/5-4_03.png" mode=""></image> -->
  19. <view class="text">正确题数</view>
  20. <text class="green">{{ reportdata.rightQuestionNum }}</text>
  21. </view>
  22. <view class="flex down">
  23. <u-icon name="close" color="#FF3B30" size="38" style="margin-right: 26rpx;"></u-icon>
  24. <!-- <image src="/static/5-4_03.png" mode=""></image> -->
  25. <view class="text">错误题数</view>
  26. <text class="red">{{ wrongRecordWrongNum }}</text>
  27. </view>
  28. </view>
  29. </view>
  30. <view class="dis_fst" v-if="!hideBtns">
  31. <navigator
  32. :url="
  33. '/pages2/bank/questionBankWrongExplain?recordId=' + reportdata.recordId+'&id='+examData.examId
  34. "
  35. >
  36. <view class="btnACs" v-if="wrongRecordWrongNum != 0">错题解析</view>
  37. </navigator>
  38. <navigator
  39. :url="
  40. '/pages2/bank/questionBankAllExplain?id=' +
  41. reportdata.examId +
  42. '&goodsid=' +
  43. reportdata.goodsId +
  44. '&moduleId=' +
  45. reportdata.moduleExamId +
  46. '&chapterId=' +
  47. reportdata.chapterExamId +
  48. '&recordId='+ reportdata.recordId
  49. "
  50. >
  51. <view class="btnACs">全部解析</view>
  52. </navigator>
  53. <view class="btnACs" @click="doRepeat(reportdata.examId, reportdata.goodsId, reportdata.moduleExamId, reportdata.chapterExamId)">重新做题</view>
  54. <view class="btnACs" @click="backBank">继续做题</view>
  55. </view>
  56. </view>
  57. <view class="bottom">
  58. <view class="circle-wrap">
  59. <view class="circle-list">
  60. <view class="item" v-show="reportdata.totalScore">
  61. <view class="title">
  62. 试卷得分
  63. <text>(不含简答和案例题)</text>
  64. </view>
  65. <canvas class="canvas" canvas-id="Canvas1"></canvas>
  66. </view>
  67. <view class="item" v-show="reportdata.examTime">
  68. <view class="title">答题时长</view>
  69. <canvas canvas-id="Canvas2"></canvas>
  70. </view>
  71. <view class="item" v-show="reportdata.score">
  72. <view class="title">试卷得分
  73. <text>(含简答和案例题)</text>
  74. </view>
  75. <canvas canvas-id="Canvas3"></canvas>
  76. </view>
  77. </view>
  78. </view>
  79. </view>
  80. </view>
  81. </template>
  82. <script>
  83. import { mapGetters } from 'vuex';
  84. export default {
  85. data() {
  86. return {
  87. id: '',
  88. hideBtns:false,
  89. recordId:'',
  90. reportdata: {},
  91. examData:{},
  92. examId:'',
  93. context1: null,
  94. context2: null,
  95. wrongRecordWrongNum:'',
  96. };
  97. },
  98. onUnload() {},
  99. computed: { ...mapGetters(['userInfo']) },
  100. async onShow() {
  101. },
  102. async onLoad(option) {
  103. this.recordId = option.id;
  104. this.examId = option.examId;
  105. this.examWrongRecordWrongNum();
  106. await this.bankExam();
  107. await this.examReport();
  108. uni.getSystemInfo({
  109. success: res => {
  110. var winW = res.screenWidth;
  111. var winH = res.screenHeight;
  112. uni.createSelectorQuery()
  113. .in(this)
  114. .select('.canvas')
  115. .boundingClientRect()
  116. .exec(async newRes => {
  117. var width = newRes[0].width;
  118. var height = newRes[0].height;
  119. var caculateX = winW / 750;
  120. var caculateY = winH / 1334;
  121. console.log(caculateX);
  122. if(this.reportdata.totalScore) {
  123. var context1 = uni.createCanvasContext('Canvas1');
  124. this.context1 = context1;
  125. context1.setStrokeStyle('#EEEEEE');
  126. context1.setLineWidth(caculateX * 20);
  127. context1.arc(caculateX * 90, caculateX * 90, caculateX * 80, 0, 2 * Math.PI, true);
  128. context1.stroke();
  129. context1.beginPath();
  130. context1.setStrokeStyle('#32D74B');
  131. context1.setFillStyle('#32D74B');
  132. context1.setTextAlign('center');
  133. context1.setTextBaseline('middle');
  134. context1.setLineCap('round');
  135. context1.setFontSize(caculateX * 64);
  136. context1.fillText(this.reportdata.performance, caculateX * 90, caculateX * 90, caculateX * 180);
  137. context1.setFillStyle('#999999');
  138. context1.setFontSize(caculateX * 20);
  139. context1.fillText(`满分${this.reportdata.totalScore}`, caculateX * 90, caculateX * 130, caculateX * 180);
  140. context1.arc(caculateX * 90, caculateX * 90, caculateX * 80, -Math.PI/2, -Math.PI/2 + (this.reportdata.performance / this.reportdata.totalScore) * 2 * Math.PI, false);
  141. context1.stroke();
  142. context1.draw();
  143. }
  144. if(this.reportdata.examTime) {
  145. var context2 = uni.createCanvasContext('Canvas2');
  146. this.context2 = context2;
  147. context2.setStrokeStyle('#EEEEEE');
  148. context2.setLineWidth(caculateX * 20);
  149. context2.arc(caculateX * 90, caculateX * 90, caculateX * 80, 0, 2 * Math.PI, true);
  150. context2.stroke();
  151. context2.beginPath();
  152. context2.setStrokeStyle('#007AFF');
  153. context2.setFillStyle('#007AFF');
  154. context2.setTextAlign('center');
  155. context2.setTextBaseline('middle');
  156. context2.setLineCap('round');
  157. context2.setFontSize(caculateX * 64);
  158. context2.fillText(`${this.reportdata.doTime}'`, caculateX * 90, caculateX * 90, caculateX * 180);
  159. context2.setFillStyle('#999999');
  160. context2.setFontSize(caculateX * 20);
  161. context2.fillText(`限时${this.reportdata.examTime}'`, caculateX * 90, caculateX * 130, caculateX * 180);
  162. context2.arc(caculateX * 90, caculateX * 90, caculateX * 80, -Math.PI/2, -Math.PI/2 + (this.reportdata.doTime / this.reportdata.examTime) * 2 * Math.PI, false);
  163. context2.stroke();
  164. context2.draw();
  165. }
  166. if(this.reportdata.score) {
  167. var context3 = uni.createCanvasContext('Canvas3');
  168. this.context3 = context3;
  169. context3.setStrokeStyle('#EEEEEE');
  170. context3.setLineWidth(caculateX * 20);
  171. context3.arc(caculateX * 90, caculateX * 90, caculateX * 80, 0, 2 * Math.PI, true);
  172. context3.stroke();
  173. context3.beginPath();
  174. context3.setStrokeStyle('#32D74B');
  175. context3.setFillStyle('#32D74B');
  176. context3.setTextAlign('center');
  177. context3.setTextBaseline('middle');
  178. context3.setLineCap('round');
  179. context3.setFontSize(caculateX * 64);
  180. context3.fillText((this.reportdata.performance + this.reportdata.score), caculateX * 90, caculateX * 90, caculateX * 180);
  181. context3.setFillStyle('#999999');
  182. context3.setFontSize(caculateX * 20);
  183. context3.fillText(`满分${this.reportdata.totalScore}`, caculateX * 90, caculateX * 130, caculateX * 180);
  184. context3.arc(caculateX * 90, caculateX * 90, caculateX * 80, -Math.PI/2, -Math.PI/2 + ((this.reportdata.performance + this.reportdata.score) / this.reportdata.totalScore) * 2 * Math.PI, false);
  185. context3.stroke();
  186. context3.draw();
  187. }
  188. });
  189. }
  190. });
  191. },
  192. methods: {
  193. backBank() {
  194. uni.navigateBack({
  195. delta:1
  196. })
  197. // uni.redirectTo({
  198. // url: '/pages2/bank/my_question'
  199. // });
  200. },
  201. bankExam(){
  202. return new Promise(resolve =>{
  203. this.$api.bankExam(this.examId).then(res => {
  204. this.examData = res.data.data;
  205. resolve()
  206. })
  207. })
  208. },
  209. /**
  210. * 去做题
  211. */
  212. async doRepeat(id, goodsId, moduleId = 0, chapterId = 0) {
  213. await this.getDetail(goodsId);
  214. let count = await this.examRecordCount(id, goodsId);
  215. let answerNum = await this.getExamDetail(id);
  216. //超过答题次数
  217. if (answerNum > 0 && count >= answerNum) {
  218. this.$u.toast('该试卷只能答题' + answerNum + '次!');
  219. return;
  220. }
  221. uni.navigateTo({
  222. url: '/pages2/bank/questionBank?id=' + id + '&goodsid=' + goodsId + '&moduleId=' + moduleId + '&chapterId=' + chapterId + ''
  223. });
  224. },
  225. /**
  226. * @param {Object} exam_id
  227. * 获取试卷可以做的次数
  228. */
  229. getExamDetail(exam_id) {
  230. return new Promise(resolve => {
  231. this.$api.getExamDetail(exam_id).then(res => {
  232. resolve(res.data.data.answerNum);
  233. });
  234. });
  235. },
  236. examWrongRecordWrongNum() {
  237. return new Promise(resolve => {
  238. this.$api.examWrongRecordWrongNum(this.recordId).then(res => {
  239. this.wrongRecordWrongNum = res.data.data;
  240. resolve();
  241. });
  242. });
  243. },
  244. /**
  245. * 查询试卷历史做题次数
  246. */
  247. examRecordCount(examId, goodsId) {
  248. return new Promise(resolve => {
  249. this.$api
  250. .examRecordCount({
  251. examId: examId,
  252. goodsId: goodsId
  253. })
  254. .then(res => {
  255. resolve(res.data.data);
  256. });
  257. });
  258. },
  259. getDetail(id) {
  260. return new Promise(resolve => {
  261. this.$api.goodsDetail(id).then(res => {
  262. this.goodsData = res.data.data;
  263. resolve();
  264. });
  265. });
  266. },
  267. examReport() {
  268. return new Promise(resolve => {
  269. this.$api.examReport(this.recordId).then(res => {
  270. this.reportdata = res.data.data;
  271. resolve()
  272. });
  273. })
  274. }
  275. }
  276. };
  277. </script>
  278. <style>
  279. page {
  280. background-color: #eaeef1;
  281. }
  282. </style>
  283. <style lang="scss" scope>
  284. .disNone {
  285. display: none;
  286. }
  287. .greenBtn {
  288. margin: 16rpx 16rpx 0;
  289. height: 80rpx;
  290. line-height: 80rpx;
  291. text-align: center;
  292. background-color: #f7fff8;
  293. border-radius: 16rpx;
  294. color: #34c759;
  295. font-weight: bold;
  296. font-size: 30rpx;
  297. }
  298. .redBtn {
  299. margin: 16rpx 16rpx 0;
  300. height: 80rpx;
  301. line-height: 80rpx;
  302. text-align: center;
  303. background-color: #FFF3F2;
  304. border-radius: 16rpx;
  305. color: #FF3B30;
  306. font-weight: bold;
  307. font-size: 30rpx;
  308. }
  309. .dis_fst {
  310. margin-top: 40rpx;
  311. display: flex;
  312. align-items: center;
  313. justify-content: space-around;
  314. }
  315. .btnACs {
  316. height: 48rpx;
  317. width: 160rpx;
  318. text-align: center;
  319. line-height: 48rpx;
  320. border: 1rpx solid #007aff;
  321. border-radius: 16rpx;
  322. color: #007aff;
  323. font-size: 24rpx;
  324. }
  325. .top {
  326. margin: 16rpx 16rpx 0;
  327. border-radius: 16rpx;
  328. padding: 40rpx 24rpx 16rpx;
  329. background: #fff;
  330. .title {
  331. font-size: 32rpx;
  332. font-weight: bold;
  333. color: #333333;
  334. }
  335. .desc {
  336. margin-top: 20rpx;
  337. font-size: 24rpx;
  338. color: #999999;
  339. }
  340. .box {
  341. margin-top: 30rpx;
  342. display: flex;
  343. .left {
  344. width: 250rpx;
  345. height: 176rpx;
  346. background: #f5f5f5;
  347. border-radius: 16rpx;
  348. display: flex;
  349. align-items: center;
  350. justify-content: center;
  351. flex-direction: column;
  352. margin-right: 16rpx;
  353. view {
  354. text-align: center;
  355. &:nth-of-type(1) {
  356. font-size: 60rpx;
  357. font-weight: bold;
  358. color: #007aff;
  359. }
  360. &:nth-of-type(2) {
  361. font-size: 32rpx;
  362. font-weight: bold;
  363. color: #333333;
  364. }
  365. &:nth-of-type(3) {
  366. font-size: 24rpx;
  367. color: #999999;
  368. }
  369. }
  370. }
  371. .right {
  372. flex: 1;
  373. display: flex;
  374. flex-direction: column;
  375. justify-content: space-between;
  376. .flex {
  377. background: #f5f5f5;
  378. display: flex;
  379. height: 80rpx;
  380. align-items: center;
  381. padding: 0 40rpx;
  382. border-radius: 16rpx;
  383. image {
  384. width: 30rpx;
  385. height: 30rpx;
  386. margin-right: 28rpx;
  387. }
  388. .text {
  389. flex: 1;
  390. font-size: 30rpx;
  391. color: #666666;
  392. }
  393. text {
  394. font-size: 48rpx;
  395. color: #e12626;
  396. &.red {
  397. color: red;
  398. }
  399. &.green {
  400. color: green;
  401. }
  402. }
  403. }
  404. }
  405. }
  406. }
  407. .bottom {
  408. .circle-wrap {
  409. .circle-list {
  410. display: flex;
  411. .item {
  412. padding: 20rpx;
  413. border-radius: 16rpx;
  414. background: #fff;
  415. margin: 16rpx;
  416. flex: 1;
  417. .title {
  418. font-weight: bold;
  419. font-size: 30rpx;
  420. line-height: 24rpx;
  421. color: #333333;
  422. text {
  423. font-size: 20rpx;
  424. color: #999999;
  425. }
  426. }
  427. canvas {
  428. margin: 36rpx auto 0;
  429. width: 180rpx;
  430. height: 180rpx;
  431. }
  432. .text {
  433. text-align: center;
  434. margin-top: 16rpx;
  435. font-size: 24rpx;
  436. color: #333333;
  437. }
  438. }
  439. }
  440. }
  441. }
  442. </style>