question_record.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747
  1. <template>
  2. <view>
  3. <nav-bar title="做题记录" class="nav"></nav-bar>
  4. <view class="tabs">
  5. <view
  6. class="tab"
  7. :class="{ active: index == 1 }"
  8. data-index="1"
  9. @click="tab(1)"
  10. >
  11. 全部题库记录
  12. <u-icon
  13. class="icon"
  14. :class="index == 1 ? 'animals' : ''"
  15. name="arrow-down"
  16. ></u-icon>
  17. </view>
  18. <view
  19. class="tab"
  20. :class="{ active: index == 2 }"
  21. data-index="2"
  22. @click="tab(2)"
  23. >
  24. 全部试卷类型
  25. <u-icon
  26. class="icon"
  27. :class="index == 2 ? 'animals' : ''"
  28. name="arrow-down"
  29. ></u-icon>
  30. </view>
  31. </view>
  32. <view class="record">
  33. <view class="item" v-for="(record, index) in recordList" :key="index">
  34. <view class="note">{{ record.paperName }}</view>
  35. <view class="title">{{ record.examName }}</view>
  36. <view class="desc">
  37. <view>
  38. <image src="/static/icon/wk_icon2.png"></image>
  39. <text>{{ $method.timestampToTime(record.updateTime, false) }}</text>
  40. </view>
  41. <view>
  42. <image src="/static/icon/wk_icon2.png"></image>
  43. <text
  44. >总共 {{ record.totalQuestionNum }} 题 做对
  45. {{ record.rightQuestionNum }} 题</text
  46. >
  47. </view>
  48. </view>
  49. <view class="btns">
  50. <view
  51. class="btn"
  52. v-if="record.doMode == 1 && record.status == 1"
  53. @click="doRepeat(record.goodsId, record)"
  54. >重做</view
  55. >
  56. <view
  57. class="btn"
  58. @click="questionBankExplain(record)"
  59. v-if="record.status == 1"
  60. >解析</view
  61. >
  62. <view
  63. class="btn"
  64. @click="questionReport(record)"
  65. v-if="record.status == 1"
  66. >报告</view
  67. >
  68. <view
  69. class="btn continue"
  70. @click="doContinue(record, index)"
  71. v-if="
  72. record.courseType != 2 &&
  73. record.status == 0 &&
  74. record.historyExamJson &&
  75. record.doMode != 3
  76. "
  77. >继续答题</view
  78. >
  79. <view class="btn continue" @click="moreRecord(record, index)"
  80. >更多记录</view
  81. >
  82. </view>
  83. </view>
  84. </view>
  85. <view class="modal" :style="{ top: modalTop + 'px' }" v-if="index == 1">
  86. <view class="content">
  87. <scroll-view scroll-y="true" style="height: 100%">
  88. <view
  89. class="top"
  90. :class="activeIndex === 0 ? 'activesty' : ''"
  91. @click="testClick(3)"
  92. >全部题库记录</view
  93. >
  94. <view class="list">
  95. <view
  96. class="item"
  97. :class="activeIndex == listItem.goodsId ? 'activesty' : ''"
  98. v-for="(listItem, listIndex) in list"
  99. :key="listIndex"
  100. @click="testClick(listItem)"
  101. >
  102. {{ listItem.goodsName }}
  103. </view>
  104. </view>
  105. </scroll-view>
  106. </view>
  107. <view class="modal_wrap" @click="index = 0"></view>
  108. </view>
  109. <view class="modal" :style="{ top: modalTop + 'px' }" v-if="index == 2">
  110. <view class="content">
  111. <scroll-view scroll-y="true" style="height: 100%">
  112. <view
  113. class="top"
  114. :class="typeIndex === 0 ? 'activesty' : ''"
  115. @click="paperClick(3)"
  116. >全部试卷类型</view
  117. >
  118. <view class="list">
  119. <view
  120. class="item"
  121. :class="typeIndex == listItem.paperId ? 'activesty' : ''"
  122. v-for="(listItem, listIndex) in list1"
  123. :key="listIndex"
  124. @click="paperClick(listItem)"
  125. >{{ listItem.paperName }}</view
  126. >
  127. </view>
  128. </scroll-view>
  129. </view>
  130. <view class="modal_wrap" @click="index = 0"></view>
  131. </view>
  132. </view>
  133. </template>
  134. <script>
  135. export default {
  136. data() {
  137. return {
  138. index: 0,
  139. list: [],
  140. list1: [],
  141. recordList: [],
  142. goodsData: {},
  143. param: {
  144. pageNum: 1,
  145. pageSize: 10,
  146. },
  147. isRepeat: false,
  148. total: 0,
  149. activeIndex: 0,
  150. typeIndex: 0,
  151. itemIndex: "",
  152. modalTop: 0,
  153. };
  154. },
  155. onLoad(option) {
  156. this.listGoodsUserQuestion();
  157. this.examaperList();
  158. // this.getExamRecordList();
  159. uni.getSystemInfo({
  160. success: (e) => {
  161. let info = uni.createSelectorQuery().select(".nav");
  162. info
  163. .boundingClientRect((navData) => {
  164. //data - 各种参数
  165. let info = uni.createSelectorQuery().select(".tabs");
  166. info
  167. .boundingClientRect((tabData) => {
  168. //data - 各种参数
  169. this.modalTop = navData.height + tabData.height;
  170. console.log(navData); // 获取元素宽度
  171. console.log(tabData); // 获取元素宽度
  172. })
  173. .exec();
  174. })
  175. .exec();
  176. },
  177. });
  178. },
  179. onPullDownRefresh() {
  180. let that = this;
  181. this.param = {
  182. pageNum: 1,
  183. pageSize: 10,
  184. };
  185. this.getExamRecordList();
  186. setTimeout(function () {
  187. uni.stopPullDownRefresh();
  188. }, 500);
  189. },
  190. onReachBottom() {
  191. if (this.recordList.length < this.total) {
  192. this.param.pageNum++;
  193. this.getExamRecordList();
  194. }
  195. },
  196. onShow() {
  197. this.param.pageNum = 1;
  198. this.getExamRecordList();
  199. if (this.isRepeat) {
  200. // this.addRecord();
  201. } else {
  202. if (this.itemIndex !== "") {
  203. this.refreshByIndex();
  204. }
  205. }
  206. },
  207. methods: {
  208. questionBankExplain(record) {
  209. let moduleId =
  210. record.courseType == 2 ? record.moduleId : record.moduleExamId;
  211. let chapterId =
  212. record.courseType == 2 ? record.chapterId : record.chapterExamId;
  213. if (record.doMode == 3) {
  214. uni.navigateTo({
  215. url:
  216. "/pages2/bank/questionBankAllExplain?id=" +
  217. record.examId +
  218. "&goodsid=" +
  219. record.goodsId +
  220. "&moduleId=" +
  221. record.moduleId +
  222. "&chapterId=" +
  223. record.chapterId +
  224. "&recordId=" +
  225. record.recordId +
  226. "&orderGoodsId=" +
  227. record.orderGoodsId +
  228. "&courseType=" +
  229. record.courseType,
  230. });
  231. return;
  232. }
  233. uni.navigateTo({
  234. url:
  235. "/pages2/bank/questionBankExplain?id=" +
  236. record.examId +
  237. "&goodsid=" +
  238. record.goodsId +
  239. "&moduleId=" +
  240. moduleId +
  241. "&chapterId=" +
  242. chapterId +
  243. "&orderGoodsId=" +
  244. record.orderGoodsId +
  245. "&doMode=" +
  246. record.doMode,
  247. });
  248. },
  249. questionReport(record) {
  250. if (record.courseType == 2) {
  251. uni.navigateTo({
  252. url:
  253. "/pages2/class/question_report?examId=" +
  254. record.examId +
  255. "&recordId=" +
  256. record.recordId +
  257. "&type=" +
  258. record.type +
  259. "&orderGoodsId=" +
  260. record.orderGoodsId +
  261. "&doMode=" +
  262. record.doMode +
  263. "&courseType=" +
  264. record.courseType,
  265. });
  266. } else {
  267. let entryType = record.doMode == 2 ? "random" : "";
  268. uni.navigateTo({
  269. url:
  270. "/pages2/bank/question_report?goodsId=" +
  271. record.goodsId +
  272. "&chapterId=" +
  273. record.chapterExamId +
  274. "&moduleId=" +
  275. record.moduleExamId +
  276. "&examId=" +
  277. record.examId +
  278. "&id=" +
  279. record.recordId +
  280. "&orderGoodsId=" +
  281. record.orderGoodsId +
  282. "&entryType=" +
  283. entryType +
  284. "&doMode=" +
  285. record.doMode +
  286. "&courseType=" +
  287. record.courseType,
  288. });
  289. }
  290. },
  291. /**
  292. * 更多记录
  293. */
  294. moreRecord(record) {
  295. if (record.courseType == 2) {
  296. uni.navigateTo({
  297. url:
  298. "/pages2/bank/question_record_list?goodsId=" +
  299. record.goodsId +
  300. "&chapterId=" +
  301. record.chapterId +
  302. "&moduleId=" +
  303. record.moduleId +
  304. "&examId=" +
  305. record.examId +
  306. "&recordId=" +
  307. record.recordId +
  308. "&courseType=" +
  309. record.courseType +
  310. "&gradeId=" +
  311. record.gradeId +
  312. "&courseId=" +
  313. record.courseId +
  314. "&sectionId=" +
  315. record.sectionId,
  316. });
  317. } else {
  318. uni.navigateTo({
  319. url:
  320. "/pages2/bank/question_record_list?goodsId=" +
  321. record.goodsId +
  322. "&chapterId=" +
  323. record.chapterExamId +
  324. "&moduleId=" +
  325. record.moduleExamId +
  326. "&examId=" +
  327. record.examId +
  328. "&recordId=" +
  329. record.recordId +
  330. "&courseType=" +
  331. record.courseType,
  332. });
  333. }
  334. },
  335. addRecord() {
  336. this.$api
  337. .examRecordList({
  338. pageNum: 1,
  339. pageSize: 1,
  340. })
  341. .then((res) => {
  342. this.recordList.unshift(res.data.rows[0]);
  343. });
  344. this.isRepeat = false;
  345. },
  346. refreshByIndex() {
  347. this.$api
  348. .examRecordGroupList({
  349. pageNum: this.itemIndex + 1,
  350. pageSize: 1,
  351. })
  352. .then((res) => {
  353. this.$set(this.recordList, this.itemIndex, res.data.rows[0]);
  354. this.itemIndex = "";
  355. });
  356. },
  357. getExamRecordList() {
  358. if (this.param.pageNum == 1) {
  359. this.recordList = [];
  360. }
  361. this.$api.examRecordGroupList(this.param).then((res) => {
  362. this.recordList.push.apply(this.recordList, res.data.rows);
  363. this.total = res.data.total;
  364. });
  365. },
  366. /**
  367. * 继续做题
  368. */
  369. doContinue(record, index) {
  370. this.itemIndex = index;
  371. this.isRepeat = false;
  372. uni.navigateTo({
  373. url:
  374. "/pages2/bank/questionBankContinue?recordId=" +
  375. record.recordId +
  376. "&id=" +
  377. record.examId +
  378. "&goodsid=" +
  379. record.goodsId +
  380. "&moduleId=" +
  381. record.moduleExamId +
  382. "&chapterId=" +
  383. record.chapterExamId +
  384. "&orderGoodsId=" +
  385. record.orderGoodsId,
  386. });
  387. },
  388. /**
  389. * 去做题
  390. */
  391. async doRepeat(goodsId, record) {
  392. // await this.getDetail(goodsId);
  393. this.itemIndex = "";
  394. this.isRepeat = true;
  395. let count = 0;
  396. if (record.courseType == 2) {
  397. count = await this.bankRecordDoNum(record);
  398. } else {
  399. count = await this.examRecordCount(record.examId, goodsId);
  400. }
  401. // let count = await this.examRecordCount(record.examId,goodsId);
  402. let answerNum = await this.getExamDetail(record.examId);
  403. //超过答题次数
  404. if (answerNum > 0 && count >= answerNum) {
  405. this.$u.toast("该试卷只能答题" + answerNum + "次!");
  406. return;
  407. }
  408. if (record.courseType == 2) {
  409. const {
  410. courseId,
  411. gradeId,
  412. sectionId,
  413. examId,
  414. orderGoodsId = 0,
  415. type,
  416. reportStatus,
  417. } = record;
  418. let moduleId = record.moduleId || 0;
  419. let chapterId = record.chapterId || 0;
  420. uni.navigateTo({
  421. url:
  422. "/pages2/class/questionBank?courseId=" +
  423. courseId +
  424. "&gradeId=" +
  425. gradeId +
  426. "&isFromVideo=1&id=" +
  427. examId +
  428. "&goodsid=" +
  429. goodsId +
  430. "&moduleId=" +
  431. moduleId +
  432. "&chapterId=" +
  433. chapterId +
  434. "&sectionId=" +
  435. sectionId +
  436. "&orderGoodsId=" +
  437. orderGoodsId +
  438. "&type=" +
  439. type +
  440. "&learning=" +
  441. reportStatus,
  442. });
  443. } else {
  444. let moduleId = record.moduleExamId || 0;
  445. let chapterId = record.chapterExamId || 0;
  446. uni.navigateTo({
  447. url:
  448. "/pages2/bank/questionBank?id=" +
  449. record.examId +
  450. "&goodsid=" +
  451. goodsId +
  452. "&moduleId=" +
  453. moduleId +
  454. "&chapterId=" +
  455. chapterId +
  456. "&orderGoodsId=" +
  457. record.orderGoodsId,
  458. });
  459. }
  460. },
  461. /**
  462. * @param {Object} exam_id
  463. * 获取试卷可以做的次数
  464. */
  465. getExamDetail(exam_id) {
  466. return new Promise((resolve) => {
  467. this.$api.getExamDetail(exam_id).then((res) => {
  468. resolve(res.data.data.answerNum);
  469. });
  470. });
  471. },
  472. /**
  473. * 查询试卷历史做题次数(题库的)
  474. */
  475. examRecordCount(examId, goodsId) {
  476. return new Promise((resolve) => {
  477. this.$api
  478. .examRecordCount({
  479. examId: examId,
  480. goodsId: goodsId,
  481. })
  482. .then((res) => {
  483. resolve(res.data.data);
  484. });
  485. });
  486. },
  487. /**
  488. * 获取试卷已做的次数(视频课程的)
  489. */
  490. bankRecordDoNum(record) {
  491. return new Promise((resolve) => {
  492. this.$api
  493. .bankRecordDoNum({
  494. goodsId: record.goodsId,
  495. gradeId: record.gradeId,
  496. chapterId: record.chapterId || 0,
  497. courseId: record.courseId,
  498. moduleId: record.moduleId || 0,
  499. examId: record.examId,
  500. })
  501. .then((res) => {
  502. resolve(res.data.data);
  503. });
  504. });
  505. },
  506. getDetail(id) {
  507. return new Promise((resolve) => {
  508. this.$api.goodsDetail(id).then((res) => {
  509. this.goodsData = res.data.data;
  510. resolve();
  511. });
  512. });
  513. },
  514. testClick(item) {
  515. if (item === 3) {
  516. this.index = 0;
  517. this.activeIndex = 0;
  518. this.param.goodsId = "";
  519. this.param.pageNum = 1;
  520. this.getExamRecordList();
  521. } else {
  522. this.index = 0;
  523. this.activeIndex = item.goodsId;
  524. this.param.goodsId = item.goodsId;
  525. this.param.pageNum = 1;
  526. this.getExamRecordList();
  527. }
  528. },
  529. paperClick(item) {
  530. if (item === 3) {
  531. this.index = 0;
  532. this.typeIndex = 0;
  533. this.param.paperId = "";
  534. this.param.pageNum = 1;
  535. this.getExamRecordList();
  536. } else {
  537. this.index = 0;
  538. this.typeIndex = item.paperId;
  539. this.param.paperId = item.paperId;
  540. this.param.pageNum = 1;
  541. this.getExamRecordList();
  542. }
  543. },
  544. tab(index) {
  545. console.log(index, this.index);
  546. if (this.index == index) {
  547. this.index = 0;
  548. return;
  549. }
  550. this.index = index;
  551. console.log(this.index);
  552. },
  553. examaperList() {
  554. this.$api.examaperList({}).then((res) => {
  555. this.list1 = res.data.rows;
  556. });
  557. },
  558. listGoodsUserQuestion() {
  559. this.$api.listGoodsUserQuestion({}).then((res) => {
  560. this.list = res.data.rows;
  561. });
  562. },
  563. },
  564. };
  565. </script>
  566. <style>
  567. page {
  568. background: #eaeef1;
  569. }
  570. </style>
  571. <style lang="scss" scope>
  572. .animals {
  573. transition: all 0.3s;
  574. transform: rotate(180deg);
  575. }
  576. .tabs {
  577. position: fixed;
  578. left: 0;
  579. width: 100%;
  580. display: flex;
  581. z-index: 10;
  582. .tab {
  583. flex: 1;
  584. height: 80rpx;
  585. text-align: center;
  586. line-height: 80rpx;
  587. background: #ffffff;
  588. font-size: 32rpx;
  589. color: #999999;
  590. &.active {
  591. color: #333333;
  592. .icon {
  593. transform: rotate(180deg);
  594. }
  595. }
  596. }
  597. }
  598. .record {
  599. margin-top: 80rpx;
  600. padding: 16rpx 8rpx;
  601. display: flex;
  602. flex-wrap: wrap;
  603. .item {
  604. margin-bottom: 16rpx;
  605. width: 359rpx;
  606. background: #ffffff;
  607. border-radius: 16rpx;
  608. padding: 65rpx 20rpx 22rpx;
  609. position: relative;
  610. overflow: hidden;
  611. &:nth-of-type(2n) {
  612. margin-left: 16rpx;
  613. }
  614. .note {
  615. color: #fff;
  616. position: absolute;
  617. left: 0;
  618. top: 0;
  619. // width: 112rpx;
  620. padding: 0rpx 10rpx;
  621. height: 40rpx;
  622. text-align: center;
  623. line-height: 40rpx;
  624. background: linear-gradient(180deg, #4facfe, #007aff);
  625. border-radius: 16rpx 0px 16rpx 0rpx;
  626. }
  627. .title {
  628. font-size: 32rpx;
  629. color: #333333;
  630. font-weight: bold;
  631. }
  632. .desc {
  633. margin-top: 26rpx;
  634. view {
  635. margin: 16rpx 0;
  636. image {
  637. width: 23rpx;
  638. height: 24rpx;
  639. }
  640. text {
  641. margin-left: 15rpx;
  642. font-size: 24rpx;
  643. color: #999999;
  644. line-height: 36rpx;
  645. }
  646. }
  647. }
  648. .btns {
  649. margin-top: 26rpx;
  650. display: flex;
  651. justify-content: space-around;
  652. flex-wrap: wrap;
  653. .btn {
  654. margin: 5rpx 0;
  655. width: 150rpx;
  656. height: 48rpx;
  657. line-height: 48rpx;
  658. text-align: center;
  659. color: #007aff;
  660. background: #ffffff;
  661. border: 1rpx solid #007aff;
  662. border-radius: 16rpx;
  663. }
  664. }
  665. }
  666. }
  667. .modal {
  668. bottom: 0;
  669. z-index: 199999999;
  670. position: fixed;
  671. left: 0;
  672. width: 100%;
  673. .content {
  674. height: 80%;
  675. overflow: hidden;
  676. position: relative;
  677. z-index: 10;
  678. background: #fff;
  679. padding: 8rpx 12rpx 20rpx;
  680. display: flex;
  681. flex-wrap: wrap;
  682. .top {
  683. margin: 0 auto;
  684. width: 726rpx;
  685. height: 80rpx;
  686. background: #f5f5f5;
  687. color: #666666;
  688. border-radius: 16rpx;
  689. text-align: center;
  690. line-height: 80rpx;
  691. font-size: 32rpx;
  692. }
  693. .list {
  694. width: 100%;
  695. margin-top: 16rpx;
  696. display: flex;
  697. flex-wrap: wrap;
  698. justify-content: space-between;
  699. .item {
  700. padding: 25rpx 20rpx;
  701. width: 49%;
  702. background: #f5f5f5;
  703. border-radius: 16rpx;
  704. font-size: 32rpx;
  705. color: #666666;
  706. margin: 8rpx 0;
  707. }
  708. }
  709. }
  710. .modal_wrap {
  711. position: absolute;
  712. left: 0;
  713. width: 100%;
  714. top: 0;
  715. height: 100%;
  716. background: rgba(0, 0, 0, 0.3);
  717. }
  718. }
  719. .activesty {
  720. background: #007aff !important;
  721. color: #fff !important;
  722. }
  723. </style>