question_record.vue 11 KB

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