learnRecord.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. <template>
  2. <view class="learn-record-page">
  3. <view class="icon-title-navBar-box">
  4. <view @click="goBack" 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="xxjlData.current -1" :values="xxjlData.items" active-color="#3A7FE9"
  9. @clickItem="onChangeTab" class="ezy-tab-box" />
  10. <view>
  11. <view v-if="xxjlData.current == 1">
  12. <scroll-view scroll-y="true" refresher-enabled="true" @scrolltolower="onScrolltolower"
  13. :refresher-triggered="xxjlData.weizhangwo.loading" :refresher-threshold="50"
  14. refresher-background="transparent" @refresherrefresh="onRefresh"
  15. class="learn-record-scroll-view">
  16. <!--数学-->
  17. <uni-list>
  18. <uni-list-item v-for="(item,index) in xxjlData.weizhangwo.list" :key="index" class="word-item-box">
  19. <template v-slot:body>
  20. <view @click="goLearn(item)" class="word-list-item">
  21. <view class="item-word">
  22. <view class="word-text">
  23. <text v-for="(word, wordIndex) in item.chaifen" :key="wordIndex"
  24. class="word-color">
  25. {{ word }}
  26. </text>
  27. </view>
  28. <view class="phonetic-alphabet">{{item.yinbiao || ''}}</view>
  29. </view>
  30. <view class="item-explain">
  31. <view class="item-explain-content">
  32. <view class="explain-text"
  33. v-for="(meaning, meaningIndex) in item.jianyi" :key="meaningIndex">
  34. {{meaning}}</view>
  35. </view>
  36. </view>
  37. <view class="item-arrow">
  38. <icon></icon>
  39. </view>
  40. </view>
  41. </template>
  42. </uni-list-item>
  43. <uni-load-more :status="xxjlData.weizhangwo.state" @click="getMore(1)"
  44. :contentText="xxjlData.weizhangwo.contentText">
  45. </uni-load-more>
  46. </uni-list>
  47. </scroll-view>
  48. </view>
  49. <view v-if="xxjlData.current == 2">
  50. <scroll-view scroll-y="true" refresher-enabled="true" @scrolltolower="onScrolltolower"
  51. :refresher-triggered="xxjlData.yizhangwo.loading" :refresher-threshold="50"
  52. refresher-background="transparent" @refresherrefresh="onRefresh"
  53. class="learn-record-scroll-view">
  54. <!--数学-->
  55. <uni-list>
  56. <uni-list-item v-for="(item,index) in xxjlData.yizhangwo.list" :key="index"
  57. class="word-list-item">
  58. <template v-slot:body>
  59. <view class="item-word">
  60. <view @click="goLearn(item)">
  61. <view class="word-text">
  62. <text v-for="(word, wordIndex) in item.chaifen" :key="wordIndex"
  63. class="word-color">
  64. {{ word }}
  65. </text>
  66. </view>
  67. <view class="phonetic-alphabet">{{item.yinbiao || ''}}</view>
  68. </view>
  69. <view class="item-explain">
  70. <view class="item-explain-content">
  71. <view class="explain-text"
  72. v-for="(meaning, meaningIndex) in item.jianyi" :key="meaningIndex">
  73. {{meaning}}</view>
  74. </view>
  75. </view>
  76. <view class="item-arrow">
  77. <icon></icon>
  78. </view>
  79. </view>
  80. </template>
  81. </uni-list-item>
  82. <uni-load-more :status="xxjlData.yizhangwo.state" @click="getMore(2)"
  83. :contentText="xxjlData.yizhangwo.contentText">
  84. </uni-load-more>
  85. </uni-list>
  86. </scroll-view>
  87. </view>
  88. <view v-if="xxjlData.current == 3">
  89. <scroll-view scroll-y="true" refresher-enabled="true" @scrolltolower="onScrolltolower"
  90. :refresher-triggered="xxjlData.shouchang.loading" :refresher-threshold="50"
  91. refresher-background="transparent" @refresherrefresh="onRefresh"
  92. class="learn-record-scroll-view">
  93. <!--数学-->
  94. <uni-list>
  95. <uni-list-item v-for="(item,index) in xxjlData.shouchang.list" :key="index"
  96. class="word-list-item">
  97. <template v-slot:body>
  98. <view @click="goLearn(item)">
  99. <view class="item-word">
  100. <view class="word-text">
  101. <text v-for="(word, wordIndex) in item.chaifen" :key="wordIndex"
  102. class="word-color">
  103. {{ word }}
  104. </text>
  105. </view>
  106. <view class="phonetic-alphabet">{{item.yinbiao || ''}}</view>
  107. </view>
  108. <view class="item-explain">
  109. <view class="item-explain-content">
  110. <view class="explain-text"
  111. v-for="(meaning, meaningIndex) in item.jianyi" :key="meaningIndex">
  112. {{meaning}}</view>
  113. </view>
  114. </view>
  115. <view class="item-arrow">
  116. <icon></icon>
  117. </view>
  118. </view>
  119. </template>
  120. </uni-list-item>
  121. <uni-load-more :status="xxjlData.shouchang.state" @click="getMore(3)"
  122. :contentText="xxjlData.shouchang.contentText">
  123. </uni-load-more>
  124. </uni-list>
  125. </scroll-view>
  126. </view>
  127. </view>
  128. </view>
  129. <CustomTabBar></CustomTabBar>
  130. </view>
  131. </template>
  132. <script setup>
  133. import {
  134. reactive,
  135. ref
  136. } from "vue";
  137. import {
  138. myWordList
  139. } from "@/api/my.js"
  140. import {
  141. onLoad
  142. } from "@dcloudio/uni-app";
  143. import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';
  144. const xxjlData = reactive({
  145. items: ['未掌握', '已掌握', '收藏'],
  146. current: 1,
  147. count: 0, // 总数,默认值设为 0
  148. studyCount: 0, // 已学总数,默认值设为 0
  149. shouchang: {
  150. page: 0,
  151. list: [],
  152. loading: false,
  153. state: 'more',
  154. contentText: {
  155. contentdown: '查看更多',
  156. contentrefresh: '加载中',
  157. contentnomore: '没有更多'
  158. }
  159. },
  160. yizhangwo: {
  161. page: 0,
  162. list: [],
  163. loading: false,
  164. state: 'more',
  165. contentText: {
  166. contentdown: '查看更多',
  167. contentrefresh: '加载中',
  168. contentnomore: '没有更多'
  169. }
  170. },
  171. weizhangwo: {
  172. page: 0,
  173. list: [],
  174. loading: false,
  175. state: 'more',
  176. contentText: {
  177. contentdown: '查看更多',
  178. contentrefresh: '加载中',
  179. contentnomore: '没有更多'
  180. }
  181. },
  182. })
  183. function goLearn(data) {
  184. uni.redirectTo({
  185. url: `/pages/newEnglish/index?jieId=0&wordId=${data.id}&isLearnStatus=${xxjlData.current}`
  186. })
  187. }
  188. function onChangeTab(e) {
  189. console.log('xxjlData.current', xxjlData.current);
  190. console.log(' e.currentIndex', e.currentIndex);
  191. xxjlData.current = e.currentIndex + 1;
  192. if (xxjlData.current == 1) {
  193. xxjlData.weizhangwo.page = 0
  194. } else if (xxjlData.current == 2) {
  195. xxjlData.yizhangwo.page = 0
  196. } else if (xxjlData.current == 3) {
  197. xxjlData.shouchang.page = 0
  198. }
  199. refreshData(xxjlData.current);
  200. }
  201. function onScrolltolower() {
  202. getMore(xxjlData.current)
  203. }
  204. function refreshData(code) {
  205. const opt = {
  206. type: code
  207. }
  208. if (code == 1) {
  209. xxjlData.weizhangwo.list = [];
  210. // 英语
  211. xxjlData.weizhangwo.state = 'loading';
  212. xxjlData.weizhangwo.page++;
  213. opt.page = xxjlData.weizhangwo.page;
  214. } else if (code == 2) {
  215. xxjlData.yizhangwo.list = [];
  216. // 英语
  217. xxjlData.yizhangwo.state = 'loading';
  218. xxjlData.yizhangwo.page++;
  219. opt.page = xxjlData.yizhangwo.page;
  220. } else if (code == 3) {
  221. xxjlData.shouchang.list = [];
  222. // 数学
  223. xxjlData.shouchang.state = 'loading';
  224. xxjlData.shouchang.page++;
  225. opt.page = xxjlData.shouchang.page;
  226. }
  227. myWordList(opt).then(res => {
  228. if (code == 1) {
  229. xxjlData.weizhangwo.list = xxjlData.weizhangwo.list.concat(res.data);
  230. xxjlData.weizhangwo.loading = false;
  231. } else if (code == 2) {
  232. xxjlData.yizhangwo.list = xxjlData.yizhangwo.list.concat(res.data);
  233. xxjlData.yizhangwo.loading = false;
  234. } else if (code == 3) {
  235. xxjlData.shouchang.list = xxjlData.shouchang.list.concat(res.data);
  236. xxjlData.shouchang.loading = false;
  237. }
  238. if (code == 1) {
  239. if (res.data.total > xxjlData.weizhangwo.list.length) {
  240. // 英语
  241. xxjlData.weizhangwo.state = 'more';
  242. xxjlData.weizhangwo.loading = false;
  243. } else {
  244. // 英语
  245. xxjlData.weizhangwo.state = 'no-more';
  246. xxjlData.weizhangwo.loading = false;
  247. }
  248. } else if (code == 2) {
  249. if (res.data.total > xxjlData.yizhangwo.list.length) {
  250. // 英语
  251. xxjlData.yizhangwo.state = 'more';
  252. xxjlData.yizhangwo.loading = false;
  253. } else {
  254. // 英语
  255. xxjlData.yizhangwo.state = 'no-more';
  256. xxjlData.yizhangwo.loading = false;
  257. }
  258. } else if (code == 3) {
  259. if (res.data.total > xxjlData.shouchang.list.length) {
  260. // 数学
  261. xxjlData.shouchang.state = 'more';
  262. xxjlData.shouchang.loading = false;
  263. } else {
  264. // 数学
  265. xxjlData.shouchang.state = 'no-more';
  266. xxjlData.shouchang.loading = false;
  267. }
  268. }
  269. }).catch(err => {
  270. if (code == 1) {
  271. xxjlData.weizhangwo.state = 'more';
  272. xxjlData.weizhangwo.loading = false;
  273. } else if (code == 2) {
  274. xxjlData.yizhangwo.state = 'more';
  275. xxjlData.yizhangwo.loading = false;
  276. } else if (code == 3) {
  277. xxjlData.shouchang.state = 'more';
  278. xxjlData.shouchang.loading = false;
  279. }
  280. })
  281. }
  282. function onRefresh() {
  283. if (xxjlData.current == 1) {
  284. xxjlData.weizhangwo.page = 0;
  285. xxjlData.weizhangwo.list = [];
  286. xxjlData.weizhangwo.loading = true;
  287. } else if (xxjlData.current == 2) {
  288. xxjlData.yizhangwo.page = 0;
  289. xxjlData.yizhangwo.list = [];
  290. xxjlData.yizhangwo.loading = true;
  291. } else if (xxjlData.current == 3) {
  292. xxjlData.shouchang.page = 0;
  293. xxjlData.shouchang.list = [];
  294. xxjlData.shouchang.loading = true;
  295. }
  296. refreshData(xxjlData.current);
  297. }
  298. function getMore(code) {
  299. const opt = {
  300. type: code,
  301. }
  302. if (code == 1) {
  303. if (xxjlData.weizhangwo.state == 'no-more') {
  304. return;
  305. }
  306. xxjlData.weizhangwo.state = 'loading';
  307. xxjlData.weizhangwo.page++;
  308. opt.page = xxjlData.weizhangwo.page;
  309. } else if (code == 2) {
  310. if (xxjlData.yizhangwo.state == 'no-more') {
  311. return;
  312. }
  313. xxjlData.yizhangwo.state = 'loading';
  314. xxjlData.yizhangwo.page++;
  315. opt.page = xxjlData.yizhangwo.page;
  316. } else if (code == 3) {
  317. if (xxjlData.shouchang.state == 'no-more') {
  318. return;
  319. }
  320. // 数学
  321. xxjlData.shouchang.state = 'loading';
  322. xxjlData.shouchang.page++;
  323. opt.page = xxjlData.shouchang.page;
  324. }
  325. myWordList(opt).then(res => {
  326. if (code == 1) {
  327. xxjlData.weizhangwo.list = xxjlData.weizhangwo.list.concat(res.data)
  328. xxjlData.weizhangwo.loading = false;
  329. } else if (code == 2) {
  330. xxjlData.yizhangwo.list = xxjlData.yizhangwo.list.concat(res.data);
  331. xxjlData.yizhangwo.loading = false;
  332. } else if (code == 3) {
  333. xxjlData.shouchang.list = xxjlData.shouchang.list.concat(res.data);
  334. xxjlData.shouchang.loading = false;
  335. }
  336. if (code == 1) {
  337. if (res.data.total > xxjlData.weizhangwo.list.length) {
  338. // 英语
  339. xxjlData.weizhangwo.state = 'more';
  340. xxjlData.weizhangwo.state_text = '加载更多';
  341. xxjlData.weizhangwo.loading = false;
  342. } else {
  343. // 英语
  344. xxjlData.weizhangwo.state = 'no-more';
  345. xxjlData.weizhangwo.state_text = '没有更多啦';
  346. xxjlData.weizhangwo.loading = false;
  347. }
  348. } else if (code == 2) {
  349. if (res.data.total > xxjlData.yizhangwo.list.length) {
  350. // 英语
  351. xxjlData.yizhangwo.state = 'more';
  352. xxjlData.yizhangwo.state_text = '加载更多';
  353. xxjlData.yizhangwo.loading = false;
  354. } else {
  355. // 英语
  356. xxjlData.yizhangwo.state = 'no-more';
  357. xxjlData.yizhangwo.state_text = '没有更多啦';
  358. xxjlData.yizhangwo.loading = false;
  359. }
  360. } else if (code == 3) {
  361. if (res.data.total > xxjlData.shouchang.list.length) {
  362. // 数学
  363. xxjlData.shouchang.state = 'more';
  364. xxjlData.shouchang.state_text = '加载更多';
  365. xxjlData.shouchang.loading = false;
  366. } else {
  367. // 数学
  368. xxjlData.shouchang.state = 'no-more';
  369. xxjlData.shouchang.state_text = '没有更多啦';
  370. xxjlData.shouchang.loading = false;
  371. }
  372. }
  373. }).catch(err => {
  374. if (code == 1) {
  375. xxjlData.weizhangwo.state = 'more';
  376. xxjlData.weizhangwo.state_text = '加载更多';
  377. xxjlData.weizhangwo.loading = false;
  378. } else if (code == 2) {
  379. xxjlData.yizhangwo.state = 'more';
  380. xxjlData.yizhangwo.state_text = '加载更多';
  381. xxjlData.yizhangwo.loading = false;
  382. } else if (code == 3) {
  383. xxjlData.shouchang.state = 'more';
  384. xxjlData.shouchang.state_text = '加载更多';
  385. xxjlData.shouchang.loading = false;
  386. }
  387. })
  388. }
  389. function goBack() {
  390. uni.redirectTo({
  391. url: '/pages/my/index'
  392. })
  393. }
  394. onLoad((options) => {
  395. xxjlData.current = Number(options.isLearnStatus) || xxjlData.current
  396. getMore(xxjlData.current);
  397. })
  398. </script>
  399. <style>
  400. </style>