question_record.vue 12 KB

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