question_detail.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. <template>
  2. <view>
  3. <view class="top">
  4. <navigator :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 :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 :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)">做题</view>
  75. </view>
  76. </view>
  77. <u-line v-if="item1.length > 1"></u-line>
  78. </view>
  79. </template>
  80. </template>
  81. <template v-if="item1.type == 2">
  82. <view class="section" @click="changeItem(index1, item1.majorId, item1.type)">
  83. <!-- <image src="/static/icon/up1.png" class="icon_up" v-if="!item1.showList"></image>
  84. <image src="/static/icon/down1.png" class="icon_up" v-if="item1.showList"></image> -->
  85. <u-icon name="arrow-up" color="#999" size="24" v-if="item1.showList"></u-icon>
  86. <u-icon name="arrow-down" color="#999" size="24" v-if="!item1.showList"></u-icon>
  87. <text style="margin-left:34rpx;">{{ item1.name }}</text>
  88. </view>
  89. <view v-if="item1.showList">
  90. <view class="article active" style="margin-left:64rpx;" v-for="(article, index2) in item1.list" :key="index2">
  91. <view class="flex_auto">{{ item1.name }}</view>
  92. <view class="btn" @click="toDo(article.examId, goodsData.goodsId, 0, item1.majorId)">做题</view>
  93. </view>
  94. </view>
  95. </template>
  96. <template v-if="item1.type == 3">
  97. <view class="article active">
  98. <view class="flex_auto">{{ item1.name }}</view>
  99. <view class="btn" @click="toDo(item1.majorId, goodsData.goodsId, 0, 0)">做题</view>
  100. </view>
  101. </template>
  102. </view>
  103. </view>
  104. </view>
  105. </view>
  106. </template>
  107. <script>
  108. import { mapGetters } from 'vuex';
  109. export default {
  110. data() {
  111. return {
  112. goodsData: {},
  113. bankList: [],
  114. id: '',
  115. goodsCount: {
  116. totalNum: 0
  117. }
  118. };
  119. },
  120. onUnload() {},
  121. computed: { ...mapGetters(['userInfo']) },
  122. onLoad(option) {
  123. this.id = option.id;
  124. this.getDetail();
  125. this.goodsBankList();
  126. // this.getCollectNum();
  127. // this.getWrongNum()
  128. this.goodsBankQuestionNum();
  129. },
  130. onShow() {
  131. this.goodsBankQuestionNum();
  132. },
  133. methods: {
  134. getDetail() {
  135. this.$api.commonGoodsDetail(this.id).then(res => {
  136. console.log(res);
  137. this.goodsData = res.data.data;
  138. });
  139. },
  140. /**
  141. * 去做题
  142. */
  143. async toDo(id, goodsId, moduleId = 0, chapterId = 0) {
  144. console.log(id,goodsId,moduleId,chapterId)
  145. let count = await this.examRecordCount(id);
  146. let answerNum = await this.getExamDetail(id);
  147. //超过答题次数
  148. if (answerNum > 0 && count >= answerNum) {
  149. this.$u.toast('该试卷只能答题' + answerNum + '次!');
  150. return;
  151. }
  152. uni.navigateTo({
  153. url: '/pages2/bank/questionBank?id=' + id + '&goodsid=' + goodsId + '&moduleId=' + moduleId + '&chapterId=' + chapterId + ''
  154. });
  155. },
  156. /**
  157. * 查询试卷历史做题次数
  158. */
  159. examRecordCount(examId) {
  160. return new Promise(resolve => {
  161. this.$api
  162. .examRecordCount({
  163. examId: examId,
  164. goodsId: this.id
  165. })
  166. .then(res => {
  167. resolve(res.data.data);
  168. });
  169. });
  170. },
  171. /**
  172. * @param {Object} exam_id
  173. * 获取试卷可以做的次数
  174. */
  175. getExamDetail(exam_id) {
  176. return new Promise(resolve => {
  177. this.$api.getExamDetail(exam_id).then(res => {
  178. resolve(res.data.data.answerNum);
  179. });
  180. });
  181. },
  182. /**
  183. * 获取用户商品统计数据
  184. */
  185. goodsBankQuestionNum() {
  186. this.$api.goodsBankQuestionNum(this.id).then(res => {
  187. this.goodsCount = res.data.data;
  188. });
  189. },
  190. goodsBankList() {
  191. this.$api
  192. .goodsBankList({
  193. goodsId: this.id
  194. })
  195. .then(res => {
  196. console.log(res);
  197. this.bankList = res.data.data;
  198. });
  199. },
  200. getCollectNum() {
  201. this.$api
  202. .goodsCollectExamList({
  203. goodsId: this.id
  204. })
  205. .then(res => {
  206. let total = 0;
  207. res.data.rows.forEach(item => {
  208. total += item.questionNum;
  209. });
  210. this.collectTotal = total;
  211. });
  212. },
  213. getWrongNum() {
  214. this.$api
  215. .wrongRecordList({
  216. goodsId: this.id
  217. })
  218. .then(res => {
  219. let total = 0;
  220. res.data.rows.forEach(item => {
  221. total += item.wrongQuestionNum;
  222. });
  223. this.wrongTotal = total;
  224. });
  225. },
  226. clickModule(id, index) {
  227. if (this.bankList[index].list) {
  228. this.$set(this.bankList[index], 'showList', !this.bankList[index].showList);
  229. return;
  230. }
  231. this.$api
  232. .goodsChapterList({
  233. moduleExamId: id
  234. })
  235. .then(res => {
  236. this.$set(this.bankList[index], 'showList', true);
  237. this.$set(this.bankList[index], 'list', res.data.data);
  238. });
  239. },
  240. changeItem(index1, id, type, index2) {
  241. if (type == 1) {
  242. console.log();
  243. if (this.bankList[index1].list[index2].list) {
  244. console.log(2);
  245. this.$set(this.bankList[index1].list[index2], 'showList', !this.bankList[index1].list[index2].showList);
  246. return;
  247. }
  248. this.$api
  249. .goodsExamList({
  250. chapterExamId: id
  251. })
  252. .then(res => {
  253. console.log(3);
  254. this.$set(this.bankList[index1].list[index2], 'showList', true);
  255. this.$set(this.bankList[index1].list[index2], 'list', res.data.data);
  256. });
  257. } else if (type == 2) {
  258. if (this.bankList[index1].list) {
  259. this.$set(this.bankList[index1], 'showList', !this.bankList[index1].showList);
  260. return;
  261. }
  262. this.$api
  263. .goodsExamList({
  264. chapterExamId: id
  265. })
  266. .then(res => {
  267. this.$set(this.bankList[index1], 'showList', true);
  268. this.$set(this.bankList[index1], 'list', res.data.data);
  269. });
  270. }
  271. }
  272. }
  273. };
  274. </script>
  275. <style>
  276. page {
  277. background-color: #eaeef1;
  278. }
  279. </style>
  280. <style lang="scss" scope>
  281. .top {
  282. padding: 16rpx 16rpx 0;
  283. display: flex;
  284. justify-content: space-between;
  285. .left {
  286. width: 326rpx;
  287. height: 180rpx;
  288. background: #ffffff;
  289. box-shadow: 0px 0px 16rpx 4rpx rgba(145, 156, 178, 0.1);
  290. border-radius: 16rpx;
  291. background: #fff;
  292. padding: 20rpx;
  293. .title {
  294. font-size: 24rpx;
  295. line-height: 24rpx;
  296. color: #333333;
  297. }
  298. .progress {
  299. margin-top: 10rpx;
  300. display: flex;
  301. .item-left {
  302. flex: 1;
  303. border-right: 1rpx solid #eeeeee;
  304. .desc {
  305. text {
  306. line-height: 24rpx;
  307. font-size: 24rpx;
  308. color: #999999;
  309. }
  310. }
  311. .percent {
  312. margin-top: 10rpx;
  313. line-height: 64rpx;
  314. font-size: 64rpx;
  315. font-weight: bold;
  316. color: #007aff;
  317. }
  318. .per {
  319. font-size: 30rpx;
  320. color: #007aff;
  321. }
  322. }
  323. .item-right {
  324. padding-left: 10rpx;
  325. flex: 1;
  326. text {
  327. line-height: 24rpx;
  328. font-size: 24rpx;
  329. color: #999999;
  330. }
  331. .orange {
  332. line-height: 24rpx;
  333. font-size: 24rpx;
  334. font-weight: bold;
  335. color: #ff9500;
  336. }
  337. .down {
  338. margin-top: 40rpx;
  339. }
  340. }
  341. }
  342. }
  343. .right {
  344. width: 180rpx;
  345. height: 180rpx;
  346. background: #ffffff;
  347. box-shadow: 0px 0px 16rpx 4rpx rgba(145, 156, 178, 0.1);
  348. background: #fff;
  349. padding: 20rpx;
  350. border-radius: 16rpx;
  351. .title {
  352. font-size: 24rpx;
  353. line-height: 24rpx;
  354. color: #333333;
  355. }
  356. .number {
  357. font-weight: bold;
  358. text-align: center;
  359. margin-top: 46rpx;
  360. font-size: 64rpx;
  361. line-height: 64rpx;
  362. color: #007aff;
  363. }
  364. }
  365. }
  366. .courseName {
  367. font-size: 24rpx;
  368. color:#666;
  369. white-space: nowrap;
  370. overflow: hidden;
  371. text-overflow: ellipsis;
  372. }
  373. .moduleItem {
  374. height: 80rpx;
  375. color: #333333;
  376. font-size: 32rpx;
  377. line-height: 80rpx;
  378. font-weight: bold;
  379. display: flex;
  380. justify-content: space-between;
  381. }
  382. .icon_up {
  383. width: 32rpx;
  384. height: 32rpx;
  385. }
  386. .title-list {
  387. background: #eaeef1;
  388. padding: 16rpx 16rpx 124rpx;
  389. .content {
  390. .list {
  391. background: #fff;
  392. margin-bottom: 30rpx;
  393. overflow: hidden;
  394. border-radius: 16rpx;
  395. padding: 10rpx 16rpx;
  396. .module {
  397. font-size: 30rpx;
  398. color: #333333;
  399. .icon {
  400. margin-right: 10rpx;
  401. }
  402. }
  403. .section {
  404. font-size: 24rpx;
  405. font-family: PingFang SC;
  406. font-weight: bold;
  407. color: #666;
  408. white-space: nowrap;
  409. overflow: hidden;
  410. text-overflow: ellipsis;
  411. margin: 20rpx 0;
  412. display: flex;
  413. align-items: center;
  414. }
  415. .article {
  416. height: 80rpx;
  417. display: flex;
  418. align-items: center;
  419. font-size: 24rpx;
  420. color: #666666;
  421. border-bottom: 1rpx solid #eeeeee;
  422. display: flex;
  423. .flex_auto {
  424. flex: 1;
  425. }
  426. &:nth-last-of-type(1) {
  427. border: 0;
  428. }
  429. &.active {
  430. color: #007aff;
  431. .btn {
  432. width: 96rpx;
  433. height: 48rpx;
  434. line-height: 48rpx;
  435. text-align: center;
  436. color: #fff;
  437. font-size: 30rpx;
  438. border-radius: 24rpx;
  439. background: #007aff;
  440. margin-left: 36rpx;
  441. border-radius: 24rpx;
  442. }
  443. }
  444. }
  445. }
  446. }
  447. }
  448. </style>