gcz 4 anni fa
parent
commit
9a87cdd960
3 ha cambiato i file con 46 aggiunte e 34 eliminazioni
  1. 41 33
      App.vue
  2. 4 0
      README.md
  3. 1 1
      pages/login/login.vue

+ 41 - 33
App.vue

@@ -4,46 +4,54 @@
 	export default {
 		onLaunch: function() {
 			//判断客户端类别
-			const _handlePush = function(message) {  
-						// console.log("接收到推送消息:" ,message);
-						// alert(message)
-						//{"message":{"__UUID__":"androidPushMsg222631973","appid":"__UNI__29ECCC8","content":"{\"type\":2,\"jumpTo\":\"pages/login/login\"}","payload":{"jumpTo":"pages/login/login","type":2},"title":"智慧停车PDA"}}
-						AndroidLog.info({message: message.content})
-						let content = JSON.parse(message.content)
-						AndroidLog.info({message: content.jumpTo})
-						
-			        };  
-					
-		setTimeout(()=>{
-			var pinf = plus.push.getClientInfo();
-			var cid = pinf.clientid;//客户端标识  
-			if(cid != null && cid !=  '' && cid != 'null'){
-				//注册设备
-				var deviceInfo = device.getDeviceInfo()
-				this.$u.api.deviceReg({deviceNo:deviceInfo.deviceId,pushCid: cid})
-				.then(res=>{
-						if (res.code == 200){
-							plus.nativeUI.toast('设备注册成功');
-						}else{
+			const _handlePush = function(message) {
+				// console.log("接收到推送消息:" ,message);
+				// alert(message)
+				//{"message":{"__UUID__":"androidPushMsg222631973","appid":"__UNI__29ECCC8","content":"{\"type\":2,\"jumpTo\":\"pages/login/login\"}","payload":{"jumpTo":"pages/login/login","type":2},"title":"智慧停车PDA"}}
+				AndroidLog.info({
+					message: message.content
+				})
+				let content = JSON.parse(message.content)
+				AndroidLog.info({
+					message: content.jumpTo
+				})
+
+			};
+			// 
+			setTimeout(() => {
+				var pinf = plus.push.getClientInfo();
+				var cid = pinf.clientid; //客户端标识  
+				if (cid != null && cid != '' && cid != 'null') {
+					//注册设备
+					var deviceInfo = device.getDeviceInfo()
+					this.$u.api.deviceReg({
+							deviceNo: deviceInfo.deviceId,
+							pushCid: cid
+						})
+						.then(res => {
+							if (res.code == 200) {
+								plus.nativeUI.toast('设备注册成功');
+							} else {
+								plus.nativeUI.toast('设备注册失败');
+							}
+						}).catch(err => {
 							plus.nativeUI.toast('设备注册失败');
-						}
-				}).catch(err=>{
-					plus.nativeUI.toast('设备注册失败');
-				});
-				clearTimeout()
-			}
-		}, 400);
-			
+						});
+					clearTimeout()
+				}
+			}, 400);
+			// 
+
 			//监听系统通知栏消息点击事件  
-			plus.push.addEventListener('click', _handlePush,false);  
-			
+			plus.push.addEventListener('click', _handlePush, false);
+
 			//监听接收透传消息事件
-			plus.push.addEventListener('receive', _handlePush,false);  
+			plus.push.addEventListener('receive', _handlePush, false);
 			// this.$wxApi.config();
 		},
 		onShow: function() {
 			// console.log('App Show')
-			
+
 		},
 		onHide: function() {
 			// console.log('App Hide')

+ 4 - 0
README.md

@@ -1,3 +1,7 @@
 ## 城市智慧停车PDA
+### H5调试,因为没有app方法,需要如下操作调试
+- `login.vue中` 找到到 `handleLogin()` 设置设配编号为固定值
+
+
 
 

+ 1 - 1
pages/login/login.vue

@@ -70,7 +70,7 @@
 			// },
 			handleLogin(){
 				// this.form.deviceNo = '1122334455';
-				this.form.deviceNo = device.getDeviceInfo().deviceId;
+				this.form.deviceNo = device?.getDeviceInfo()?.deviceId;
 				this.$u.api.login(this.form)
 				.then(res=>{
 					this.$refs.uToast.show({