question_record.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741
  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.chapterExamId +
  224. "&recordId=" +
  225. record.recordId +
  226. "&orderGoodsId=" +
  227. record.orderGoodsId,
  228. });
  229. return;
  230. }
  231. uni.navigateTo({
  232. url:
  233. "/pages2/bank/questionBankExplain?id=" +
  234. record.examId +
  235. "&goodsid=" +
  236. record.goodsId +
  237. "&moduleId=" +
  238. moduleId +
  239. "&chapterId=" +
  240. chapterId +
  241. "&orderGoodsId=" +
  242. record.orderGoodsId +
  243. "&doMode=" +
  244. record.doMode,
  245. });
  246. },
  247. questionReport(record) {
  248. if (record.courseType == 2) {
  249. uni.navigateTo({
  250. url:
  251. "/pages2/class/question_report?examId=" +
  252. record.examId +
  253. "&recordId=" +
  254. record.recordId +
  255. "&type=" +
  256. record.type +
  257. "&orderGoodsId=" +
  258. record.orderGoodsId +
  259. "&doMode=" +
  260. record.doMode,
  261. });
  262. } else {
  263. let entryType = record.doMode == 2 ? "random" : "";
  264. uni.navigateTo({
  265. url:
  266. "/pages2/bank/question_report?goodsId=" +
  267. record.goodsId +
  268. "&chapterId=" +
  269. record.chapterExamId +
  270. "&moduleId=" +
  271. record.moduleExamId +
  272. "&examId=" +
  273. record.examId +
  274. "&id=" +
  275. record.recordId +
  276. "&orderGoodsId=" +
  277. record.orderGoodsId +
  278. "&entryType=" +
  279. entryType +
  280. "&doMode=" +
  281. record.doMode,
  282. });
  283. }
  284. },
  285. /**
  286. * 更多记录
  287. */
  288. moreRecord(record) {
  289. if (record.courseType == 2) {
  290. uni.navigateTo({
  291. url:
  292. "/pages2/bank/question_record_list?goodsId=" +
  293. record.goodsId +
  294. "&chapterId=" +
  295. record.chapterId +
  296. "&moduleId=" +
  297. record.moduleId +
  298. "&examId=" +
  299. record.examId +
  300. "&recordId=" +
  301. record.recordId +
  302. "&courseType=" +
  303. record.courseType +
  304. "&gradeId=" +
  305. record.gradeId +
  306. "&courseId=" +
  307. record.courseId +
  308. "&sectionId=" +
  309. record.sectionId,
  310. });
  311. } else {
  312. uni.navigateTo({
  313. url:
  314. "/pages2/bank/question_record_list?goodsId=" +
  315. record.goodsId +
  316. "&chapterId=" +
  317. record.chapterExamId +
  318. "&moduleId=" +
  319. record.moduleExamId +
  320. "&examId=" +
  321. record.examId +
  322. "&recordId=" +
  323. record.recordId +
  324. "&courseType=" +
  325. record.courseType,
  326. });
  327. }
  328. },
  329. addRecord() {
  330. this.$api
  331. .examRecordList({
  332. pageNum: 1,
  333. pageSize: 1,
  334. })
  335. .then((res) => {
  336. this.recordList.unshift(res.data.rows[0]);
  337. });
  338. this.isRepeat = false;
  339. },
  340. refreshByIndex() {
  341. this.$api
  342. .examRecordGroupList({
  343. pageNum: this.itemIndex + 1,
  344. pageSize: 1,
  345. })
  346. .then((res) => {
  347. this.$set(this.recordList, this.itemIndex, res.data.rows[0]);
  348. this.itemIndex = "";
  349. });
  350. },
  351. getExamRecordList() {
  352. if (this.param.pageNum == 1) {
  353. this.recordList = [];
  354. }
  355. this.$api.examRecordGroupList(this.param).then((res) => {
  356. this.recordList.push.apply(this.recordList, res.data.rows);
  357. this.total = res.data.total;
  358. });
  359. },
  360. /**
  361. * 继续做题
  362. */
  363. doContinue(record, index) {
  364. this.itemIndex = index;
  365. this.isRepeat = false;
  366. uni.navigateTo({
  367. url:
  368. "/pages2/bank/questionBankContinue?recordId=" +
  369. record.recordId +
  370. "&id=" +
  371. record.examId +
  372. "&goodsid=" +
  373. record.goodsId +
  374. "&moduleId=" +
  375. record.moduleExamId +
  376. "&chapterId=" +
  377. record.chapterExamId +
  378. "&orderGoodsId=" +
  379. record.orderGoodsId,
  380. });
  381. },
  382. /**
  383. * 去做题
  384. */
  385. async doRepeat(goodsId, record) {
  386. // await this.getDetail(goodsId);
  387. this.itemIndex = "";
  388. this.isRepeat = true;
  389. let count = 0;
  390. if (record.courseType == 2) {
  391. count = await this.bankRecordDoNum(record);
  392. } else {
  393. count = await this.examRecordCount(record.examId, goodsId);
  394. }
  395. // let count = await this.examRecordCount(record.examId,goodsId);
  396. let answerNum = await this.getExamDetail(record.examId);
  397. //超过答题次数
  398. if (answerNum > 0 && count >= answerNum) {
  399. this.$u.toast("该试卷只能答题" + answerNum + "次!");
  400. return;
  401. }
  402. if (record.courseType == 2) {
  403. const {
  404. courseId,
  405. gradeId,
  406. sectionId,
  407. examId,
  408. orderGoodsId = 0,
  409. type,
  410. reportStatus,
  411. } = record;
  412. let moduleId = record.moduleId || 0;
  413. let chapterId = record.chapterId || 0;
  414. uni.navigateTo({
  415. url:
  416. "/pages2/class/questionBank?courseId=" +
  417. courseId +
  418. "&gradeId=" +
  419. gradeId +
  420. "&isFromVideo=1&id=" +
  421. examId +
  422. "&goodsid=" +
  423. goodsId +
  424. "&moduleId=" +
  425. moduleId +
  426. "&chapterId=" +
  427. chapterId +
  428. "&sectionId=" +
  429. sectionId +
  430. "&orderGoodsId=" +
  431. orderGoodsId +
  432. "&type=" +
  433. type +
  434. "&learning=" +
  435. reportStatus,
  436. });
  437. } else {
  438. let moduleId = record.moduleExamId || 0;
  439. let chapterId = record.chapterExamId || 0;
  440. uni.navigateTo({
  441. url:
  442. "/pages2/bank/questionBank?id=" +
  443. record.examId +
  444. "&goodsid=" +
  445. goodsId +
  446. "&moduleId=" +
  447. moduleId +
  448. "&chapterId=" +
  449. chapterId +
  450. "&orderGoodsId=" +
  451. record.orderGoodsId,
  452. });
  453. }
  454. },
  455. /**
  456. * @param {Object} exam_id
  457. * 获取试卷可以做的次数
  458. */
  459. getExamDetail(exam_id) {
  460. return new Promise((resolve) => {
  461. this.$api.getExamDetail(exam_id).then((res) => {
  462. resolve(res.data.data.answerNum);
  463. });
  464. });
  465. },
  466. /**
  467. * 查询试卷历史做题次数(题库的)
  468. */
  469. examRecordCount(examId, goodsId) {
  470. return new Promise((resolve) => {
  471. this.$api
  472. .examRecordCount({
  473. examId: examId,
  474. goodsId: goodsId,
  475. })
  476. .then((res) => {
  477. resolve(res.data.data);
  478. });
  479. });
  480. },
  481. /**
  482. * 获取试卷已做的次数(视频课程的)
  483. */
  484. bankRecordDoNum(record) {
  485. return new Promise((resolve) => {
  486. this.$api
  487. .bankRecordDoNum({
  488. goodsId: record.goodsId,
  489. gradeId: record.gradeId,
  490. chapterId: record.chapterId || 0,
  491. courseId: record.courseId,
  492. moduleId: record.moduleId || 0,
  493. examId: record.examId,
  494. })
  495. .then((res) => {
  496. resolve(res.data.data);
  497. });
  498. });
  499. },
  500. getDetail(id) {
  501. return new Promise((resolve) => {
  502. this.$api.goodsDetail(id).then((res) => {
  503. this.goodsData = res.data.data;
  504. resolve();
  505. });
  506. });
  507. },
  508. testClick(item) {
  509. if (item === 3) {
  510. this.index = 0;
  511. this.activeIndex = 0;
  512. this.param.goodsId = "";
  513. this.param.pageNum = 1;
  514. this.getExamRecordList();
  515. } else {
  516. this.index = 0;
  517. this.activeIndex = item.goodsId;
  518. this.param.goodsId = item.goodsId;
  519. this.param.pageNum = 1;
  520. this.getExamRecordList();
  521. }
  522. },
  523. paperClick(item) {
  524. if (item === 3) {
  525. this.index = 0;
  526. this.typeIndex = 0;
  527. this.param.paperId = "";
  528. this.param.pageNum = 1;
  529. this.getExamRecordList();
  530. } else {
  531. this.index = 0;
  532. this.typeIndex = item.paperId;
  533. this.param.paperId = item.paperId;
  534. this.param.pageNum = 1;
  535. this.getExamRecordList();
  536. }
  537. },
  538. tab(index) {
  539. console.log(index, this.index);
  540. if (this.index == index) {
  541. this.index = 0;
  542. return;
  543. }
  544. this.index = index;
  545. console.log(this.index);
  546. },
  547. examaperList() {
  548. this.$api.examaperList({}).then((res) => {
  549. this.list1 = res.data.rows;
  550. });
  551. },
  552. listGoodsUserQuestion() {
  553. this.$api.listGoodsUserQuestion({}).then((res) => {
  554. this.list = res.data.rows;
  555. });
  556. },
  557. },
  558. };
  559. </script>
  560. <style>
  561. page {
  562. background: #eaeef1;
  563. }
  564. </style>
  565. <style lang="scss" scope>
  566. .animals {
  567. transition: all 0.3s;
  568. transform: rotate(180deg);
  569. }
  570. .tabs {
  571. position: fixed;
  572. left: 0;
  573. width: 100%;
  574. display: flex;
  575. z-index: 10;
  576. .tab {
  577. flex: 1;
  578. height: 80rpx;
  579. text-align: center;
  580. line-height: 80rpx;
  581. background: #ffffff;
  582. font-size: 32rpx;
  583. color: #999999;
  584. &.active {
  585. color: #333333;
  586. .icon {
  587. transform: rotate(180deg);
  588. }
  589. }
  590. }
  591. }
  592. .record {
  593. margin-top: 80rpx;
  594. padding: 16rpx 8rpx;
  595. display: flex;
  596. flex-wrap: wrap;
  597. .item {
  598. margin-bottom: 16rpx;
  599. width: 359rpx;
  600. background: #ffffff;
  601. border-radius: 16rpx;
  602. padding: 65rpx 20rpx 22rpx;
  603. position: relative;
  604. overflow: hidden;
  605. &:nth-of-type(2n) {
  606. margin-left: 16rpx;
  607. }
  608. .note {
  609. color: #fff;
  610. position: absolute;
  611. left: 0;
  612. top: 0;
  613. // width: 112rpx;
  614. padding: 0rpx 10rpx;
  615. height: 40rpx;
  616. text-align: center;
  617. line-height: 40rpx;
  618. background: linear-gradient(180deg, #4facfe, #007aff);
  619. border-radius: 16rpx 0px 16rpx 0rpx;
  620. }
  621. .title {
  622. font-size: 32rpx;
  623. color: #333333;
  624. font-weight: bold;
  625. }
  626. .desc {
  627. margin-top: 26rpx;
  628. view {
  629. margin: 16rpx 0;
  630. image {
  631. width: 23rpx;
  632. height: 24rpx;
  633. }
  634. text {
  635. margin-left: 15rpx;
  636. font-size: 24rpx;
  637. color: #999999;
  638. line-height: 36rpx;
  639. }
  640. }
  641. }
  642. .btns {
  643. margin-top: 26rpx;
  644. display: flex;
  645. justify-content: space-around;
  646. flex-wrap: wrap;
  647. .btn {
  648. margin: 5rpx 0;
  649. width: 150rpx;
  650. height: 48rpx;
  651. line-height: 48rpx;
  652. text-align: center;
  653. color: #007aff;
  654. background: #ffffff;
  655. border: 1rpx solid #007aff;
  656. border-radius: 16rpx;
  657. }
  658. }
  659. }
  660. }
  661. .modal {
  662. bottom: 0;
  663. z-index: 199999999;
  664. position: fixed;
  665. left: 0;
  666. width: 100%;
  667. .content {
  668. height: 80%;
  669. overflow: hidden;
  670. position: relative;
  671. z-index: 10;
  672. background: #fff;
  673. padding: 8rpx 12rpx 20rpx;
  674. display: flex;
  675. flex-wrap: wrap;
  676. .top {
  677. margin: 0 auto;
  678. width: 726rpx;
  679. height: 80rpx;
  680. background: #f5f5f5;
  681. color: #666666;
  682. border-radius: 16rpx;
  683. text-align: center;
  684. line-height: 80rpx;
  685. font-size: 32rpx;
  686. }
  687. .list {
  688. width: 100%;
  689. margin-top: 16rpx;
  690. display: flex;
  691. flex-wrap: wrap;
  692. justify-content: space-between;
  693. .item {
  694. padding: 25rpx 20rpx;
  695. width: 49%;
  696. background: #f5f5f5;
  697. border-radius: 16rpx;
  698. font-size: 32rpx;
  699. color: #666666;
  700. margin: 8rpx 0;
  701. }
  702. }
  703. }
  704. .modal_wrap {
  705. position: absolute;
  706. left: 0;
  707. width: 100%;
  708. top: 0;
  709. height: 100%;
  710. background: rgba(0, 0, 0, 0.3);
  711. }
  712. }
  713. .activesty {
  714. background: #007aff !important;
  715. color: #fff !important;
  716. }
  717. </style>