wangguoyu пре 3 месеци
родитељ
комит
a465f6b3cc
2 измењених фајлова са 153 додато и 96 уклоњено
  1. 11 0
      api/my.js
  2. 142 96
      pages/my/learnRecord.vue

+ 11 - 0
api/my.js

@@ -55,4 +55,15 @@ export function commonCardList(data = {}) {
     data,
     timeout: 20000
   })
+}
+export function myWordList(data = {}) {
+  return request({
+    'url': '/app/user/my/word/list',
+    headers: {
+      isToken: true
+    },
+    method: 'post',
+    data,
+    timeout: 20000
+  })
 }

+ 142 - 96
pages/my/learnRecord.vue

@@ -6,86 +6,122 @@
 		</view>
 		<view class="ezy-tab-border">
 
-			<uni-segmented-control :current="xxjlData.current" :values="xxjlData.items" active-color="#3A7FE9"
+			<uni-segmented-control :current="xxjlData.current -1" :values="xxjlData.items" active-color="#3A7FE9"
 				@clickItem="onChangeTab" class="ezy-tab-box" />
 			<view>
-				<view v-if="xxjlData.current == 0">
+				<view v-if="xxjlData.current == 1">
 					<scroll-view scroll-y="true" refresher-enabled="true" @scrolltolower="onScrolltolower"
 						:refresher-triggered="xxjlData.weizhangwo.loading" :refresher-threshold="50"
-						refresher-background="transparent" @refresherrefresh="onRefresh" class="learn-record-scroll-view">
+						refresher-background="transparent" @refresherrefresh="onRefresh"
+						class="learn-record-scroll-view">
 						<!--数学-->
 						<uni-list>
 							<uni-list-item v-for="(item,index) in xxjlData.weizhangwo.list" :key="index"
 								class="word-list-item">
 								<template v-slot:body>
-									<view class="item-word">
-										<view class="word-text">
-											<text v-for="(word, wordIndex) in item.chaifen" 
-											:key="wordIndex" class="word-color">
-											{{ word }}
-											</text>
+									<view @click="goLearn(item)">
+										<view class="item-word">
+											<view class="word-text">
+												<text v-for="(word, wordIndex) in item.chaifen" :key="wordIndex"
+													class="word-color">
+													{{ word }}
+												</text>
+											</view>
+											<view class="phonetic-alphabet">{{item.yinbiao || ''}}</view>
 										</view>
-										<view class="phonetic-alphabet">{{item.yinbiao || ''}}</view>
-									</view>
-									<view class="item-explain">
-										<view class="item-explain-content">
-											<view class="explain-text" v-for="(meaning, meaningIndex) in item.jianyi" :key="meaningIndex">{{meaning}}</view>
+										<view class="item-explain">
+											<view class="item-explain-content">
+												<view class="explain-text"
+													v-for="(meaning, meaningIndex) in item.jianyi" :key="meaningIndex">
+													{{meaning}}</view>
+											</view>
+										</view>
+										<view class="item-arrow">
+											<icon></icon>
 										</view>
 									</view>
-									<view class="item-arrow"><icon></icon></view>
+
 								</template>
 							</uni-list-item>
-							<uni-load-more :status="xxjlData.weizhangwo.state" @click="getMore(2)"
+							<uni-load-more :status="xxjlData.weizhangwo.state" @click="getMore(1)"
 								:contentText="xxjlData.weizhangwo.contentText">
 							</uni-load-more>
 						</uni-list>
 					</scroll-view>
 				</view>
-				<view v-if="xxjlData.current == 1">
+				<view v-if="xxjlData.current == 2">
 					<scroll-view scroll-y="true" refresher-enabled="true" @scrolltolower="onScrolltolower"
 						:refresher-triggered="xxjlData.yizhangwo.loading" :refresher-threshold="50"
-						refresher-background="transparent" @refresherrefresh="onRefresh" class="learn-record-scroll-view">
+						refresher-background="transparent" @refresherrefresh="onRefresh"
+						class="learn-record-scroll-view">
 						<!--数学-->
 						<uni-list>
 							<uni-list-item v-for="(item,index) in xxjlData.yizhangwo.list" :key="index"
 								class="word-list-item">
 								<template v-slot:body>
-									
+									<view class="item-word">
+										<view @click="goLearn(item)">
+											<view class="word-text">
+												<text v-for="(word, wordIndex) in item.chaifen" :key="wordIndex"
+													class="word-color">
+													{{ word }}
+												</text>
+											</view>
+											<view class="phonetic-alphabet">{{item.yinbiao || ''}}</view>
+										</view>
+										<view class="item-explain">
+											<view class="item-explain-content">
+												<view class="explain-text"
+													v-for="(meaning, meaningIndex) in item.jianyi" :key="meaningIndex">
+													{{meaning}}</view>
+											</view>
+										</view>
+										<view class="item-arrow">
+											<icon></icon>
+										</view>
+									</view>
 								</template>
 							</uni-list-item>
-							<uni-load-more :status="xxjlData.yizhangwo.state" @click="getMore(1)"
+							<uni-load-more :status="xxjlData.yizhangwo.state" @click="getMore(2)"
 								:contentText="xxjlData.yizhangwo.contentText">
 							</uni-load-more>
 						</uni-list>
 					</scroll-view>
 				</view>
-				<view v-if="xxjlData.current == 2">
+				<view v-if="xxjlData.current == 3">
 					<scroll-view scroll-y="true" refresher-enabled="true" @scrolltolower="onScrolltolower"
 						:refresher-triggered="xxjlData.shouchang.loading" :refresher-threshold="50"
-						refresher-background="transparent" @refresherrefresh="onRefresh" class="learn-record-scroll-view">
+						refresher-background="transparent" @refresherrefresh="onRefresh"
+						class="learn-record-scroll-view">
 						<!--数学-->
 						<uni-list>
 							<uni-list-item v-for="(item,index) in xxjlData.shouchang.list" :key="index"
 								class="word-list-item">
 								<template v-slot:body>
-									<view class="item-word">
-										<view class="word-text">
-											<text v-for="(word, wordIndex) in item.chaifen" 
-											:key="wordIndex" class="word-color">
-											{{ word }}
-											</text>
+									<view @click="goLearn(item)">
+										<view class="item-word">
+											<view class="word-text">
+												<text v-for="(word, wordIndex) in item.chaifen" :key="wordIndex"
+													class="word-color">
+													{{ word }}
+												</text>
+											</view>
+											<view class="phonetic-alphabet">{{item.yinbiao || ''}}</view>
 										</view>
-										<view class="phonetic-alphabet">{{item.yinbiao || ''}}</view>
-									</view>
-									<view class="item-explain">
-										<view class="item-explain-content">
-											<view class="explain-text" v-for="(meaning, meaningIndex) in item.jianyi" :key="meaningIndex">{{meaning}}</view>
+										<view class="item-explain">
+											<view class="item-explain-content">
+												<view class="explain-text"
+													v-for="(meaning, meaningIndex) in item.jianyi" :key="meaningIndex">
+													{{meaning}}</view>
+											</view>
+										</view>
+										<view class="item-arrow">
+											<icon></icon>
 										</view>
 									</view>
-									<view class="item-arrow"><icon></icon></view>
 								</template>
 							</uni-list-item>
-							<uni-load-more :status="xxjlData.shouchang.state" @click="getMore(0)"
+							<uni-load-more :status="xxjlData.shouchang.state" @click="getMore(3)"
 								:contentText="xxjlData.shouchang.contentText">
 							</uni-load-more>
 						</uni-list>
@@ -98,13 +134,20 @@
 </template>
 
 <script setup>
-	import {reactive,ref} from "vue";
-	import {getWordList} from "@/api/word.js"
-	import {onLoad} from "@dcloudio/uni-app";
+	import {
+		reactive,
+		ref
+	} from "vue";
+	import {
+		myWordList
+	} from "@/api/my.js"
+	import {
+		onLoad
+	} from "@dcloudio/uni-app";
 	import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';
 	const xxjlData = reactive({
-		items: [ '未掌握', '已掌握', '收藏'],
-		current: 0,
+		items: ['未掌握', '已掌握', '收藏'],
+		current: 1,
 		count: 0, // 总数,默认值设为 0
 		studyCount: 0, // 已学总数,默认值设为 0
 		shouchang: {
@@ -144,19 +187,22 @@
 	})
 
 
+	function goLearn() {
+		console.log('data', 123123);
+	}
 
 	function onChangeTab(e) {
-		if (xxjlData.current !== e.currentIndex) {
-			xxjlData.current = e.currentIndex;
-			if (xxjlData.current == 0) {
-				xxjlData.weizhangwo.page = 0
-			} else if (xxjlData.current == 1) {
-				xxjlData.yizhangwo.page = 0
-			} else if (xxjlData.current == 2) {
-				xxjlData.shouchang.page = 0
-			}
-			refreshData(xxjlData.current);
+		console.log('xxjlData.current', xxjlData.current);
+		console.log(' e.currentIndex', e.currentIndex);
+		xxjlData.current = e.currentIndex + 1;
+		if (xxjlData.current == 1) {
+			xxjlData.weizhangwo.page = 0
+		} else if (xxjlData.current == 2) {
+			xxjlData.yizhangwo.page = 0
+		} else if (xxjlData.current == 3) {
+			xxjlData.shouchang.page = 0
 		}
+		refreshData(xxjlData.current);
 	}
 
 	function onScrolltolower() {
@@ -165,41 +211,41 @@
 
 	function refreshData(code) {
 		const opt = {
-			jieId:"666",
+			type: code
 		}
 
-		if (code == 0) {
+		if (code == 1) {
 			xxjlData.weizhangwo.list = [];
 			// 英语
 			xxjlData.weizhangwo.state = 'loading';
 			xxjlData.weizhangwo.page++;
 			opt.page = xxjlData.weizhangwo.page;
-		} else if (code == 1) {
+		} else if (code == 2) {
 			xxjlData.yizhangwo.list = [];
 			// 英语
 			xxjlData.yizhangwo.state = 'loading';
 			xxjlData.yizhangwo.page++;
 			opt.page = xxjlData.yizhangwo.page;
-		} else if (code == 2) {
+		} else if (code == 3) {
 			xxjlData.shouchang.list = [];
 			// 数学
 			xxjlData.shouchang.state = 'loading';
 			xxjlData.shouchang.page++;
 			opt.page = xxjlData.shouchang.page;
 		}
-		getWordList(opt).then(res => {
-			if (code == 0) {
-				xxjlData.weizhangwo.list = xxjlData.weizhangwo.list.concat(res.data.data);
+		myWordList(opt).then(res => {
+			if (code == 1) {
+				xxjlData.weizhangwo.list = xxjlData.weizhangwo.list.concat(res.data);
 				xxjlData.weizhangwo.loading = false;
-				
-			} else if (code == 1) {
-				xxjlData.yizhangwo.list = xxjlData.yizhangwo.list.concat(res.data.data);
-				xxjlData.yizhangwo.loading = false;
+
 			} else if (code == 2) {
-				xxjlData.shouchang.list = xxjlData.shouchang.list.concat(res.data.data);
+				xxjlData.yizhangwo.list = xxjlData.yizhangwo.list.concat(res.data);
+				xxjlData.yizhangwo.loading = false;
+			} else if (code == 3) {
+				xxjlData.shouchang.list = xxjlData.shouchang.list.concat(res.data);
 				xxjlData.shouchang.loading = false;
 			}
-			if (code == 0) {
+			if (code == 1) {
 				if (res.data.total > xxjlData.weizhangwo.list.length) {
 					// 英语
 					xxjlData.weizhangwo.state = 'more';
@@ -209,7 +255,7 @@
 					xxjlData.weizhangwo.state = 'no-more';
 					xxjlData.weizhangwo.loading = false;
 				}
-			} else if (code == 1) {
+			} else if (code == 2) {
 				if (res.data.total > xxjlData.yizhangwo.list.length) {
 					// 英语
 					xxjlData.yizhangwo.state = 'more';
@@ -219,7 +265,7 @@
 					xxjlData.yizhangwo.state = 'no-more';
 					xxjlData.yizhangwo.loading = false;
 				}
-			} else if (code == 2) {
+			} else if (code == 3) {
 				if (res.data.total > xxjlData.shouchang.list.length) {
 					// 数学
 					xxjlData.shouchang.state = 'more';
@@ -229,16 +275,16 @@
 					xxjlData.shouchang.state = 'no-more';
 					xxjlData.shouchang.loading = false;
 				}
-				
+
 			}
 		}).catch(err => {
-			if (code == 0) {
+			if (code == 1) {
 				xxjlData.weizhangwo.state = 'more';
 				xxjlData.weizhangwo.loading = false;
-			} else if (code == 1) {
+			} else if (code == 2) {
 				xxjlData.yizhangwo.state = 'more';
 				xxjlData.yizhangwo.loading = false;
-			} else if (code == 2) {
+			} else if (code == 3) {
 				xxjlData.shouchang.state = 'more';
 				xxjlData.shouchang.loading = false;
 			}
@@ -246,16 +292,16 @@
 	}
 
 	function onRefresh() {
-		if (xxjlData.current == 0) {
+		if (xxjlData.current == 1) {
 			xxjlData.weizhangwo.page = 0;
 			xxjlData.weizhangwo.list = [];
 			xxjlData.weizhangwo.loading = true;
-			
-		} else if (xxjlData.current == 1) {
+
+		} else if (xxjlData.current == 2) {
 			xxjlData.yizhangwo.page = 0;
 			xxjlData.yizhangwo.list = [];
 			xxjlData.yizhangwo.loading = true;
-		} else if (xxjlData.current == 2) {
+		} else if (xxjlData.current == 3) {
 			xxjlData.shouchang.page = 0;
 			xxjlData.shouchang.list = [];
 			xxjlData.shouchang.loading = true;
@@ -265,25 +311,25 @@
 
 	function getMore(code) {
 		const opt = {
-			jieId:"666",
+			type: code,
 		}
 
-		if (code == 0) {
+		if (code == 1) {
 			if (xxjlData.weizhangwo.state == 'no-more') {
 				return;
 			}
 			xxjlData.weizhangwo.state = 'loading';
 			xxjlData.weizhangwo.page++;
 			opt.page = xxjlData.weizhangwo.page;
-			
-		} else if (code == 1) {
+
+		} else if (code == 2) {
 			if (xxjlData.yizhangwo.state == 'no-more') {
 				return;
 			}
 			xxjlData.yizhangwo.state = 'loading';
 			xxjlData.yizhangwo.page++;
 			opt.page = xxjlData.yizhangwo.page;
-		} else if (code == 2) {
+		} else if (code == 3) {
 			if (xxjlData.shouchang.state == 'no-more') {
 				return;
 			}
@@ -292,18 +338,18 @@
 			xxjlData.shouchang.page++;
 			opt.page = xxjlData.shouchang.page;
 		}
-		getWordList(opt).then(res => {
-			if (code == 0) {
-				xxjlData.weizhangwo.list = res.data.wordList;
+		myWordList(opt).then(res => {
+			if (code == 1) {
+				xxjlData.weizhangwo.list = xxjlData.weizhangwo.list.concat(res.data)
 				xxjlData.weizhangwo.loading = false;
-			} else if (code == 1) {
-				xxjlData.yizhangwo.list = xxjlData.yizhangwo.list.concat(res.data.data);
-				xxjlData.yizhangwo.loading = false;
 			} else if (code == 2) {
-				xxjlData.shouchang.list = xxjlData.shouchang.list.concat(res.data.data);
+				xxjlData.yizhangwo.list = xxjlData.yizhangwo.list.concat(res.data);
+				xxjlData.yizhangwo.loading = false;
+			} else if (code == 3) {
+				xxjlData.shouchang.list = xxjlData.shouchang.list.concat(res.data);
 				xxjlData.shouchang.loading = false;
 			}
-			if (code == 0) {
+			if (code == 1) {
 				if (res.data.total > xxjlData.weizhangwo.list.length) {
 					// 英语
 					xxjlData.weizhangwo.state = 'more';
@@ -313,11 +359,11 @@
 					// 英语
 					xxjlData.weizhangwo.state = 'no-more';
 					xxjlData.weizhangwo.state_text = '没有更多啦';
-				
+
 					xxjlData.weizhangwo.loading = false;
 				}
-				
-			} else if (code == 1) {
+
+			} else if (code == 2) {
 				if (res.data.total > xxjlData.yizhangwo.list.length) {
 					// 英语
 					xxjlData.yizhangwo.state = 'more';
@@ -330,7 +376,7 @@
 					xxjlData.yizhangwo.state_text = '没有更多啦';
 					xxjlData.yizhangwo.loading = false;
 				}
-			} else if (code == 2) {
+			} else if (code == 3) {
 				if (res.data.total > xxjlData.shouchang.list.length) {
 					// 数学
 					xxjlData.shouchang.state = 'more';
@@ -340,20 +386,20 @@
 					// 数学
 					xxjlData.shouchang.state = 'no-more';
 					xxjlData.shouchang.state_text = '没有更多啦';
-				
+
 					xxjlData.shouchang.loading = false;
 				}
 			}
 		}).catch(err => {
-			if (code == 0) {
+			if (code == 1) {
 				xxjlData.weizhangwo.state = 'more';
 				xxjlData.weizhangwo.state_text = '加载更多';
 				xxjlData.weizhangwo.loading = false;
-			} else if (code == 1) {
+			} else if (code == 2) {
 				xxjlData.yizhangwo.state = 'more';
 				xxjlData.yizhangwo.state_text = '加载更多';
 				xxjlData.yizhangwo.loading = false;
-			} else if (code == 2) {
+			} else if (code == 3) {
 				xxjlData.shouchang.state = 'more';
 				xxjlData.shouchang.state_text = '加载更多';
 				xxjlData.shouchang.loading = false;
@@ -366,9 +412,9 @@
 			url: '/pages/my/index'
 		})
 	}
-	
+
 	onLoad((options) => {
-		xxjlData.current = Number(options.status) || xxjlData.current
+		xxjlData.current = xxjlData.current
 		getMore(xxjlData.current);
 	})
 </script>