Browse Source

返回导航

wangxy 4 weeks ago
parent
commit
2de0cb4d25
1 changed files with 45 additions and 1 deletions
  1. 45 1
      components/questions/yuedu.vue

+ 45 - 1
components/questions/yuedu.vue

@@ -30,6 +30,9 @@
 				</template>
 			</swiper-item>
 		</swiper>
+		<view @click="handleRight" :class="{disable: swiperDotIndex == 0}">shang</view>
+		<view @click="handleLeft" :class="{disable: swiperDotIndex == data.content.length-1}">xia</view>
+		<view v-if="showTishi">提示信息</view>
 	</view>
 </template>
 
@@ -37,13 +40,15 @@
 	import {
 		reactive,
 		watch,
-		ref
+		ref,
+		computed
 	} from 'vue';
 	import danxuan from "@/components/questions/danxuan.vue";
 	import duoxuan from "@/components/questions/duoxuan.vue";
 	import tiankong from "@/components/questions/tiankong.vue";
 	import panduan from "@/components/questions/panduan.vue";
 	import jianda from "@/components/questions/jianda.vue";
+import cacheManager from '../../utils/cacheManager';
 	const props = defineProps({
 		question: {
 			type: Object,
@@ -51,6 +56,10 @@
 		showError: {
 			type: Boolean,
 			default: false
+		},
+		showTishixinxi: {
+			type:Boolean,
+			default: false,
 		}
 	})
 	const data = reactive({
@@ -59,6 +68,7 @@
 	const Emits = defineEmits(['yudu-change'])
 
 	const swiperDotIndex = ref(0);
+	const showTishi = ref(false);
 
 	watch(() => props.question, (question) => {
 		const danxuanlist = question.danxuan.forEach(item => item.type = 'danxuan')
@@ -80,8 +90,42 @@
 		immediate: true
 	})
 
+	watch(() => {
+		if (props.showTishixinxi) {
+			if (!cacheManager.get('exam-tishi')) {
+				// 首次考试打开提示信息
+				showTishi.value = true
+			} else {
+				showTishi.value = false
+			}
+		} else {
+			showTishi.value = false
+		}
+	}, {
+		immediate: true
+	})
+
 	function onSwitchChange(e) {
 		console.log('eeee', e.detail,data.content[e.detail.current])
 		Emits('yudu-change', data.content[e.detail.current])
 	}
+	
+	function handleRight() {
+		if (swiperDotIndex.value > 0) {
+			swiperDotIndex.value = swiperDotIndex.value--;
+		}
+	}
+	
+	function handleLeft() {
+		
+		if (props.showTishixinxi) {
+			// 阅读题提示
+			cacheManager.set('exam-tishi', 1)
+			showTishi.value = false
+		}
+		
+		if (swiperDotIndex.value < data.content.length-1) {
+			swiperDotIndex.value = swiperDotIndex.value++;
+		}
+	}
 </script>