index.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  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. uni.$emit('back-outpage')
  127. }
  128. function handleBackFromCuoti() {
  129. wrongRef.value.closePopup();
  130. }
  131. function onChangeTab(e) {
  132. if (data.current !== e.currentIndex) {
  133. data.current = e.currentIndex;
  134. cardId.value = data.current+1;
  135. if (data.current == 0) {
  136. data.shuxue.page = 0
  137. } else if (data.current == 1) {
  138. data.yingyu.page = 0
  139. }
  140. refreshData(data.current);
  141. }
  142. }
  143. function refreshData(code) {
  144. const opt = {
  145. page: 1,
  146. size: 10, // 固定查询10条
  147. cardId: data.current + 1 // 前台索引加1为学科cardId
  148. }
  149. if (code == 0) {
  150. data.shuxue.list = [];
  151. // 数学
  152. data.shuxue.state = 'loading';
  153. data.shuxue.page++;
  154. opt.page = data.shuxue.page;
  155. } else if (code == 1) {
  156. data.yingyu.list = [];
  157. // 英语
  158. data.yingyu.state = 'loading';
  159. data.yingyu.page++;
  160. opt.page = data.yingyu.page;
  161. }
  162. getWrongData(opt).then(res => {
  163. if (code == 0) {
  164. data.shuxue.list = data.shuxue.list.concat(res.data.data);
  165. data.shuxue.loading = false;
  166. } else if (code == 1) {
  167. data.yingyu.list = data.yingyu.list.concat(res.data.data);
  168. data.yingyu.loading = false;
  169. }
  170. if (code == 0) {
  171. if (res.data.total >= data.shuxue.list.length) {
  172. // 数学
  173. data.shuxue.state = 'no-more';
  174. data.shuxue.loading = false;
  175. } else {
  176. // 数学
  177. data.shuxue.state = 'more';
  178. data.shuxue.loading = false;
  179. }
  180. } else if (code == 1) {
  181. if (res.data.total >= data.yingyu.list.length) {
  182. // 英语
  183. data.yingyu.state = 'no-more';
  184. data.yingyu.loading = false;
  185. } else {
  186. // 英语
  187. data.yingyu.state = 'more';
  188. data.yingyu.loading = false;
  189. }
  190. }
  191. }).catch(err => {
  192. if (code == 0) {
  193. // 数学
  194. data.shuxue.state = 'more';
  195. data.shuxue.loading = false;
  196. } else if (code == 1) {
  197. // 英语
  198. data.yingyu.state = 'more';
  199. data.yingyu.loading = false;
  200. }
  201. })
  202. }
  203. function getMore(code) {
  204. const opt = {
  205. page: 1,
  206. size: 10, // 固定查询10条
  207. cardId: data.current + 1 // 前台索引加1为学科cardId
  208. }
  209. if (code == 0) {
  210. if (data.shuxue.state == 'no-more') return;
  211. // 数学
  212. data.shuxue.state = 'loading';
  213. data.shuxue.page++;
  214. opt.page = data.shuxue.page;
  215. } else if (code == 1) {
  216. // 英语
  217. if (data.yingyu.state == 'no-more') return;
  218. data.yingyu.state = 'loading';
  219. data.yingyu.page++;
  220. opt.page = data.yingyu.page;
  221. }
  222. getWrongData(opt).then(res => {
  223. if (code == 0) {
  224. data.shuxue.list = data.shuxue.list.concat(res.data.data);
  225. data.shuxue.loading = false;
  226. } else if (code == 1) {
  227. data.yingyu.list = data.yingyu.list.concat(res.data.data);
  228. data.yingyu.loading = false;
  229. }
  230. if (code == 0) {
  231. if (res.data.total >= data.shuxue.list.length) {
  232. // 数学
  233. data.shuxue.state = 'no-more';
  234. data.shuxue.state_text = '没有更多啦';
  235. data.shuxue.loading = false;
  236. } else {
  237. // 数学
  238. data.shuxue.state = 'more';
  239. data.shuxue.state_text = '加载更多';
  240. data.shuxue.loading = false;
  241. }
  242. } else if (code == 1) {
  243. if (res.data.total >= data.yingyu.list.length) {
  244. // 英语
  245. data.yingyu.state = 'no-more';
  246. data.yingyu.state_text = '没有更多啦';
  247. data.yingyu.loading = false;
  248. } else {
  249. // 英语
  250. data.yingyu.state = 'more';
  251. data.yingyu.state_text = '加载更多';
  252. data.yingyu.loading = false;
  253. }
  254. }
  255. }).catch(err => {
  256. if (code == 0) {
  257. // 数学
  258. data.shuxue.state = 'more';
  259. data.shuxue.state_text = '加载更多';
  260. data.shuxue.loading = false;
  261. } else if (code == 1) {
  262. // 英语
  263. data.yingyu.state = 'more';
  264. data.yingyu.state_text = '加载更多';
  265. data.yingyu.loading = false;
  266. }
  267. })
  268. }
  269. function formatListToUse(list) {
  270. list.forEach((item, index) => {
  271. item.mta_show = false;
  272. if (item.type == 3) {
  273. item.result = JSON.parse(item.result);
  274. item.placeholders = item.result.map((item, cindex) => `[bank${cindex+1}]`)
  275. item.reply = item.reply ? JSON.parse(item.reply) : item.result.map(() => '');
  276. }
  277. if (item.type == 4) {
  278. // 特殊题型英语题
  279. const audioList = item.audios ? item.audios.split(',') : [];
  280. item.placeholders = audioList.map((item, cindex) => `[yingyu${cindex+1}]`)
  281. item.audioList = audioList;
  282. }
  283. })
  284. }
  285. function getCuotiData(item) {
  286. getWrongInfo({
  287. cardId: data.current + 1,
  288. cdate: item.cdate
  289. }).then(res => {
  290. formatListToUse(res.data)
  291. data.wrongList = res.data;
  292. wrongRef.value.showPopup();
  293. })
  294. }
  295. function onRefresh() {
  296. if (data.current == 0) {
  297. data.shuxue.page = 0;
  298. data.shuxue.list = [];
  299. data.shuxue.loading = true;
  300. } else if (data.current == 1) {
  301. data.yingyu.page = 0;
  302. data.yingyu.list = [];
  303. data.yingyu.loading = true;
  304. }
  305. refreshData(data.current);
  306. }
  307. onLoad(() => {
  308. getMore(data.current);
  309. })
  310. </script>
  311. <style>
  312. </style>