question_record.vue 18 KB

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