question_record.vue 11 KB

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