question_report.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  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" v-if="nextExamId" @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. moduleId:'',
  94. goodsId:'',
  95. chapterId:'',
  96. context1: null,
  97. context2: null,
  98. nextExamId:'',
  99. wrongRecordWrongNum:'',
  100. };
  101. },
  102. onUnload() {},
  103. computed: { ...mapGetters(['userInfo']) },
  104. async onShow() {
  105. },
  106. async onLoad(option) {
  107. this.recordId = option.id;
  108. this.examId = option.examId;
  109. this.moduleId = option.moduleId || 0;
  110. this.chapterId = option.chapterId || 0;
  111. this.goodsId = option.goodsId || '';
  112. this.examWrongRecordWrongNum();
  113. this.bankExamNextExam()
  114. await this.bankExam();
  115. await this.examReport();
  116. uni.getSystemInfo({
  117. success: res => {
  118. var winW = res.screenWidth;
  119. var winH = res.screenHeight;
  120. uni.createSelectorQuery()
  121. .in(this)
  122. .select('.canvas')
  123. .boundingClientRect()
  124. .exec(async newRes => {
  125. var width = newRes[0].width;
  126. var height = newRes[0].height;
  127. var caculateX = winW / 750;
  128. var caculateY = winH / 1334;
  129. console.log(caculateX);
  130. if(this.reportdata.totalScore) {
  131. var context1 = uni.createCanvasContext('Canvas1');
  132. this.context1 = context1;
  133. context1.setStrokeStyle('#EEEEEE');
  134. context1.setLineWidth(caculateX * 20);
  135. context1.arc(caculateX * 90, caculateX * 90, caculateX * 80, 0, 2 * Math.PI, true);
  136. context1.stroke();
  137. context1.beginPath();
  138. context1.setStrokeStyle('#32D74B');
  139. context1.setFillStyle('#32D74B');
  140. context1.setTextAlign('center');
  141. context1.setTextBaseline('middle');
  142. context1.setLineCap('round');
  143. context1.setFontSize(caculateX * 64);
  144. context1.fillText(this.reportdata.performance, caculateX * 90, caculateX * 90, caculateX * 180);
  145. context1.setFillStyle('#999999');
  146. context1.setFontSize(caculateX * 20);
  147. context1.fillText(`满分${this.reportdata.totalScore}`, caculateX * 90, caculateX * 130, caculateX * 180);
  148. context1.arc(caculateX * 90, caculateX * 90, caculateX * 80, -Math.PI/2, -Math.PI/2 + (this.reportdata.performance / this.reportdata.totalScore) * 2 * Math.PI, false);
  149. context1.stroke();
  150. context1.draw();
  151. }
  152. if(this.reportdata.examTime) {
  153. var context2 = uni.createCanvasContext('Canvas2');
  154. this.context2 = context2;
  155. context2.setStrokeStyle('#EEEEEE');
  156. context2.setLineWidth(caculateX * 20);
  157. context2.arc(caculateX * 90, caculateX * 90, caculateX * 80, 0, 2 * Math.PI, true);
  158. context2.stroke();
  159. context2.beginPath();
  160. context2.setStrokeStyle('#007AFF');
  161. context2.setFillStyle('#007AFF');
  162. context2.setTextAlign('center');
  163. context2.setTextBaseline('middle');
  164. context2.setLineCap('round');
  165. context2.setFontSize(caculateX * 64);
  166. context2.fillText(`${this.reportdata.doTime}'`, caculateX * 90, caculateX * 90, caculateX * 180);
  167. context2.setFillStyle('#999999');
  168. context2.setFontSize(caculateX * 20);
  169. context2.fillText(`限时${this.reportdata.examTime}'`, caculateX * 90, caculateX * 130, caculateX * 180);
  170. context2.arc(caculateX * 90, caculateX * 90, caculateX * 80, -Math.PI/2, -Math.PI/2 + (this.reportdata.doTime / this.reportdata.examTime) * 2 * Math.PI, false);
  171. context2.stroke();
  172. context2.draw();
  173. }
  174. if(this.reportdata.score) {
  175. var context3 = uni.createCanvasContext('Canvas3');
  176. this.context3 = context3;
  177. context3.setStrokeStyle('#EEEEEE');
  178. context3.setLineWidth(caculateX * 20);
  179. context3.arc(caculateX * 90, caculateX * 90, caculateX * 80, 0, 2 * Math.PI, true);
  180. context3.stroke();
  181. context3.beginPath();
  182. context3.setStrokeStyle('#32D74B');
  183. context3.setFillStyle('#32D74B');
  184. context3.setTextAlign('center');
  185. context3.setTextBaseline('middle');
  186. context3.setLineCap('round');
  187. context3.setFontSize(caculateX * 64);
  188. context3.fillText((this.reportdata.performance + this.reportdata.score), caculateX * 90, caculateX * 90, caculateX * 180);
  189. context3.setFillStyle('#999999');
  190. context3.setFontSize(caculateX * 20);
  191. context3.fillText(`满分${this.reportdata.totalScore}`, caculateX * 90, caculateX * 130, caculateX * 180);
  192. 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);
  193. context3.stroke();
  194. context3.draw();
  195. }
  196. });
  197. }
  198. });
  199. },
  200. methods: {
  201. bankExamNextExam() {
  202. this.$api.bankExamNextExam({
  203. chapterExamId:this.chapterId,
  204. examId:this.examId,
  205. goodsId:this.goodsId,
  206. moduleExamId:this.moduleId
  207. }).then(res => {
  208. if(res.data.code == 500) {
  209. this.nextExamId = '';
  210. } else if(res.data.code == 200) {
  211. this.nextExamId = res.data.data.examId;
  212. }
  213. })
  214. },
  215. backBank() {
  216. uni.navigateTo({
  217. url: '/pages2/bank/questionBank?id=' +this.nextExamId + '&goodsid=' + this.goodsId + '&moduleId=' + this.moduleId + '&chapterId=' + this.chapterId + ''
  218. });
  219. // uni.navigateBack({
  220. // delta:1
  221. // })
  222. // uni.redirectTo({
  223. // url: '/pages2/bank/my_question'
  224. // });
  225. },
  226. bankExam(){
  227. return new Promise(resolve =>{
  228. this.$api.bankExam(this.examId).then(res => {
  229. this.examData = res.data.data;
  230. resolve()
  231. })
  232. })
  233. },
  234. /**
  235. * 去做题
  236. */
  237. async doRepeat(id, goodsId, moduleId = 0, chapterId = 0) {
  238. await this.getDetail(goodsId);
  239. let count = await this.examRecordCount(id, goodsId);
  240. let answerNum = await this.getExamDetail(id);
  241. //超过答题次数
  242. if (answerNum > 0 && count >= answerNum) {
  243. this.$u.toast('该试卷只能答题' + answerNum + '次!');
  244. return;
  245. }
  246. uni.navigateTo({
  247. url: '/pages2/bank/questionBank?id=' + id + '&goodsid=' + goodsId + '&moduleId=' + moduleId + '&chapterId=' + chapterId + ''
  248. });
  249. },
  250. /**
  251. * @param {Object} exam_id
  252. * 获取试卷可以做的次数
  253. */
  254. getExamDetail(exam_id) {
  255. return new Promise(resolve => {
  256. this.$api.getExamDetail(exam_id).then(res => {
  257. resolve(res.data.data.answerNum);
  258. });
  259. });
  260. },
  261. examWrongRecordWrongNum() {
  262. return new Promise(resolve => {
  263. this.$api.examWrongRecordWrongNum(this.recordId).then(res => {
  264. this.wrongRecordWrongNum = res.data.data;
  265. resolve();
  266. });
  267. });
  268. },
  269. /**
  270. * 查询试卷历史做题次数
  271. */
  272. examRecordCount(examId, goodsId) {
  273. return new Promise(resolve => {
  274. this.$api
  275. .examRecordCount({
  276. examId: examId,
  277. goodsId: goodsId
  278. })
  279. .then(res => {
  280. resolve(res.data.data);
  281. });
  282. });
  283. },
  284. getDetail(id) {
  285. return new Promise(resolve => {
  286. this.$api.goodsDetail(id).then(res => {
  287. this.goodsData = res.data.data;
  288. resolve();
  289. });
  290. });
  291. },
  292. examReport() {
  293. return new Promise(resolve => {
  294. this.$api.examReport(this.recordId).then(res => {
  295. this.reportdata = res.data.data;
  296. resolve()
  297. });
  298. })
  299. }
  300. }
  301. };
  302. </script>
  303. <style>
  304. page {
  305. background-color: #eaeef1;
  306. }
  307. </style>
  308. <style lang="scss" scope>
  309. .disNone {
  310. display: none;
  311. }
  312. .greenBtn {
  313. margin: 16rpx 16rpx 0;
  314. height: 80rpx;
  315. line-height: 80rpx;
  316. text-align: center;
  317. background-color: #f7fff8;
  318. border-radius: 16rpx;
  319. color: #34c759;
  320. font-weight: bold;
  321. font-size: 30rpx;
  322. }
  323. .redBtn {
  324. margin: 16rpx 16rpx 0;
  325. height: 80rpx;
  326. line-height: 80rpx;
  327. text-align: center;
  328. background-color: #FFF3F2;
  329. border-radius: 16rpx;
  330. color: #FF3B30;
  331. font-weight: bold;
  332. font-size: 30rpx;
  333. }
  334. .dis_fst {
  335. margin-top: 40rpx;
  336. display: flex;
  337. align-items: center;
  338. justify-content: space-around;
  339. }
  340. .btnACs {
  341. height: 48rpx;
  342. width: 160rpx;
  343. text-align: center;
  344. line-height: 48rpx;
  345. border: 1rpx solid #007aff;
  346. border-radius: 16rpx;
  347. color: #007aff;
  348. font-size: 24rpx;
  349. }
  350. .top {
  351. margin: 16rpx 16rpx 0;
  352. border-radius: 16rpx;
  353. padding: 40rpx 24rpx 16rpx;
  354. background: #fff;
  355. .title {
  356. font-size: 32rpx;
  357. font-weight: bold;
  358. color: #333333;
  359. }
  360. .desc {
  361. margin-top: 20rpx;
  362. font-size: 24rpx;
  363. color: #999999;
  364. }
  365. .box {
  366. margin-top: 30rpx;
  367. display: flex;
  368. .left {
  369. width: 250rpx;
  370. height: 176rpx;
  371. background: #f5f5f5;
  372. border-radius: 16rpx;
  373. display: flex;
  374. align-items: center;
  375. justify-content: center;
  376. flex-direction: column;
  377. margin-right: 16rpx;
  378. view {
  379. text-align: center;
  380. &:nth-of-type(1) {
  381. font-size: 60rpx;
  382. font-weight: bold;
  383. color: #007aff;
  384. }
  385. &:nth-of-type(2) {
  386. font-size: 32rpx;
  387. font-weight: bold;
  388. color: #333333;
  389. }
  390. &:nth-of-type(3) {
  391. font-size: 24rpx;
  392. color: #999999;
  393. }
  394. }
  395. }
  396. .right {
  397. flex: 1;
  398. display: flex;
  399. flex-direction: column;
  400. justify-content: space-between;
  401. .flex {
  402. background: #f5f5f5;
  403. display: flex;
  404. height: 80rpx;
  405. align-items: center;
  406. padding: 0 40rpx;
  407. border-radius: 16rpx;
  408. image {
  409. width: 30rpx;
  410. height: 30rpx;
  411. margin-right: 28rpx;
  412. }
  413. .text {
  414. flex: 1;
  415. font-size: 30rpx;
  416. color: #666666;
  417. }
  418. text {
  419. font-size: 48rpx;
  420. color: #e12626;
  421. &.red {
  422. color: red;
  423. }
  424. &.green {
  425. color: green;
  426. }
  427. }
  428. }
  429. }
  430. }
  431. }
  432. .bottom {
  433. .circle-wrap {
  434. .circle-list {
  435. display: flex;
  436. .item {
  437. padding: 20rpx;
  438. border-radius: 16rpx;
  439. background: #fff;
  440. margin: 16rpx;
  441. flex: 1;
  442. .title {
  443. font-weight: bold;
  444. font-size: 30rpx;
  445. line-height: 24rpx;
  446. color: #333333;
  447. text {
  448. font-size: 20rpx;
  449. color: #999999;
  450. }
  451. }
  452. canvas {
  453. margin: 36rpx auto 0;
  454. width: 180rpx;
  455. height: 180rpx;
  456. }
  457. .text {
  458. text-align: center;
  459. margin-top: 16rpx;
  460. font-size: 24rpx;
  461. color: #333333;
  462. }
  463. }
  464. }
  465. }
  466. }
  467. </style>