question_record.vue 18 KB

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