index.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. <template>
  2. <view class="ezy-cuoti-page">
  3. <view class="icon-title-navBar-box">
  4. <view @click="handleBack" class="nav-bar-icon"></view>
  5. <text class="nav-bar-title">我的错题</text>
  6. </view>
  7. <view class="ezy-tab-border">
  8. <uni-segmented-control :current="data.current" :values="data.items" active-color="#3A7FE9"
  9. @clickItem="onChangeTab" class="ezy-tab-box" />
  10. <view class="cuoti-content-box">
  11. <view v-if="data.current === 0">
  12. <scroll-view scroll-y="true" refresher-enabled="true" :refresher-triggered="data.shuxue.loading"
  13. :refresher-threshold="50" refresher-background="transparent" @refresherrefresh="onRefresh"
  14. class="cuoti-scroll-view">
  15. <!--数学-->
  16. <uni-list>
  17. <uni-list-item v-for="item in data.shuxue.list" class="list-item-box">
  18. <template v-slot:body>
  19. <!-- 时间 -->
  20. <view class="item-date-row">
  21. <icon class="data-icon"></icon>
  22. <text>{{ item.cdate }}</text>
  23. </view>
  24. <!-- 数量 -->
  25. <view class="item-cuoti-row">
  26. <icon class="cuoti-icon"></icon>
  27. <view class="cuoti-content">错题数:<text
  28. class="cuoti-text">{{ item.count }}</text>题</view>
  29. </view>
  30. <view @click="getCuotiData(item)" class="cuoti-btn">查看错题</view>
  31. </template>
  32. </uni-list-item>
  33. <uni-load-more :status="data.shuxue.state" @click="getMore(0)"
  34. :contentText="data.shuxue.contentText"></uni-load-more>
  35. </uni-list>
  36. </scroll-view>
  37. </view>
  38. <view v-if="data.current === 1">
  39. <scroll-view scroll-y="true" refresher-enabled="true" :refresher-triggered="data.yingyu.loading"
  40. :refresher-threshold="50" refresher-background="transparent" @refresherrefresh="onRefresh"
  41. class="cuoti-scroll-view">
  42. <!--英语-->
  43. <uni-list>
  44. <uni-list-item v-for="item in data.yingyu.list" class="list-item-box">
  45. <template v-slot:body>
  46. <!-- 时间 -->
  47. <view class="item-date-row">
  48. <icon class="data-icon"></icon>
  49. <text>{{ item.cdate }}</text>
  50. </view>
  51. <!-- 数量 -->
  52. <view class="item-cuoti-row">
  53. <icon class="cuoti-icon"></icon>
  54. <view class="cuoti-content">错题数:<text
  55. class="cuoti-text">{{ item.count }}</text>题</view>
  56. </view>
  57. <view @click="getCuotiData(item)" class="cuoti-btn">查看错题</view>
  58. </template>
  59. </uni-list-item>
  60. <uni-load-more :status="data.yingyu.state" @click="getMore(1)"
  61. :contentText="data.yingyu.contentText"></uni-load-more>
  62. </uni-list>
  63. </scroll-view>
  64. </view>
  65. </view>
  66. </view>
  67. <cuoti ref="wrongRef" :cardId="cardId" :list="data.wrongList" @back="handleBackFromCuoti"></cuoti>
  68. <CustomTabBar :cardId="cardId" :nianji="nianji" :zhangId="zhangId"></CustomTabBar>
  69. <!-- 音频播放组件 -->
  70. <mtaRadio></mtaRadio>
  71. </view>
  72. </template>
  73. <script setup>
  74. import {
  75. reactive,
  76. ref
  77. } from "vue";
  78. import {
  79. getWrongData
  80. } from "@/api/wrong";
  81. import {
  82. onLoad
  83. } from "@dcloudio/uni-app";
  84. import cuoti from "@/components/chengji/chengji.vue";
  85. import mtaRadio from '@/components/question/yingyu/mtaRadio.vue'
  86. import {
  87. getWrongInfo
  88. } from "@/api/wrong";
  89. import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';
  90. const zhangId = ref(null);
  91. const nianji = ref(null);
  92. const cardId = ref(null);
  93. const wrongRef = ref(null);
  94. const data = reactive({
  95. items: ['数学', '英语'],
  96. current: 0,
  97. shuxue: {
  98. page: 0,
  99. list: [],
  100. loading: false,
  101. state: 'more',
  102. contentText: {
  103. contentdown: '查看更多',
  104. contentrefresh: '加载中',
  105. contentnomore: '没有更多'
  106. }
  107. },
  108. yingyu: {
  109. page: 0,
  110. list: [],
  111. loading: false,
  112. state: 'more',
  113. contentText: {
  114. contentdown: '查看更多',
  115. contentrefresh: '加载中',
  116. contentnomore: '没有更多'
  117. }
  118. },
  119. wrongList: [],
  120. })
  121. cardId.value = data.current+1;
  122. function handleBack() {
  123. uni.redirectTo({
  124. url: '/pages/my/index'
  125. })
  126. }
  127. function handleBackFromCuoti() {
  128. wrongRef.value.closePopup();
  129. }
  130. function onChangeTab(e) {
  131. if (data.current !== e.currentIndex) {
  132. data.current = e.currentIndex;
  133. cardId.value = data.current+1;
  134. if (data.current == 0) {
  135. data.shuxue.page = 0
  136. } else if (data.current == 1) {
  137. data.yingyu.page = 0
  138. }
  139. refreshData(data.current);
  140. }
  141. }
  142. function refreshData(code) {
  143. const opt = {
  144. page: 1,
  145. size: 10, // 固定查询10条
  146. cardId: data.current + 1 // 前台索引加1为学科cardId
  147. }
  148. if (code == 0) {
  149. data.shuxue.list = [];
  150. // 数学
  151. data.shuxue.state = 'loading';
  152. data.shuxue.page++;
  153. opt.page = data.shuxue.page;
  154. } else if (code == 1) {
  155. data.yingyu.list = [];
  156. // 英语
  157. data.yingyu.state = 'loading';
  158. data.yingyu.page++;
  159. opt.page = data.yingyu.page;
  160. }
  161. getWrongData(opt).then(res => {
  162. if (code == 0) {
  163. data.shuxue.list = data.shuxue.list.concat(res.data.data);
  164. data.shuxue.loading = false;
  165. } else if (code == 1) {
  166. data.yingyu.list = data.yingyu.list.concat(res.data.data);
  167. data.yingyu.loading = false;
  168. }
  169. if (code == 0) {
  170. if (res.data.total >= data.shuxue.list.length) {
  171. // 数学
  172. data.shuxue.state = 'no-more';
  173. data.shuxue.loading = false;
  174. } else {
  175. // 数学
  176. data.shuxue.state = 'more';
  177. data.shuxue.loading = false;
  178. }
  179. } else if (code == 1) {
  180. if (res.data.total >= data.yingyu.list.length) {
  181. // 英语
  182. data.yingyu.state = 'no-more';
  183. data.yingyu.loading = false;
  184. } else {
  185. // 英语
  186. data.yingyu.state = 'more';
  187. data.yingyu.loading = false;
  188. }
  189. }
  190. }).catch(err => {
  191. if (code == 0) {
  192. // 数学
  193. data.shuxue.state = 'more';
  194. data.shuxue.loading = false;
  195. } else if (code == 1) {
  196. // 英语
  197. data.yingyu.state = 'more';
  198. data.yingyu.loading = false;
  199. }
  200. })
  201. }
  202. function getMore(code) {
  203. const opt = {
  204. page: 1,
  205. size: 10, // 固定查询10条
  206. cardId: data.current + 1 // 前台索引加1为学科cardId
  207. }
  208. if (code == 0) {
  209. if (data.shuxue.state == 'no-more') return;
  210. // 数学
  211. data.shuxue.state = 'loading';
  212. data.shuxue.page++;
  213. opt.page = data.shuxue.page;
  214. } else if (code == 1) {
  215. // 英语
  216. if (data.yingyu.state == 'no-more') return;
  217. data.yingyu.state = 'loading';
  218. data.yingyu.page++;
  219. opt.page = data.yingyu.page;
  220. }
  221. getWrongData(opt).then(res => {
  222. if (code == 0) {
  223. data.shuxue.list = data.shuxue.list.concat(res.data.data);
  224. data.shuxue.loading = false;
  225. } else if (code == 1) {
  226. data.yingyu.list = data.yingyu.list.concat(res.data.data);
  227. data.yingyu.loading = false;
  228. }
  229. if (code == 0) {
  230. if (res.data.total >= data.shuxue.list.length) {
  231. // 数学
  232. data.shuxue.state = 'no-more';
  233. data.shuxue.state_text = '没有更多啦';
  234. data.shuxue.loading = false;
  235. } else {
  236. // 数学
  237. data.shuxue.state = 'more';
  238. data.shuxue.state_text = '加载更多';
  239. data.shuxue.loading = false;
  240. }
  241. } else if (code == 1) {
  242. if (res.data.total >= data.yingyu.list.length) {
  243. // 英语
  244. data.yingyu.state = 'no-more';
  245. data.yingyu.state_text = '没有更多啦';
  246. data.yingyu.loading = false;
  247. } else {
  248. // 英语
  249. data.yingyu.state = 'more';
  250. data.yingyu.state_text = '加载更多';
  251. data.yingyu.loading = false;
  252. }
  253. }
  254. }).catch(err => {
  255. if (code == 0) {
  256. // 数学
  257. data.shuxue.state = 'more';
  258. data.shuxue.state_text = '加载更多';
  259. data.shuxue.loading = false;
  260. } else if (code == 1) {
  261. // 英语
  262. data.yingyu.state = 'more';
  263. data.yingyu.state_text = '加载更多';
  264. data.yingyu.loading = false;
  265. }
  266. })
  267. }
  268. function formatListToUse(list) {
  269. list.forEach((item, index) => {
  270. item.mta_show = false;
  271. if (item.type == 3) {
  272. item.result = JSON.parse(item.result);
  273. item.placeholders = item.result.map((item, cindex) => `[bank${cindex+1}]`)
  274. item.reply = item.reply ? JSON.parse(item.reply) : item.result.map(() => '');
  275. }
  276. if (item.type == 4) {
  277. // 特殊题型英语题
  278. const audioList = item.audios ? item.audios.split(',') : [];
  279. item.placeholders = audioList.map((item, cindex) => `[yingyu${cindex+1}]`)
  280. item.audioList = audioList;
  281. }
  282. })
  283. }
  284. function getCuotiData(item) {
  285. getWrongInfo({
  286. cardId: data.current + 1,
  287. cdate: item.cdate
  288. }).then(res => {
  289. formatListToUse(res.data)
  290. data.wrongList = res.data;
  291. wrongRef.value.showPopup();
  292. })
  293. }
  294. function onRefresh() {
  295. if (data.current == 0) {
  296. data.shuxue.page = 0;
  297. data.shuxue.list = [];
  298. data.shuxue.loading = true;
  299. } else if (data.current == 1) {
  300. data.yingyu.page = 0;
  301. data.yingyu.list = [];
  302. data.yingyu.loading = true;
  303. }
  304. refreshData(data.current);
  305. }
  306. onLoad(() => {
  307. getMore(data.current);
  308. })
  309. </script>
  310. <style>
  311. </style>