question_detail.vue 14 KB

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