xuexiJilu.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  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. <view @click="goDao(item)">
  20. <view class="item-date-row">
  21. <icon class="data-icon"></icon>
  22. <text>{{ item.levelName }}</text>
  23. </view>
  24. <view>
  25. <text>{{ item.zhangName }}</text>
  26. </view>
  27. <view>
  28. <text>{{ item.jieName }}</text>
  29. </view>
  30. </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. <view>
  47. <view class="item-date-row">
  48. <icon class="data-icon"></icon>
  49. <text>{{ item.levelName }}</text>
  50. </view>
  51. <view>
  52. <text>{{ item.zhangName }}</text>
  53. </view>
  54. <view>
  55. <text>{{ item.jieName }}</text>
  56. </view>
  57. </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. <CustomTabBar></CustomTabBar>
  68. </view>
  69. </template>
  70. <script setup>
  71. import {
  72. reactive,
  73. ref
  74. } from "vue";
  75. import {
  76. xuexiJilu
  77. } from "@/api/my.js";
  78. import {
  79. onLoad
  80. } from "@dcloudio/uni-app";
  81. import cuoti from "@/components/chengji/chengji.vue";
  82. import {
  83. getWrongInfo
  84. } from "@/api/wrong";
  85. import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';
  86. import cacheManager from "@/utils/cacheManager.js"
  87. const zhangId = ref(null);
  88. const nianji = ref(null);
  89. const subjectId = ref(null);
  90. const wrongRef = ref(null);
  91. const data = reactive({
  92. items: ['数学', '英语'],
  93. current: 0,
  94. shuxue: {
  95. page: 0,
  96. list: [],
  97. loading: false,
  98. state: 'more',
  99. contentText: {
  100. contentdown: '查看更多',
  101. contentrefresh: '加载中',
  102. contentnomore: '没有更多'
  103. }
  104. },
  105. yingyu: {
  106. page: 0,
  107. list: [],
  108. loading: false,
  109. state: 'more',
  110. contentText: {
  111. contentdown: '查看更多',
  112. contentrefresh: '加载中',
  113. contentnomore: '没有更多'
  114. }
  115. },
  116. wrongList: [],
  117. })
  118. subjectId.value = data.current + 1;
  119. function goDao(data) {
  120. const auth = cacheManager.get('auth');
  121. cacheManager.updateObject('auth', {
  122. levelId: data.levelId,
  123. zhangId: data.zhangId,
  124. })
  125. cacheManager.remove('zhangInfo')
  126. uni.redirectTo({
  127. url: `/pages/study/index`
  128. })
  129. }
  130. function handleBack() {
  131. uni.redirectTo({
  132. url: '/pages/my/index'
  133. })
  134. uni.$emit('back-outpage')
  135. }
  136. function handleBackFromCuoti() {
  137. wrongRef.value.closePopup();
  138. uni.$emit('back-outpage')
  139. }
  140. function onChangeTab(e) {
  141. if (data.current !== e.currentIndex) {
  142. data.current = e.currentIndex;
  143. subjectId.value = data.current + 1;
  144. if (data.current == 0) {
  145. data.shuxue.page = 0
  146. } else if (data.current == 1) {
  147. data.yingyu.page = 0
  148. }
  149. refreshData(data.current);
  150. }
  151. }
  152. function refreshData(code) {
  153. const opt = {
  154. page: 1,
  155. size: 10, // 固定查询10条
  156. subjectId: data.current + 1 // 前台索引加1为学科cardId
  157. }
  158. if (code == 0) {
  159. data.shuxue.list = [];
  160. // 数学
  161. data.shuxue.state = 'loading';
  162. data.shuxue.page++;
  163. opt.page = data.shuxue.page;
  164. } else if (code == 1) {
  165. data.yingyu.list = [];
  166. // 英语
  167. data.yingyu.state = 'loading';
  168. data.yingyu.page++;
  169. opt.page = data.yingyu.page;
  170. }
  171. xuexiJilu(opt).then(res => {
  172. if (code == 0) {
  173. data.shuxue.list = data.shuxue.list.concat(res.data.data);
  174. data.shuxue.loading = false;
  175. } else if (code == 1) {
  176. data.yingyu.list = data.yingyu.list.concat(res.data.data);
  177. data.yingyu.loading = false;
  178. }
  179. if (code == 0) {
  180. if (res.data.total > data.shuxue.list.length) {
  181. // 数学
  182. data.shuxue.state = 'more';
  183. data.shuxue.loading = false;
  184. } else {
  185. // 数学
  186. data.shuxue.state = 'no-more';
  187. data.shuxue.loading = false;
  188. }
  189. } else if (code == 1) {
  190. if (res.data.total > data.yingyu.list.length) {
  191. // 英语
  192. data.yingyu.state = 'more';
  193. data.yingyu.loading = false;
  194. } else {
  195. // 英语
  196. data.yingyu.state = 'no-more';
  197. data.yingyu.loading = false;
  198. }
  199. }
  200. }).catch(err => {
  201. if (code == 0) {
  202. // 数学
  203. data.shuxue.state = 'more';
  204. data.shuxue.loading = false;
  205. } else if (code == 1) {
  206. // 英语
  207. data.yingyu.state = 'more';
  208. data.yingyu.loading = false;
  209. }
  210. })
  211. }
  212. function getMore(code) {
  213. const opt = {
  214. page: 1,
  215. size: 10, // 固定查询10条
  216. subjectId: data.current + 1 // 前台索引加1为学科cardId
  217. }
  218. if (code == 0) {
  219. if (data.shuxue.state == 'no-more') return;
  220. // 数学
  221. data.shuxue.state = 'loading';
  222. data.shuxue.page++;
  223. opt.page = data.shuxue.page;
  224. } else if (code == 1) {
  225. // 英语
  226. if (data.yingyu.state == 'no-more') return;
  227. data.yingyu.state = 'loading';
  228. data.yingyu.page++;
  229. opt.page = data.yingyu.page;
  230. }
  231. xuexiJilu(opt).then(res => {
  232. if (code == 0) {
  233. data.shuxue.list = data.shuxue.list.concat(res.data.data);
  234. data.shuxue.loading = false;
  235. } else if (code == 1) {
  236. data.yingyu.list = data.yingyu.list.concat(res.data.data);
  237. data.yingyu.loading = false;
  238. }
  239. if (code == 0) {
  240. if (res.data.total > data.shuxue.list.length) {
  241. // 数学
  242. data.shuxue.state = 'more';
  243. data.shuxue.state_text = '加载更多';
  244. data.shuxue.loading = false;
  245. } else {
  246. // 数学
  247. data.shuxue.state = 'no-more';
  248. data.shuxue.state_text = '没有更多啦';
  249. data.shuxue.loading = false;
  250. }
  251. } else if (code == 1) {
  252. if (res.data.total > data.yingyu.list.length) {
  253. // 英语
  254. data.yingyu.state = 'more';
  255. data.yingyu.state_text = '加载更多';
  256. data.yingyu.loading = false;
  257. } else {
  258. // 英语
  259. data.yingyu.state = 'no-more';
  260. data.yingyu.state_text = '没有更多啦';
  261. data.yingyu.loading = false;
  262. }
  263. }
  264. }).catch(err => {
  265. if (code == 0) {
  266. // 数学
  267. data.shuxue.state = 'more';
  268. data.shuxue.state_text = '加载更多';
  269. data.shuxue.loading = false;
  270. } else if (code == 1) {
  271. // 英语
  272. data.yingyu.state = 'more';
  273. data.yingyu.state_text = '加载更多';
  274. data.yingyu.loading = false;
  275. }
  276. })
  277. }
  278. // function formatListToUse(list) {
  279. // list.forEach((item, index) => {
  280. // item.mta_show = false;
  281. // if (item.type == 3) {
  282. // item.result = JSON.parse(item.result);
  283. // item.placeholders = item.result.map((item, cindex) => `[bank${cindex+1}]`)
  284. // item.reply = item.reply ? JSON.parse(item.reply) : item.result.map(() => '');
  285. // }
  286. // if (item.type == 4) {
  287. // // 特殊题型英语题
  288. // const audioList = item.audios ? item.audios.split(',') : [];
  289. // item.placeholders = audioList.map((item, cindex) => `[yingyu${cindex+1}]`)
  290. // item.audioList = audioList;
  291. // }
  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>