xuexiJilu.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  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,1)">
  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 @click="goDao(item,2)">
  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. userZhangInfo,
  103. userLocate,
  104. userZhangForntInfo,
  105. userZhangNextInfo,
  106. getCommonZhangInfo
  107. } from "@/api/learnPlan.js"
  108. import {
  109. onLoad
  110. } from "@dcloudio/uni-app";
  111. import cuoti from "@/components/chengji/chengji.vue";
  112. import tipSmallDialog from '@/components/dialog/tipSmallDialog.vue';
  113. import {
  114. getWrongInfo
  115. } from "@/api/wrong";
  116. import {
  117. getWordListYk,
  118. getWordList,
  119. wordXuewan
  120. } from "@/api/word.js"
  121. import {
  122. toast,
  123. getUserIdentity
  124. } from "@/utils/common";
  125. import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';
  126. import cacheManager from "@/utils/cacheManager.js"
  127. const zhangId = ref(null);
  128. const nianji = ref(null);
  129. const subjectId = ref(null);
  130. const deleteJiluDialogRef = ref(null);
  131. const deleteJiluContent = '你确定要执行这个操作吗?';
  132. const wrongRef = ref(null);
  133. const deleteId = ref('');
  134. const localAuth = ref(null);
  135. const data = reactive({
  136. items: ['数学', '英语'],
  137. current: 0,
  138. shuxue: {
  139. page: 0,
  140. list: [],
  141. loading: false,
  142. state: 'more',
  143. contentText: {
  144. contentdown: '查看更多',
  145. contentrefresh: '加载中',
  146. contentnomore: '没有更多'
  147. }
  148. },
  149. yingyu: {
  150. page: 0,
  151. list: [],
  152. loading: false,
  153. state: 'more',
  154. contentText: {
  155. contentdown: '查看更多',
  156. contentrefresh: '加载中',
  157. contentnomore: '没有更多'
  158. }
  159. },
  160. wrongList: [],
  161. })
  162. subjectId.value = data.current + 1;
  163. function goDao(data, subjectId) {
  164. console.log('data', data);
  165. console.log('subjectId', subjectId);
  166. if (subjectId == 2 && data.typeId == 1) {
  167. cacheManager.remove('zhangInfo')
  168. cacheManager.updateObject('auth', {
  169. levelId: data.levelId + ',' + data.zhangId,
  170. typeId: data.typeId,
  171. subjectId: subjectId,
  172. })
  173. localAuth.value = cacheManager.get('auth');
  174. data.subjectId = subjectId
  175. getZhangInfoNewYingyu(data)
  176. } else {
  177. cacheManager.remove('zhangInfo')
  178. cacheManager.updateObject('auth', {
  179. levelId: data.levelId,
  180. typeId: data.typeId,
  181. subjectId: subjectId,
  182. })
  183. localAuth.value = cacheManager.get('auth');
  184. data.subjectId = subjectId
  185. getZhangInfo(data)
  186. }
  187. }
  188. function goDanciList(data) {
  189. getWordList({
  190. jieId: data.jieId
  191. }).then(res => {
  192. if (res.code == 0 && res.data.wordList.length > 0) {
  193. uni.redirectTo({
  194. url: '/pages/wordList/wordList?jieId=' + data.jieId
  195. })
  196. } else {
  197. toast("wordList数据错误!");
  198. return false
  199. }
  200. })
  201. }
  202. function listClick(data) {
  203. if (data.subjectId == 2 && data.typeId == 1) {
  204. goDanciList(data)
  205. } else {
  206. if (data.type == 2) {
  207. // 最后一项
  208. goKaoshi(data)
  209. } else {
  210. goLookShipin(data)
  211. }
  212. }
  213. }
  214. function goKaoshi(data) {
  215. uni.redirectTo({
  216. url: `/pages/unitTest/index?jieId=` + data.jieId
  217. })
  218. }
  219. function goLookShipin(data, index) {
  220. if (data.typeId == 1) {
  221. // 1新 2旧
  222. if (!data.videoId) {
  223. toast("videoId 丢失!");
  224. return false
  225. }
  226. uni.redirectTo({
  227. url: '/pages/study/lookShipinNew?jieId=' + data.jieId
  228. })
  229. } else {
  230. if (!data.videoId) {
  231. toast("videoId 丢失!");
  232. return false
  233. }
  234. uni.redirectTo({
  235. url: '/pages/study/lookShipin?jieId=' + data.jieId
  236. })
  237. }
  238. }
  239. function getZhangInfoNewYingyu(item) {
  240. const arr = localAuth.value.levelId.split(",");
  241. let req = {
  242. levelId: arr[0],
  243. zhangId: arr[1]
  244. }
  245. userZhangInfo(req).then(res => {
  246. if (res.code == 0) {
  247. cacheManager.set('zhangInfo', res.data)
  248. setTimeout(() => {
  249. cacheManager.updateObject('zhangInfo', {
  250. curZid: item.zid
  251. })
  252. listClick(item)
  253. recordZhangJie()
  254. }, 100)
  255. }
  256. }).catch((err) => {
  257. toast('数据异常,请重新登录!1')
  258. cacheManager.clearAll();
  259. uni.reLaunch({
  260. url: '/pages/login/index'
  261. });
  262. })
  263. }
  264. function getZhangInfo(item) {
  265. let req = {
  266. levelId: item.levelId
  267. }
  268. userZhangInfo(req).then(res => {
  269. if (res.code == 0) {
  270. cacheManager.set('zhangInfo', res.data)
  271. setTimeout(() => {
  272. cacheManager.updateObject('zhangInfo', {
  273. curZhangId: item.zhangId
  274. })
  275. listClick(item)
  276. recordZhangJie()
  277. }, 100)
  278. }
  279. }).catch((err) => {
  280. toast('数据异常,请重新登录!2')
  281. cacheManager.clearAll();
  282. uni.reLaunch({
  283. url: '/pages/login/index'
  284. });
  285. })
  286. }
  287. function recordZhangJie() {
  288. let req = {
  289. levelId: localAuth.value.levelId,
  290. userId: localAuth.value.userId,
  291. subjectId: currentProduct.value,
  292. }
  293. userLocate(req).then(res => {
  294. })
  295. }
  296. function deleteJilu(item) {
  297. deleteId.value = item.id
  298. deleteJiluDialogRef.value.handleShow();
  299. }
  300. function deleteJiluBtn(id) {
  301. let req = {
  302. id: deleteId.value
  303. }
  304. xuexiJiluDelete(req).then(res => {
  305. if (res.code == 0) {
  306. if (data.current === 0) {
  307. data.shuxue.list = [];
  308. data.shuxue.page = 0;
  309. } else {
  310. data.yingyu.list = [];
  311. data.yingyu.page = 0;
  312. }
  313. // 重新加载数据
  314. refreshData(data.current);
  315. } else {
  316. toast('失败,请稍后重试')
  317. }
  318. }).catch(err => {
  319. toast('失败,请稍后重试')
  320. })
  321. }
  322. function handleBack() {
  323. uni.redirectTo({
  324. url: '/pages/my/index'
  325. })
  326. uni.$emit('back-outpage')
  327. }
  328. function handleBackFromCuoti() {
  329. wrongRef.value.closePopup();
  330. uni.$emit('back-outpage')
  331. }
  332. function onChangeTab(e) {
  333. if (data.current !== e.currentIndex) {
  334. data.current = e.currentIndex;
  335. subjectId.value = data.current + 1;
  336. if (data.current == 0) {
  337. data.shuxue.page = 0
  338. } else if (data.current == 1) {
  339. data.yingyu.page = 0
  340. }
  341. refreshData(data.current);
  342. }
  343. }
  344. function refreshData(code) {
  345. const opt = {
  346. page: 1,
  347. size: 10, // 固定查询10条
  348. subjectId: data.current + 1 // 前台索引加1为学科cardId
  349. }
  350. if (code == 0) {
  351. data.shuxue.list = [];
  352. // 数学
  353. data.shuxue.state = 'loading';
  354. data.shuxue.page++;
  355. opt.page = data.shuxue.page;
  356. } else if (code == 1) {
  357. data.yingyu.list = [];
  358. // 英语
  359. data.yingyu.state = 'loading';
  360. data.yingyu.page++;
  361. opt.page = data.yingyu.page;
  362. }
  363. xuexiJilu(opt).then(res => {
  364. if (code == 0) {
  365. data.shuxue.list = data.shuxue.list.concat(res.data.data);
  366. data.shuxue.loading = false;
  367. } else if (code == 1) {
  368. data.yingyu.list = data.yingyu.list.concat(res.data.data);
  369. data.yingyu.loading = false;
  370. }
  371. if (code == 0) {
  372. if (res.data.total > data.shuxue.list.length) {
  373. // 数学
  374. data.shuxue.state = 'more';
  375. data.shuxue.loading = false;
  376. } else {
  377. // 数学
  378. data.shuxue.state = 'no-more';
  379. data.shuxue.loading = false;
  380. }
  381. } else if (code == 1) {
  382. if (res.data.total > data.yingyu.list.length) {
  383. // 英语
  384. data.yingyu.state = 'more';
  385. data.yingyu.loading = false;
  386. } else {
  387. // 英语
  388. data.yingyu.state = 'no-more';
  389. data.yingyu.loading = false;
  390. }
  391. }
  392. }).catch(err => {
  393. if (code == 0) {
  394. // 数学
  395. data.shuxue.state = 'more';
  396. data.shuxue.loading = false;
  397. } else if (code == 1) {
  398. // 英语
  399. data.yingyu.state = 'more';
  400. data.yingyu.loading = false;
  401. }
  402. })
  403. }
  404. function getMore(code) {
  405. console.log('12312312312');
  406. const opt = {
  407. page: 1,
  408. size: 10, // 固定查询10条
  409. subjectId: data.current + 1 // 前台索引加1为学科cardId
  410. }
  411. if (code == 0) {
  412. if (data.shuxue.state == 'no-more') return;
  413. // 数学
  414. data.shuxue.state = 'loading';
  415. data.shuxue.page++;
  416. opt.page = data.shuxue.page;
  417. } else if (code == 1) {
  418. // 英语
  419. if (data.yingyu.state == 'no-more') return;
  420. data.yingyu.state = 'loading';
  421. data.yingyu.page++;
  422. opt.page = data.yingyu.page;
  423. }
  424. xuexiJilu(opt).then(res => {
  425. if (code == 0) {
  426. data.shuxue.list = data.shuxue.list.concat(res.data.data);
  427. data.shuxue.loading = false;
  428. } else if (code == 1) {
  429. data.yingyu.list = data.yingyu.list.concat(res.data.data);
  430. data.yingyu.loading = false;
  431. }
  432. if (code == 0) {
  433. if (res.data.total > data.shuxue.list.length) {
  434. // 数学
  435. data.shuxue.state = 'more';
  436. data.shuxue.state_text = '加载更多';
  437. data.shuxue.loading = false;
  438. } else {
  439. // 数学
  440. data.shuxue.state = 'no-more';
  441. data.shuxue.state_text = '没有更多啦';
  442. data.shuxue.loading = false;
  443. }
  444. } else if (code == 1) {
  445. if (res.data.total > data.yingyu.list.length) {
  446. // 英语
  447. data.yingyu.state = 'more';
  448. data.yingyu.state_text = '加载更多';
  449. data.yingyu.loading = false;
  450. } else {
  451. // 英语
  452. data.yingyu.state = 'no-more';
  453. data.yingyu.state_text = '没有更多啦';
  454. data.yingyu.loading = false;
  455. }
  456. }
  457. }).catch(err => {
  458. if (code == 0) {
  459. // 数学
  460. data.shuxue.state = 'more';
  461. data.shuxue.state_text = '加载更多';
  462. data.shuxue.loading = false;
  463. } else if (code == 1) {
  464. // 英语
  465. data.yingyu.state = 'more';
  466. data.yingyu.state_text = '加载更多';
  467. data.yingyu.loading = false;
  468. }
  469. })
  470. }
  471. // function formatListToUse(list) {
  472. // list.forEach((item, index) => {
  473. // item.mta_show = false;
  474. // if (item.type == 3) {
  475. // item.result = JSON.parse(item.result);
  476. // item.placeholders = item.result.map((item, cindex) => `[bank${cindex+1}]`)
  477. // item.reply = item.reply ? JSON.parse(item.reply) : item.result.map(() => '');
  478. // }
  479. // if (item.type == 4) {
  480. // // 特殊题型英语题
  481. // const audioList = item.audios ? item.audios.split(',') : [];
  482. // item.placeholders = audioList.map((item, cindex) => `[yingyu${cindex+1}]`)
  483. // item.audioList = audioList;
  484. // }
  485. // })
  486. // }
  487. function onRefresh() {
  488. if (data.current == 0) {
  489. data.shuxue.page = 0;
  490. data.shuxue.list = [];
  491. data.shuxue.loading = true;
  492. } else if (data.current == 1) {
  493. data.yingyu.page = 0;
  494. data.yingyu.list = [];
  495. data.yingyu.loading = true;
  496. }
  497. refreshData(data.current);
  498. }
  499. onLoad(() => {
  500. getMore(data.current);
  501. })
  502. </script>
  503. <style>
  504. </style>