mock_record.vue 11 KB

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