learnRecord.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  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. page: 1,
  206. size: 10, // 固定查询10条
  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.data);
  230. xxjlData.weizhangwo.loading = false;
  231. } else if (code == 2) {
  232. xxjlData.yizhangwo.list = xxjlData.yizhangwo.list.concat(res.data.data);
  233. xxjlData.yizhangwo.loading = false;
  234. } else if (code == 3) {
  235. xxjlData.shouchang.list = xxjlData.shouchang.list.concat(res.data.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. page: 1,
  301. size: 10, // 固定查询10条
  302. type: code,
  303. }
  304. if (code == 1) {
  305. if (xxjlData.weizhangwo.state == 'no-more') {
  306. return;
  307. }
  308. xxjlData.weizhangwo.state = 'loading';
  309. xxjlData.weizhangwo.page++;
  310. opt.page = xxjlData.weizhangwo.page;
  311. } else if (code == 2) {
  312. if (xxjlData.yizhangwo.state == 'no-more') {
  313. return;
  314. }
  315. xxjlData.yizhangwo.state = 'loading';
  316. xxjlData.yizhangwo.page++;
  317. opt.page = xxjlData.yizhangwo.page;
  318. } else if (code == 3) {
  319. if (xxjlData.shouchang.state == 'no-more') {
  320. return;
  321. }
  322. // 数学
  323. xxjlData.shouchang.state = 'loading';
  324. xxjlData.shouchang.page++;
  325. opt.page = xxjlData.shouchang.page;
  326. }
  327. myWordList(opt).then(res => {
  328. if (code == 1) {
  329. xxjlData.weizhangwo.list = xxjlData.weizhangwo.list.concat(res.data.data)
  330. xxjlData.weizhangwo.loading = false;
  331. } else if (code == 2) {
  332. xxjlData.yizhangwo.list = xxjlData.yizhangwo.list.concat(res.data.data);
  333. xxjlData.yizhangwo.loading = false;
  334. } else if (code == 3) {
  335. xxjlData.shouchang.list = xxjlData.shouchang.list.concat(res.data.data);
  336. xxjlData.shouchang.loading = false;
  337. }
  338. if (code == 1) {
  339. if (res.data.total > xxjlData.weizhangwo.list.length) {
  340. // 英语
  341. xxjlData.weizhangwo.state = 'more';
  342. xxjlData.weizhangwo.state_text = '加载更多';
  343. xxjlData.weizhangwo.loading = false;
  344. } else {
  345. // 英语
  346. xxjlData.weizhangwo.state = 'no-more';
  347. xxjlData.weizhangwo.state_text = '没有更多啦';
  348. xxjlData.weizhangwo.loading = false;
  349. }
  350. } else if (code == 2) {
  351. if (res.data.total > xxjlData.yizhangwo.list.length) {
  352. // 英语
  353. xxjlData.yizhangwo.state = 'more';
  354. xxjlData.yizhangwo.state_text = '加载更多';
  355. xxjlData.yizhangwo.loading = false;
  356. } else {
  357. // 英语
  358. xxjlData.yizhangwo.state = 'no-more';
  359. xxjlData.yizhangwo.state_text = '没有更多啦';
  360. xxjlData.yizhangwo.loading = false;
  361. }
  362. } else if (code == 3) {
  363. if (res.data.total > xxjlData.shouchang.list.length) {
  364. // 数学
  365. xxjlData.shouchang.state = 'more';
  366. xxjlData.shouchang.state_text = '加载更多';
  367. xxjlData.shouchang.loading = false;
  368. } else {
  369. // 数学
  370. xxjlData.shouchang.state = 'no-more';
  371. xxjlData.shouchang.state_text = '没有更多啦';
  372. xxjlData.shouchang.loading = false;
  373. }
  374. }
  375. }).catch(err => {
  376. if (code == 1) {
  377. xxjlData.weizhangwo.state = 'more';
  378. xxjlData.weizhangwo.state_text = '加载更多';
  379. xxjlData.weizhangwo.loading = false;
  380. } else if (code == 2) {
  381. xxjlData.yizhangwo.state = 'more';
  382. xxjlData.yizhangwo.state_text = '加载更多';
  383. xxjlData.yizhangwo.loading = false;
  384. } else if (code == 3) {
  385. xxjlData.shouchang.state = 'more';
  386. xxjlData.shouchang.state_text = '加载更多';
  387. xxjlData.shouchang.loading = false;
  388. }
  389. })
  390. }
  391. function goBack() {
  392. uni.redirectTo({
  393. url: '/pages/my/index'
  394. })
  395. }
  396. onLoad((options) => {
  397. xxjlData.current = Number(options.isLearnStatus) || xxjlData.current
  398. getMore(xxjlData.current);
  399. })
  400. </script>
  401. <style>
  402. </style>