question_record.vue 17 KB

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