From 0ab4bf8f3982bdee9962076f29c5664185328517 Mon Sep 17 00:00:00 2001
From: loulijun2021 <1694218219@qq.com>
Date: 星期五, 21 十月 2022 17:02:10 +0800
Subject: [PATCH] 1.消息全局化2.消息响应静态页面实现

---
 pages/adgl/adhj.html |  114 +++++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 82 insertions(+), 32 deletions(-)

diff --git a/pages/adgl/adhj.html b/pages/adgl/adhj.html
index ae4a279..7ea27c7 100644
--- a/pages/adgl/adhj.html
+++ b/pages/adgl/adhj.html
@@ -21,9 +21,14 @@
 		<script type="text/javascript" src="../../js/global.js"></script>
 
 
-		<script src="http://121.196.36.24:8001/Scripts/jquery-3.4.1.min.js"></script>
-		<script src="http://121.196.36.24:8001/Scripts/jquery.signalR-2.2.2.min.js"></script>
-		<script src="http://121.196.36.24:8001/SignalR/Hubs"></script>
+		<!-- <script src="http://121.196.36.24:8001/Scripts/jquery-3.4.1.min.js"></script> -->
+		<!-- <script src="http://121.196.36.24:8001/Scripts/jquery.signalR-2.2.2.min.js"></script> -->
+		<!-- <script src="http://121.196.36.24:8001/SignalR/Hubs"></script> -->
+
+		<script src="../../js/jquery-3.4.1.min.js"></script>
+		<script src="../../js/jquery.signalR-2.2.2.min.js"></script>
+		<script src="../../js/Hubs.js"></script>
+
 
 		<script type="text/javascript">
 			var pushServer = "http://demo.dcloud.net.cn/push/?";
@@ -183,15 +188,61 @@
 
 
 
+			function CreateNotification(msg, n) {
+				console.log(msg, n)
+
+				vant.Notify(msg, n, 9999999999)
+
+				var NotifyID = n;
+				var Context = plus.android.importClass("android.content.Context");
+				var main = plus.android.runtimeMainActivity();
+				var Noti = plus.android.importClass("android.app.Notification");
+				var NotificationManager = plus.android.importClass("android.app.NotificationManager");
+				var nm = main.getSystemService(Context.NOTIFICATION_SERVICE)
+				var Notification = plus.android.importClass("android.app.Notification");
+				var mNotification = new Notification.Builder(main);
+				var pending = plus.android.importClass("android.app.PendingIntent");
+				var intent = plus.android.importClass("android.content.Intent");
+
+				//mNotification.setOngoing(true);
+				mNotification.setContentTitle("鎮ㄦ湁涓�鏉℃湭璇绘秷鎭�"); //鏍囬
+				mNotification.setContentText(msg); //鍐呭
+				mNotification.setSmallIcon(17301620); //鍥炬爣
+				mNotification.setTicker("First Time"); //閫氱煡棣栨鍑虹幇鍦ㄩ�氱煡鏍忔椂鐨勬晥鏋�
+				mNotification.setNumber(5); //閫氱煡闆嗗悎鐨勬暟閲�
+				//var str = dateToStr(new Date());
+				//mNotification.setWhen(str);//閫氱煡浜х敓鏃堕棿
+				//mNotification.setContentIntent();//閫氱煡鏍忕偣鍑讳簨浠�
+				mNotification.setDefaults(Noti.DEFAULT_VIBRATE); //澹伴煶銆侀棯鐏�侀渿鍔ㄦ晥鏋滐紝鍙彔鍔�
+				mNotification.setPriority(Noti.PRIORITY_DEFAULT); //閫氱煡浼樺厛绾�
+				mNotification.flags = Notification.FLAG_ONLY_ALERT_ONCE; //鍙戣捣閫氱煡鏃堕渿鍔�
+				var mNb = mNotification.build()
+				nm.notify(NotifyID, mNb);
+			}
+
+			// wakeLock()
+			// var g_wakelock = null;
+			// //鍏佽绋嬪簭鍚庡彴杩愯锛屼互鎸佺画鑾峰彇GPS浣嶇疆
+			// function wakeLock() {
+			// 	//Android
+			// 	var main = plus.android.runtimeMainActivity();
+			// 	var Context = plus.android.importClass("android.content.Context");
+			// 	var PowerManager = plus.android.importClass("android.os.PowerManager");
+			// 	var pm = main.getSystemService(Context.POWER_SERVICE);
+			// 	g_wakelock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "ANY_NAME");
+			// 	g_wakelock.acquire();
+			// }
 
 			$(function() {
 				//鍓嶇Hub鐨勪娇鐢紝娉ㄦ剰鐨勬槸锛孒ub鐨勫悕瀛楁槸ChatHub锛岃繖閲屼娇鐢ㄦ椂棣栧瓧姣嶅皬鍐�
 				var work = $.connection.chatHub;
-
+				// work
+				console.log(work, 1)
 				//瀵瑰簲鍚庣鐨凷endMessage鍑芥暟锛屾秷鎭帴鏀跺嚱鏁�
 				// console.log(work.client.sendMessage)
 				work.client.sendMessage = function(msg) {
-					console.log(msg, 1)
+					// console.log(msg, 1)
+					// CreateNotification(msg, Math.random())
 					createLocalPushMsg(msg)
 				};
 
@@ -331,6 +382,8 @@
 						falseArray.push({
 							id: '1'
 						})
+					}else{
+						topContentClick(topContent[0].code, topContent[0].wksp_code)
 					}
 
 				})
@@ -370,8 +423,8 @@
 		</script>
 
 	</head>
-	<body onload="scaned('SB001')">
-		<!-- <body> -->
+	<!-- <body onload="scaned('SB001')"> -->
+	<body>
 		<div id="app">
 
 			<div class="body">
@@ -588,7 +641,7 @@
 									})
 									if (topContent.length >= 1) {
 										radioValue = topContent[0].code
-										topContentClick(radioValue, topContent.find(i => i.code ===
+										this.topContentClick(radioValue, topContent.find(i => i.code ===
 											radioValue).wksp_code)
 									}
 
@@ -599,33 +652,30 @@
 					}, 100)
 
 				},
-				// topContentClick(code, wksp_code) {
-				// 	radioValue = code
-				// 	this.$forceUpdate()
+				topContentClick(code, wksp_code) {
+					radioValue = code
+					const data = {
+						eqpcode: code,
+						wkshpcode: wksp_code
+					}
+					post('AppDeviceManage/AppDeviceAnDengCallItemSearch' + formatParams(data)).then(res => {
+						if (res.code === '200') {
+							centerContent = res.data
 
-				// 	const data = {
-				// 		eqpcode: code,
-				// 		wkshpcode: wksp_code
-				// 	}
-				// 	post('AppDeviceManage/AppDeviceAnDengCallItemSearch' + formatParams(data)).then(res => {
-				// 		if (res.code === '200') {
-				// 			centerContent = res.data
+							currentValue = centerContent.map(r => {
+								if (r.flag === 'Y') {
+									return r.code
+								}
+							})
 
-				// 			currentValue = centerContent.map(r => {
-				// 				if (r.flag === 'Y') {
-				// 					return r.code
-				// 				}
-				// 			})
-				// 			centerContent.forEach(i => {
-				// 				i.isTrue = i.flag === 'Y'
-				// 			})
+							centerContent.forEach(i => {
+								i.isTrue = i.flag === 'Y'
+							})
 
-				// 			this.$forceUpdate()
-
-				// 		}
-				// 	})
-
-				// },
+							this.$forceUpdate()
+						}
+					})
+				},
 
 
 				topScanClick() {

--
Gitblit v1.9.3