浏览代码

学生登录

liurongli 1 月之前
父节点
当前提交
16d9687f3d
共有 3 个文件被更改,包括 57 次插入 和 7 次删除
  1. 2 1
      config.js
  2. 49 0
      pages/webview/studentApp.vue
  3. 6 6
      pages/webview/teacherApp.vue

+ 2 - 1
config.js

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

+ 49 - 0
pages/webview/studentApp.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('');
+	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;//${encodeURIComponent(token)}
+		webviewUrl.value = `${basUrl}/studentapp/#/pages/login/index?appName=studentApp&statusBarHeight=${statusBarHeight}`;
+	}
+	const handleMessage = () => {
+		
+	}
+</script>
+
+<style>
+</style>

+ 6 - 6
pages/webview/teacherApp.vue

@@ -7,14 +7,14 @@
 	import { onReady } from '@dcloudio/uni-app';
 	import config from '@/config.js'; // 引入配置文件
 	const token = uni.getStorageSync('token') || '';
-	const webviewUrl = ref(null);
+	const webviewUrl = ref('');
 	const statusBarHeight = uni.getSystemInfoSync().statusBarHeight || 0;
 	onReady(() => {
 		getApiBaseUrl();
 		// #ifdef APP-PLUS
-		fixWebviewPosition();
-		// 子 webview 异步创建,等它创建完再设
-		setTimeout(fixWebviewPosition, 800);
+		// fixWebviewPosition();
+		// // 子 webview 异步创建,等它创建完再设
+		// setTimeout(fixWebviewPosition, 800);
 		// setTimeout(fixWebviewPosition, 1500); // 兜底防框架重置
 		// #endif
 	});
@@ -37,8 +37,8 @@
 	};
 	//上传接口地址
 	const getApiBaseUrl = () => {
-		let basUrl = config.basUrl;
-		webviewUrl.value = `${basUrl}/markingapp/#/pages/login/index?appToken=${encodeURIComponent(token)}`;
+		let basUrl = config.basUrl;//${encodeURIComponent(token)}
+		webviewUrl.value = `${basUrl}/markingapp/#/pages/login/index?appName=teacherApp&statusBarHeight=${statusBarHeight}`;
 	}
 	const handleMessage = () => {