index.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <template>
  2. <div class="collection-box">
  3. <div>
  4. <img class="collectionHeader" mode="widthFix" :src="collectionHeader" />
  5. </div>
  6. <div class="choose">
  7. <div class="choose-img" @click="goExercise('wrong')">
  8. <span class="choose-text1"> 做错题 </span>
  9. <span class="choose-text2"> 共 {{ wrongListCount }} 题 </span>
  10. <image mode="widthFix" class="bg" :src="wrongBg" />
  11. <image mode="widthFix" class="goArrow" :src="goArrow" />
  12. <view
  13. :hover-stop-propagation="true"
  14. data-type="wrong"
  15. @touchend.stop="clearTopics('wrong')"
  16. style="color: #498ef5"
  17. class="clear"
  18. >
  19. 清空错题
  20. </view>
  21. </div>
  22. <div class="choose-img" @click="goExercise('collect')">
  23. <span class="choose-text1">收藏题</span>
  24. <span class="choose-text2"> 共 {{ collectionListCount }} 题 </span>
  25. <image mode="widthFix" class="bg" :src="collectionBg" />
  26. <image mode="widthFix" class="goArrow" :src="goArrow" />
  27. <view
  28. :hover-stop-propagation="true"
  29. data-type="collect"
  30. @touchend.stop="clearTopics('collect')"
  31. style="color: #01c18d"
  32. class="clear"
  33. >
  34. 清空收藏
  35. </view>
  36. </div>
  37. </div>
  38. <div class="bottom">
  39. <image mode="widthFix" :src="collectionBottomBg" />
  40. </div>
  41. <!-- <van-swipe ref="swiper" :show-indicators="false" :touchable="false">
  42. <van-swipe-item> <listCom type="wrong" /> </van-swipe-item>
  43. <van-swipe-item> <listCom type="collection" /> </van-swipe-item>
  44. </van-swipe> -->
  45. </div>
  46. </template>
  47. <script>
  48. import goArrow from "@/assets/img/goArrow.png";
  49. import api from "@/api/index";
  50. import utils from "@/utils/index";
  51. export default {
  52. data() {
  53. return {
  54. wrongBg:
  55. "https://ct.zzxcx.net/ctjk/mp-wx/collection/wrongBg.png",
  56. collectionBottomBg:
  57. "https://ct.zzxcx.net/ctjk/mp-wx/collection/collectionBottomBg.png",
  58. goArrow,
  59. collectionBg:
  60. "https://ct.zzxcx.net/ctjk/mp-wx/collection/collectionBg.png",
  61. collectionHeader:
  62. "https://ct.zzxcx.net/ctjk/mp-wx/collection/collectionHeader.png",
  63. query: {
  64. questionIds: "",
  65. },
  66. gsMap: {
  67. xc: "小车",
  68. hc: "货车",
  69. mtc: "摩托车",
  70. kc: "客车",
  71. },
  72. wrongList: [],
  73. wrongListCount: 1,
  74. collectionList: [],
  75. collectionListCount: 1,
  76. };
  77. },
  78. onLoad(query) {
  79. this.query = query;
  80. api.exam
  81. .studentQuestionWrongWrongCountByUser({
  82. carType: this.gsMap[query.gs],
  83. km: query.subject === "1" ? "科目一" : "科目四",
  84. pageNum: 1,
  85. pageSize: 10000,
  86. })
  87. .then((res) => {
  88. this.wrongListCount = res.data;
  89. });
  90. api.exam
  91. .studentQuestionCollectionCollectionCountByUser({
  92. carType: this.gsMap[query.gs],
  93. km: query.subject === "1" ? "科目一" : "科目四",
  94. pageNum: 1,
  95. pageSize: 10000,
  96. })
  97. .then((res) => {
  98. this.collectionListCount = res.data;
  99. });
  100. },
  101. methods: {
  102. goExercise(type) {
  103. let query = Object.assign({}, this.query);
  104. if (type == "wrong" && this.wrongListCount == 0) {
  105. uni.showToast({
  106. title: "没有题目了",
  107. icon: "none",
  108. });
  109. return;
  110. }
  111. if (type == "collect" && this.collectionListCount == 0) {
  112. uni.showToast({
  113. title: "没有题目了",
  114. icon: "none",
  115. });
  116. return;
  117. }
  118. if (type == "wrong") {
  119. uni.navigateTo({
  120. url: "/otherPages/exerciseWrong/index?" + utils.mapToUrlQuery(query),
  121. });
  122. }
  123. if (type === "collect") {
  124. uni.navigateTo({
  125. url:
  126. "/otherPages/exerciseCollect/index?" + utils.mapToUrlQuery(query),
  127. });
  128. }
  129. },
  130. clearTopics(type) {
  131. let that = this;
  132. if (type === "wrong") {
  133. uni.showModal({
  134. title: "是否清空错题",
  135. success(res) {
  136. if (res.confirm) {
  137. api.exam
  138. .studentQuestionWrongCancelAll({
  139. carType: that.gsMap[that.query.gs],
  140. km: that.query.subject === "1" ? "科目一" : "科目四",
  141. })
  142. .then((res) => {
  143. api.exam
  144. .studentQuestionWrongWrongCountByUser({
  145. carType: that.gsMap[that.query.gs],
  146. km: that.query.subject === "1" ? "科目一" : "科目四",
  147. pageNum: 1,
  148. pageSize: 10000,
  149. })
  150. .then((res) => {
  151. that.wrongListCount = res.data;
  152. });
  153. });
  154. }
  155. },
  156. });
  157. } else if (type === "collect") {
  158. uni.showModal({
  159. title: "是否清空收藏题",
  160. success(res) {
  161. if (res.confirm) {
  162. api.exam
  163. .studentQuestionCollectionCancelAll({
  164. carType: that.gsMap[that.query.gs],
  165. km: that.query.subject === "1" ? "科目一" : "科目四",
  166. })
  167. .then((res) => {
  168. api.exam
  169. .studentQuestionCollectionCollectionCountByUser({
  170. carType: that.gsMap[that.query.gs],
  171. km: that.query.subject === "1" ? "科目一" : "科目四",
  172. pageNum: 1,
  173. pageSize: 10000,
  174. })
  175. .then((res) => {
  176. that.collectionListCount = res.data;
  177. });
  178. });
  179. }
  180. },
  181. });
  182. }
  183. },
  184. },
  185. };
  186. </script>
  187. <style lang="scss" scoped>
  188. .bottom {
  189. bottom: 0;
  190. image {
  191. width: 100%;
  192. }
  193. }
  194. .choose {
  195. width: 100%;
  196. display: flex;
  197. justify-content: center;
  198. align-content: space-between;
  199. align-items: space-between;
  200. flex-wrap: wrap;
  201. transform: translate(0%, -8%);
  202. .choose-img {
  203. width: 690rpx;
  204. position: relative;
  205. margin-bottom: 25rpx;
  206. .bg {
  207. width: 690rpx;
  208. }
  209. .clear {
  210. background: #fff;
  211. border-radius: 30rpx;
  212. position: absolute;
  213. bottom: 40rpx;
  214. width: 200rpx;
  215. height: 60rpx;
  216. left: 40rpx;
  217. bottom: 40rpx;
  218. border: 0;
  219. font-size: 26rpx;
  220. line-height: 60rpx;
  221. text-align: center;
  222. }
  223. .goArrow {
  224. position: absolute;
  225. top: 64rpx;
  226. right: 40rpx;
  227. width: 146rpx;
  228. }
  229. .choose-text1 {
  230. position: absolute;
  231. font-size: 50rpx;
  232. color: #fff;
  233. left: 40rpx;
  234. top: 40rpx;
  235. }
  236. .choose-text2 {
  237. position: absolute;
  238. top: 112rpx;
  239. left: 44rpx;
  240. color: #fff;
  241. }
  242. img {
  243. width: 100%;
  244. }
  245. }
  246. }
  247. .collectionHeader {
  248. width: 100%;
  249. }
  250. .collection-box {
  251. height: 100vh;
  252. display: flex;
  253. flex-direction: column;
  254. }
  255. </style>