question_record.vue 18 KB

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