xuexiJilu.vue 9.2 KB

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