question_record.vue 8.6 KB

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