xuexishichang.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  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. <text>学习时长</text>
  8. <CustomTabBar></CustomTabBar>
  9. </view>
  10. </template>
  11. <script setup>
  12. import {
  13. reactive,
  14. ref
  15. } from "vue";
  16. import {
  17. getWrongData
  18. } from "@/api/wrong";
  19. import {
  20. onLoad
  21. } from "@dcloudio/uni-app";
  22. import cuoti from "@/components/chengji/chengji.vue";
  23. import {
  24. getWrongInfo
  25. } from "@/api/wrong";
  26. import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';
  27. const zhangId = ref(null);
  28. const nianji = ref(null);
  29. const subjectId = ref(null);
  30. const wrongRef = ref(null);
  31. const data = reactive({
  32. items: ['数学', '英语'],
  33. current: 0,
  34. shuxue: {
  35. page: 0,
  36. list: [],
  37. loading: false,
  38. state: 'more',
  39. contentText: {
  40. contentdown: '查看更多',
  41. contentrefresh: '加载中',
  42. contentnomore: '没有更多'
  43. }
  44. },
  45. yingyu: {
  46. page: 0,
  47. list: [],
  48. loading: false,
  49. state: 'more',
  50. contentText: {
  51. contentdown: '查看更多',
  52. contentrefresh: '加载中',
  53. contentnomore: '没有更多'
  54. }
  55. },
  56. wrongList: [],
  57. })
  58. subjectId.value = data.current+1;
  59. function handleBack() {
  60. uni.redirectTo({
  61. url: '/pages/my/index'
  62. })
  63. }
  64. function handleBackFromCuoti() {
  65. wrongRef.value.closePopup();
  66. uni.$emit('back-outpage')
  67. }
  68. function onChangeTab(e) {
  69. if (data.current !== e.currentIndex) {
  70. data.current = e.currentIndex;
  71. subjectId.value = data.current+1;
  72. if (data.current == 0) {
  73. data.shuxue.page = 0
  74. } else if (data.current == 1) {
  75. data.yingyu.page = 0
  76. }
  77. refreshData(data.current);
  78. }
  79. }
  80. function refreshData(code) {
  81. const opt = {
  82. page: 1,
  83. size: 10, // 固定查询10条
  84. subjectId: data.current + 1 // 前台索引加1为学科cardId
  85. }
  86. if (code == 0) {
  87. data.shuxue.list = [];
  88. // 数学
  89. data.shuxue.state = 'loading';
  90. data.shuxue.page++;
  91. opt.page = data.shuxue.page;
  92. } else if (code == 1) {
  93. data.yingyu.list = [];
  94. // 英语
  95. data.yingyu.state = 'loading';
  96. data.yingyu.page++;
  97. opt.page = data.yingyu.page;
  98. }
  99. getWrongData(opt).then(res => {
  100. if (code == 0) {
  101. data.shuxue.list = data.shuxue.list.concat(res.data.data);
  102. data.shuxue.loading = false;
  103. } else if (code == 1) {
  104. data.yingyu.list = data.yingyu.list.concat(res.data.data);
  105. data.yingyu.loading = false;
  106. }
  107. if (code == 0) {
  108. if (res.data.total > data.shuxue.list.length) {
  109. // 数学
  110. data.shuxue.state = 'more';
  111. data.shuxue.loading = false;
  112. } else {
  113. // 数学
  114. data.shuxue.state = 'no-more';
  115. data.shuxue.loading = false;
  116. }
  117. } else if (code == 1) {
  118. if (res.data.total > data.yingyu.list.length) {
  119. // 英语
  120. data.yingyu.state = 'more';
  121. data.yingyu.loading = false;
  122. } else {
  123. // 英语
  124. data.yingyu.state = 'no-more';
  125. data.yingyu.loading = false;
  126. }
  127. }
  128. }).catch(err => {
  129. if (code == 0) {
  130. // 数学
  131. data.shuxue.state = 'more';
  132. data.shuxue.loading = false;
  133. } else if (code == 1) {
  134. // 英语
  135. data.yingyu.state = 'more';
  136. data.yingyu.loading = false;
  137. }
  138. })
  139. }
  140. function getMore(code) {
  141. const opt = {
  142. page: 1,
  143. size: 10, // 固定查询10条
  144. subjectId: data.current + 1 // 前台索引加1为学科cardId
  145. }
  146. if (code == 0) {
  147. if (data.shuxue.state == 'no-more') return;
  148. // 数学
  149. data.shuxue.state = 'loading';
  150. data.shuxue.page++;
  151. opt.page = data.shuxue.page;
  152. } else if (code == 1) {
  153. // 英语
  154. if (data.yingyu.state == 'no-more') return;
  155. data.yingyu.state = 'loading';
  156. data.yingyu.page++;
  157. opt.page = data.yingyu.page;
  158. }
  159. getWrongData(opt).then(res => {
  160. if (code == 0) {
  161. data.shuxue.list = data.shuxue.list.concat(res.data.data);
  162. data.shuxue.loading = false;
  163. } else if (code == 1) {
  164. data.yingyu.list = data.yingyu.list.concat(res.data.data);
  165. data.yingyu.loading = false;
  166. }
  167. if (code == 0) {
  168. if (res.data.total > data.shuxue.list.length) {
  169. // 数学
  170. data.shuxue.state = 'more';
  171. data.shuxue.state_text = '加载更多';
  172. data.shuxue.loading = false;
  173. } else {
  174. // 数学
  175. data.shuxue.state = 'no-more';
  176. data.shuxue.state_text = '没有更多啦';
  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 = 'more';
  183. data.yingyu.state_text = '加载更多';
  184. data.yingyu.loading = false;
  185. } else {
  186. // 英语
  187. data.yingyu.state = 'no-more';
  188. data.yingyu.state_text = '没有更多啦';
  189. data.yingyu.loading = false;
  190. }
  191. }
  192. }).catch(err => {
  193. if (code == 0) {
  194. // 数学
  195. data.shuxue.state = 'more';
  196. data.shuxue.state_text = '加载更多';
  197. data.shuxue.loading = false;
  198. } else if (code == 1) {
  199. // 英语
  200. data.yingyu.state = 'more';
  201. data.yingyu.state_text = '加载更多';
  202. data.yingyu.loading = false;
  203. }
  204. })
  205. }
  206. function formatListToUse(list) {
  207. list.forEach((item, index) => {
  208. item.mta_show = false;
  209. if (item.type == 3) {
  210. item.result = JSON.parse(item.result);
  211. item.placeholders = item.result.map((item, cindex) => `[bank${cindex+1}]`)
  212. item.reply = item.reply ? JSON.parse(item.reply) : item.result.map(() => '');
  213. }
  214. if (item.type == 4) {
  215. // 特殊题型英语题
  216. const audioList = item.audios ? item.audios.split(',') : [];
  217. item.placeholders = audioList.map((item, cindex) => `[yingyu${cindex+1}]`)
  218. item.audioList = audioList;
  219. }
  220. })
  221. }
  222. function getCuotiData(item) {
  223. getWrongInfo({
  224. subjectId: data.current + 1,
  225. cdate: item.cdate
  226. }).then(res => {
  227. formatListToUse(res.data)
  228. data.wrongList = res.data;
  229. wrongRef.value.showPopup();
  230. })
  231. }
  232. function onRefresh() {
  233. if (data.current == 0) {
  234. data.shuxue.page = 0;
  235. data.shuxue.list = [];
  236. data.shuxue.loading = true;
  237. } else if (data.current == 1) {
  238. data.yingyu.page = 0;
  239. data.yingyu.list = [];
  240. data.yingyu.loading = true;
  241. }
  242. refreshData(data.current);
  243. }
  244. onLoad(() => {
  245. getMore(data.current);
  246. })
  247. </script>
  248. <style>
  249. </style>