question_report.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  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">{{ reportdata.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="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" @click="doRepeat(reportdata.examId, reportdata.goodsId, reportdata.moduleExamId, reportdata.chapterExamId)">重新做题</view>
  80. <view class="btnACs" v-if="nextExamId" @click="backBank">继续做题</view>
  81. </view>
  82. </view>
  83. <view 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. };
  167. },
  168. onUnload() {},
  169. computed: { ...mapGetters(['userInfo', 'hideBuyState']) },
  170. onShow() {
  171. this.courseList = []
  172. this.getcourList()
  173. },
  174. async onLoad(option) {
  175. console.log(option)
  176. this.orderGoodsId = option.orderGoodsId
  177. this.recordId = option.id;
  178. this.examId = option.examId;
  179. this.moduleId = option.moduleId || 0;
  180. this.chapterId = option.chapterId || 0;
  181. this.goodsId = option.goodsId || '';
  182. this.examWrongRecordWrongNum();
  183. this.bankExamNextExam()
  184. await this.bankExam();
  185. await this.examReport();
  186. uni.getSystemInfo({
  187. success: res => {
  188. var winW = res.screenWidth;
  189. var winH = res.screenHeight;
  190. uni.createSelectorQuery()
  191. .in(this)
  192. .select('.canvas')
  193. .boundingClientRect()
  194. .exec(async newRes => {
  195. var width = newRes[0].width;
  196. var height = newRes[0].height;
  197. var caculateX = winW / 750;
  198. var caculateY = winH / 1334;
  199. console.log(caculateX);
  200. if(this.reportdata.totalScore) {
  201. var context1 = uni.createCanvasContext('Canvas1');
  202. this.context1 = context1;
  203. context1.setStrokeStyle('#EEEEEE');
  204. context1.setLineWidth(caculateX * 20);
  205. context1.arc(caculateX * 90, caculateX * 90, caculateX * 80, 0, 2 * Math.PI, true);
  206. context1.stroke();
  207. context1.beginPath();
  208. context1.setStrokeStyle('#32D74B');
  209. context1.setFillStyle('#32D74B');
  210. context1.setTextAlign('center');
  211. context1.setTextBaseline('middle');
  212. context1.setLineCap('round');
  213. context1.setFontSize(caculateX * 64);
  214. context1.fillText(this.reportdata.performance, caculateX * 90, caculateX * 90, caculateX * 180);
  215. context1.setFillStyle('#999999');
  216. context1.setFontSize(caculateX * 20);
  217. context1.fillText(`满分${this.reportdata.totalScore}`, caculateX * 90, caculateX * 130, caculateX * 180);
  218. context1.arc(caculateX * 90, caculateX * 90, caculateX * 80, -Math.PI/2, -Math.PI/2 + (this.reportdata.performance / this.reportdata.totalScore) * 2 * Math.PI, false);
  219. context1.stroke();
  220. context1.draw();
  221. }
  222. if(this.reportdata.examTime) {
  223. var context2 = uni.createCanvasContext('Canvas2');
  224. this.context2 = context2;
  225. context2.setStrokeStyle('#EEEEEE');
  226. context2.setLineWidth(caculateX * 20);
  227. context2.arc(caculateX * 90, caculateX * 90, caculateX * 80, 0, 2 * Math.PI, true);
  228. context2.stroke();
  229. context2.beginPath();
  230. context2.setStrokeStyle('#007AFF');
  231. context2.setFillStyle('#007AFF');
  232. context2.setTextAlign('center');
  233. context2.setTextBaseline('middle');
  234. context2.setLineCap('round');
  235. context2.setFontSize(caculateX * 64);
  236. context2.fillText(`${this.reportdata.doTime}'`, caculateX * 90, caculateX * 90, caculateX * 180);
  237. context2.setFillStyle('#999999');
  238. context2.setFontSize(caculateX * 20);
  239. context2.fillText(`限时${this.reportdata.examTime}'`, caculateX * 90, caculateX * 130, caculateX * 180);
  240. context2.arc(caculateX * 90, caculateX * 90, caculateX * 80, -Math.PI/2, -Math.PI/2 + (this.reportdata.doTime / this.reportdata.examTime) * 2 * Math.PI, false);
  241. context2.stroke();
  242. context2.draw();
  243. }
  244. if(this.reportdata.score != -1) {
  245. var context3 = uni.createCanvasContext('Canvas3');
  246. this.context3 = context3;
  247. context3.setStrokeStyle('#EEEEEE');
  248. context3.setLineWidth(caculateX * 20);
  249. context3.arc(caculateX * 90, caculateX * 90, caculateX * 80, 0, 2 * Math.PI, true);
  250. context3.stroke();
  251. context3.beginPath();
  252. context3.setStrokeStyle('#32D74B');
  253. context3.setFillStyle('#32D74B');
  254. context3.setTextAlign('center');
  255. context3.setTextBaseline('middle');
  256. context3.setLineCap('round');
  257. context3.setFontSize(caculateX * 64);
  258. context3.fillText((this.reportdata.performance + this.reportdata.score), caculateX * 90, caculateX * 90, caculateX * 180);
  259. context3.setFillStyle('#999999');
  260. context3.setFontSize(caculateX * 20);
  261. context3.fillText(`满分${this.reportdata.totalScore}`, caculateX * 90, caculateX * 130, caculateX * 180);
  262. 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);
  263. context3.stroke();
  264. context3.draw();
  265. }
  266. });
  267. }
  268. });
  269. },
  270. onPullDownRefresh() {
  271. this.pageNum = 1
  272. this.getcourList()
  273. // this.timer = setTimeout(function() {
  274. // uni.stopPullDownRefresh()
  275. // }, 500)
  276. },
  277. onReachBottom() {
  278. console.log(this.total,'total')
  279. console.log(this.courseList.length,'length')
  280. if (this.courseList.length < this.total) {
  281. this.pageNum++
  282. this.getcourList()
  283. }
  284. },
  285. methods: {
  286. getcourList() {
  287. this.$http({
  288. url: '/apply/recommend/goodsList',
  289. method: 'post',
  290. data: {
  291. examId: this.examId,
  292. pageNum: this.pageNum,
  293. pageSize: this.pageSize,
  294. }
  295. }).then((res) => {
  296. if (res.data.code == 200) {
  297. this.courseList.push(...(res.data.rows || [] ))
  298. console.log('this.courseList', this.courseList)
  299. this.total = res.data.total
  300. }
  301. })
  302. },
  303. toBuy(item) {
  304. if (item.goodsType == 2) {
  305. uni.navigateTo({
  306. url: '/pages2/bank/detail?id='+item.goodsId
  307. })
  308. } else {
  309. // /pages5/liveDetail/index
  310. uni.navigateTo({
  311. url: '/pages3/course/detail?id='+item.goodsId + '&goodsType=' + item.goodsType
  312. })
  313. }
  314. },
  315. bankExamNextExam() {
  316. this.$api.bankExamNextExam({
  317. chapterExamId:this.chapterId,
  318. examId:this.examId,
  319. goodsId:this.goodsId,
  320. orderGoodsId:this.orderGoodsId,
  321. moduleExamId:this.moduleId
  322. }).then(res => {
  323. if(res.data.code == 500) {
  324. this.nextExamId = '';
  325. } else if(res.data.code == 200) {
  326. this.nextExamId = res.data.data.examId;
  327. }
  328. })
  329. },
  330. backBank() {
  331. uni.navigateTo({
  332. url: '/pages2/bank/questionBank?orderGoodsId='+this.orderGoodsId+'&id=' +this.nextExamId + '&goodsid=' + this.goodsId + '&moduleId=' + this.moduleId + '&chapterId=' + this.chapterId + ''
  333. });
  334. // uni.navigateBack({
  335. // delta:1
  336. // })
  337. // uni.redirectTo({
  338. // url: '/pages2/bank/my_question'
  339. // });
  340. },
  341. bankExam(){
  342. return new Promise(resolve =>{
  343. this.$api.bankExam(this.examId).then(res => {
  344. this.examData = res.data.data;
  345. resolve()
  346. })
  347. })
  348. },
  349. /**
  350. * 去做题
  351. */
  352. async doRepeat(id, goodsId, moduleId = 0, chapterId = 0) {
  353. // await this.getDetail(goodsId);
  354. let count = await this.examRecordCount(id, goodsId);
  355. let answerNum = await this.getExamDetail(id);
  356. //超过答题次数
  357. if (answerNum > 0 && count >= answerNum) {
  358. this.$u.toast('该试卷只能答题' + answerNum + '次!');
  359. return;
  360. }
  361. var pages = getCurrentPages();
  362. var prepage = pages[pages.length - 2]; //上一个页面
  363. prepage.$vm.isRepeat = true;
  364. uni.redirectTo({
  365. url: '/pages2/bank/questionBank?orderGoodsId='+this.orderGoodsId+'&id=' + id + '&goodsid=' + goodsId + '&moduleId=' + moduleId + '&chapterId=' + chapterId + ''
  366. });
  367. },
  368. /**
  369. * @param {Object} exam_id
  370. * 获取试卷可以做的次数
  371. */
  372. getExamDetail(exam_id) {
  373. return new Promise(resolve => {
  374. this.$api.getExamDetail(exam_id).then(res => {
  375. resolve(res.data.data.answerNum);
  376. });
  377. });
  378. },
  379. examWrongRecordWrongNum() {
  380. return new Promise(resolve => {
  381. this.$api.examWrongRecordWrongNum(this.recordId).then(res => {
  382. this.wrongRecordWrongNum = res.data.data || 0;
  383. resolve();
  384. });
  385. });
  386. },
  387. /**
  388. * 查询试卷历史做题次数
  389. */
  390. examRecordCount(examId, goodsId) {
  391. return new Promise(resolve => {
  392. this.$api
  393. .examRecordCount({
  394. examId: examId,
  395. orderGoodsId: this.orderGoodsId,
  396. })
  397. .then(res => {
  398. resolve(res.data.data);
  399. });
  400. });
  401. },
  402. getDetail(id) {
  403. return new Promise(resolve => {
  404. this.$api.goodsDetail(id).then(res => {
  405. this.goodsData = res.data.data;
  406. resolve();
  407. });
  408. });
  409. },
  410. examReport() {
  411. return new Promise(resolve => {
  412. this.$api.examReport(this.recordId).then(res => {
  413. this.reportdata = res.data.data;
  414. resolve()
  415. });
  416. })
  417. }
  418. }
  419. };
  420. </script>
  421. <style>
  422. page {
  423. background-color: #eaeef1;
  424. }
  425. </style>
  426. <style lang="scss" scope>
  427. @import '../../pages5/examReport/indexCourseList.scss';
  428. .disNone {
  429. display: none;
  430. }
  431. .greenBtn {
  432. margin: 16rpx 16rpx 0;
  433. height: 80rpx;
  434. line-height: 80rpx;
  435. text-align: center;
  436. background-color: #f7fff8;
  437. border-radius: 16rpx;
  438. color: #34c759;
  439. font-weight: bold;
  440. font-size: 30rpx;
  441. }
  442. .redBtn {
  443. margin: 16rpx 16rpx 0;
  444. height: 80rpx;
  445. line-height: 80rpx;
  446. text-align: center;
  447. background-color: #FFF3F2;
  448. border-radius: 16rpx;
  449. color: #FF3B30;
  450. font-weight: bold;
  451. font-size: 30rpx;
  452. }
  453. .dis_fst {
  454. margin-top: 40rpx;
  455. display: flex;
  456. align-items: center;
  457. justify-content: space-around;
  458. }
  459. .btnACs {
  460. height: 48rpx;
  461. width: 160rpx;
  462. text-align: center;
  463. line-height: 48rpx;
  464. border: 1rpx solid #007aff;
  465. border-radius: 16rpx;
  466. color: #007aff;
  467. font-size: 24rpx;
  468. }
  469. .top {
  470. margin: 16rpx 16rpx 0;
  471. border-radius: 16rpx;
  472. padding: 40rpx 24rpx 16rpx;
  473. background: #fff;
  474. .title {
  475. font-size: 32rpx;
  476. font-weight: bold;
  477. color: #333333;
  478. }
  479. .desc {
  480. margin-top: 20rpx;
  481. font-size: 24rpx;
  482. color: #999999;
  483. }
  484. .box {
  485. margin-top: 30rpx;
  486. display: flex;
  487. .left {
  488. width: 250rpx;
  489. height: 272rpx;
  490. background: #f5f5f5;
  491. border-radius: 16rpx;
  492. display: flex;
  493. align-items: center;
  494. justify-content: center;
  495. flex-direction: column;
  496. margin-right: 16rpx;
  497. view {
  498. text-align: center;
  499. &:nth-of-type(1) {
  500. font-size: 60rpx;
  501. font-weight: bold;
  502. color: #007aff;
  503. }
  504. &:nth-of-type(2) {
  505. font-size: 32rpx;
  506. font-weight: bold;
  507. color: #333333;
  508. }
  509. &:nth-of-type(3) {
  510. font-size: 24rpx;
  511. color: #999999;
  512. }
  513. }
  514. }
  515. .right {
  516. flex: 1;
  517. display: flex;
  518. flex-direction: column;
  519. justify-content: space-between;
  520. .flex {
  521. background: #f5f5f5;
  522. display: flex;
  523. height: 80rpx;
  524. align-items: center;
  525. padding: 0 40rpx;
  526. border-radius: 16rpx;
  527. image {
  528. margin-right: 28rpx;
  529. &.right_num {
  530. width:26rpx;
  531. }
  532. &.out_num {
  533. width:38rpx;
  534. }
  535. &.wrong_num {
  536. width:30rpx;
  537. }
  538. }
  539. .text {
  540. flex: 1;
  541. font-size: 30rpx;
  542. color: #666666;
  543. }
  544. text {
  545. font-size: 48rpx;
  546. color: #e12626;
  547. &.red {
  548. color: #FF3B30;
  549. }
  550. &.green {
  551. color: #36C75A;
  552. }
  553. &.yellow {
  554. color:#FFC53D;
  555. }
  556. }
  557. }
  558. }
  559. }
  560. }
  561. .bottom {
  562. .circle-wrap {
  563. .circle-list {
  564. display: flex;
  565. .item {
  566. padding: 20rpx;
  567. border-radius: 16rpx;
  568. background: #fff;
  569. margin: 16rpx;
  570. flex: 1;
  571. .title {
  572. font-weight: bold;
  573. font-size: 30rpx;
  574. line-height: 24rpx;
  575. color: #333333;
  576. text {
  577. font-size: 20rpx;
  578. color: #999999;
  579. }
  580. }
  581. canvas {
  582. margin: 36rpx auto 0;
  583. width: 180rpx;
  584. height: 180rpx;
  585. }
  586. .text {
  587. text-align: center;
  588. margin-top: 16rpx;
  589. font-size: 24rpx;
  590. color: #333333;
  591. }
  592. }
  593. }
  594. }
  595. }
  596. </style>