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