浏览代码

修改获取ip

Zt 1 年之前
父节点
当前提交
6b370ff580
共有 3 个文件被更改,包括 17 次插入15 次删除
  1. 8 7
      reado-app/static/webview/record-wv.html
  2. 7 6
      reado-app/static/webview/report-wv.html
  3. 2 2
      reado-app/utils/request.js

+ 8 - 7
reado-app/static/webview/record-wv.html

@@ -30,23 +30,24 @@
 
 		<!-- uni 的 SDK -->
 		<script src="./wvIP.js"></script>
-		
+
 		<script type="text/javascript" src="../luckysheet/dist/plugins/js/uni-webview-js0.0.3_index.js"></script>
 		<script>
 			document.addEventListener('UniAppJSBridgeReady', function() {
 				uni.getEnv(function(res) {
 					console.log('当前环境:' + JSON.stringify(res));
 					const id = window.location.search.split('?id=')[1]
-					
+
 					$.ajax({
 						url: "/reportTable/getReportTableById/" + id,
 						type: 'GET',
 						beforeSend: function() {
-							getUserIP(function(ip) {
-								console.log("得到的本地IP :" + ip);
-								this.url = "http://" + ip +
-									":8081/reportTable/getReportTableById/" + this.id
-							});
+							// getUserIP(function(ip) {
+							// 	console.log("得到的本地IP :" + ip);
+							// 	this.url = "http://" + ip +
+							// 		":8081/reportTable/getReportTableById/" + this.id
+							// });
+							this.url = window.location.origin
 						},
 						success: function(res) {
 							if (res.code === 200) {

+ 7 - 6
reado-app/static/webview/report-wv.html

@@ -128,13 +128,14 @@
 					uni.getEnv(function(res) {
 						console.log('当前环境:' + JSON.stringify(res));
 						const id = window.location.search.split('?id=')[1]
-
-						axios.defaults.baseURL = "http://192.168.0.40:8081"
 						
-						getUserIP(function(ip) {
-							console.log(ip);
-							// axios.defaults.baseURL = "http://" + ip + ":8081"
-						});
+						const baseUrl = window.location.origin
+						axios.defaults.baseURL = baseUrl
+
+						// getUserIP(function(ip) {
+						// 	console.log(ip);
+						// 	// axios.defaults.baseURL = "http://" + ip + ":8081"
+						// });
 
 						axios.get('/reportTable/getReportTableById?id=' + id).then(res => {
 							console.log(res, 'res');

+ 2 - 2
reado-app/utils/request.js

@@ -20,8 +20,8 @@ import {
 // getUserIP((ip) => {
 // 	$http.baseUrl = 'http://' + ip + ':8081'
 // })
-
-const baseUrl = window.location.href.split('#')[0].slice(0, -1)
+console.log(window.location.origin);
+const baseUrl = window.location.origin
 
 $http.baseUrl = baseUrl
 // 请求拦截器