question_report.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  1. <template>
  2. <view>
  3. <nav-bar title="试卷报告"></nav-bar>
  4. <view :class="reportdata.reportStatus === 0 ? 'redBtn' : reportdata.reportStatus === 1 ? 'greenBtn' : 'disNone'" v-if="examData.doType == 2 && reportdata.reportStatus !== null">
  5. {{ reportdata.reportStatus === 0 ? '测试未通过' : reportdata.reportStatus === 1 ? '测试通过' : '' }}
  6. </view>
  7. <view class="top">
  8. <view class="title">{{ examName }}</view>
  9. <view class="desc">交卷时间:{{ $method.timestampToTime(reportdata.updateTime, false) }}</view>
  10. <view class="box">
  11. <view class="left">
  12. <view>
  13. <!-- 练习 -->
  14. <template v-if="entryType == 'random' || (examData.doType && examData.doType == 1)">
  15. <!-- ((reportdata.rightQuestionNum /
  16. reportdata.doQuestionNum || 0).toFixed(0) *
  17. 100) -->
  18. {{ (((reportdata.rightQuestionNum / reportdata.doQuestionNum )|| 0) * 100).toFixed(0)
  19. }}%
  20. </template>
  21. <!-- 考试 -->
  22. <template v-if="examData.doType == 2">
  23. <!-- ((reportdata.rightQuestionNum /
  24. reportdata.totalQuestionNum || 0).toFixed(0) *
  25. 100) -->
  26. {{ (((reportdata.rightQuestionNum / reportdata.totalQuestionNum )|| 0) * 100).toFixed(0)
  27. }}%
  28. </template>
  29. <!-- {{ (((reportdata.rightQuestionNum / (reportdata.rightQuestionNum + wrongRecordWrongNum)) || 0) * 100).toFixed(0)}}% -->
  30. </view>
  31. <view>正确率</view>
  32. <view>不含简答/案例题</view>
  33. </view>
  34. <view class="right">
  35. <view class="flex up">
  36. <!-- <u-icon name="checkmark" color="#16D48B" size="48" style="margin-right: 14rpx;"></u-icon> -->
  37. <image class="right_num" src="/static/right_num.png" mode="widthFix"></image>
  38. <view class="text">正确题数</view>
  39. <text class="green">{{ reportdata.rightQuestionNum }}</text>
  40. </view>
  41. <view class="flex up">
  42. <!-- <u-icon name="checkmark" color="#16D48B" size="48" style="margin-right: 14rpx;"></u-icon> -->
  43. <image class="out_num" src="/static/out_num.png" mode="widthFix"></image>
  44. <view class="text">少选题数</view>
  45. <text class="yellow">{{ reportdata.lessQuestionNum }}</text>
  46. </view>
  47. <view class="flex down">
  48. <!-- <u-icon name="close" color="#FF3B30" size="38" style="margin-right: 26rpx;"></u-icon> -->
  49. <image class="wrong_num" src="/static/wrong_num.png" mode="widthFix"></image>
  50. <view class="text">错误题数</view>
  51. <text class="red">{{ wrongRecordWrongNum }}</text>
  52. </view>
  53. </view>
  54. </view>
  55. <view class="dis_fst" v-if="!hideBtns">
  56. <navigator
  57. v-if="wrongRecordWrongNum != 0"
  58. :url="
  59. '/pages2/bank/questionBankWrongExplain?recordId=' + reportdata.recordId+'&id='+examData.examId
  60. "
  61. >
  62. <view class="btnACs">错题解析</view>
  63. </navigator>
  64. <navigator
  65. :url="
  66. '/pages2/bank/questionBankAllExplain?id=' +
  67. reportdata.examId +
  68. '&goodsid=' +
  69. reportdata.goodsId +
  70. '&moduleId=' +
  71. reportdata.moduleExamId +
  72. '&chapterId=' +
  73. reportdata.chapterExamId +
  74. '&recordId='+ reportdata.recordId
  75. "
  76. >
  77. <view class="btnACs">全部解析</view>
  78. </navigator>
  79. <view class="btnACs" v-if="entryType != 'daily'" @click="doRepeat(reportdata.examId, reportdata.goodsId, reportdata.moduleExamId, reportdata.chapterExamId)">重新做题</view>
  80. <view class="btnACs" v-if="entryType != 'random' || nextExamId" @click="backBank">继续做题</view>
  81. </view>
  82. </view>
  83. <view v-show="entryType != 'random'" class="bottom">
  84. <view class="circle-wrap">
  85. <view class="circle-list">
  86. <view class="item" v-show="reportdata.totalScore">
  87. <view class="title">
  88. 试卷得分
  89. <text>(不含简答和案例题)</text>
  90. </view>
  91. <canvas class="canvas" canvas-id="Canvas1"></canvas>
  92. </view>
  93. <view class="item" v-show="reportdata.examTime">
  94. <view class="title">答题时长</view>
  95. <canvas canvas-id="Canvas2"></canvas>
  96. </view>
  97. <view class="item" v-show="reportdata.score != -1">
  98. <view class="title">试卷得分
  99. <text>(含简答和案例题)</text>
  100. </view>
  101. <canvas canvas-id="Canvas3"></canvas>
  102. </view>
  103. </view>
  104. </view>
  105. </view>
  106. <view v-if="courseList.length" class="course_list">
  107. <view class="titles">
  108. <image class="code" src="@/static/learn/act_icon.png" ></image>
  109. <text class="title">推荐课程</text>
  110. </view>
  111. <view class="list_item" v-for="(item,index) in courseList" :key="index" @click="toBuy(item)">
  112. <view class="course_content">
  113. <view class="c_title">{{item.goodsName}}</view>
  114. <view class="c_downs">
  115. <view class="img">
  116. <image :src="$method.splitImgHost(item.coverUrl, true)"></image>
  117. <view class="time" v-if="item.year">{{item.year?item.year:''}}</view>
  118. </view>
  119. <view class="text">
  120. <view class="desc">
  121. <view class="left">
  122. <text class="mon_t">¥ {{item.standPrice}}</text>
  123. <!-- <text class="sale">/限时优惠</text> -->
  124. <text v-if="item.linePrice" class="sale"> ¥ </text>
  125. <text v-if="item.linePrice" class="price_line">&nbsp;{{ item.linePrice }}</text>
  126. </view>
  127. <view class="right">
  128. <view class="regiser_row" v-if="!hideBuyState">立即购买</view>
  129. </view>
  130. </view>
  131. <view v-if="item.buyUserNum" class="joins">
  132. <!-- <image class="people" src="/static/index/people.png"></image> -->
  133. <!-- 为0时,不显示 -->
  134. <view class="people">{{ item.buyUserNum }}人参与</view>
  135. </view>
  136. </view>
  137. </view>
  138. </view>
  139. </view>
  140. </view>
  141. </view>
  142. </template>
  143. <script>
  144. import { mapGetters } from 'vuex';
  145. export default {
  146. data() {
  147. return {
  148. id: '',
  149. hideBtns:false,
  150. recordId:'',
  151. reportdata: {},
  152. examData:{},
  153. examId:'',
  154. moduleId:'',
  155. goodsId:'',
  156. chapterId:'',
  157. context1: null,
  158. context2: null,
  159. nextExamId:'',
  160. wrongRecordWrongNum:'',
  161. orderGoodsId:'',
  162. courseList: [],
  163. pageNum: 1,
  164. pageSize: 10,
  165. total: 0,
  166. entryType: '', // 进入做题页面的入口类型,daily-每日一练进来,其他的-题库做题进入
  167. bankNum: 5, // 随机练习的题目数量
  168. examName: '', // 试卷名称
  169. };
  170. },
  171. onUnload() {},
  172. computed: { ...mapGetters(['userInfo', 'hideBuyState']) },
  173. onShow() {
  174. this.pageNum = 1
  175. this.courseList = []
  176. this.getcourList()
  177. },
  178. async onLoad(option) {
  179. console.log(option)
  180. this.entryType = option.entryType
  181. this.bankNum = option.bankNum
  182. this.orderGoodsId = option.orderGoodsId
  183. this.recordId = option.id;
  184. this.examId = option.examId;
  185. this.moduleId = option.moduleId || 0;
  186. this.chapterId = option.chapterId || 0;
  187. this.goodsId = option.goodsId || '';
  188. this.examWrongRecordWrongNum();
  189. this.bankExamNextExam()
  190. // await this.bankExam();
  191. await this.examReport();
  192. if (this.entryType == 'random') {
  193. this.bankExamTemp()
  194. } else {
  195. await this.bankExam();
  196. }
  197. },
  198. onPullDownRefresh() {
  199. this.pageNum = 1
  200. this.courseList = []
  201. this.getcourList()
  202. // this.timer = setTimeout(function() {
  203. // uni.stopPullDownRefresh()
  204. // }, 500)
  205. },
  206. onReachBottom() {
  207. if (this.courseList.length < this.total) {
  208. this.pageNum++
  209. this.getcourList()
  210. }
  211. },
  212. methods: {
  213. getCanvas() {
  214. uni.getSystemInfo({
  215. success: res => {
  216. var winW = res.screenWidth;
  217. var winH = res.screenHeight;
  218. uni.createSelectorQuery()
  219. .in(this)
  220. .select('.canvas')
  221. .boundingClientRect()
  222. .exec(async newRes => {
  223. var width = newRes[0].width;
  224. var height = newRes[0].height;
  225. var caculateX = winW / 750;
  226. var caculateY = winH / 1334;
  227. console.log(caculateX);
  228. if(this.reportdata.totalScore) {
  229. var context1 = uni.createCanvasContext('Canvas1');
  230. this.context1 = context1;
  231. context1.setStrokeStyle('#EEEEEE');
  232. context1.setLineWidth(caculateX * 20);
  233. context1.arc(caculateX * 90, caculateX * 90, caculateX * 80, 0, 2 * Math.PI, true);
  234. context1.stroke();
  235. context1.beginPath();
  236. context1.setStrokeStyle('#32D74B');
  237. context1.setFillStyle('#32D74B');
  238. context1.setTextAlign('center');
  239. context1.setTextBaseline('middle');
  240. context1.setLineCap('round');
  241. context1.setFontSize(caculateX * 64);
  242. context1.fillText(this.reportdata.performance, caculateX * 90, caculateX * 90, caculateX * 180);
  243. context1.setFillStyle('#999999');
  244. context1.setFontSize(caculateX * 20);
  245. context1.fillText(`满分${this.reportdata.totalScore || 0}`, caculateX * 90, caculateX * 130, caculateX * 180);
  246. context1.arc(caculateX * 90, caculateX * 90, caculateX * 80, -Math.PI/2, -Math.PI/2 + (this.reportdata.performance / this.reportdata.totalScore) * 2 * Math.PI, false);
  247. context1.stroke();
  248. context1.draw();
  249. }
  250. if(this.reportdata.examTime) {
  251. var context2 = uni.createCanvasContext('Canvas2');
  252. this.context2 = context2;
  253. context2.setStrokeStyle('#EEEEEE');
  254. context2.setLineWidth(caculateX * 20);
  255. context2.arc(caculateX * 90, caculateX * 90, caculateX * 80, 0, 2 * Math.PI, true);
  256. context2.stroke();
  257. context2.beginPath();
  258. context2.setStrokeStyle('#007AFF');
  259. context2.setFillStyle('#007AFF');
  260. context2.setTextAlign('center');
  261. context2.setTextBaseline('middle');
  262. context2.setLineCap('round');
  263. context2.setFontSize(caculateX * 64);
  264. context2.fillText(`${this.reportdata.doTime}'`, caculateX * 90, caculateX * 90, caculateX * 180);
  265. context2.setFillStyle('#999999');
  266. context2.setFontSize(caculateX * 20);
  267. context2.fillText(`限时${this.reportdata.examTime}'`, caculateX * 90, caculateX * 130, caculateX * 180);
  268. context2.arc(caculateX * 90, caculateX * 90, caculateX * 80, -Math.PI/2, -Math.PI/2 + (this.reportdata.doTime / this.reportdata.examTime) * 2 * Math.PI, false);
  269. context2.stroke();
  270. context2.draw();
  271. }
  272. if(this.reportdata.score != -1) {
  273. var context3 = uni.createCanvasContext('Canvas3');
  274. this.context3 = context3;
  275. context3.setStrokeStyle('#EEEEEE');
  276. context3.setLineWidth(caculateX * 20);
  277. context3.arc(caculateX * 90, caculateX * 90, caculateX * 80, 0, 2 * Math.PI, true);
  278. context3.stroke();
  279. context3.beginPath();
  280. context3.setStrokeStyle('#32D74B');
  281. context3.setFillStyle('#32D74B');
  282. context3.setTextAlign('center');
  283. context3.setTextBaseline('middle');
  284. context3.setLineCap('round');
  285. context3.setFontSize(caculateX * 64);
  286. context3.fillText((this.reportdata.performance + this.reportdata.score), caculateX * 90, caculateX * 90, caculateX * 180);
  287. context3.setFillStyle('#999999');
  288. context3.setFontSize(caculateX * 20);
  289. context3.fillText(`满分${this.reportdata.totalScore || 0}`, caculateX * 90, caculateX * 130, caculateX * 180);
  290. 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);
  291. context3.stroke();
  292. context3.draw();
  293. }
  294. });
  295. }
  296. });
  297. },
  298. getcourList() {
  299. this.$http({
  300. url: '/apply/recommend/goodsList',
  301. method: 'post',
  302. data: {
  303. examId: this.examId,
  304. pageNum: this.pageNum,
  305. pageSize: this.pageSize,
  306. }
  307. }).then((res) => {
  308. if (res.data.code == 200) {
  309. this.courseList.push(...(res.data.rows || [] ))
  310. console.log('this.courseList', this.courseList)
  311. this.total = res.data.total
  312. }
  313. })
  314. },
  315. toBuy(item) {
  316. if (item.goodsType == 2) {
  317. uni.navigateTo({
  318. url: '/pages2/bank/detail?id='+item.goodsId
  319. })
  320. } else {
  321. // /pages5/liveDetail/index
  322. uni.navigateTo({
  323. url: '/pages3/course/detail?id='+item.goodsId + '&goodsType=' + item.goodsType
  324. })
  325. }
  326. },
  327. bankExamNextExam() {
  328. this.$api.bankExamNextExam({
  329. chapterExamId:this.chapterId,
  330. examId:this.examId,
  331. goodsId:this.goodsId,
  332. orderGoodsId:this.orderGoodsId,
  333. moduleExamId:this.moduleId
  334. }).then(res => {
  335. if(res.data.code == 500) {
  336. this.nextExamId = '';
  337. } else if(res.data.code == 200) {
  338. this.nextExamId = res.data.data.examId;
  339. }
  340. })
  341. },
  342. backBank() {
  343. if (this.entryType == 'daily') {
  344. uni.navigateBack()
  345. return
  346. }
  347. uni.navigateTo({
  348. url: '/pages2/bank/questionBank?orderGoodsId='+this.orderGoodsId+'&id=' +this.nextExamId + '&goodsid=' + this.goodsId + '&moduleId=' + this.moduleId + '&chapterId=' + this.chapterId + ''
  349. });
  350. // uni.navigateBack({
  351. // delta:1
  352. // })
  353. // uni.redirectTo({
  354. // url: '/pages2/bank/my_question'
  355. // });
  356. },
  357. bankExam(){
  358. // '/bank/exam/'+data
  359. return new Promise(resolve =>{
  360. this.$api.bankExam(this.examId).then(res => {
  361. this.examData = res.data.data;
  362. resolve()
  363. })
  364. })
  365. },
  366. /**
  367. * 去做题
  368. */
  369. async doRepeat(id, goodsId, moduleId = 0, chapterId = 0) {
  370. if (this.entryType == 'random') {
  371. uni.navigateBack()
  372. return
  373. }
  374. // await this.getDetail(goodsId);
  375. let count = await this.examRecordCount(id, goodsId);
  376. let answerNum = await this.getExamDetail(id);
  377. //超过答题次数
  378. if (answerNum > 0 && count >= answerNum) {
  379. this.$u.toast('该试卷只能答题' + answerNum + '次!');
  380. return;
  381. }
  382. var pages = getCurrentPages();
  383. var prepage = pages[pages.length - 2]; //上一个页面
  384. prepage.$vm.isRepeat = true;
  385. uni.redirectTo({
  386. url: '/pages2/bank/questionBank?orderGoodsId='+this.orderGoodsId+'&id=' + id + '&goodsid=' + goodsId + '&moduleId=' + moduleId + '&chapterId=' + chapterId
  387. + '&entryType=' + this.entryType + '&bankNum=' + this.bankNum
  388. });
  389. },
  390. /**
  391. * @param {Object} exam_id
  392. * 获取试卷可以做的次数
  393. */
  394. getExamDetail(exam_id) {
  395. return new Promise(resolve => {
  396. this.$api.getExamDetail(exam_id).then(res => {
  397. resolve(res.data.data.answerNum);
  398. });
  399. });
  400. },
  401. examWrongRecordWrongNum() {
  402. return new Promise(resolve => {
  403. this.$api.examWrongRecordWrongNum(this.recordId).then(res => {
  404. this.wrongRecordWrongNum = res.data.data || 0;
  405. resolve();
  406. });
  407. });
  408. },
  409. /**
  410. * 查询试卷历史做题次数
  411. */
  412. examRecordCount(examId, goodsId) {
  413. return new Promise(resolve => {
  414. this.$api
  415. .examRecordCount({
  416. examId: examId,
  417. orderGoodsId: this.orderGoodsId,
  418. })
  419. .then(res => {
  420. resolve(res.data.data);
  421. });
  422. });
  423. },
  424. getDetail(id) {
  425. return new Promise(resolve => {
  426. this.$api.goodsDetail(id).then(res => {
  427. this.goodsData = res.data.data;
  428. resolve();
  429. });
  430. });
  431. },
  432. examReport() {
  433. return new Promise(resolve => {
  434. this.$api.examReport(this.recordId).then(res => {
  435. this.reportdata = res.data.data;
  436. if (this.entryType != 'random') {
  437. this.examName = this.reportdata.examName
  438. }
  439. this.getCanvas()
  440. resolve()
  441. });
  442. })
  443. },
  444. bankExamTemp() {
  445. // '/bank/exam/temp/'+data
  446. this.$api.bankTempReport(this.examId).then(res => {
  447. if (res.data.code == 200) {
  448. this.examName = res.data.data.examName
  449. }
  450. });
  451. },
  452. }
  453. };
  454. </script>
  455. <style>
  456. page {
  457. background-color: #eaeef1;
  458. }
  459. </style>
  460. <style lang="scss" scope>
  461. @import '../../pages5/examReport/indexCourseList.scss';
  462. .disNone {
  463. display: none;
  464. }
  465. .greenBtn {
  466. margin: 16rpx 16rpx 0;
  467. height: 80rpx;
  468. line-height: 80rpx;
  469. text-align: center;
  470. background-color: #f7fff8;
  471. border-radius: 16rpx;
  472. color: #34c759;
  473. font-weight: bold;
  474. font-size: 30rpx;
  475. }
  476. .redBtn {
  477. margin: 16rpx 16rpx 0;
  478. height: 80rpx;
  479. line-height: 80rpx;
  480. text-align: center;
  481. background-color: #FFF3F2;
  482. border-radius: 16rpx;
  483. color: #FF3B30;
  484. font-weight: bold;
  485. font-size: 30rpx;
  486. }
  487. .dis_fst {
  488. margin-top: 40rpx;
  489. display: flex;
  490. align-items: center;
  491. justify-content: space-around;
  492. }
  493. .btnACs {
  494. height: 48rpx;
  495. width: 160rpx;
  496. text-align: center;
  497. line-height: 48rpx;
  498. border: 1rpx solid #007aff;
  499. border-radius: 16rpx;
  500. color: #007aff;
  501. font-size: 24rpx;
  502. }
  503. .top {
  504. margin: 16rpx 16rpx 0;
  505. border-radius: 16rpx;
  506. padding: 40rpx 24rpx 16rpx;
  507. background: #fff;
  508. .title {
  509. font-size: 32rpx;
  510. font-weight: bold;
  511. color: #333333;
  512. white-space: nowrap;
  513. overflow: hidden;
  514. text-overflow: ellipsis;
  515. }
  516. .desc {
  517. margin-top: 20rpx;
  518. font-size: 24rpx;
  519. color: #999999;
  520. }
  521. .box {
  522. margin-top: 30rpx;
  523. display: flex;
  524. .left {
  525. width: 250rpx;
  526. height: 272rpx;
  527. background: #f5f5f5;
  528. border-radius: 16rpx;
  529. display: flex;
  530. align-items: center;
  531. justify-content: center;
  532. flex-direction: column;
  533. margin-right: 16rpx;
  534. view {
  535. text-align: center;
  536. &:nth-of-type(1) {
  537. font-size: 60rpx;
  538. font-weight: bold;
  539. color: #007aff;
  540. }
  541. &:nth-of-type(2) {
  542. font-size: 32rpx;
  543. font-weight: bold;
  544. color: #333333;
  545. }
  546. &:nth-of-type(3) {
  547. font-size: 24rpx;
  548. color: #999999;
  549. }
  550. }
  551. }
  552. .right {
  553. flex: 1;
  554. display: flex;
  555. flex-direction: column;
  556. justify-content: space-between;
  557. .flex {
  558. background: #f5f5f5;
  559. display: flex;
  560. height: 80rpx;
  561. align-items: center;
  562. padding: 0 40rpx;
  563. border-radius: 16rpx;
  564. image {
  565. margin-right: 28rpx;
  566. &.right_num {
  567. width:26rpx;
  568. }
  569. &.out_num {
  570. width:38rpx;
  571. }
  572. &.wrong_num {
  573. width:30rpx;
  574. }
  575. }
  576. .text {
  577. flex: 1;
  578. font-size: 30rpx;
  579. color: #666666;
  580. }
  581. text {
  582. font-size: 48rpx;
  583. color: #e12626;
  584. &.red {
  585. color: #FF3B30;
  586. }
  587. &.green {
  588. color: #36C75A;
  589. }
  590. &.yellow {
  591. color:#FFC53D;
  592. }
  593. }
  594. }
  595. }
  596. }
  597. }
  598. .bottom {
  599. .circle-wrap {
  600. .circle-list {
  601. display: flex;
  602. .item {
  603. padding: 20rpx;
  604. border-radius: 16rpx;
  605. background: #fff;
  606. margin: 16rpx;
  607. flex: 1;
  608. .title {
  609. font-weight: bold;
  610. font-size: 30rpx;
  611. line-height: 24rpx;
  612. color: #333333;
  613. text {
  614. font-size: 20rpx;
  615. color: #999999;
  616. }
  617. }
  618. canvas {
  619. margin: 36rpx auto 0;
  620. width: 180rpx;
  621. height: 180rpx;
  622. }
  623. .text {
  624. text-align: center;
  625. margin-top: 16rpx;
  626. font-size: 24rpx;
  627. color: #333333;
  628. }
  629. }
  630. }
  631. }
  632. }
  633. </style>