question_record.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  1. <template>
  2. <view>
  3. <nav-bar title="做题记录" class="nav"></nav-bar>
  4. <view class="tabs">
  5. <view class="tab" :class="{ active: index == 1 }" data-index="1" @click="tab(1)">
  6. 全部题库记录
  7. <u-icon class="icon" :class="index ==1? 'animals':''" name="arrow-down"></u-icon>
  8. </view>
  9. <view class="tab" :class="{ active: index == 2 }" data-index="2" @click="tab(2)">
  10. 全部试卷类型
  11. <u-icon class="icon" :class="index ==2? 'animals':''" name="arrow-down"></u-icon>
  12. </view>
  13. </view>
  14. <view class="record">
  15. <view class="item" v-for="(record,index) in recordList" :key="index">
  16. <view class="note">{{ record.paperName }}</view>
  17. <view class="title">{{ record.examName }}</view>
  18. <view class="desc">
  19. <view>
  20. <image src="/static/icon/wk_icon2.png"></image>
  21. <text>{{ $method.timestampToTime(record.updateTime, false) }}</text>
  22. </view>
  23. <view>
  24. <image src="/static/icon/wk_icon2.png"></image>
  25. <text>总共 {{ record.totalQuestionNum }} 题 做对 {{ record.rightQuestionNum }} 题</text>
  26. </view>
  27. </view>
  28. <view class="btns">
  29. <view class="btn" v-if="record.doMode == 1 && record.status == 1" @click="doRepeat(record.goodsId, record)">重做</view>
  30. <view class="btn" @click="questionBankExplain(record)" v-if="record.status == 1">解析</view>
  31. <view class="btn" @click="questionReport(record)" v-if="record.status == 1">报告</view>
  32. <view class="btn continue" @click="doContinue(record,index)" v-if="record.courseType != 2 && record.status == 0 && record.historyExamJson">继续答题</view>
  33. <view class="btn continue" @click="moreRecord(record,index)" >更多记录</view>
  34. </view>
  35. </view>
  36. </view>
  37. <view class="modal" :style="{top:modalTop+'px'}" v-if="index == 1">
  38. <view class="content">
  39. <scroll-view scroll-y="true" style="height:100%">
  40. <view class="top" :class="activeIndex === 0 ? 'activesty' : ''" @click="testClick(3)">全部题库记录</view>
  41. <view class="list">
  42. <view class="item" :class="activeIndex == listItem.goodsId ? 'activesty' : ''" v-for="(listItem,listIndex) in list" :key="listIndex" @click="testClick(listItem)">
  43. {{ listItem.goodsName }}
  44. </view>
  45. </view>
  46. </scroll-view>
  47. </view>
  48. <view class="modal_wrap" @click="index = 0"></view>
  49. </view>
  50. <view class="modal" :style="{top:modalTop+'px'}" v-if="index == 2">
  51. <view class="content">
  52. <scroll-view scroll-y="true" style="height:100%">
  53. <view class="top" :class="typeIndex === 0 ? 'activesty' : ''" @click="paperClick(3)">全部试卷类型</view>
  54. <view class="list">
  55. <view class="item" :class="typeIndex == listItem.paperId ? 'activesty' : ''" v-for="(listItem,listIndex) in list1" :key="listIndex" @click="paperClick(listItem)">{{ listItem.paperName }}</view>
  56. </view>
  57. </scroll-view>
  58. </view>
  59. <view class="modal_wrap" @click="index = 0"></view>
  60. </view>
  61. </view>
  62. </template>
  63. <script>
  64. export default {
  65. data() {
  66. return {
  67. index: 0,
  68. list: [],
  69. list1: [],
  70. recordList: [],
  71. goodsData: {},
  72. param: {
  73. pageNum: 1,
  74. pageSize: 10
  75. },
  76. isRepeat:false,
  77. total: 0,
  78. activeIndex: 0,
  79. typeIndex:0,
  80. itemIndex:'',
  81. modalTop:0,
  82. };
  83. },
  84. onLoad(option) {
  85. this.listGoodsUserQuestion();
  86. this.examaperList();
  87. this.getExamRecordList();
  88. uni.getSystemInfo({
  89. success:(e) => {
  90. let info = uni.createSelectorQuery().select(".nav");
  91. info.boundingClientRect((navData) => { //data - 各种参数
  92. let info = uni.createSelectorQuery().select(".tabs");
  93. info.boundingClientRect((tabData) => { //data - 各种参数
  94. this.modalTop = navData.height + tabData.height
  95. console.log(navData) // 获取元素宽度
  96. console.log(tabData) // 获取元素宽度
  97. }).exec()
  98. }).exec()
  99. }
  100. })
  101. },
  102. onPullDownRefresh() {
  103. let that = this;
  104. this.param = {
  105. pageNum: 1,
  106. pageSize: 10
  107. };
  108. this.getExamRecordList();
  109. setTimeout(function() {
  110. uni.stopPullDownRefresh();
  111. }, 500);
  112. },
  113. onReachBottom() {
  114. if (this.recordList.length < this.total) {
  115. this.param.pageNum++;
  116. this.getExamRecordList();
  117. }
  118. },
  119. onShow() {
  120. if(this.isRepeat) {
  121. this.addRecord();
  122. } else {
  123. if(this.itemIndex !== '') {
  124. this.refreshByIndex();
  125. }
  126. }
  127. },
  128. methods: {
  129. questionBankExplain(record) {
  130. let moduleId = record.courseType == 2 ? record.moduleId : record.moduleExamId
  131. let chapterId = record.courseType == 2 ? record.chapterId : record.chapterExamId
  132. uni.navigateTo({
  133. url:'/pages2/bank/questionBankExplain?id='+record.examId +'&goodsid='+record.goodsId+'&moduleId='+moduleId+'&chapterId='+chapterId
  134. +'&orderGoodsId='+record.orderGoodsId + '&doMode=' + record.doMode
  135. })
  136. },
  137. questionReport(record) {
  138. if (record.courseType == 2) {
  139. uni.navigateTo({
  140. url: "/pages2/class/question_report?examId=" + record.examId + '&recordId=' + record.recordId + '&type=' + record.type + '&orderGoodsId='+ record.orderGoodsId,
  141. });
  142. } else {
  143. let entryType = record.doMode == 2 ? 'random' : ''
  144. uni.navigateTo({
  145. url:'/pages2/bank/question_report?goodsId='+record.goodsId+'&chapterId='+record.chapterExamId+'&moduleId='+record.moduleExamId
  146. +'&examId='+record.examId+'&id=' + record.recordId+'&orderGoodsId='+record.orderGoodsId + '&entryType=' + entryType
  147. })
  148. }
  149. },
  150. /**
  151. * 更多记录
  152. */
  153. moreRecord(record) {
  154. if (record.courseType == 2) {
  155. uni.navigateTo({
  156. url:'/pages2/bank/question_record_list?goodsId='+record.goodsId+'&chapterId='+record.chapterId+'&moduleId='+record.moduleId
  157. +'&examId='+record.examId+'&recordId=' + record.recordId + '&courseType=' + record.courseType + '&gradeId=' +record.gradeId
  158. + '&courseId=' + record.courseId + '&sectionId=' + record.sectionId
  159. })
  160. } else {
  161. uni.navigateTo({
  162. url:'/pages2/bank/question_record_list?goodsId='+record.goodsId+'&chapterId='+record.chapterExamId+'&moduleId='+record.moduleExamId
  163. +'&examId='+record.examId+'&recordId=' + record.recordId + '&courseType=' + record.courseType
  164. })
  165. }
  166. },
  167. addRecord() {
  168. this.$api.examRecordList({
  169. pageNum: 1,
  170. pageSize: 1
  171. }).then(res => {
  172. this.recordList.unshift(res.data.rows[0])
  173. });
  174. this.isRepeat = false;
  175. },
  176. refreshByIndex() {
  177. this.$api.examRecordGroupList({
  178. pageNum: this.itemIndex+1,
  179. pageSize: 1
  180. }).then(res => {
  181. this.$set(this.recordList,this.itemIndex,res.data.rows[0])
  182. this.itemIndex = ''
  183. });
  184. },
  185. getExamRecordList() {
  186. if (this.param.pageNum == 1) {
  187. this.recordList = [];
  188. }
  189. this.$api.examRecordGroupList(this.param).then(res => {
  190. this.recordList.push.apply(this.recordList, res.data.rows);
  191. this.total = res.data.total;
  192. });
  193. },
  194. /**
  195. * 继续做题
  196. */
  197. doContinue(record,index) {
  198. this.itemIndex = index;
  199. this.isRepeat = false;
  200. uni.navigateTo({
  201. url:'/pages2/bank/questionBankContinue?recordId=' +
  202. record.recordId +
  203. '&id=' +
  204. record.examId +
  205. '&goodsid=' +
  206. record.goodsId +
  207. '&moduleId=' +
  208. record.moduleExamId +
  209. '&chapterId=' +
  210. record.chapterExamId +
  211. '&orderGoodsId=' +
  212. record.orderGoodsId
  213. })
  214. },
  215. /**
  216. * 去做题
  217. */
  218. async doRepeat(goodsId, record) {
  219. // await this.getDetail(goodsId);
  220. this.itemIndex = '';
  221. this.isRepeat = true;
  222. let count = 0
  223. if (record.courseType == 2) {
  224. count = await this.bankRecordDoNum(record)
  225. } else {
  226. count = await this.examRecordCount(record.examId, goodsId);
  227. }
  228. // let count = await this.examRecordCount(record.examId,goodsId);
  229. let answerNum = await this.getExamDetail(record.examId);
  230. //超过答题次数
  231. if (answerNum > 0 && count >= answerNum) {
  232. this.$u.toast('该试卷只能答题' + answerNum + '次!');
  233. return;
  234. }
  235. if (record.courseType == 2) {
  236. const {courseId, gradeId, sectionId, examId, orderGoodsId = 0, type, reportStatus} = record
  237. let moduleId = record.moduleId || 0
  238. let chapterId = record.chapterId || 0
  239. uni.navigateTo({
  240. url:"/pages2/class/questionBank?courseId=" + courseId + "&gradeId=" + gradeId + "&isFromVideo=1&id=" + examId +
  241. "&goodsid=" + goodsId + "&moduleId=" + moduleId + "&chapterId=" + chapterId + "&sectionId=" + sectionId + "&orderGoodsId=" +
  242. orderGoodsId + "&type=" + type+ '&learning=' + reportStatus,
  243. })
  244. } else {
  245. let moduleId = record.moduleExamId || 0
  246. let chapterId = record.chapterExamId || 0
  247. uni.navigateTo({
  248. url: '/pages2/bank/questionBank?id=' + record.examId + '&goodsid=' + goodsId + '&moduleId=' + moduleId + '&chapterId=' + chapterId + '&orderGoodsId='+record.orderGoodsId
  249. });
  250. }
  251. },
  252. /**
  253. * @param {Object} exam_id
  254. * 获取试卷可以做的次数
  255. */
  256. getExamDetail(exam_id) {
  257. return new Promise(resolve => {
  258. this.$api.getExamDetail(exam_id).then(res => {
  259. resolve(res.data.data.answerNum);
  260. });
  261. });
  262. },
  263. /**
  264. * 查询试卷历史做题次数(题库的)
  265. */
  266. examRecordCount(examId,goodsId) {
  267. return new Promise(resolve => {
  268. this.$api
  269. .examRecordCount({
  270. examId: examId,
  271. goodsId: goodsId
  272. })
  273. .then(res => {
  274. resolve(res.data.data);
  275. });
  276. });
  277. },
  278. /**
  279. * 获取试卷已做的次数(视频课程的)
  280. */
  281. bankRecordDoNum(record) {
  282. return new Promise((resolve) => {
  283. this.$api.bankRecordDoNum({
  284. goodsId: record.goodsId,
  285. gradeId: record.gradeId,
  286. chapterId: record.chapterId || 0,
  287. courseId: record.courseId,
  288. moduleId: record.moduleId || 0,
  289. examId: record.examId,
  290. })
  291. .then((res) => {
  292. resolve(res.data.data)
  293. });
  294. });
  295. },
  296. getDetail(id) {
  297. return new Promise(resolve => {
  298. this.$api.goodsDetail(id).then(res => {
  299. this.goodsData = res.data.data;
  300. resolve();
  301. });
  302. });
  303. },
  304. testClick(item) {
  305. if (item === 3) {
  306. this.index = 0;
  307. this.activeIndex = 0;
  308. this.param.goodsId = '';
  309. this.param.pageNum = 1;
  310. this.getExamRecordList();
  311. } else {
  312. this.index = 0;
  313. this.activeIndex = item.goodsId;
  314. this.param.goodsId = item.goodsId;
  315. this.param.pageNum = 1;
  316. this.getExamRecordList();
  317. }
  318. },
  319. paperClick(item) {
  320. if (item === 3) {
  321. this.index = 0;
  322. this.typeIndex = 0;
  323. this.param.paperId = '';
  324. this.param.pageNum = 1;
  325. this.getExamRecordList();
  326. } else {
  327. this.index = 0;
  328. this.typeIndex = item.paperId;
  329. this.param.paperId = item.paperId;
  330. this.param.pageNum = 1;
  331. this.getExamRecordList();
  332. }
  333. },
  334. tab(index) {
  335. console.log(index,this.index)
  336. if(this.index == index) {
  337. this.index = 0;
  338. return;
  339. }
  340. this.index = index;
  341. console.log(this.index);
  342. },
  343. examaperList() {
  344. this.$api.examaperList({}).then(res => {
  345. this.list1 = res.data.rows;
  346. });
  347. },
  348. listGoodsUserQuestion() {
  349. this.$api.listGoodsUserQuestion({}).then(res => {
  350. this.list = res.data.rows;
  351. });
  352. }
  353. }
  354. };
  355. </script>
  356. <style>
  357. page {
  358. background: #eaeef1;
  359. }
  360. </style>
  361. <style lang="scss" scope>
  362. .animals{
  363. transition: all 0.3s;
  364. transform: rotate(180deg);
  365. }
  366. .tabs {
  367. position: fixed;
  368. left: 0;
  369. width: 100%;
  370. display: flex;
  371. z-index: 10;
  372. .tab {
  373. flex: 1;
  374. height: 80rpx;
  375. text-align: center;
  376. line-height: 80rpx;
  377. background: #ffffff;
  378. font-size: 32rpx;
  379. color: #999999;
  380. &.active {
  381. color: #333333;
  382. .icon{
  383. transform: rotate(180deg);
  384. }
  385. }
  386. }
  387. }
  388. .record {
  389. margin-top: 80rpx;
  390. padding: 16rpx 8rpx;
  391. display: flex;
  392. flex-wrap: wrap;
  393. .item {
  394. margin-bottom: 16rpx;
  395. width:359rpx;
  396. background: #ffffff;
  397. border-radius: 16rpx;
  398. padding: 65rpx 20rpx 22rpx;
  399. position: relative;
  400. overflow: hidden;
  401. &:nth-of-type(2n) {
  402. margin-left:16rpx;
  403. }
  404. .note {
  405. color: #fff;
  406. position: absolute;
  407. left: 0;
  408. top: 0;
  409. // width: 112rpx;
  410. padding: 0rpx 10rpx;
  411. height: 40rpx;
  412. text-align: center;
  413. line-height: 40rpx;
  414. background: linear-gradient(180deg, #4facfe, #007aff);
  415. border-radius: 16rpx 0px 16rpx 0rpx;
  416. }
  417. .title {
  418. font-size: 32rpx;
  419. color: #333333;
  420. font-weight: bold;
  421. }
  422. .desc {
  423. margin-top: 26rpx;
  424. view {
  425. margin: 16rpx 0;
  426. image {
  427. width: 23rpx;
  428. height: 24rpx;
  429. }
  430. text {
  431. margin-left: 15rpx;
  432. font-size: 24rpx;
  433. color: #999999;
  434. line-height: 36rpx;
  435. }
  436. }
  437. }
  438. .btns {
  439. margin-top: 26rpx;
  440. display: flex;
  441. justify-content: space-around;
  442. flex-wrap: wrap;
  443. .btn {
  444. margin:5rpx 0;
  445. width:150rpx;
  446. height: 48rpx;
  447. line-height: 48rpx;
  448. text-align: center;
  449. color: #007aff;
  450. background: #ffffff;
  451. border: 1rpx solid #007aff;
  452. border-radius: 16rpx;
  453. }
  454. }
  455. }
  456. }
  457. .modal {
  458. bottom:0;
  459. z-index: 199999999;
  460. position: fixed;
  461. left: 0;
  462. width: 100%;
  463. .content {
  464. height:80%;
  465. overflow: hidden;
  466. position: relative;
  467. z-index: 10;
  468. background: #fff;
  469. padding: 8rpx 12rpx 20rpx;
  470. display: flex;
  471. flex-wrap: wrap;
  472. .top {
  473. margin: 0 auto;
  474. width: 726rpx;
  475. height: 80rpx;
  476. background: #f5f5f5;
  477. color: #666666;
  478. border-radius: 16rpx;
  479. text-align: center;
  480. line-height: 80rpx;
  481. font-size: 32rpx;
  482. }
  483. .list {
  484. width:100%;
  485. margin-top: 16rpx;
  486. display: flex;
  487. flex-wrap: wrap;
  488. justify-content: space-between;
  489. .item {
  490. padding: 25rpx 20rpx;
  491. width: 49%;
  492. background: #f5f5f5;
  493. border-radius: 16rpx;
  494. font-size: 32rpx;
  495. color: #666666;
  496. margin: 8rpx 0;
  497. }
  498. }
  499. }
  500. .modal_wrap {
  501. position: absolute;
  502. left: 0;
  503. width: 100%;
  504. top: 0;
  505. height: 100%;
  506. background: rgba(0, 0, 0, 0.3);
  507. }
  508. }
  509. .activesty {
  510. background: #007aff !important;
  511. color: #fff !important;
  512. }
  513. </style>