Browse Source

从工作台进入教师端

liurongli 1 month ago
parent
commit
781011afa4
5 changed files with 120 additions and 52 deletions
  1. 1 0
      config.js
  2. 7 0
      pages.json
  3. 37 38
      pages/login/index.vue
  4. 49 0
      pages/webview/teacherApp.vue
  5. 26 14
      pages/workspace/index.vue

+ 1 - 0
config.js

@@ -2,6 +2,7 @@
 export default {
   apiBaseUrl: 'https://index.k12100.net/teaching',
   // apiBaseUrl: 'https://www.k12100.com/teaching',
+  basUrl:'https://www.k12100.com',
   proxyBaseUrl:'',//h5 代理接口地址
   // apiBaseUrl:'http://192.168.0.42:47001'
  

+ 7 - 0
pages.json

@@ -324,6 +324,13 @@
 				"navigationBarTitleText": "审核材料-审核详情-审核",
 				"navigationStyle": "custom"
 			}
+		},
+		{
+			"path": "pages/webview/teacherApp",
+			"style": {
+				"navigationBarTitleText": "大数据精准教学诊断平台",
+				"navigationStyle": "custom"
+			}
 		}
 	],
 	"easycom": {

+ 37 - 38
pages/login/index.vue

@@ -131,44 +131,44 @@ const state = reactive({
 });
 
 onMounted(() => {
-	// #ifdef H5
-	const options = route.query;
-	if (options.schoolId && options.ticket) {
-		state.isLoading = true;
-		uni.showLoading({
-			title: '登录中,请稍等!'
-		});
-		user.adminLoginTeach({
-			id: options.schoolId,
-			ticket: options.ticket
-		}).then(res => {
-			if (res.code == 200) {
-				//先清除所有缓存
-				store.dispatch('logout', false);
-
-				const token = res.data.tokenValue;
-				store.dispatch('setToken', token);
-				uni.setStorageSync('token', token); // 存储 token 到本地
-				store.dispatch('setUserInfo');
-
-				uni.redirectTo({
-				url: '/pages/workspace/index'
-			});
-		} else {
-				uni.showToast({
-					title: res.msg || '账号不存在或者密码错误!',
-					icon: 'none'
-				});
-			}
-		}).finally(() => {
-			state.isLoading = false;
-			uni.hideLoading();
-		})
-	}
+	// // #ifdef H5
+	// const options = route.query;
+	// if (options.schoolId && options.ticket) {
+	// 	state.isLoading = true;
+	// 	uni.showLoading({
+	// 		title: '登录中,请稍等!'
+	// 	});
+	// 	user.adminLoginTeach({
+	// 		id: options.schoolId,
+	// 		ticket: options.ticket
+	// 	}).then(async res => {
+	// 		if (res.code == 200) {
+	// 			//先清除所有缓存
+	// 			store.dispatch('logout', false);
+
+	// 			const token = res.data.tokenValue;
+	// 			store.dispatch('setToken', token);
+	// 			uni.setStorageSync('token', token); // 存储 token 到本地
+	// 			await store.dispatch('setUserInfo');
+
+	// 			uni.redirectTo({
+	// 				url: '/pages/workspace/index'
+	// 			});
+	// 	} else {
+	// 			uni.showToast({
+	// 				title: res.msg || '账号不存在或者密码错误!',
+	// 				icon: 'none'
+	// 			});
+	// 		}
+	// 	}).finally(() => {
+	// 		state.isLoading = false;
+	// 		uni.hideLoading();
+	// 	})
+	// }
+	// // #endif
 	const systemInfo = uni.getSystemInfoSync();
 	state.deviceFinger = systemInfo.deviceId;//设备指纹
 	console.log('设备标识id', systemInfo);
-	// #endif
 });
 const ChangeTab = (value) => {
 	state.tabActive = value;
@@ -468,15 +468,14 @@ const HandleSuccessfulLogin = (res) => {
 	}
 }
 
-const LoginSuccess = () => {
+const LoginSuccess = async () => {
 	uni.showToast({
 		title: '登录成功',
 		icon: 'success',
 		mask: true,
 		duration: 2000
 	});
-	store.dispatch('setUserInfo');
-
+	await store.dispatch('setUserInfo');
 	uni.redirectTo({
 		url: '/pages/workspace/index'
 	});

+ 49 - 0
pages/webview/teacherApp.vue

@@ -0,0 +1,49 @@
+<template>
+	<web-view :src="webviewUrl" @message="handleMessage"></web-view>
+</template>
+
+<script setup>
+	import { ref } from 'vue';
+	import { onReady } from '@dcloudio/uni-app';
+	import config from '@/config.js'; // 引入配置文件
+	const token = uni.getStorageSync('token') || '';
+	const webviewUrl = ref(null);
+	const statusBarHeight = uni.getSystemInfoSync().statusBarHeight || 0;
+	onReady(() => {
+		getApiBaseUrl();
+		// #ifdef APP-PLUS
+		fixWebviewPosition();
+		// 子 webview 异步创建,等它创建完再设
+		setTimeout(fixWebviewPosition, 800);
+		// setTimeout(fixWebviewPosition, 1500); // 兜底防框架重置
+		// #endif
+	});
+	const fixWebviewPosition = () => {
+		const pages = getCurrentPages();
+		const page = pages[pages.length - 1];
+		const pageWebview = page?.$getAppWebview?.();
+	
+		const info = uni.getSystemInfoSync();
+		const statusBarHeight = info.statusBarHeight || 0;
+		const screenHeight = info.screenHeight || 0;
+		const children = pageWebview?.children?.() || [];
+		const wv = children[0];
+		if (!wv) return;
+		wv.setStyle({
+			top: statusBarHeight,
+			// 固定基准:webview 原本全屏,高度就是 screenHeight,只减一次状态栏
+			height: screenHeight - statusBarHeight
+		});
+	};
+	//上传接口地址
+	const getApiBaseUrl = () => {
+		let basUrl = config.basUrl;
+		webviewUrl.value = `${basUrl}/markingapp/#/pages/login/index?appToken=${encodeURIComponent(token)}`;
+	}
+	const handleMessage = () => {
+		
+	}
+</script>
+
+<style>
+</style>

+ 26 - 14
pages/workspace/index.vue

@@ -10,7 +10,7 @@
 				</view>
 			</template>
 		</nav-bar>
-		<scroll-view scroll-y class="workspace_content">
+		<view class="workspace_content">
 			<!-- 系统列表 -->
 			<view class="system_list">
 				<template v-if="largeCard?.visible">
@@ -123,7 +123,7 @@
 					<text class="btn_text">新增日程</text>
 				</view>
 			</view>
-		</scroll-view>
+		</view>
 
 		<view v-if="showAddScheduleModal" class="modal-overlay" @click="handleCloseModal">
 			<view class="modal-content" @click.stop>
@@ -184,7 +184,7 @@ const store = useStore();
 const { statusBarHeight, safeAreaBottom, initSafeArea } = useSafeArea();
 
 const systemItems = ref([
-	{ name: '大数据精准教学诊断平台', id: '1', key: '', image: '/static/image/workspace/iconLeft.png', isLarge: true, visible: true },
+	{ name: '大数据精准教学诊断平台', id: '1', key: 'bigData', image: '/static/image/workspace/iconLeft.png', isLarge: true, visible: true },
 	{ name: '选择题判分', id: '3', key: '', image: '/static/image/workspace/icon1.png', isLarge: false, visible: true },
 	{ name: '材料采集', id: '7', key: 'materialCollection', image: '/static/image/workspace/icon2.png', isLarge: false, visible: true },
 	{ name: '教师研修', id: '9', key: 'teacherStudy', image: '/static/image/workspace/icon3.png', isLarge: false, visible: true },
@@ -365,11 +365,14 @@ onMounted(() => {
 });
 
 onShow(() => {
+	pageInit();
+});
+const pageInit = () => {
 	modulesList.value = store.state.userStore.modulesList || uni.getStorageSync('modulesList') || [];
 	fetchScheduleList();
-});
-
+}
 const handleSystemClick = (item) => {
+	console.log(item,9888)
 	const isSelect = getModulePermission(item.id);
 	if (isSelect == 0) {
 		uni.showToast({ title: '暂无权限,敬请期待!', icon: 'none' });
@@ -394,6 +397,10 @@ const handleSystemClick = (item) => {
 		uni.navigateTo({
 			url: `/pages/${item.key}/index`
 		});
+	}else if(item.key === 'bigData'){
+		uni.navigateTo({
+			url: `/pages/webview/teacherApp`
+		});
 	} else {
 		uni.showToast({ title: `即将打开:${item.name}`, icon: 'none' });
 	}
@@ -486,7 +493,6 @@ const handleConfirmSchedule = async () => {
 //获取学生信息
 const getSchoolInfo = () => {
 	state.schoolName = store.state.userStore.userInfo.schoolName;
-	console.log(state.schoolName,323233)
 	state.schoolId = store.state.userStore.userInfo.schoolId;
 }
 //切换学校弹框
@@ -501,10 +507,14 @@ const DialogSchoolConfirm = () => {
 	user.chooseBelongSchool({
 		schoolId:state.schoolId,
 		deviceType:'APP'
-	}).then(res=>{
+	}).then(async res=>{
 		if(res.code == 200){
-			state.schoolName = res?.data?.schoolName || '';
-			store.dispatch('setUserInfo');
+			// state.schoolName = res?.data?.schoolName || '';
+			const modules = res?.data?.modules || [];
+			store.dispatch('setModulesList', modules);
+			uni.setStorageSync('modulesList', modules);
+			await store.dispatch('setUserInfo');
+			pageInit();
 		}
 	})
 }
@@ -571,17 +581,19 @@ $shadow-sm: 0 4rpx 20rpx rgba(0, 0, 0, 0.05);
 }
 
 .page_workspace {
-	min-height: 100vh;
+	height: 100vh;
+	display: flex;
+	flex-direction: column;
 	background-color: #F8F9FD;
 	box-sizing: border-box;
+	overflow: hidden;
 }
 
 .workspace_content {
-	padding-left: 24rpx;
-	padding-right: 24rpx;
-	height: 100%;
+	padding: 24rpx 24rpx 0;
+	flex:1;
 	box-sizing: border-box;
-	overflow: hidden;
+	overflow: auto;
 }
 
 // 系统列表