dufeng 3 tháng trước cách đây
mục cha
commit
3dba748a27
2 tập tin đã thay đổi với 77 bổ sung53 xóa
  1. 74 50
      pages/webViews/webViews.vue
  2. 3 3
      utils/config.js

+ 74 - 50
pages/webViews/webViews.vue

@@ -1,55 +1,55 @@
 <template>
-    <web-view
-        :src="src">
-    </web-view>
+	<web-view :src="src">
+	</web-view>
 </template>
 
 <script>
 import { getToken } from '@/utils/auth'
-import {server_url} from '@/utils/config.js'
+import { server_url } from '@/utils/config.js'
 var wv;
 export default {
-    data() {
-        return {
-            src: '',
+	data() {
+		return {
+			src: '',
 			query: {},
 			webviewServer: server_url,
-			
-        };
-    },
-    onLoad(query) {
+
+		};
+	},
+	onLoad(query) {
 		this.query = query
-		
+
 		this.initData(query)
-        
-    },
-	
+		
+
+	},
+
 	onReady() {
-	  // #ifdef APP-PLUS
-	  var self = this;
-	  var currentWebview = this.$scope.$getAppWebview(); //此对象相当于html5plus里的plus.webview.currentWebview()。在uni-app里vue页面直接使用plus.webview.currentWebview()无效,非v3编译模式使用this.$mp.page.$getAppWebview()
-	  setTimeout(function () {
-		wv = currentWebview.children()[0];
-		wv.addEventListener(
-			"progressChanged",
-			function (e) {
-			  wv.canBack(function (e) {
-				self.canBack = e.canBack;
-			  });
-			},
-			false
-		);
-	  }, 500); //如果是页面初始化调用时,需要延时一下
-	  // #endif
+		// #ifdef APP-PLUS
+		var self = this;
+		var currentWebview = this.$scope.$getAppWebview(); //此对象相当于html5plus里的plus.webview.currentWebview()。在uni-app里vue页面直接使用plus.webview.currentWebview()无效,非v3编译模式使用this.$mp.page.$getAppWebview()
+		setTimeout(function () {
+			wv = currentWebview.children()[0];
+			wv.addEventListener(
+				"progressChanged",
+				function (e) {
+					wv.canBack(function (e) {
+						self.canBack = e.canBack;
+					});
+				},
+				false
+			);
+		}, 500); //如果是页面初始化调用时,需要延时一下
+		// #endif
 	},
 	// 设备上点击返回按钮时的处理
 	onBackPress(e) {
-	  if (wv && this.canBack) {
-		wv.back();
-	  } else {
-		// 没有可返回的页面了, 可以做些其他的处理, 比如回首页等等
-	  }
-	  return true;
+		if (wv && this.canBack) {
+			wv.back();
+		} else {
+			// 没有可返回的页面了, 可以做些其他的处理, 比如回首页等等
+		}
+		return true;
 	},
 	/* onNavigationBarButtonTap(e) {
 		
@@ -90,30 +90,54 @@ export default {
 	},
 	computed: {
 		token() {
-			return this.$store.state.user.token 
+			return this.$store.state.user.token
 		}
 	},
-    methods: {
-	
+	methods: {
+
+		
+		
+		getUuid() {
+			var uuid = "";
+			// #ifdef APP-PLUS
+			if (plus.os.name == "Android") {
+				try {
+					var Build = plus.android.importClass("android.os.Build");
+					var serial = Build.SERIAL;
+					var mainActivity = plus.android.runtimeMainActivity();
+					var Settings = plus.android.importClass("android.provider.Settings");
+					var ANDROID_ID = Settings.Secure.getString(mainActivity.getContentResolver(), Settings.Secure.ANDROID_ID)
+					uuid = `${ANDROID_ID}-${serial}`
+				} catch (e) {
+					console.log("获取设备唯一标识失败:", e);
+				}
+			}
+			// #endif
+			return uuid;
+		},
+		
 		
 		initData(query) {
+
+			
 			let urlParams = ''
 			for (let key in query) {
-			    if (key != 'token') {
-			        urlParams += `&${key}=${query[key]}`
-			    }		
+				if (key != 'token') {
+					urlParams += `&${key}=${query[key]}`
+				}
 			}
-			urlParams = urlParams.replace('&', '?')
+			urlParams += `&uuid=${this.getUuid()}`
+			urlParams = urlParams.replace('&', '')
 			this.src = `${this.webviewServer}/mobile/?${urlParams}`
-			
+			console.log('webview地址', this.src)
 		},
-        getLocation() {
+		getLocation() {
 
-        },
-        scanCode() {
+		},
+		scanCode() {
 
-        }
-    }
+		}
+	}
 }
 </script>
 

+ 3 - 3
utils/config.js

@@ -4,7 +4,7 @@ const {PLATFORM} = env
 
 // #ifdef H5
 // const url_all = { 'DEV': '/dev-api', 'BUILD': '' }	 // h5配置
-const url_all = { 'DEV': 'http://47.110.52.61:8011', 'BUILD': '' }	 // h5配置
+const url_all = { 'DEV': 'http://61.53.66.104:8011', 'BUILD': '' }	 // h5配置
 let protocol = window.location.protocol;
 if (protocol === "https:") {
     protocol = "wss:";
@@ -20,8 +20,8 @@ let url_all,ws_url_all
 
 if (PLATFORM === "enterprises") {
   // 企事业
-	 url_all = { 'DEV': 'http://47.110.52.61:8011', 'BUILD': 'http://47.110.52.61:8011' }	 // 非h5配置
-	 ws_url_all = { 'DEV': 'http://47.110.52.61:8011', 'BUILD': 'http://47.110.52.61:8011' }	 // 非h5配置
+	 url_all = { 'DEV': 'http://61.53.66.104:8011', 'BUILD': 'http://61.53.66.104:8011' }	 // 非h5配置
+	 ws_url_all = { 'DEV': 'http://61.53.66.104:8011', 'BUILD': 'http://61.53.66.104:8011' }	 // 非h5配置
 }else if (PLATFORM === "sanitation") {
 	 url_all = { 'DEV': 'http://tq.5000v.com:8025', 'BUILD': 'http://tq.5000v.com:8025' }	 // 非h5配置
 	 ws_url_all = { 'DEV': 'http://tq.5000v.com:8025', 'BUILD': 'http://tq.5000v.com:8025' }	 // 非h5配置