learnRecord.vue 11 KB

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