question_detail.vue 10 KB

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