xuexiJilu.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  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 @click.stop="deleteJilu(item)" 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 @click.stop="deleteJilu(item)" 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. <tip-small-dialog ref="deleteJiluDialogRef" @confirm-btn="deleteJiluBtn"
  88. :content="deleteJiluContent"></tip-small-dialog>
  89. <CustomTabBar></CustomTabBar>
  90. </view>
  91. </template>
  92. <script setup>
  93. import {
  94. reactive,
  95. ref
  96. } from "vue";
  97. import {
  98. xuexiJilu,
  99. xuexiJiluDelete
  100. } from "@/api/my.js";
  101. import {
  102. onLoad
  103. } from "@dcloudio/uni-app";
  104. import cuoti from "@/components/chengji/chengji.vue";
  105. import tipSmallDialog from '@/components/dialog/tipSmallDialog.vue';
  106. import {
  107. getWrongInfo
  108. } from "@/api/wrong";
  109. import {
  110. toast,
  111. getUserIdentity
  112. } from "@/utils/common";
  113. import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';
  114. import cacheManager from "@/utils/cacheManager.js"
  115. const zhangId = ref(null);
  116. const nianji = ref(null);
  117. const subjectId = ref(null);
  118. const deleteJiluDialogRef = ref(null);
  119. const deleteJiluContent = '你确定要执行这个操作吗?';
  120. const wrongRef = ref(null);
  121. const deleteId = ref('');
  122. const data = reactive({
  123. items: ['数学', '英语'],
  124. current: 0,
  125. shuxue: {
  126. page: 0,
  127. list: [],
  128. loading: false,
  129. state: 'more',
  130. contentText: {
  131. contentdown: '查看更多',
  132. contentrefresh: '加载中',
  133. contentnomore: '没有更多'
  134. }
  135. },
  136. yingyu: {
  137. page: 0,
  138. list: [],
  139. loading: false,
  140. state: 'more',
  141. contentText: {
  142. contentdown: '查看更多',
  143. contentrefresh: '加载中',
  144. contentnomore: '没有更多'
  145. }
  146. },
  147. wrongList: [],
  148. })
  149. subjectId.value = data.current + 1;
  150. function goDao(data) {
  151. const auth = cacheManager.get('auth');
  152. cacheManager.updateObject('auth', {
  153. levelId: data.levelId,
  154. zhangId: data.zhangId,
  155. })
  156. cacheManager.remove('zhangInfo')
  157. uni.redirectTo({
  158. url: `/pages/study/index`
  159. })
  160. }
  161. function deleteJilu(item) {
  162. deleteId.value = item.id
  163. deleteJiluDialogRef.value.handleShow();
  164. }
  165. function deleteJiluBtn(id) {
  166. let req = {
  167. id: deleteId.value
  168. }
  169. xuexiJiluDelete(req).then(res => {
  170. if (res.code == 0) {
  171. if (data.current === 0) {
  172. data.shuxue.list = [];
  173. data.shuxue.page = 0;
  174. } else {
  175. data.yingyu.list = [];
  176. data.yingyu.page = 0;
  177. }
  178. // 重新加载数据
  179. refreshData(data.current);
  180. } else {
  181. toast('失败,请稍后重试')
  182. }
  183. }).catch(err => {
  184. toast('失败,请稍后重试')
  185. })
  186. }
  187. function handleBack() {
  188. uni.redirectTo({
  189. url: '/pages/my/index'
  190. })
  191. uni.$emit('back-outpage')
  192. }
  193. function handleBackFromCuoti() {
  194. wrongRef.value.closePopup();
  195. uni.$emit('back-outpage')
  196. }
  197. function onChangeTab(e) {
  198. if (data.current !== e.currentIndex) {
  199. data.current = e.currentIndex;
  200. subjectId.value = data.current + 1;
  201. if (data.current == 0) {
  202. data.shuxue.page = 0
  203. } else if (data.current == 1) {
  204. data.yingyu.page = 0
  205. }
  206. refreshData(data.current);
  207. }
  208. }
  209. function refreshData(code) {
  210. const opt = {
  211. page: 1,
  212. size: 10, // 固定查询10条
  213. subjectId: data.current + 1 // 前台索引加1为学科cardId
  214. }
  215. if (code == 0) {
  216. data.shuxue.list = [];
  217. // 数学
  218. data.shuxue.state = 'loading';
  219. data.shuxue.page++;
  220. opt.page = data.shuxue.page;
  221. } else if (code == 1) {
  222. data.yingyu.list = [];
  223. // 英语
  224. data.yingyu.state = 'loading';
  225. data.yingyu.page++;
  226. opt.page = data.yingyu.page;
  227. }
  228. xuexiJilu(opt).then(res => {
  229. if (code == 0) {
  230. data.shuxue.list = data.shuxue.list.concat(res.data.data);
  231. data.shuxue.loading = false;
  232. } else if (code == 1) {
  233. data.yingyu.list = data.yingyu.list.concat(res.data.data);
  234. data.yingyu.loading = false;
  235. }
  236. if (code == 0) {
  237. if (res.data.total > data.shuxue.list.length) {
  238. // 数学
  239. data.shuxue.state = 'more';
  240. data.shuxue.loading = false;
  241. } else {
  242. // 数学
  243. data.shuxue.state = 'no-more';
  244. data.shuxue.loading = false;
  245. }
  246. } else if (code == 1) {
  247. if (res.data.total > data.yingyu.list.length) {
  248. // 英语
  249. data.yingyu.state = 'more';
  250. data.yingyu.loading = false;
  251. } else {
  252. // 英语
  253. data.yingyu.state = 'no-more';
  254. data.yingyu.loading = false;
  255. }
  256. }
  257. }).catch(err => {
  258. if (code == 0) {
  259. // 数学
  260. data.shuxue.state = 'more';
  261. data.shuxue.loading = false;
  262. } else if (code == 1) {
  263. // 英语
  264. data.yingyu.state = 'more';
  265. data.yingyu.loading = false;
  266. }
  267. })
  268. }
  269. function getMore(code) {
  270. console.log('12312312312');
  271. const opt = {
  272. page: 1,
  273. size: 10, // 固定查询10条
  274. subjectId: data.current + 1 // 前台索引加1为学科cardId
  275. }
  276. if (code == 0) {
  277. if (data.shuxue.state == 'no-more') return;
  278. // 数学
  279. data.shuxue.state = 'loading';
  280. data.shuxue.page++;
  281. opt.page = data.shuxue.page;
  282. } else if (code == 1) {
  283. // 英语
  284. if (data.yingyu.state == 'no-more') return;
  285. data.yingyu.state = 'loading';
  286. data.yingyu.page++;
  287. opt.page = data.yingyu.page;
  288. }
  289. xuexiJilu(opt).then(res => {
  290. if (code == 0) {
  291. data.shuxue.list = data.shuxue.list.concat(res.data.data);
  292. data.shuxue.loading = false;
  293. } else if (code == 1) {
  294. data.yingyu.list = data.yingyu.list.concat(res.data.data);
  295. data.yingyu.loading = false;
  296. }
  297. if (code == 0) {
  298. if (res.data.total > data.shuxue.list.length) {
  299. // 数学
  300. data.shuxue.state = 'more';
  301. data.shuxue.state_text = '加载更多';
  302. data.shuxue.loading = false;
  303. } else {
  304. // 数学
  305. data.shuxue.state = 'no-more';
  306. data.shuxue.state_text = '没有更多啦';
  307. data.shuxue.loading = false;
  308. }
  309. } else if (code == 1) {
  310. if (res.data.total > data.yingyu.list.length) {
  311. // 英语
  312. data.yingyu.state = 'more';
  313. data.yingyu.state_text = '加载更多';
  314. data.yingyu.loading = false;
  315. } else {
  316. // 英语
  317. data.yingyu.state = 'no-more';
  318. data.yingyu.state_text = '没有更多啦';
  319. data.yingyu.loading = false;
  320. }
  321. }
  322. }).catch(err => {
  323. if (code == 0) {
  324. // 数学
  325. data.shuxue.state = 'more';
  326. data.shuxue.state_text = '加载更多';
  327. data.shuxue.loading = false;
  328. } else if (code == 1) {
  329. // 英语
  330. data.yingyu.state = 'more';
  331. data.yingyu.state_text = '加载更多';
  332. data.yingyu.loading = false;
  333. }
  334. })
  335. }
  336. // function formatListToUse(list) {
  337. // list.forEach((item, index) => {
  338. // item.mta_show = false;
  339. // if (item.type == 3) {
  340. // item.result = JSON.parse(item.result);
  341. // item.placeholders = item.result.map((item, cindex) => `[bank${cindex+1}]`)
  342. // item.reply = item.reply ? JSON.parse(item.reply) : item.result.map(() => '');
  343. // }
  344. // if (item.type == 4) {
  345. // // 特殊题型英语题
  346. // const audioList = item.audios ? item.audios.split(',') : [];
  347. // item.placeholders = audioList.map((item, cindex) => `[yingyu${cindex+1}]`)
  348. // item.audioList = audioList;
  349. // }
  350. // })
  351. // }
  352. function onRefresh() {
  353. if (data.current == 0) {
  354. data.shuxue.page = 0;
  355. data.shuxue.list = [];
  356. data.shuxue.loading = true;
  357. } else if (data.current == 1) {
  358. data.yingyu.page = 0;
  359. data.yingyu.list = [];
  360. data.yingyu.loading = true;
  361. }
  362. refreshData(data.current);
  363. }
  364. onLoad(() => {
  365. getMore(data.current);
  366. })
  367. </script>
  368. <style>
  369. </style>