wangxy 4 miesięcy temu
rodzic
commit
3e7c12646e
2 zmienionych plików z 26 dodań i 9 usunięć
  1. 7 3
      pages/game/index.vue
  2. 19 6
      pages/selectGradesTerms/index.vue

+ 7 - 3
pages/game/index.vue

@@ -7,19 +7,23 @@
 	<!-- 大鹅 4阶段 -->
 	<gooseVue :growth="growth" :growthType="growthType" :progress="progress"></gooseVue>
 	<!-- 食物选择 -->
-	<foodSelectVue :shiwuId="shiwuId" @weishi="onWeiShi"></foodSelectVue>
+	<foodSelectVue ref="foodSelectRef" :shiwuId="shiwuId" @weishi="onWeiShi"></foodSelectVue>
 </template>
 
 <script setup>
-
+	import {ref} from "vue";
 	import foodVue from "./components/food.vue";
 	import gooseVue from "./components/goose.vue";
 	import foodSelectVue from "./components/foodSelect.vue";
 	import { useGame } from "./useGame";
 	const {	credit,growth,growthType,progress,shiwuId ,handleWeishi } = useGame();
 	
+	const foodSelectRef = ref(null);
+	
 	function onWeiShi(data) {
-		handleWeishi(data)
+		handleWeishi(data.id, () => {
+			foodSelectRef.value.handleClose();
+		})
 	}
 </script>
 

+ 19 - 6
pages/selectGradesTerms/index.vue

@@ -2,7 +2,7 @@
 	<view class="grades-terms-page">
 		<view class="icon-title-navBar-box">
 			<!-- 返回按钮↓ -->
-			<view class="nav-bar-icon"></view>
+			<view class="nav-bar-icon"  @click="handleBack"></view>
 		</view>
 		<view class="grades-body">
 			<view class="grades-change-title"></view>
@@ -26,7 +26,8 @@
 <script setup>
 	import {
 		reactive,
-		toRefs
+		toRefs,
+		ref,
 	} from "vue";
 	import {
 		nianji_list,
@@ -37,7 +38,7 @@
 	} from "@dcloudio/uni-app";
 	import {getUserIdentity} from "@/utils/common.js"
 	import cacheManager from "@/utils/cacheManager.js"
-		
+
 	function useSelectGrade() {
 		const userCode = getUserIdentity();
 		const data = reactive({
@@ -66,6 +67,7 @@
 				uni.showToast({
 					title: "请选择年级",
 					duration: 2000,
+					icon: 'error'
 				});
 				return;
 			}
@@ -74,6 +76,7 @@
 				uni.showToast({
 					title: "请选择学科",
 					duration: 2000,
+					icon: 'error'
 				});
 				return;
 			}
@@ -102,10 +105,17 @@
 			}
 
 		}
-
+		function handleBack() {
+			if (userCode !== 'Visitor') {
+				uni.redirectTo({ url: `/pages/study/index`})
+			} else {
+				uni.redirectTo({url: '/pages/login/index'})
+			}
+		}
+		
 		return {
 			...toRefs(data),
-
+			handleBack,
 			// 方法
 			handleConfirm, // 选择年级+学科
 		};
@@ -114,7 +124,8 @@
 	const {
 		activeNianji,
 		activeXueke,
-		handleConfirm
+		handleConfirm,
+		handleBack
 	} = useSelectGrade()
 
 	function handleSelectGrade(item) {
@@ -124,4 +135,6 @@
 	function handleSelectXueke(item) {
 		activeXueke.value = item.id;
 	}
+	
+
 </script>