question_detail.vue 14 KB

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