xuexiJilu.vue 8.4 KB

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