Sfoglia il codice sorgente

添加条件编译

aleyds 3 anni fa
parent
commit
0583295400
5 ha cambiato i file con 51 aggiunte e 26 eliminazioni
  1. 28 13
      App.vue
  2. 1 1
      common/http.api.js
  3. 3 10
      pages/index/index.vue
  4. 9 2
      pages/login/login.vue
  5. 10 0
      pages/setting/setting.vue

+ 28 - 13
App.vue

@@ -1,20 +1,14 @@
 <script>
+	//#ifdef APP-PLUS
 	var AndroidLog = uni.requireNativePlugin("AndroidLog")
 	var device = uni.requireNativePlugin("DeviceInfo")
+	//#endif
 	export default {
 		onLaunch: function() {
+			//#ifdef APP-PLUS
 			//判断客户端类别
 			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
-				})
 
 			};
 			// 
@@ -40,14 +34,35 @@
 					clearTimeout()
 				}
 			}, 400);
-			// 
-
 			//监听系统通知栏消息点击事件  
 			plus.push.addEventListener('click', _handlePush, false);
-
 			//监听接收透传消息事件
 			plus.push.addEventListener('receive', _handlePush, false);
-			// this.$wxApi.config();
+			//#endif
+			//#ifdef H5
+			  this.$u.api.deviceReg({
+			  		deviceNo: '123456789',
+			  		pushCid: '123456789'
+			  	})
+			  	.then(res => {
+			  		if (res.code == 200) {
+						uni.showToast({
+							title: '设备注册成功',
+							duration: 2000
+						});
+			  		} else {
+						uni.showToast({
+							title: '设备注册失败',
+							duration: 2000
+						});
+			  		}
+			  	}).catch(err => {
+					uni.showToast({
+						title: '设备注册失败',
+						duration: 2000
+					});
+			  	});
+			//#endif
 		},
 		onShow: function() {
 			// console.log('App Show')

+ 1 - 1
common/http.api.js

@@ -55,7 +55,7 @@ const install = (Vue, vm) => {
 		parkInConfirm,
 		parkInInfo,
 		qiniuUpload,
-		achievement
+		achievement,
 		printIn
 	};
 }

+ 3 - 10
pages/index/index.vue

@@ -61,8 +61,6 @@
 					<u-image width="160rpx" height="160rpx" src="/static/img/index-feature-07.png"></u-image>
 					<view class="feature-item-text">密码修改</view>
 				</view> -->
-				<view class="feature-item" @click="openPage('pages/ownersquery/ownersquery')">
-					<u-image width="160rpx" height="160rpx" src="/static/img/index-feature-10.png"></u-image>
 				<view class="feature-item" @click="onPrint()">
 					<u-image width="120rpx" height="120rpx" src="/static/img/index-feature-10.png"></u-image>
 					<view class="feature-item-text">车主查询</view>
@@ -88,10 +86,12 @@
 </template>
 
 <script>
+	//#ifdef APP-PLUS
 	var ALog = uni.requireNativePlugin("AndroidLog")
 	var location = uni.requireNativePlugin("Location")
 	var speak = uni.requireNativePlugin("SpeechPlug")
 	var device = uni.requireNativePlugin("DeviceInfo")
+	//#endif
 	export default {
 		data() {
 			return {
@@ -145,22 +145,15 @@
 				
 			},
 			getLocation(){
-				ALog.info({msg:'请求定位'})
 				uni.getLocation({
 					type:"gcj02",
 					success : function (res) {
-						// console.log("定位返回信息:", res)
-						// alert(res.longitude + "," + res.latitude )
-						ALog.info({msg:res})
 						var dst = '26.58751,106.78329';
 						var src = res.latitude + ',' + res.longitude;
 						var locRet = location.distance(src, dst)
-						ALog.info({msg:locRet.distance})
-						
 					},
 					fail: function(res){
-					
-						ALog.info({msg:'请求错误',err:res})
+
 					}
 				})
 			},

+ 9 - 2
pages/login/login.vue

@@ -23,7 +23,9 @@
 </template>
 
 <script>
+	//#ifdef APP-PLUS
 	var device = uni.requireNativePlugin("DeviceInfo")
+	//#endif
 	export default {
 		data() {
 			return {
@@ -69,8 +71,13 @@
 		methods: {
 
 			handleLogin(){
-				this.form.deviceNo = '123456789';
-				// this.form.deviceNo = device?.getDeviceInfo()?.deviceId;
+				
+				//#ifdef APP-PLUS
+				this.form.deviceNo = device?.getDeviceInfo()?.deviceId;
+				//#endif
+				//#ifdef H5
+				 this.form.deviceNo = '123456789';
+				//#endif
 				this.$u.api.login(this.form)
 				.then(res=>{
 					this.$refs.uToast.show({

+ 10 - 0
pages/setting/setting.vue

@@ -27,7 +27,9 @@
 </template>
 
 <script>
+	//#ifdef APP-PLUS
 	var device = uni.requireNativePlugin("DeviceInfo")
+	//#endif
 	export default{
 		data(){
 			return{
@@ -54,7 +56,15 @@
 				});
 			},
 			onPrintFeed(){
+				//#ifdef APP-PLUS
 				device.printFeed(10);
+				//#endif
+				//#ifdef H5
+				uni.showToast({
+					title: '非APP环境',
+					duration: 2000
+				});
+				//#endif
 			},
 			onLoginOut(){
 				uni.showModal({