question_report.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  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: { ...mapGetters(['userInfo', 'hideBuyState']) },
  163. async onShow() {
  164. this.courseList = []
  165. this.getcourList()
  166. uni.getSystemInfo({
  167. success: res => {
  168. var winW = res.screenWidth;
  169. var winH = res.screenHeight;
  170. uni.createSelectorQuery()
  171. .in(this)
  172. .select('.canvas')
  173. .boundingClientRect()
  174. .exec(async newRes => {
  175. var width = newRes[0].width;
  176. var height = newRes[0].height;
  177. var caculateX = winW / 750;
  178. var caculateY = winH / 1334;
  179. console.log(caculateX);
  180. if(this.totalScore) {
  181. var context1 = uni.createCanvasContext('Canvas1');
  182. this.context1 = context1;
  183. context1.setStrokeStyle('#EEEEEE');
  184. context1.setLineWidth(caculateX * 20);
  185. context1.arc(caculateX * 90, caculateX * 90, caculateX * 80, 0, 2 * Math.PI, true);
  186. context1.stroke();
  187. context1.beginPath();
  188. context1.setStrokeStyle('#32D74B');
  189. context1.setFillStyle('#32D74B');
  190. context1.setTextAlign('center');
  191. context1.setTextBaseline('middle');
  192. context1.setLineCap('round');
  193. context1.setFontSize(caculateX * 64);
  194. context1.fillText(this.score, caculateX * 90, caculateX * 90, caculateX * 180);
  195. context1.setFillStyle('#999999');
  196. context1.setFontSize(caculateX * 20);
  197. context1.fillText(`满分${this.totalScore}`, caculateX * 90, caculateX * 130, caculateX * 180);
  198. context1.arc(caculateX * 90, caculateX * 90, caculateX * 80, -Math.PI/2, -Math.PI/2 + (this.score / this.totalScore) * 2 * Math.PI, false);
  199. context1.stroke();
  200. context1.draw();
  201. }
  202. if(this.examTime) {
  203. var context2 = uni.createCanvasContext('Canvas2');
  204. this.context2 = context2;
  205. context2.setStrokeStyle('#EEEEEE');
  206. context2.setLineWidth(caculateX * 20);
  207. context2.arc(caculateX * 90, caculateX * 90, caculateX * 80, 0, 2 * Math.PI, true);
  208. context2.stroke();
  209. context2.beginPath();
  210. context2.setStrokeStyle('#007AFF');
  211. context2.setFillStyle('#007AFF');
  212. context2.setTextAlign('center');
  213. context2.setTextBaseline('middle');
  214. context2.setLineCap('round');
  215. context2.setFontSize(caculateX * 64);
  216. context2.fillText(`${this.doTime}'`, caculateX * 90, caculateX * 90, caculateX * 180);
  217. context2.setFillStyle('#999999');
  218. context2.setFontSize(caculateX * 20);
  219. context2.fillText(`限时${this.examTime}'`, caculateX * 90, caculateX * 130, caculateX * 180);
  220. context2.arc(caculateX * 90, caculateX * 90, caculateX * 80, -Math.PI/2, -Math.PI/2 + (this.doTime / this.examTime) * 2 * Math.PI, false);
  221. context2.stroke();
  222. context2.draw();
  223. }
  224. });
  225. }
  226. });
  227. },
  228. async onLoad(option) {
  229. this.examType = option.type
  230. this.recordId = option.recordId
  231. this.examId = option.examId
  232. this.orderGoodsId = option.orderGoodsId
  233. this.examTime = option.examTime;
  234. this.doTime = option.doTime;
  235. this.reportStatus = option.reportStatus;
  236. this.rightQuestionNum = +option.rightQuestionNum;
  237. this.doWrongQuestionNum = +option.doWrongQuestionNum;
  238. this.score = +option.score;
  239. this.lessQuestionNum = option.lessQuestionNum;
  240. this.totalScore = +option.totalScore;
  241. // this.hideBtns = Boolean(option.hideBtns);
  242. this.bankReport()
  243. },
  244. methods: {
  245. getcourList() {
  246. this.$http({
  247. url: '/apply/recommend/goodsList',
  248. method: 'post',
  249. data: {
  250. examId: this.examId,
  251. pageNum: this.pageNum,
  252. pageSize: this.pageSize,
  253. }
  254. }).then((res) => {
  255. if (res.data.code == 200) {
  256. this.courseList.push(...(res.data.rows || [] ))
  257. this.total = res.data.total
  258. }
  259. })
  260. },
  261. toBuy(item) {
  262. // if (item.goodsType == 1) {
  263. // uni.navigateTo({
  264. // url: '/pages3/course/detail?id='+item.goodsId
  265. // })
  266. // } else
  267. if (item.goodsType == 2) {
  268. uni.navigateTo({
  269. url: '/pages2/bank/detail?id='+item.goodsId
  270. })
  271. } else {
  272. // /pages5/liveDetail/index
  273. uni.navigateTo({
  274. url: '/pages3/course/detail?id='+item.goodsId + '&goodsType=' + item.goodsType
  275. })
  276. }
  277. },
  278. bankReport() {
  279. this.$api.bankReportData(this.recordId).then((res) => {
  280. this.reportdata = res.data.data
  281. console.log('reportdata:', this.reportdata)
  282. });
  283. },
  284. /**
  285. * 去做题
  286. */
  287. async doRepeat(examId, goodsId, moduleId = 0, chapterId = 0) {
  288. let count = await this.bankRecordDoNum()
  289. let answerNum = await this.getExamDetail(examId);
  290. //超过答题次数
  291. if (answerNum > 0 && count >= answerNum) {
  292. this.$u.toast('该试卷只能答题' + answerNum + '次!');
  293. return;
  294. }
  295. // answerNum==0没有答题次数限制
  296. if (answerNum == 0 || (answerNum - count > 0 && answerNum > 0)) {
  297. const {courseId, gradeId, sectionId} = this.reportdata
  298. uni.redirectTo({
  299. url:"/pages2/class/questionBank?courseId=" + courseId + "&gradeId=" + gradeId + "&isFromVideo=1&id=" + examId +
  300. "&goodsid=" + goodsId + "&moduleId=" + moduleId + "&chapterId=" + chapterId + "&sectionId=" + sectionId + "&orderGoodsId=" +
  301. this.orderGoodsId + "&type=" + this.examType,
  302. })
  303. }
  304. },
  305. /**
  306. * 获取试卷已做的次数
  307. */
  308. bankRecordDoNum() {
  309. return new Promise((resolve) => {
  310. this.$api.bankRecordDoNum({
  311. goodsId: this.reportdata.goodsId,
  312. gradeId: this.reportdata.gradeId,
  313. chapterId: this.reportdata.chapterId || 0,
  314. courseId: this.reportdata.courseId,
  315. moduleId: this.reportdata.moduleId || 0,
  316. examId: this.reportdata.examId,
  317. })
  318. .then((res) => {
  319. resolve(res.data.data);
  320. });
  321. });
  322. },
  323. /**
  324. * @param {Object} exam_id
  325. * 获取试卷可以做的次数
  326. */
  327. getExamDetail(exam_id) {
  328. return new Promise(resolve => {
  329. this.$api.getExamDetail(exam_id).then(res => {
  330. resolve(res.data.data.answerNum);
  331. });
  332. });
  333. },
  334. }
  335. };
  336. </script>
  337. <style>
  338. page {
  339. background-color: #eaeef1;
  340. }
  341. </style>
  342. <style lang="scss" scope>
  343. @import '../../pages5/examReport/indexCourseList.scss';
  344. .disNone {
  345. display: none;
  346. }
  347. .greenBtn {
  348. margin: 16rpx 16rpx 0;
  349. height: 80rpx;
  350. line-height: 80rpx;
  351. text-align: center;
  352. background-color: #f7fff8;
  353. border-radius: 16rpx;
  354. color: #34c759;
  355. font-weight: bold;
  356. font-size: 30rpx;
  357. }
  358. .redBtn {
  359. margin: 16rpx 16rpx 0;
  360. height: 80rpx;
  361. line-height: 80rpx;
  362. text-align: center;
  363. background-color: #FFF3F2;
  364. border-radius: 16rpx;
  365. color: #FF3B30;
  366. font-weight: bold;
  367. font-size: 30rpx;
  368. }
  369. .dis_fst {
  370. margin-top: 40rpx;
  371. display: flex;
  372. align-items: center;
  373. justify-content: space-around;
  374. }
  375. .btnACs {
  376. height: 48rpx;
  377. width: 160rpx;
  378. text-align: center;
  379. line-height: 48rpx;
  380. border: 1rpx solid #007aff;
  381. border-radius: 16rpx;
  382. color: #007aff;
  383. font-size: 24rpx;
  384. }
  385. .top {
  386. margin: 16rpx 16rpx 0;
  387. border-radius: 16rpx;
  388. padding: 40rpx 24rpx 16rpx;
  389. background: #fff;
  390. .title {
  391. font-size: 32rpx;
  392. font-weight: bold;
  393. color: #333333;
  394. }
  395. .desc {
  396. margin-top: 20rpx;
  397. font-size: 24rpx;
  398. color: #999999;
  399. }
  400. .box {
  401. margin-top: 30rpx;
  402. display: flex;
  403. .left {
  404. width: 250rpx;
  405. height: 176rpx;
  406. background: #f5f5f5;
  407. border-radius: 16rpx;
  408. display: flex;
  409. align-items: center;
  410. justify-content: center;
  411. flex-direction: column;
  412. margin-right: 16rpx;
  413. view {
  414. text-align: center;
  415. &:nth-of-type(1) {
  416. font-size: 60rpx;
  417. font-weight: bold;
  418. color: #007aff;
  419. }
  420. &:nth-of-type(2) {
  421. font-size: 32rpx;
  422. font-weight: bold;
  423. color: #333333;
  424. }
  425. &:nth-of-type(3) {
  426. font-size: 24rpx;
  427. color: #999999;
  428. }
  429. }
  430. }
  431. .right {
  432. flex: 1;
  433. display: flex;
  434. flex-direction: column;
  435. justify-content: space-between;
  436. .flex {
  437. background: #f5f5f5;
  438. display: flex;
  439. height: 80rpx;
  440. align-items: center;
  441. padding: 0 40rpx;
  442. border-radius: 16rpx;
  443. image {
  444. margin-right: 28rpx;
  445. &.right_num {
  446. width:26rpx;
  447. }
  448. &.out_num {
  449. width:38rpx;
  450. }
  451. &.wrong_num {
  452. width:30rpx;
  453. }
  454. }
  455. .text {
  456. flex: 1;
  457. font-size: 30rpx;
  458. color: #666666;
  459. }
  460. text {
  461. font-size: 48rpx;
  462. color: #e12626;
  463. &.red {
  464. color: #FF3B30;
  465. }
  466. &.green {
  467. color: #36C75A;
  468. }
  469. &.yellow {
  470. color:#FFC53D;
  471. }
  472. }
  473. }
  474. }
  475. }
  476. }
  477. .bottom {
  478. .circle-wrap {
  479. .circle-list {
  480. display: flex;
  481. .item {
  482. padding: 20rpx;
  483. border-radius: 16rpx;
  484. background: #fff;
  485. margin: 16rpx;
  486. flex: 1;
  487. .title {
  488. font-weight: bold;
  489. font-size: 30rpx;
  490. line-height: 24rpx;
  491. color: #333333;
  492. text {
  493. font-size: 20rpx;
  494. color: #999999;
  495. }
  496. }
  497. canvas {
  498. margin: 36rpx auto 0;
  499. width: 180rpx;
  500. height: 180rpx;
  501. }
  502. .text {
  503. text-align: center;
  504. margin-top: 16rpx;
  505. font-size: 24rpx;
  506. color: #333333;
  507. }
  508. }
  509. }
  510. }
  511. }
  512. </style>