question_report.vue 15 KB

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