Browse Source

修复引导页按接口

1
mo 1 year ago
parent
commit
5066fd835d

+ 39 - 10
src/page-instrument/custom-plugins/guide-page/student-bottom.tsx

@@ -4,6 +4,7 @@ import { defineComponent, nextTick, onMounted, reactive, ref, watch } from "vue"
 import styles from "./index.module.less";
 import { getImage } from "./images";
 import { getQuery } from "/src/utils/queryString";
+import { getGuidance, setGuidance } from "./api";
 
 export default defineComponent({
 	name: "studentB-guide",
@@ -19,7 +20,7 @@ export default defineComponent({
 					img: getImage("studentB1.png"),
 					handStyle: {
 						top: "-1.39rem",
-						left: "1.4rem",
+						left: "1.7rem",
 						transform: "rotate(180deg)",
 					},
 					imgStyle: {
@@ -75,12 +76,35 @@ export default defineComponent({
 		});
 		const tipShow = ref(false);
 		const query: any = getQuery();
-		const guideInfo = localStorage.getItem("guideInfo");
-		if ((guideInfo && JSON.parse(guideInfo).studentB) || !query.showGuide) {
+		// const guideInfo = localStorage.getItem("guideInfo");
+		// if ((guideInfo && JSON.parse(guideInfo).studentB) || !query.showGuide) {
+		// 	tipShow.value = false;
+		// } else {
+		// 	tipShow.value = true;
+		// }
+		const guideInfo = ref({} as any)
+		const getAllGuidance = async()=>{
+		  try{
+		  const res = await getGuidance({guideTag:'guideInfo'})
+		  if(res.data){
+			guideInfo.value = JSON.parse(res.data?.guideValue) || null
+		  }else{
+			guideInfo.value = {}
+		  }
+	  
+	  
+		  if (guideInfo.value && guideInfo.value.studentB || !query.showGuide) {
 			tipShow.value = false;
-		} else {
+		  } else {
 			tipShow.value = true;
+		  }
+		  }catch(e){
+		  console.log(e)
+		  }
+		  // const guideInfo = localStorage.getItem('teacher-guideInfo');
+	  
 		}
+		getAllGuidance()
 		const steps = [ "modeType-0", "modeType-1", "modeType-2"];
 		const getStepELe = () => {
 			console.log(steps[data.step]);
@@ -108,14 +132,19 @@ export default defineComponent({
 			getStepELe();
 		};
 
-		const endGuide = () => {
-			let guideInfo = JSON.parse(localStorage.getItem("guideInfo") || "{}") || null;
-			if (!guideInfo) {
-				guideInfo = { studentB: true };
+		const endGuide = async() => {
+			// let guideInfo = JSON.parse(localStorage.getItem("guideInfo") || "{}") || null;
+			if (!guideInfo.value) {
+				guideInfo.value = { studentB: true };
 			} else {
-				guideInfo.studentB = true;
+				guideInfo.value.studentB = true;
 			}
-			localStorage.setItem("guideInfo", JSON.stringify(guideInfo));
+			// localStorage.setItem("guideInfo", JSON.stringify(guideInfo));
+			try{
+				const res = await setGuidance({guideTag:'guideInfo',guideValue:JSON.stringify(guideInfo.value)})
+			  }catch(e){
+				console.log(e)
+			  }
 			tipShow.value = false;
 			//  localStorage.setItem('endC')
 		};

+ 43 - 12
src/page-instrument/custom-plugins/guide-page/student-top.tsx

@@ -5,6 +5,7 @@ import styles from "./index.module.less";
 import { getImage } from "./images";
 import { useRoute } from "vue-router";
 import { getQuery } from "/src/utils/queryString";
+import { getGuidance, setGuidance } from "./api";
 
 export default defineComponent({
   name: "studnetT-guide",
@@ -169,12 +170,37 @@ export default defineComponent({
     });
     const tipShow = ref(false)
     const query: any = getQuery();
-   const guideInfo = localStorage.getItem('guideInfo')
-   if(guideInfo&&JSON.parse(guideInfo).studnetT || !query.showGuide){
-    tipShow.value =false
-   }else {
-    tipShow.value =true
-   }
+  //  const guideInfo = localStorage.getItem('guideInfo')
+  //  if(guideInfo&&JSON.parse(guideInfo).studnetT || !query.showGuide){
+  //   tipShow.value =false
+  //  }else {
+  //   tipShow.value =true
+  //  }
+
+  const guideInfo = ref({} as any)
+  const getAllGuidance = async()=>{
+    try{
+    const res = await getGuidance({guideTag:'guideInfo'})
+    if(res.data){
+      guideInfo.value = JSON.parse(res.data?.guideValue) || null
+    }else{
+      guideInfo.value = {}
+    }
+
+
+    if (guideInfo.value && guideInfo.value.studnetT || !query.showGuide) {
+      tipShow.value = false;
+    } else {
+      tipShow.value = true;
+    }
+    }catch(e){
+    console.log(e)
+    }
+    // const guideInfo = localStorage.getItem('teacher-guideInfo');
+
+  }
+  getAllGuidance()
+
     const getStepELe = () => {
       console.log(`studnetT${data.step}`)
       const ele: HTMLElement = document.getElementById(`studnetT-${data.step}`)!;
@@ -206,14 +232,19 @@ export default defineComponent({
       getStepELe();
     };
     
-    const endGuide = ()=>{
-      let guideInfo = JSON.parse(localStorage.getItem('guideInfo') || '{}') || null
-      if(!guideInfo){
-        guideInfo = {studnetT:true}
+    const endGuide = async()=>{
+      // let guideInfo = JSON.parse(localStorage.getItem('guideInfo') || '{}') || null
+      if(!guideInfo.value){
+        guideInfo.value = {studnetT:true}
       }else{
-        guideInfo.studnetT = true
+        guideInfo.value.studnetT = true
       }
-      localStorage.setItem('guideInfo',JSON.stringify(guideInfo))
+      // localStorage.setItem('guideInfo',JSON.stringify(guideInfo))
+      try{
+				const res = await setGuidance({guideTag:'guideInfo',guideValue:JSON.stringify(guideInfo.value)})
+			  }catch(e){
+				console.log(e)
+			  }
       tipShow.value = false
     //  localStorage.setItem('endC')
     }