question_record.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  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+'&orderGoodsId='+record.orderGoodsId
  134. })
  135. },
  136. questionReport(record) {
  137. if (record.courseType == 2) {
  138. uni.navigateTo({
  139. url: "/pages2/class/question_report?examId=" + record.examId + '&recordId=' + record.recordId + '&type=' + record.type + '&orderGoodsId='+ record.orderGoodsId,
  140. });
  141. } else {
  142. uni.navigateTo({
  143. url:'/pages2/bank/question_report?goodsId='+record.goodsId+'&chapterId='+record.chapterExamId+'&moduleId='+record.moduleExamId+'&examId='+record.examId+'&id=' + record.recordId+'&orderGoodsId='+record.orderGoodsId
  144. })
  145. }
  146. },
  147. /**
  148. * 更多记录
  149. */
  150. moreRecord(record) {
  151. if (record.courseType == 2) {
  152. uni.navigateTo({
  153. url:'/pages2/bank/question_record_list?goodsId='+record.goodsId+'&chapterId='+record.chapterId+'&moduleId='+record.moduleId
  154. +'&examId='+record.examId+'&recordId=' + record.recordId + '&courseType=' + record.courseType + '&gradeId=' +record.gradeId
  155. + '&courseId=' + record.courseId + '&sectionId=' + record.sectionId
  156. })
  157. } else {
  158. uni.navigateTo({
  159. url:'/pages2/bank/question_record_list?goodsId='+record.goodsId+'&chapterId='+record.chapterExamId+'&moduleId='+record.moduleExamId
  160. +'&examId='+record.examId+'&recordId=' + record.recordId + '&courseType=' + record.courseType
  161. })
  162. }
  163. },
  164. addRecord() {
  165. this.$api.examRecordList({
  166. pageNum: 1,
  167. pageSize: 1
  168. }).then(res => {
  169. this.recordList.unshift(res.data.rows[0])
  170. });
  171. this.isRepeat = false;
  172. },
  173. refreshByIndex() {
  174. this.$api.examRecordGroupList({
  175. pageNum: this.itemIndex+1,
  176. pageSize: 1
  177. }).then(res => {
  178. this.$set(this.recordList,this.itemIndex,res.data.rows[0])
  179. this.itemIndex = ''
  180. });
  181. },
  182. getExamRecordList() {
  183. if (this.param.pageNum == 1) {
  184. this.recordList = [];
  185. }
  186. this.$api.examRecordGroupList(this.param).then(res => {
  187. this.recordList.push.apply(this.recordList, res.data.rows);
  188. this.total = res.data.total;
  189. });
  190. },
  191. /**
  192. * 继续做题
  193. */
  194. doContinue(record,index) {
  195. this.itemIndex = index;
  196. this.isRepeat = false;
  197. uni.navigateTo({
  198. url:'/pages2/bank/questionBankContinue?recordId=' +
  199. record.recordId +
  200. '&id=' +
  201. record.examId +
  202. '&goodsid=' +
  203. record.goodsId +
  204. '&moduleId=' +
  205. record.moduleExamId +
  206. '&chapterId=' +
  207. record.chapterExamId +
  208. '&orderGoodsId=' +
  209. record.orderGoodsId
  210. })
  211. },
  212. /**
  213. * 去做题
  214. */
  215. async doRepeat(goodsId, record) {
  216. // await this.getDetail(goodsId);
  217. this.itemIndex = '';
  218. this.isRepeat = true;
  219. let count = 0
  220. if (record.courseType == 2) {
  221. count = await this.bankRecordDoNum(record)
  222. } else {
  223. count = await this.examRecordCount(record.examId, goodsId);
  224. }
  225. // let count = await this.examRecordCount(record.examId,goodsId);
  226. let answerNum = await this.getExamDetail(record.examId);
  227. //超过答题次数
  228. if (answerNum > 0 && count >= answerNum) {
  229. this.$u.toast('该试卷只能答题' + answerNum + '次!');
  230. return;
  231. }
  232. if (record.courseType == 2) {
  233. const {courseId, gradeId, sectionId, examId, orderGoodsId = 0, type, reportStatus} = record
  234. let moduleId = record.moduleId || 0
  235. let chapterId = record.chapterId || 0
  236. uni.navigateTo({
  237. url:"/pages2/class/questionBank?courseId=" + courseId + "&gradeId=" + gradeId + "&isFromVideo=1&id=" + examId +
  238. "&goodsid=" + goodsId + "&moduleId=" + moduleId + "&chapterId=" + chapterId + "&sectionId=" + sectionId + "&orderGoodsId=" +
  239. orderGoodsId + "&type=" + type+ '&learning=' + reportStatus,
  240. })
  241. } else {
  242. let moduleId = record.moduleExamId || 0
  243. let chapterId = record.chapterExamId || 0
  244. uni.navigateTo({
  245. url: '/pages2/bank/questionBank?id=' + record.examId + '&goodsid=' + goodsId + '&moduleId=' + moduleId + '&chapterId=' + chapterId + '&orderGoodsId='+record.orderGoodsId
  246. });
  247. }
  248. },
  249. /**
  250. * @param {Object} exam_id
  251. * 获取试卷可以做的次数
  252. */
  253. getExamDetail(exam_id) {
  254. return new Promise(resolve => {
  255. this.$api.getExamDetail(exam_id).then(res => {
  256. resolve(res.data.data.answerNum);
  257. });
  258. });
  259. },
  260. /**
  261. * 查询试卷历史做题次数(题库的)
  262. */
  263. examRecordCount(examId,goodsId) {
  264. return new Promise(resolve => {
  265. this.$api
  266. .examRecordCount({
  267. examId: examId,
  268. goodsId: goodsId
  269. })
  270. .then(res => {
  271. resolve(res.data.data);
  272. });
  273. });
  274. },
  275. /**
  276. * 获取试卷已做的次数(视频课程的)
  277. */
  278. bankRecordDoNum(record) {
  279. return new Promise((resolve) => {
  280. this.$api.bankRecordDoNum({
  281. goodsId: record.goodsId,
  282. gradeId: record.gradeId,
  283. chapterId: record.chapterId || 0,
  284. courseId: record.courseId,
  285. moduleId: record.moduleId || 0,
  286. examId: record.examId,
  287. })
  288. .then((res) => {
  289. resolve(res.data.data)
  290. });
  291. });
  292. },
  293. getDetail(id) {
  294. return new Promise(resolve => {
  295. this.$api.goodsDetail(id).then(res => {
  296. this.goodsData = res.data.data;
  297. resolve();
  298. });
  299. });
  300. },
  301. testClick(item) {
  302. if (item === 3) {
  303. this.index = 0;
  304. this.activeIndex = 0;
  305. this.param.goodsId = '';
  306. this.param.pageNum = 1;
  307. this.getExamRecordList();
  308. } else {
  309. this.index = 0;
  310. this.activeIndex = item.goodsId;
  311. this.param.goodsId = item.goodsId;
  312. this.param.pageNum = 1;
  313. this.getExamRecordList();
  314. }
  315. },
  316. paperClick(item) {
  317. if (item === 3) {
  318. this.index = 0;
  319. this.typeIndex = 0;
  320. this.param.paperId = '';
  321. this.param.pageNum = 1;
  322. this.getExamRecordList();
  323. } else {
  324. this.index = 0;
  325. this.typeIndex = item.paperId;
  326. this.param.paperId = item.paperId;
  327. this.param.pageNum = 1;
  328. this.getExamRecordList();
  329. }
  330. },
  331. tab(index) {
  332. console.log(index,this.index)
  333. if(this.index == index) {
  334. this.index = 0;
  335. return;
  336. }
  337. this.index = index;
  338. console.log(this.index);
  339. },
  340. examaperList() {
  341. this.$api.examaperList({}).then(res => {
  342. this.list1 = res.data.rows;
  343. });
  344. },
  345. listGoodsUserQuestion() {
  346. this.$api.listGoodsUserQuestion({}).then(res => {
  347. this.list = res.data.rows;
  348. });
  349. }
  350. }
  351. };
  352. </script>
  353. <style>
  354. page {
  355. background: #eaeef1;
  356. }
  357. </style>
  358. <style lang="scss" scope>
  359. .animals{
  360. transition: all 0.3s;
  361. transform: rotate(180deg);
  362. }
  363. .tabs {
  364. position: fixed;
  365. left: 0;
  366. width: 100%;
  367. display: flex;
  368. z-index: 10;
  369. .tab {
  370. flex: 1;
  371. height: 80rpx;
  372. text-align: center;
  373. line-height: 80rpx;
  374. background: #ffffff;
  375. font-size: 32rpx;
  376. color: #999999;
  377. &.active {
  378. color: #333333;
  379. .icon{
  380. transform: rotate(180deg);
  381. }
  382. }
  383. }
  384. }
  385. .record {
  386. margin-top: 80rpx;
  387. padding: 16rpx 8rpx;
  388. display: flex;
  389. flex-wrap: wrap;
  390. .item {
  391. margin-bottom: 16rpx;
  392. width:359rpx;
  393. background: #ffffff;
  394. border-radius: 16rpx;
  395. padding: 65rpx 20rpx 22rpx;
  396. position: relative;
  397. overflow: hidden;
  398. &:nth-of-type(2n) {
  399. margin-left:16rpx;
  400. }
  401. .note {
  402. color: #fff;
  403. position: absolute;
  404. left: 0;
  405. top: 0;
  406. // width: 112rpx;
  407. padding: 0rpx 10rpx;
  408. height: 40rpx;
  409. text-align: center;
  410. line-height: 40rpx;
  411. background: linear-gradient(180deg, #4facfe, #007aff);
  412. border-radius: 16rpx 0px 16rpx 0rpx;
  413. }
  414. .title {
  415. font-size: 32rpx;
  416. color: #333333;
  417. font-weight: bold;
  418. }
  419. .desc {
  420. margin-top: 26rpx;
  421. view {
  422. margin: 16rpx 0;
  423. image {
  424. width: 23rpx;
  425. height: 24rpx;
  426. }
  427. text {
  428. margin-left: 15rpx;
  429. font-size: 24rpx;
  430. color: #999999;
  431. line-height: 36rpx;
  432. }
  433. }
  434. }
  435. .btns {
  436. margin-top: 26rpx;
  437. display: flex;
  438. justify-content: space-around;
  439. flex-wrap: wrap;
  440. .btn {
  441. margin:5rpx 0;
  442. width:150rpx;
  443. height: 48rpx;
  444. line-height: 48rpx;
  445. text-align: center;
  446. color: #007aff;
  447. background: #ffffff;
  448. border: 1rpx solid #007aff;
  449. border-radius: 16rpx;
  450. }
  451. }
  452. }
  453. }
  454. .modal {
  455. bottom:0;
  456. z-index: 199999999;
  457. position: fixed;
  458. left: 0;
  459. width: 100%;
  460. .content {
  461. height:80%;
  462. overflow: hidden;
  463. position: relative;
  464. z-index: 10;
  465. background: #fff;
  466. padding: 8rpx 12rpx 20rpx;
  467. display: flex;
  468. flex-wrap: wrap;
  469. .top {
  470. margin: 0 auto;
  471. width: 726rpx;
  472. height: 80rpx;
  473. background: #f5f5f5;
  474. color: #666666;
  475. border-radius: 16rpx;
  476. text-align: center;
  477. line-height: 80rpx;
  478. font-size: 32rpx;
  479. }
  480. .list {
  481. width:100%;
  482. margin-top: 16rpx;
  483. display: flex;
  484. flex-wrap: wrap;
  485. justify-content: space-between;
  486. .item {
  487. padding: 25rpx 20rpx;
  488. width: 49%;
  489. background: #f5f5f5;
  490. border-radius: 16rpx;
  491. font-size: 32rpx;
  492. color: #666666;
  493. margin: 8rpx 0;
  494. }
  495. }
  496. }
  497. .modal_wrap {
  498. position: absolute;
  499. left: 0;
  500. width: 100%;
  501. top: 0;
  502. height: 100%;
  503. background: rgba(0, 0, 0, 0.3);
  504. }
  505. }
  506. .activesty {
  507. background: #007aff !important;
  508. color: #fff !important;
  509. }
  510. </style>