question_detail.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. <template>
  2. <view>
  3. <nav-bar title="进入刷题"></nav-bar>
  4. <view class="top">
  5. <navigator hover-class="none" :url="'/pages2/bank/question_statistics?orderGoodsId='+orderGoodsId+'&id=' + id">
  6. <view class="left">
  7. <view class="title">
  8. 做题统计
  9. <u-icon name="arrow-right"></u-icon>
  10. </view>
  11. <view class="progress">
  12. <view class="item-left">
  13. <view class="desc"><text>总进度</text></view>
  14. <view class="percent">
  15. {{
  16. goodsCount.totalNum > 0
  17. ? ((goodsCount.doNum / goodsCount.totalNum) * 100).toFixed((goodsCount.doNum / goodsCount.totalNum) * 100 == 100 ? 0 : 1)
  18. : 0
  19. }}
  20. <text class="per">%</text>
  21. </view>
  22. </view>
  23. <view class="item-right">
  24. <view class="up">
  25. <text class="orange">已答</text>
  26. <text>/未答</text>
  27. </view>
  28. <view class="down">
  29. <text class="orange">{{ goodsCount.doNum }}</text>
  30. <text>/{{ goodsCount.totalNum - goodsCount.doNum }}</text>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. </navigator>
  36. <navigator hover-class="none" :url="'/pages2/bank/wrongById?orderGoodsId='+orderGoodsId+'&goodsid=' + id">
  37. <view class="right">
  38. <view class="title">
  39. 错题集
  40. <u-icon name="arrow-right"></u-icon>
  41. </view>
  42. <view class="number">{{ goodsCount.wrongNum || '0' }}</view>
  43. </view>
  44. </navigator>
  45. <navigator hover-class="none" :url="'/pages2/bank/collectById?orderGoodsId='+orderGoodsId+'&goodsid=' + id">
  46. <view class="right">
  47. <view class="title">
  48. 收藏集
  49. <u-icon name="arrow-right"></u-icon>
  50. </view>
  51. <view class="number">{{ goodsCount.collectNum || '0' }}</view>
  52. </view>
  53. </navigator>
  54. </view>
  55. <view class="title-list">
  56. <view class="content">
  57. <view class="list" v-for="(item1, index1) in bankList" :key="index1">
  58. <template v-if="item1.type == 1">
  59. <view class="moduleItem" @click="clickModule(item1.majorId, index1)">
  60. <view class="courseName">{{ item1.name }}</view>
  61. <view>
  62. <image src="/static/icon/up.png" class="icon_up" v-if="!item1.showList"></image>
  63. <image src="/static/icon/down.png" class="icon_up" v-if="item1.showList"></image>
  64. </view>
  65. </view>
  66. <template v-if="item1.showList">
  67. <view v-for="(item2, index2) in item1.list" :key="index2">
  68. <view class="section" @click="changeItem(index1, item2.chapterExamId, item1.type, index2,item1.majorId)">
  69. <!-- <image src="/static/icon/up1.png" class="icon_up" v-if="!item2.showList"></image>
  70. <image src="/static/icon/down1.png" class="icon_up" v-if="item2.showList"></image> -->
  71. <u-icon name="arrow-up" color="#999" size="24" v-if="!item2.showList"></u-icon>
  72. <u-icon name="arrow-down" color="#999" size="24" v-if="item2.showList"></u-icon>
  73. <text style="margin-left:14rpx;">{{ item2.name }}</text>
  74. </view>
  75. <view v-if="item2.showList">
  76. <view class="article active" style="margin-left:62rpx;" v-for="(article, index3) in item2.list" :key="index3">
  77. <view class="flex_auto">{{ article.examName }}</view>
  78. <view class="btn" @click="toDo(article.examId, goodsData.goodsId, item1.majorId, item2.chapterExamId)" v-if="article.recordStatus == -1">做题</view>
  79. <view class="btn" @click="continueDo(article.recordId,article.examId, goodsData.goodsId, item2.chapterExamId, item1.majorId)" v-if="article.recordStatus == 0 && article.doType == 1">继续</view>
  80. <view class="btn" :class="{disabled:(article.answerNum > 0 && article.doNum >= article.answerNum)}" @click="doRepeat(article.recordId,article.examId, goodsData.goodsId, item2.chapterExamId, item1.majorId)" v-if="article.recordStatus == 1 || (article.recordStatus == 0 && article.doType == 2)">重做</view>
  81. </view>
  82. </view>
  83. <u-line v-if="item1.length > 1"></u-line>
  84. </view>
  85. </template>
  86. </template>
  87. <template v-if="item1.type == 2">
  88. <view class="section" @click="changeItem(index1, item1.majorId, item1.type,'',0)">
  89. <!-- <image src="/static/icon/up1.png" class="icon_up" v-if="!item1.showList"></image>
  90. <image src="/static/icon/down1.png" class="icon_up" v-if="item1.showList"></image> -->
  91. <u-icon name="arrow-up" color="#999" size="24" v-if="!item1.showList"></u-icon>
  92. <u-icon name="arrow-down" color="#999" size="24" v-if="item1.showList"></u-icon>
  93. <text style="margin-left:14rpx;">{{ item1.name }}</text>
  94. </view>
  95. <view v-if="item1.showList">
  96. <view class="article active" style="margin-left:64rpx;" v-for="(article, index2) in item1.list" :key="index2">
  97. <view class="flex_auto">{{ article.examName }}</view>
  98. <view class="btn" @click="toDo(article.examId, goodsData.goodsId, 0, item1.majorId)" v-if="article.recordStatus == -1">做题</view>
  99. <view class="btn" @click="continueDo(article.recordId,article.examId, goodsData.goodsId, 0, item1.majorId)" v-if="article.recordStatus == 0 && article.doType == 1">继续</view>
  100. <view class="btn" :class="{disabled:(article.answerNum > 0 && article.doNum >= article.answerNum)}" @click="doRepeat(article.recordId,article.examId, goodsData.goodsId, item1.majorId,0)" v-if="article.recordStatus == 1 || (article.recordStatus == 0 && article.doType == 2)">重做</view>
  101. </view>
  102. </view>
  103. </template>
  104. <template v-if="item1.type == 3">
  105. <view class="article active">
  106. <view class="flex_auto">{{ item1.name }}</view>
  107. <view class="btn" @click="toDo(item1.majorId, goodsData.goodsId, 0, 0)" v-if="item1.recordStatus == -1">做题</view>
  108. <view class="btn" @click="continueDo(item1.recordId,item1.majorId, goodsData.goodsId, 0, 0)" v-if="item1.recordStatus == 0 && item1.doType == 1">继续</view>
  109. <view class="btn" :class="{disabled:(item1.answerNum > 0 && item1.doNum >= item1.answerNum)}" @click="doRepeat(item1.recordId,item1.majorId, goodsData.goodsId, 0, 0)" v-if="item1.recordStatus == 1 || (item1.recordStatus == 0 && item1.doType == 2)">重做</view>
  110. </view>
  111. </template>
  112. </view>
  113. </view>
  114. </view>
  115. </view>
  116. </template>
  117. <script>
  118. import { mapGetters } from 'vuex';
  119. export default {
  120. data() {
  121. return {
  122. goodsData: {},
  123. bankList: [],
  124. id: '',
  125. goodsCount: {
  126. totalNum: 0
  127. },
  128. orderGoodsId:'',
  129. firstEnter:true,
  130. };
  131. },
  132. onUnload() {
  133. clearInterval(this.timer)
  134. this.$api.lockDelLock({
  135. action:'bank'
  136. }).then(res => {
  137. })
  138. },
  139. computed: { ...mapGetters(['userInfo']) },
  140. onLoad(option) {
  141. this.orderGoodsId = option.orderGoodsId
  142. this.id = option.id;
  143. this.getDetail();
  144. this.getLock()
  145. this.timer = setInterval(this.getLock,10000)
  146. // this.goodsBankList();
  147. // this.getCollectNum();
  148. // this.getWrongNum()
  149. },
  150. onShow() {
  151. this.goodsBankQuestionNum();
  152. this.goodsBank();
  153. },
  154. methods: {
  155. getLock() {
  156. this.$api.lockLockAction({
  157. action:'bank'
  158. }).then(res => {
  159. })
  160. },
  161. // 新增用户视频学习日志
  162. studyLog(goodsId, courseId, moduleId, chapterId, examId) {
  163. this.$http({
  164. url: '/user/study/log',
  165. method: 'post',
  166. data: {
  167. goodsId: goodsId,
  168. courseId: courseId,
  169. moduleId: moduleId || 0,
  170. chapterId: chapterId || 0,
  171. sectionId: examId || 0,
  172. fromPlat: 1, //来源平台 1小程序 2PC网站
  173. goodsType: 2, // 商品类型 1视频2题库 3补考 4前培 5虚拟赠送题库 6直播
  174. orderGoodsId: this.orderGoodsId,
  175. }
  176. }).then((res) => {
  177. console.log('题库的用户学习日志:', res)
  178. })
  179. },
  180. /**
  181. * 继续做题
  182. */
  183. continueDo(recordId,examId,goodsId,chapterId = 0,moduleId = 0) {
  184. // examId-试卷id,chapterId =>chapterExamId-章卷ID, moduleId =>majorId-主ID/模块id
  185. uni.navigateTo({
  186. url:'/pages2/bank/questionBankContinue?orderGoodsId='+this.orderGoodsId+'&recordId=' +recordId +'&id=' +examId +'&goodsid=' +goodsId +'&chapterId='+chapterId+'&moduleId='+moduleId
  187. })
  188. this.studyLog(goodsId, 0, moduleId, chapterId, examId)
  189. },
  190. /**
  191. * 重做
  192. * @param {Object} recordId
  193. * @param {Object} examId
  194. * @param {Object} goodsId
  195. * @param {Object} chapterExamId
  196. */
  197. async doRepeat(recordId,examId,goodsId,chapterExamId=0,moduleId=0) {
  198. let count = await this.examRecordCount(examId);
  199. let answerNum = await this.getExamDetail(examId);
  200. //超过答题次数
  201. if (answerNum > 0 && count >= answerNum) {
  202. this.$u.toast('该试卷只能答题' + answerNum + '次!');
  203. return;
  204. }
  205. uni.showModal({
  206. title: '提示',
  207. content: '是否清空答案重做?',
  208. cancelText:'查看上次',
  209. cancelColor:'',
  210. confirmText:'重做',
  211. confirmColor:'',
  212. success: (res) => {
  213. if (res.confirm) {
  214. uni.navigateTo({
  215. url:'/pages2/bank/questionBank?orderGoodsId='+this.orderGoodsId+'&id=' +examId +'&goodsid=' +goodsId +'&moduleId='+moduleId+'&chapterId=' +chapterExamId
  216. })
  217. } else if (res.cancel) {
  218. uni.navigateTo({
  219. url:'/pages2/bank/questionBankAllExplain?id=' + examId +
  220. '&goodsid=' + goodsId +
  221. '&moduleId=' + moduleId +
  222. '&chapterId=' + chapterExamId +
  223. '&recordId='+ recordId+
  224. '&orderGoodsId='+this.orderGoodsId
  225. })
  226. console.log('查看上次答题');
  227. }
  228. }
  229. });
  230. this.studyLog(goodsId, 0, moduleId, chapterExamId, examId)
  231. },
  232. /**
  233. * 获取课程目录
  234. */
  235. goodsBank() {
  236. this.$api.goodsBank({
  237. orderGoodsId:this.orderGoodsId,
  238. goodsId: this.id
  239. }).then(res => {
  240. this.bankList = res.data.data;
  241. console.log('---banklist:', this.bankList)
  242. console.log('')
  243. if(this.firstEnter) {
  244. this.showAllCharpter();
  245. this.firstEnter = false;
  246. }
  247. });
  248. },
  249. /**
  250. * 展示第一个章下的节内容
  251. */
  252. showAllCharpter() {
  253. for(let i = 0; i < this.bankList.length; i++) {
  254. if(this.bankList[i].type == 1) { //第一个是模块直接展开,再展开章下面的节
  255. this.$api
  256. .goodsChapterList({
  257. moduleExamId: this.bankList[i].majorId
  258. })
  259. .then(res => {
  260. this.$set(this.bankList[i], 'showList', true);
  261. this.$set(this.bankList[i], 'list', res.data.data);
  262. if(this.bankList[i].list.length) {
  263. this.changeItem(i,this.bankList[i].list[0].chapterExamId,this.bankList[i].type,0,this.bankList[i].majorId)
  264. }
  265. });
  266. break;
  267. } else if(this.bankList[i].type == 2) { //第一个章展开下面的节
  268. this.changeItem(i,this.bankList[i].majorId,this.bankList[i].type,'',0)
  269. break;
  270. }
  271. }
  272. },
  273. getDetail() {
  274. this.$api.commonGoodsDetail(this.id).then(res => {
  275. console.log(res);
  276. this.goodsData = res.data.data;
  277. });
  278. },
  279. /**
  280. * 去做题
  281. */
  282. async toDo(id, goodsId, moduleId = 0, chapterId = 0) {
  283. console.log(id,goodsId,moduleId,chapterId)
  284. let count = await this.examRecordCount(id);
  285. let answerNum = await this.getExamDetail(id);
  286. //超过答题次数
  287. if (answerNum > 0 && count >= answerNum) {
  288. this.$u.toast('该试卷只能答题' + answerNum + '次!');
  289. return;
  290. }
  291. uni.navigateTo({
  292. url: '/pages2/bank/questionBank?orderGoodsId='+this.orderGoodsId+'&id=' + id + '&goodsid=' + goodsId + '&moduleId=' + moduleId + '&chapterId=' + chapterId + ''
  293. });
  294. this.studyLog(goodsId, 0, moduleId, chapterId, id)
  295. },
  296. /**
  297. * 查询试卷历史做题次数
  298. */
  299. examRecordCount(examId) {
  300. return new Promise(resolve => {
  301. this.$api
  302. .examRecordCount({
  303. examId: examId,
  304. orderGoodsId: this.orderGoodsId
  305. })
  306. .then(res => {
  307. resolve(res.data.data);
  308. });
  309. });
  310. },
  311. /**
  312. * @param {Object} exam_id
  313. * 获取试卷可以做的次数
  314. */
  315. getExamDetail(exam_id) {
  316. return new Promise(resolve => {
  317. this.$api.getExamDetail(exam_id).then(res => {
  318. resolve(res.data.data.answerNum);
  319. });
  320. });
  321. },
  322. /**
  323. * 获取用户商品统计数据
  324. */
  325. goodsBankQuestionNum() {
  326. this.$api.goodsBankQuestionNum(this.orderGoodsId).then(res => {
  327. this.goodsCount = res.data.data;
  328. });
  329. },
  330. goodsBankList() {
  331. this.$api
  332. .goodsBankList({
  333. goodsId: this.id
  334. })
  335. .then(res => {
  336. console.log(res);
  337. this.bankList = res.data.data;
  338. });
  339. },
  340. getCollectNum() {
  341. this.$api
  342. .goodsCollectExamList({
  343. orderGoodsId: this.orderGoodsId
  344. })
  345. .then(res => {
  346. let total = 0;
  347. res.data.rows.forEach(item => {
  348. total += item.questionNum;
  349. });
  350. this.collectTotal = total;
  351. });
  352. },
  353. getWrongNum() {
  354. this.$api
  355. .wrongRecordList({
  356. orderGoodsId: this.orderGoodsId
  357. })
  358. .then(res => {
  359. let total = 0;
  360. res.data.rows.forEach(item => {
  361. total += item.wrongQuestionNum;
  362. });
  363. this.wrongTotal = total;
  364. });
  365. },
  366. clickModule(id, index) {
  367. if (this.bankList[index].list) {
  368. this.$set(this.bankList[index], 'showList', !this.bankList[index].showList);
  369. return;
  370. }
  371. this.$api
  372. .goodsChapterList({
  373. moduleExamId: id,
  374. orderGoodsId: this.orderGoodsId,
  375. goodsId: this.id
  376. })
  377. .then(res => {
  378. this.$set(this.bankList[index], 'showList', true);
  379. this.$set(this.bankList[index], 'list', res.data.data);
  380. });
  381. },
  382. changeItem(index1, id, type, index2,moduleExamId) {
  383. if (type == 1) {
  384. if (this.bankList[index1].list[index2].list) {
  385. this.$set(this.bankList[index1].list[index2], 'showList', !this.bankList[index1].list[index2].showList);
  386. return;
  387. }
  388. this.$api
  389. .bankExamExamList({
  390. moduleExamId:moduleExamId,
  391. orderGoodsId: this.orderGoodsId,
  392. chapterExamId: id,
  393. goodsId: this.id
  394. })
  395. .then(res => {
  396. let _data = res.data.data
  397. if (_data && _data.length) {
  398. _data.sort((a, b) => a.sort - b.sort)
  399. }
  400. this.$set(this.bankList[index1].list[index2], 'showList', true);
  401. this.$set(this.bankList[index1].list[index2], 'list', _data);
  402. });
  403. } else if (type == 2) {
  404. if (this.bankList[index1].list) {
  405. this.$set(this.bankList[index1], 'showList', !this.bankList[index1].showList);
  406. return;
  407. }
  408. this.$api
  409. .bankExamExamList({
  410. moduleExamId:moduleExamId,
  411. orderGoodsId: this.orderGoodsId,
  412. chapterExamId: id,
  413. goodsId: this.id
  414. })
  415. .then(res => {
  416. let _data = res.data.data
  417. if (_data && _data.length) {
  418. _data.sort((a, b) => a.sort - b.sort)
  419. }
  420. this.$set(this.bankList[index1], 'showList', true);
  421. this.$set(this.bankList[index1], 'list', _data);
  422. });
  423. }
  424. }
  425. }
  426. };
  427. </script>
  428. <style>
  429. page {
  430. background-color: #eaeef1;
  431. }
  432. </style>
  433. <style lang="scss" scope>
  434. .top {
  435. padding: 16rpx 16rpx 0;
  436. display: flex;
  437. justify-content: space-between;
  438. .left {
  439. width: 326rpx;
  440. height: 180rpx;
  441. background: #ffffff;
  442. box-shadow: 0px 0px 16rpx 4rpx rgba(145, 156, 178, 0.1);
  443. border-radius: 16rpx;
  444. background: #fff;
  445. padding: 20rpx;
  446. .title {
  447. font-size: 24rpx;
  448. line-height: 24rpx;
  449. color: #333333;
  450. }
  451. .progress {
  452. margin-top: 10rpx;
  453. display: flex;
  454. .item-left {
  455. flex: 1;
  456. border-right: 1rpx solid #eeeeee;
  457. .desc {
  458. text {
  459. line-height: 24rpx;
  460. font-size: 24rpx;
  461. color: #999999;
  462. }
  463. }
  464. .percent {
  465. margin-top: 10rpx;
  466. line-height: 64rpx;
  467. font-size: 64rpx;
  468. font-weight: bold;
  469. color: #007aff;
  470. }
  471. .per {
  472. font-size: 30rpx;
  473. color: #007aff;
  474. }
  475. }
  476. .item-right {
  477. padding-left: 10rpx;
  478. flex: 1;
  479. text {
  480. line-height: 24rpx;
  481. font-size: 24rpx;
  482. color: #999999;
  483. }
  484. .orange {
  485. line-height: 24rpx;
  486. font-size: 24rpx;
  487. font-weight: bold;
  488. color: #ff9500;
  489. }
  490. .down {
  491. margin-top: 40rpx;
  492. }
  493. }
  494. }
  495. }
  496. .right {
  497. width: 180rpx;
  498. height: 180rpx;
  499. background: #ffffff;
  500. box-shadow: 0px 0px 16rpx 4rpx rgba(145, 156, 178, 0.1);
  501. background: #fff;
  502. padding: 20rpx;
  503. border-radius: 16rpx;
  504. .title {
  505. font-size: 24rpx;
  506. line-height: 24rpx;
  507. color: #333333;
  508. }
  509. .number {
  510. font-weight: bold;
  511. text-align: center;
  512. margin-top: 46rpx;
  513. font-size: 64rpx;
  514. line-height: 64rpx;
  515. color: #007aff;
  516. }
  517. }
  518. }
  519. .courseName {
  520. font-size: 24rpx;
  521. color:#333;
  522. white-space: nowrap;
  523. overflow: hidden;
  524. text-overflow: ellipsis;
  525. }
  526. .moduleItem {
  527. height: 80rpx;
  528. color: #333333;
  529. font-size: 24rpx;
  530. line-height: 80rpx;
  531. font-weight: bold;
  532. display: flex;
  533. justify-content: space-between;
  534. border-bottom: 1rpx solid #eee;
  535. }
  536. .icon_up {
  537. width: 32rpx;
  538. height: 32rpx;
  539. }
  540. .title-list {
  541. background: #eaeef1;
  542. padding: 16rpx 16rpx 124rpx;
  543. .content {
  544. .list {
  545. background: #fff;
  546. margin-bottom: 30rpx;
  547. overflow: hidden;
  548. border-radius: 16rpx;
  549. padding: 10rpx 16rpx;
  550. .module {
  551. font-size: 30rpx;
  552. color: #333333;
  553. .icon {
  554. margin-right: 10rpx;
  555. }
  556. }
  557. .section {
  558. font-size: 24rpx;
  559. font-family: PingFang SC;
  560. font-weight: bold;
  561. color: #333;
  562. white-space: nowrap;
  563. overflow: hidden;
  564. text-overflow: ellipsis;
  565. padding: 20rpx 0;
  566. display: flex;
  567. align-items: center;
  568. border-bottom: 1rpx solid #eee;
  569. }
  570. .article {
  571. height: 80rpx;
  572. display: flex;
  573. align-items: center;
  574. font-size: 30rpx;
  575. color: #666666;
  576. border-bottom: 1rpx solid #eeeeee;
  577. display: flex;
  578. .flex_auto {
  579. flex: 1;
  580. }
  581. &:nth-last-of-type(1) {
  582. border: 0;
  583. }
  584. &.active {
  585. color: #007aff;
  586. .btn {
  587. width: 96rpx;
  588. height: 48rpx;
  589. line-height: 48rpx;
  590. text-align: center;
  591. color: #fff;
  592. font-size: 30rpx;
  593. border-radius: 24rpx;
  594. background: #007aff;
  595. margin-left: 36rpx;
  596. border-radius: 24rpx;
  597. &.disabled {
  598. opacity: 0.6;
  599. }
  600. }
  601. }
  602. }
  603. }
  604. }
  605. }
  606. </style>