question_record.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  1. <template>
  2. <view>
  3. <view class="tabs">
  4. <view class="tab" :class="{ active: index == 1 }" data-index="1" @click="tab">
  5. 全部题库记录
  6. <u-icon class="icon" :class="index ==1? 'animals':''" name="arrow-down"></u-icon>
  7. </view>
  8. <view class="tab" :class="{ active: index == 2 }" data-index="2" @click="tab">
  9. 全部试卷类型
  10. <u-icon class="icon" :class="index ==2? 'animals':''" name="arrow-down"></u-icon>
  11. </view>
  12. </view>
  13. <view class="record">
  14. <view class="item" v-for="(record,index) in recordList" :key="index">
  15. <view class="note">{{ record.paperName }}</view>
  16. <view class="title">{{ record.examName }}</view>
  17. <view class="desc">
  18. <view>
  19. <image src="/static/icon/wk_icon2.png"></image>
  20. <text>{{ $method.timestampToTime(record.updateTime, false) }}</text>
  21. </view>
  22. <view>
  23. <image src="/static/icon/wk_icon2.png"></image>
  24. <text>总共 {{ record.totalQuestionNum }} 题 做对 {{ record.rightQuestionNum }} 题</text>
  25. </view>
  26. </view>
  27. <view class="btns">
  28. <view class="btn" v-if="record.status == 1" @click="doRepeat(record.examId, record.goodsId, record.moduleExamId, record.chapterExamId,index)">重做</view>
  29. <navigator
  30. :url="
  31. '/pages2/bank/questionBankExplain?id=' +
  32. record.examId +
  33. '&goodsid=' +
  34. record.goodsId +
  35. '&moduleId=' +
  36. record.moduleExamId +
  37. '&chapterId=' +
  38. record.chapterExamId +
  39. ''
  40. "
  41. >
  42. <view class="btn" v-if="record.status == 1">解析</view>
  43. </navigator>
  44. <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>
  45. <view class="btn continue" @click="doContinue(record,index)" v-if="record.status == 0 && record.historyExamJson">继续答题</view>
  46. </view>
  47. </view>
  48. </view>
  49. <view class="modal" v-if="index == 1">
  50. <view class="content">
  51. <view class="top" :class="activeIndex === 0 ? 'activesty' : ''" @click="testClick(3)">全部题库记录</view>
  52. <view class="list">
  53. <view class="item" :class="activeIndex == listItem.goodsId ? 'activesty' : ''" v-for="(listItem,listIndex) in list" :key="listIndex" @click="testClick(listItem)">
  54. {{ listItem.goodsName }}
  55. </view>
  56. </view>
  57. </view>
  58. <view class="modal_wrap" @click="index = 0"></view>
  59. </view>
  60. <view class="modal" v-if="index == 2">
  61. <view class="content">
  62. <view class="top" :class="typeIndex === 0 ? 'activesty' : ''" @click="paperClick(3)">全部试卷类型</view>
  63. <view class="list">
  64. <view class="item" :class="typeIndex == listItem.paperId ? 'activesty' : ''" v-for="(listItem,listIndex) in list1" :key="listIndex" @click="paperClick(listItem)">{{ listItem.paperName }}</view>
  65. </view>
  66. </view>
  67. <view class="modal_wrap" @click="index = 0"></view>
  68. </view>
  69. </view>
  70. </template>
  71. <script>
  72. export default {
  73. data() {
  74. return {
  75. index: 0,
  76. list: [],
  77. list1: [],
  78. recordList: [],
  79. goodsData: {},
  80. param: {
  81. pageNum: 1,
  82. pageSize: 10
  83. },
  84. isRepeat:false,
  85. total: 0,
  86. activeIndex: 0,
  87. typeIndex:0,
  88. itemIndex:''
  89. };
  90. },
  91. onLoad(option) {
  92. this.listGoodsUserQuestion();
  93. this.examaperList();
  94. this.getExamRecordList();
  95. },
  96. onPullDownRefresh() {
  97. let that = this;
  98. this.param = {
  99. pageNum: 1,
  100. pageSize: 10
  101. };
  102. this.getExamRecordList();
  103. setTimeout(function() {
  104. uni.stopPullDownRefresh();
  105. }, 500);
  106. },
  107. onReachBottom() {
  108. if (this.recordList.length < this.total) {
  109. this.param.pageNum++;
  110. this.getExamRecordList();
  111. }
  112. },
  113. onShow() {
  114. if(this.isRepeat) {
  115. this.addRecord();
  116. } else {
  117. if(this.itemIndex !== '') {
  118. this.refreshByIndex();
  119. }
  120. }
  121. },
  122. methods: {
  123. addRecord() {
  124. this.$api.examRecordList({
  125. pageNum: 1,
  126. pageSize: 1
  127. }).then(res => {
  128. this.recordList.unshift(res.data.rows[0])
  129. });
  130. this.isRepeat = false;
  131. },
  132. refreshByIndex() {
  133. this.$api.examRecordList({
  134. pageNum: this.itemIndex+1,
  135. pageSize: 1
  136. }).then(res => {
  137. this.$set(this.recordList,this.itemIndex,res.data.rows[0])
  138. this.itemIndex = ''
  139. });
  140. },
  141. getExamRecordList() {
  142. if (this.param.pageNum == 1) {
  143. this.recordList = [];
  144. }
  145. this.$api.examRecordList(this.param).then(res => {
  146. this.recordList.push.apply(this.recordList, res.data.rows);
  147. this.total = res.data.total;
  148. });
  149. },
  150. /**
  151. * 继续做题
  152. */
  153. doContinue(record,index) {
  154. this.itemIndex = index;
  155. this.isRepeat = false;
  156. uni.navigateTo({
  157. url:'/pages2/bank/questionBankContinue?recordId=' +
  158. record.recordId +
  159. '&id=' +
  160. record.examId +
  161. '&goodsid=' +
  162. record.goodsId +
  163. '&moduleId=' +
  164. record.moduleExamId +
  165. '&chapterId=' +
  166. record.chapterExamId
  167. })
  168. },
  169. /**
  170. * 去做题
  171. */
  172. async doRepeat(id, goodsId, moduleId = 0, chapterId = 0,index) {
  173. // await this.getDetail(goodsId);
  174. this.itemIndex = '';
  175. this.isRepeat = true;
  176. let count = await this.examRecordCount(id,goodsId);
  177. let answerNum = await this.getExamDetail(id);
  178. //超过答题次数
  179. if (answerNum > 0 && count >= answerNum) {
  180. this.$u.toast('该试卷只能答题' + answerNum + '次!');
  181. return;
  182. }
  183. uni.navigateTo({
  184. url: '/pages2/bank/questionBank?id=' + id + '&goodsid=' + goodsId + '&moduleId=' + moduleId + '&chapterId=' + chapterId + ''
  185. });
  186. },
  187. /**
  188. * @param {Object} exam_id
  189. * 获取试卷可以做的次数
  190. */
  191. getExamDetail(exam_id) {
  192. return new Promise(resolve => {
  193. this.$api.getExamDetail(exam_id).then(res => {
  194. resolve(res.data.data.answerNum);
  195. });
  196. });
  197. },
  198. /**
  199. * 查询试卷历史做题次数
  200. */
  201. examRecordCount(examId,goodsId) {
  202. return new Promise(resolve => {
  203. this.$api
  204. .examRecordCount({
  205. examId: examId,
  206. goodsId: goodsId
  207. })
  208. .then(res => {
  209. resolve(res.data.data);
  210. });
  211. });
  212. },
  213. getDetail(id) {
  214. return new Promise(resolve => {
  215. this.$api.goodsDetail(id).then(res => {
  216. this.goodsData = res.data.data;
  217. resolve();
  218. });
  219. });
  220. },
  221. testClick(item) {
  222. if (item === 3) {
  223. this.index = 0;
  224. this.activeIndex = 0;
  225. this.param.goodsId = '';
  226. this.param.pageNum = 1;
  227. this.getExamRecordList();
  228. } else {
  229. this.index = 0;
  230. this.activeIndex = item.goodsId;
  231. this.param.goodsId = item.goodsId;
  232. this.param.pageNum = 1;
  233. this.getExamRecordList();
  234. }
  235. },
  236. paperClick(item) {
  237. if (item === 3) {
  238. this.index = 0;
  239. this.typeIndex = 0;
  240. this.param.paperId = '';
  241. this.param.pageNum = 1;
  242. this.getExamRecordList();
  243. } else {
  244. this.index = 0;
  245. this.typeIndex = item.paperId;
  246. this.param.paperId = item.paperId;
  247. this.param.pageNum = 1;
  248. this.getExamRecordList();
  249. }
  250. },
  251. tab(e) {
  252. this.index = e.currentTarget.dataset.index;
  253. console.log(this.index);
  254. },
  255. examaperList() {
  256. this.$api.examaperList({}).then(res => {
  257. this.list1 = res.data.rows;
  258. });
  259. },
  260. listGoodsUserQuestion() {
  261. this.$api.listGoodsUserQuestion({}).then(res => {
  262. this.list = res.data.rows;
  263. });
  264. }
  265. }
  266. };
  267. </script>
  268. <style>
  269. page {
  270. background: #eaeef1;
  271. }
  272. </style>
  273. <style lang="scss" scope>
  274. .animals{
  275. transition: all 0.3s;
  276. transform: rotate(180deg);
  277. }
  278. .tabs {
  279. position: fixed;
  280. left: 0;
  281. width: 100%;
  282. top: 0;
  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>