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"
  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() {
  184. console.log('data', 123123);
  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 = xxjlData.current
  394. getMore(xxjlData.current);
  395. })
  396. </script>
  397. <style>
  398. </style>