Jelajahi Sumber

调整跳转

wangxy 5 bulan lalu
induk
melakukan
c64d980b15
5 mengubah file dengan 198 tambahan dan 73 penghapusan
  1. 25 0
      api/wrong.js
  2. 6 13
      components/chengji/chengji.vue
  3. 2 2
      pages/login/login.vue
  4. 8 0
      pages/my/index.vue
  5. 157 58
      pages/wrong/index.vue

+ 25 - 0
api/wrong.js

@@ -0,0 +1,25 @@
+import request from '@/utils/request'
+export function getWrongData(data = {}) {
+    return request({
+        'url': '/app/wrong/list',
+        headers: {
+            isToken: true
+        },
+        method: 'post',
+        data,
+        timeout: 20000
+    })
+}
+
+
+export function getWrongInfo(data = {}) {
+    return request({
+        'url': '/app/wrong/info',
+        headers: {
+            isToken: true
+        },
+        method: 'post',
+        data,
+        timeout: 20000
+    })
+}

+ 6 - 13
components/chengji/chengji.vue

@@ -65,18 +65,6 @@
 		list: {
 			type: Array,
 		},
-		jieId: {
-			type: [String, Number]
-		},
-		zhangId: {
-			type: [String, Number]
-		},
-		nianji: {
-			type: [String, Number]
-		},
-		xueqi: {
-			type: [String,Number]
-		}
 	})
 
 	const emits = defineEmits(['back'])
@@ -90,6 +78,10 @@
 		popupRef.value.open()
 	}
 
+  function closePopup() {
+    popupRef.value.close()
+  }
+
 	// 展示
 	function showJiexiPopup(data) {
 		jiexiRef.value.showPopup(data);
@@ -132,6 +124,7 @@
 	}
 
 	defineExpose({
-		showPopup
+		showPopup,
+    closePopup
 	})
 </script>

+ 2 - 2
pages/login/login.vue

@@ -96,12 +96,12 @@
 						// 暂时写死
 						res.data.cardId = 1
 						cacheManager.set('auth',res.data)
-						updateXueke(res.data.nianji,res.data.cardId)
-						if (res.data.nianji == 0 && res.data.cardId == 0 ) {
+						if (res.data.cardId == 0 ) {
 							uni.redirectTo({
 								url: `/pages/selectGradesTerms/index`
 							})
 						} else {
+							updateXueke(res.data.nianji,res.data.cardId)
 							uni.redirectTo({
 								url: `/pages/study/index?nianji=${res.data.nianji}&cardId=${res.data.cardId}&zhangId=${cacheManager.get('auth').zhangId}`
 							})

+ 8 - 0
pages/my/index.vue

@@ -46,8 +46,10 @@
 	import {reactive,ref} from "vue";
 	import { toast } from "../../utils/common";
 	import tipSmallDialog from '@/components/dialog/tipSmallDialog.vue'
+	import {MESSAGE_VISITER_TO_LOGIN} from "@/utils/constant.js"
 	
 	const tipContent = '你确定要执行这个操作吗?'; 
+
 	let loginFlag = ref(false);
 	let myInfoData = reactive({
 		userImg: 'static/images/my/head-unlogin-img.png',
@@ -60,6 +62,12 @@
 	const exitLogin = () => {
 		exitDialogRef.value.handleShow();
 	}
+	const wrongBtn = () => {
+		toast(MESSAGE_VISITER_TO_LOGIN);
+		uni.navigateTo({
+			url: '/pages/login/index'
+		});
+	}
 
 	const exitBtn = () => {
 		cacheManager.clearAll();

+ 157 - 58
pages/wrong/index.vue

@@ -1,69 +1,168 @@
 <template>
 	<view>
-    <uni-section title="实心标签" type="line">
-      <view class="uni-padding-wrap uni-common-mt">
-        <uni-segmented-control :current="data.current" :values="data.items" style-type="button"
-                               active-color="#007aff" @clickItem="onChangeTab" />
-      </view>
-      <view class="content">
-        <view v-if="data.current === 0">
-          <!--数学-->
-          <uni-list>
-            <uni-list-item v-for="item in data.ShuxueList">
-              <template v-slot:body>
-                <view class="slot-box">
-                  {{item}}
-                  <text class="slot-text">title</text>
-                  <text class="slot-text">date</text>
-                  <text class="slot-text">wrong</text>
-                  <button>查看错题</button>
-                </view>
-              </template>
-            </uni-list-item>
-            <uni-load-more :status="data.moreShuxue"></uni-load-more>
-          </uni-list>
-        </view>
-        <view v-if="data.current === 1">
-          <!--英语-->
-          <uni-list>
-            <uni-list-item v-for="item in data.YingyuList">
-              <template v-slot:body>
-                <view class="slot-box">
-                  {{item}}
-                  <text class="slot-text">title</text>
-                  <text class="slot-text">date</text>
-                  <text class="slot-text">wrong</text>
-                  <button>查看错题</button>
-                </view>
-              </template>
-            </uni-list-item>
-            <uni-load-more :status="data.moreYingyu"></uni-load-more>
-          </uni-list>
-        </view>
-      </view>
-    </uni-section>
+		<view class="ezy-navBar-box">
+			<view @click="handleBack" class="nav-bar-icon"></view>
+			<text class="nav-bar-title">我的错题</text>
+		</view>
+		<view class="uni-padding-wrap uni-common-mt">
+			<uni-segmented-control :current="data.current" :values="data.items" style-type="button"
+				active-color="#007aff" @clickItem="onChangeTab" />
+		</view>
+		<view class="content">
+			<view v-if="data.current === 0">
+				<!--数学-->
+				<uni-list>
+					<uni-list-item v-for="item in data.shuxue.list">
+						<template v-slot:body>
+							<view class="slot-box">
+								{{ item }}
+								<text class="slot-text">{{ item.title }}</text>
+								<text class="slot-text">{{ item.date }}</text>
+								<text class="slot-text">错题数:{{ item.count }}题</text>
+								<button @click="getCuotiData(item)">查看错题</button>
+							</view>
+						</template>
+					</uni-list-item>
+					<uni-load-more :status="data.shuxue.state" @click="getMore(0)"></uni-load-more>
+				</uni-list>
+			</view>
+			<view v-if="data.current === 1">
+				<!--英语-->
+				<uni-list>
+					<uni-list-item v-for="item in data.yingyu.list">
+						<template v-slot:body>
+							<view class="slot-box">
+								{{ item }}
+								<text class="slot-text">title</text>
+								<text class="slot-text">date</text>
+								<text class="slot-text">wrong</text>
+								<button>查看错题</button>
+							</view>
+						</template>
+					</uni-list-item>
+					<uni-load-more :status="data.yingyu.state" @click="getMore(1)"></uni-load-more>
+				</uni-list>
+			</view>
+		</view>
+		<cuoti ref="wrongRef" :list="data.wrongList" @back="handleBackFromCuoti"></cuoti>
 	</view>
 </template>
 
 <script setup>
-	import {reactive, computed} from "vue";
+	import {
+		reactive,
+		ref
+	} from "vue";
+	import {
+		getWrongData
+	} from "@/api/wrong";
+	import {
+		onLoad
+	} from "@dcloudio/uni-app";
+	import cuoti from "@/components/chengji/chengji.vue";
+	import {
+		getWrongInfo
+	} from "@/api/wrong";
 
-  const data = reactive({
-    items: ['选项卡1', '选项卡2', '选项卡3'],
-    current: 0,
-    ShuxueList: [],
-    YingyuList: [],
-    moreYingyu: 'more',
-    moreShuxue: 'more'
-  })
+	const wrongRef = ref(null);
 
-  function onChangeTab(e) {
-    if (this.current !== e.currentIndex) {
-      this.current = e.currentIndex
-    }
-  }
+	const data = reactive({
+		items: ['数学', '英语'],
+		current: 0,
+		shuxue: {
+			page: 0,
+			list: [],
+			loading: false,
+			state: 'more',
+		},
+		yingyu: {
+			page: 0,
+			list: [],
+			loading: false,
+			state: 'more',
+		},
+		wrongList: [],
+	})
+
+	function handleBack() {
+		uni.redirectTo({
+			url: '/pages/my/index'
+		})
+	}
+
+	function handleBackFromCuoti() {
+		wrongRef.value.closePopup();
+	}
+
+	function onChangeTab(e) {
+		if (data.current !== e.currentIndex) {
+			data.current = e.currentIndex
+		}
+	}
+
+	function getMore(code) {
+		const opt = {
+			page: 1,
+			size: 10, // 固定查询10条
+		}
+
+		if (code == 0) {
+			if (data.shuxue.state == 'no-more') return;
+			data.shuxue.state = 'loading';
+			// 数学
+			data.shuxue.page++;
+			opt.page = data.shuxue.page;
+		} else if (code == 1) {
+			if (data.yingyu.state == 'no-more') return;
+			data.yingyu.state = 'loading';
+			// 英语
+			data.yingyu.page++;
+			opt.page = data.yingyu.page;
+		}
+		getWrongData(opt).then(res => {
+
+			if (code == 0) {
+				data.shuxue.list.push(res.data);
+			} else if (code == 1) {
+				data.yingyu.list.push(res.data);
+			}
+
+			if (res.data.total * res.data.size >= res.data.length) {
+				if (code == 0) {
+					data.shuxue.state = 'no-more';
+				} else if (code == 1) {
+					data.yingyu.state = 'no-more';
+				}
+			} else {
+				if (code == 0) {
+					data.shuxue.state = 'more';
+				} else if (code == 1) {
+					data.yingyu.state = 'more';
+				}
+			}
+		}).catch(err => {
+			if (code == 0) {
+				data.shuxue.state = 'more';
+			} else if (code == 1) {
+				data.yingyu.state = 'more';
+			}
+		})
+	}
+
+	function getCuotiData(data) {
+		getWrongInfo({
+			id: data.id
+		}).then(res => {
+			data.wrongList = res.data;
+			wrongRef.value.showPopup();
+		})
+	}
+
+	onLoad(() => {
+		getMore(data.current);
+	})
 </script>
 
 <style>
-	       
-</style>
+
+</style>