浏览代码

Merge branch '2024鹅状元' of https://gogs.mtavip.com/wangguoyu/uniProject into 2024鹅状元

tanxue 6 月之前
父节点
当前提交
c1b4f24f9b

+ 10 - 5
components/catalogue/catalogue.vue

@@ -27,6 +27,7 @@
 				</uni-collapse-item>
 			</uni-collapse>
 			<tip-small-dialog ref="confirmDialogRef" @confirm-btn="handleConfirmPay" :content="Message"></tip-small-dialog>
+			<tip-middle-dialog ref="youkeDialogRef" @confirm-btn="ykConfirm" :content="MESSAGE_VISITER_TO_LOGIN"></tip-middle-dialog>
 		</view>
 	</uni-popup>
 </template>
@@ -44,7 +45,7 @@
 	import {getUserIdentity} from "@/utils/common.js"
 	import {MESSAGE_VISITER_TO_LOGIN,MESSAGE_BEFORE_PAY} from "@/utils/constant.js"
     import tipSmallDialog from '@/components/dialog/tipSmallDialog.vue'
-	
+	import tipMiddleDialog from '@/components/dialog/tipMiddleDialog.vue';
 
 	const $emit = defineEmits(['change-zhang'])
 
@@ -56,6 +57,13 @@
 	const activeCollapse = ref('');
 	const Message = MESSAGE_BEFORE_PAY;
 	const AuthCode = getUserIdentity(); // 用户身份
+	const youkeDialogRef = ref(null);
+
+	function ykConfirm() {
+		uni.redirectTo({
+			url: '/pages/login/index'
+		});
+	}
 
 	/**
 	 * @summary 展示弹窗 暴露函数
@@ -97,10 +105,7 @@
 	function handleSelectZhang(data,index) {
 		if(index !=0 && AuthCode == 'Visitor'){
 			// 游客
-			toast(MESSAGE_VISITER_TO_LOGIN)
-			uni.redirectTo({
-				url: '/pages/login/index'
-			})
+			youkeDialogRef.value.handleShow();
 			return;
 		}
 

+ 2 - 2
components/question/FillItem.vue

@@ -1,7 +1,7 @@
 <template>
 	<uni-popup background-color="#fff" ref="fillRef">
 		<view class="popup-content">
-			<input v-model.trim="result"  style="width: 100%" @blur="onBlur" type="text" class="input-box" />
+			<input v-model.trim="result" :focus="true" placeholder="请输入答案" style="width: 100%" @blur="onBlur" type="text" class="input-box" />
 		</view>
 	</uni-popup>
 </template>
@@ -39,6 +39,6 @@
 
 <style lang="scss" scoped>
 .popup-content {
-	padding: 10px;
+	padding: 20px;
 }
 </style>

+ 24 - 5
components/question/tiankong.vue

@@ -1,12 +1,14 @@
 <template>
-	<div class="fill-in-the-blank">
+	<view class="fill-in-the-blank">
 		<!-- 显示填空后的文本 -->
-		<view class="formatted-text" v-html="formattedText" :question="question" :change:question="TK.watchQuestionChange"></view>
+		<view class="formatted-text" v-html="formattedText" :question="question" :myflag="myflag"
+			:change:myflag="TK.updateFlag" :change:question="TK.watchQuestionChange"></view>
 		<!-- 提供与占位符数量相匹配的输入框 -->
 		<template v-for="(placeholder, index) in placeholders" :key="index">
 			<FillItem :value="question.reply[index]" :ref="`popup${index}Ref`" :index="index" @blur="onBlur"></FillItem>
 		</template>
-	</div>
+
+	</view>
 </template>
 
 <script>
@@ -28,6 +30,11 @@
 				default: false
 			}
 		},
+		data() {
+			return {
+				myflag: 0
+			}
+		},
 		computed: {
 			// 计算属性,用于生成填空后的文本
 			formattedText() {
@@ -54,6 +61,7 @@
 
 					}
 				});
+				this.myflag++;
 				return result;
 			},
 		},
@@ -71,7 +79,6 @@
 					result
 				} = data;
 
-				this.question.reply[index] = result;
 				this.setResult(data);
 			},
 			showPopup(str) {
@@ -83,19 +90,31 @@
 
 <script module="TK" lang="renderjs">
 	export default {
+		data() {
+			return {
+				myQ: null
+			}
+		},
 		methods: {
+			updateFlag() {
+				this.initListener(this.myQ)
+			},
 			updateFn(e) {
 				const str = `popup${e.target.dataset.index}Ref`;
-				this.$ownerInstance.callMethod('showPopup',str)
+				this.$ownerInstance.callMethod('showPopup', str);
 			},
 
 			watchQuestionChange(newValue, oldValue, ownerInstance, instance) {
 				if (newValue) {
+					this.myQ = newValue;
 					this.initListener(newValue)
 				}
 			},
 
 			initListener(question) {
+				if (!question) {
+					return;
+				}
 				question.result.forEach((item, index) => {
 					const dom = document.getElementById(`t_${question.stId}_${index}`)
 					dom && dom.addEventListener('focus', (e) => this.updateFn(e))

+ 2 - 6
pages/my/index.vue

@@ -41,7 +41,7 @@
 		</view>
 		<CustomTabBar :cardId="cardId" :nianji="nianji" :zhangId="zhangId"></CustomTabBar>
 		<tip-small-dialog ref="exitDialogRef" @confirm-btn="exitBtn" :content="tipContent"></tip-small-dialog>
-		<tip-middle-dialog ref="youkeDialogRef" @confirm-btn="ykConfirm" :content="YouKeContent"></tip-middle-dialog>
+		<tip-middle-dialog ref="youkeDialogRef" @confirm-btn="ykConfirm" :content="MESSAGE_VISITER_TO_LOGIN"></tip-middle-dialog>
 		<tel-dialog @telClose="telClose" @bindBtn="bindBtn" v-if="telDialogFlag"></tel-dialog>
 	</view>
 </template>
@@ -63,7 +63,6 @@
 	const nianji = ref(null);
 	const cardId = ref(null);
 	const tipContent = '你确定要执行这个操作吗?'; 
-	const YouKeContent = '您当前是游客身份,登录后才能浏览内容,现在去登录?';
 	let hyqyData = reactive({
 			indicatorDots: true,
 			autoplay: true,
@@ -271,10 +270,7 @@
 	if(loginFlag.value){
 		const AuthCode = getUserIdentity();
 		if (AuthCode == 'Visitor') {
-			toast(MESSAGE_VISITER_TO_LOGIN);
-			uni.navigateTo({
-				url: '/pages/login/index'
-			});
+			youkeDialogRef.value.handleShow();
 			return;
 		}  
 		uni.redirectTo({

+ 2 - 0
pages/study/eggDialog.vue

@@ -13,6 +13,7 @@
 
 <script setup>
 	import { ref } from 'vue';
+	 const $emit = defineEmits(['eggBtn'])
 	const eggPopup = ref(null); // 索引
 	// 打开弹窗
 	function eggShow() {
@@ -21,6 +22,7 @@
 	// 开启提分之旅按钮
 	function eggBtn(){
 		eggPopup.value.close();
+		$emit('eggBtn')
 	}
 	defineExpose({
 			eggShow

+ 13 - 9
pages/study/index.vue

@@ -23,6 +23,7 @@
 	import {
 		reactive,
 		ref,
+		nextTick,
 		getCurrentInstance,
 		onMounted
 	} from "vue";
@@ -47,7 +48,7 @@
 	} from "@/utils/common";
 	import cacheManager from "@/utils/cacheManager.js";
 	const tipContent = '付费章节,是否前往开通付费?'; //当前产品
-	const goPayDialogRef = ref(null);
+	const goPayDialogRef = ref(null);
 	const youkeDialogRef = ref(null);
 	const eggDialogRef = ref(null);
 	const YouKeContent = '您当前是游客身份,登录后才能浏览内容,现在去登录?';
@@ -80,6 +81,9 @@
 			// 已登录
 			// 选择年级进入调用此接口
 			//options.flag == 'selectGrades'
+			nextTick(() => {
+				eggDialogRef.value.eggShow();
+			})
 			getZhangInfo()
 			// 蛋
 			// eggDialogRef.value.eggShow();
@@ -142,10 +146,10 @@
 
 
 
-	function onLeft(event) {
-		const authCode = getUserIdentity();
-		if (authCode !== 'VIP') {
-			return false
+	function onLeft(event) {
+		const authCode = getUserIdentity();
+		if (authCode !== 'VIP') {
+			return false
 		}
 		console.log('用户左滑了');
 		let req = {
@@ -168,10 +172,10 @@
 		})
 	}
 
-	function onRight(event) {
-		const authCode = getUserIdentity();
-		if (authCode !== 'VIP') {
-			return false
+	function onRight(event) {
+		const authCode = getUserIdentity();
+		if (authCode !== 'VIP') {
+			return false
 		}
 		console.log('用户又滑了');
 		let req = {

+ 3 - 3
pages/unitTest/index.vue

@@ -5,7 +5,6 @@
 			<text class="nav-bar-title">单元测试</text>
 			<view class="nav-bar-other"><text class="key-note">{{count}}</text>/<text>{{total}}</text></view>
 		</view>
-		
 		<view class="shiti-frame-box">
 			<w-swiper :list="list" :current="current" class="ezy-exam-swiper" @change="onSwiperChange">
 				<template v-slot:default="{item}">
@@ -51,8 +50,8 @@
 	import {
 		ref,
 	} from "vue";
-  import cacheManager from "@/utils/cacheManager";
-
+    import cacheManager from "@/utils/cacheManager";
+  
 	const {
 		count,
 		total,
@@ -74,6 +73,7 @@
 
 	const uniPointsRef = ref(null);
 	const chengjiRef = ref(null);
+	const popupRef = ref(null);
 
 	// 查看答案
 	function checkAnswer() {

+ 57 - 28
pages/unitTest/useUnit.js

@@ -8,15 +8,18 @@ import {
 	computed,
 	toRefs,
 	onMounted,
-	watch
+	watch,
+	nextTick
 } from "vue";
 import {
 	catchError,
 	toast
 } from "@/utils/common.js"
 import * as httpUnit from "@/api/unitTest.js"
-import cacheManager, {useUnitTestTishi} from "@/utils/cacheManager.js"
-	
+import cacheManager, {
+	useUnitTestTishi
+} from "@/utils/cacheManager.js"
+
 
 function useJifen() {
 	const data = reactive({
@@ -25,12 +28,16 @@ function useJifen() {
 		jifen: 0, // 积分
 	})
 
-	function updateJifen({rightAnswer,wrongAnswer,jifen}) {
+	function updateJifen({
+		rightAnswer,
+		wrongAnswer,
+		jifen
+	}) {
 		data.rightAnswer = rightAnswer;
 		data.wrongAnswer = wrongAnswer;
 		data.jifen = jifen;
 	}
-	
+
 	return {
 		...toRefs(data),
 		updateJifen
@@ -40,10 +47,19 @@ function useJifen() {
 export function useExam() {
 	// 缓存
 
-	const {	showTishi, handleCloseTishi, handleShowTishi} = useTishiLeftRight()
-	const {rightAnswer,wrongAnswer,jifen, updateJifen} = useJifen();
+	const {
+		showTishi,
+		handleCloseTishi,
+		handleShowTishi
+	} = useTishiLeftRight()
+	const {
+		rightAnswer,
+		wrongAnswer,
+		jifen,
+		updateJifen
+	} = useJifen();
+
 
-	
 	const data = reactive({
 		count: 0, // 已答题数
 		total: 0, // 总题数
@@ -63,29 +79,35 @@ export function useExam() {
 		}
 		const cacheZhangInfo = cacheManager.get('zhangInfo');
 		let currentObject = cacheZhangInfo.jieList.find(item => item.number == options.jieNumber);
-		const { cardId,zhangId,nianji } = cacheManager.get('auth');
-		
+		const {
+			cardId,
+			zhangId,
+			nianji
+		} = cacheManager.get('auth');
+
 		data.jieId = currentObject.jieId; // 需要路由参数 节Id
-		data.zhangId = zhangId;// 需要路由参数 章Id
+		data.zhangId = zhangId; // 需要路由参数 章Id
 		data.nianji = nianji; // 需要年纪Id 来执行返回页面
 		data.xueke = cardId; // 需要年纪Id 来执行返回页面
 		data.haveFlag = cacheZhangInfo.haveFlag
-		
+
 		// 初始化页面数据
 		initPage();
 	})
-	
+
 	watch(() => data.list, (val) => {
 		const list = data.list.filter(item => {
 			if (item.type == 3) {
 				// 填空题 所有试题答完
 				return !item.reply.some(citem => citem.trim() == '');
 			} else {
-				return item.reply!==null
+				return item.reply !== null
 			}
 		});
 		data.count = list.length;
-	},{deep: true})
+	}, {
+		deep: true
+	})
 
 
 	// 初始化页面数据
@@ -106,8 +128,8 @@ export function useExam() {
 			item.reply = null;
 			if (item.type == 3) {
 				item.result = JSON.parse(item.result);
-				item.placeholders = item.result.map((item,cindex) => `[bank${cindex}]`)
-				item.reply =  item.result.map(() => '');
+				item.placeholders = item.result.map((item, cindex) => `[bank${cindex}]`)
+				item.reply = item.result.map(() => '');
 			}
 		})
 	}
@@ -118,7 +140,7 @@ export function useExam() {
 		formatListToUse(cList)
 		data.list = cList;
 		data.total = cList.length;
-		
+
 		handleShowTishi();
 	}
 
@@ -126,22 +148,25 @@ export function useExam() {
 	async function handleSubmit(dom) {
 		const result = [];
 		data.list.forEach(item => {
-			result.push({reply: item.reply ? JSON.stringify(item.reply):'',stId: item.stId})
+			result.push({
+				reply: item.reply ? JSON.stringify(item.reply) : '',
+				stId: item.stId
+			})
 		})
-		
-		const [error, cdata] =await catchError(httpUnit.getExamSubmit({
+
+		const [error, cdata] = await catchError(httpUnit.getExamSubmit({
 			jieId: data.jieId,
 			shitiList: result
 		}));
 
 		if (error) {
 			toast("单元测试数据提交异常");
-			return ;
+			return;
 		}
 		dom.showPopup({
-			right:cdata.dui,
-			wrong:cdata.cuo,
-			jifen:cdata.jifen
+			right: cdata.dui,
+			wrong: cdata.cuo,
+			jifen: cdata.jifen
 		});
 	}
 
@@ -163,7 +188,10 @@ export function useExam() {
 
 // 提示信息显示隐藏
 function useTishiLeftRight() {
-	const { updateTishi, getTishi} = useUnitTestTishi();
+	const {
+		updateTishi,
+		getTishi
+	} = useUnitTestTishi();
 	const showTishi = ref(false);
 	// 大鹅关闭追加缓存 --- 单独针对当前手机的缓存提示
 	function handleCloseTishi() {
@@ -175,10 +203,11 @@ function useTishiLeftRight() {
 		const isNotShow = Boolean(getTishi());
 		showTishi.value = !isNotShow;
 	}
-	
+
 	return {
 		showTishi,
 		handleCloseTishi,
 		handleShowTishi
 	}
-}
+}
+

+ 1 - 1
utils/constant.js

@@ -41,4 +41,4 @@ export const xueke_list = [
 ]
 
 export const MESSAGE_BEFORE_PAY = `当前为非会员模式请先购买!`;
-export const MESSAGE_VISITER_TO_LOGIN = `当前为游客模式请登录!`;
+export const MESSAGE_VISITER_TO_LOGIN = `您当前是游客身份,登录后才能浏览内容,现在去登录?`;