learnRecord.vue 12 KB

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