question_record.vue 9.7 KB

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