xuexiJilu.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  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. const zhangId = ref(null);
  87. const nianji = ref(null);
  88. const subjectId = ref(null);
  89. const wrongRef = ref(null);
  90. const data = reactive({
  91. items: ['数学', '英语'],
  92. current: 0,
  93. shuxue: {
  94. page: 0,
  95. list: [],
  96. loading: false,
  97. state: 'more',
  98. contentText: {
  99. contentdown: '查看更多',
  100. contentrefresh: '加载中',
  101. contentnomore: '没有更多'
  102. }
  103. },
  104. yingyu: {
  105. page: 0,
  106. list: [],
  107. loading: false,
  108. state: 'more',
  109. contentText: {
  110. contentdown: '查看更多',
  111. contentrefresh: '加载中',
  112. contentnomore: '没有更多'
  113. }
  114. },
  115. wrongList: [],
  116. })
  117. subjectId.value = data.current + 1;
  118. function goDao(data) {
  119. console.log('data', data);
  120. }
  121. function handleBack() {
  122. uni.redirectTo({
  123. url: '/pages/my/index'
  124. })
  125. uni.$emit('back-outpage')
  126. }
  127. function handleBackFromCuoti() {
  128. wrongRef.value.closePopup();
  129. uni.$emit('back-outpage')
  130. }
  131. function onChangeTab(e) {
  132. if (data.current !== e.currentIndex) {
  133. data.current = e.currentIndex;
  134. subjectId.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. subjectId: 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. xuexiJilu(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 = 'more';
  174. data.shuxue.loading = false;
  175. } else {
  176. // 数学
  177. data.shuxue.state = 'no-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 = 'more';
  184. data.yingyu.loading = false;
  185. } else {
  186. // 英语
  187. data.yingyu.state = 'no-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. subjectId: 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. xuexiJilu(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 = 'more';
  234. data.shuxue.state_text = '加载更多';
  235. data.shuxue.loading = false;
  236. } else {
  237. // 数学
  238. data.shuxue.state = 'no-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 = 'more';
  246. data.yingyu.state_text = '加载更多';
  247. data.yingyu.loading = false;
  248. } else {
  249. // 英语
  250. data.yingyu.state = 'no-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 onRefresh() {
  286. if (data.current == 0) {
  287. data.shuxue.page = 0;
  288. data.shuxue.list = [];
  289. data.shuxue.loading = true;
  290. } else if (data.current == 1) {
  291. data.yingyu.page = 0;
  292. data.yingyu.list = [];
  293. data.yingyu.loading = true;
  294. }
  295. refreshData(data.current);
  296. }
  297. onLoad(() => {
  298. getMore(data.current);
  299. })
  300. </script>
  301. <style>
  302. </style>