question_record.vue 11 KB

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