瀏覽代碼

Merge branch 'lw_test' into gyq_test

郭宇琦 1 周之前
父節點
當前提交
0fe51c9680

+ 3 - 3
.hbuilderx/launch.json

@@ -19,12 +19,12 @@
             "type" : "uniCloud"
         },
         {
-            "openVueDevtools" : true,
-            "playground" : "custom",
+            "openVueDevtools" : false,
+            "playground" : "standard",
             "type" : "uni-app:app-android"
         },
         {
-            "openVueDevtools" : true,
+            "openVueDevtools" : false,
             "playground" : "standard",
             "type" : "uni-app:app-ios"
         }

+ 2 - 2
common/bluetooth.js

@@ -451,7 +451,7 @@ function alterConnect(device, deviceId, callback = () => {}, fail = () => {}) {
                                                         // 写入数据
 														setTimeout(()=>{
 															writeData(device, deviceId, data, callback, fail);
-														},200)
+														},500)
                                                         
                                                     } else {
                                                         // 调用回调函数
@@ -517,7 +517,7 @@ function alterConnect(device, deviceId, callback = () => {}, fail = () => {}) {
                     fail(res);
                 }
             });	
-			},500)
+			},800)
             
         },
         fail(res) {

+ 11 - 2
common/bluetooth/ZXCar.js

@@ -49,6 +49,7 @@ function isDevice(device, data) {
 	// }
 		//判断是否是智寻的蓝牙
 	const result = data.name.startsWith("ZX");
+	// const result = data.name.startsWith("ZN");
 	// if (data.name === "865416038002201") {
 	// if (data.name === "ZX2503150000000") {
 	if (result) {
@@ -73,6 +74,10 @@ function alterConnect(device, deviceId) {
 	let data=[ 0x1F, 0x0F]
 	const device_name=app.globalData.connectionState[deviceId].deviceName
 	const device_sn=stringToHexArray(device_name)
+	
+	// const car_info = uni.getStorageSync('car_info')
+	// const device_sn=stringToHexArray(car_info.car_sn)
+	// const device_sn=stringToHexArray('865416038001109')
 	data.push(...device_sn)
 	data.push(0x08, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x67, 0xAC, 0x53, 0xE7, 0x08, 0x00)
 	// const data=[ 0x1F, 0x0F,0x38, 0x36, 0x35, 0x34, 0x31, 0x36, 0x30, 0x33, 0x38, 0x30, 0x30, 0x32, 0x32, 0x30, 0x31,0x08, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x67, 0xAC, 0x53, 0xE7, 0x08, 0x00]
@@ -400,8 +405,10 @@ function getNearUnlockSet(device, deviceId,type) {
 }
 
 function getNearCarCmdInfo(macid,data){
+	console.log('getNearCarCmdInfo',macid,data);
+	
 	
-	if(pData.lockType==0x02||pData.lockType==0x01){
+	if(data[5]==0x02||data[5]==0x01){
 		uni.hideLoading();
 		const pData={
 				lockType:data[4],//接近解锁配置
@@ -450,7 +457,9 @@ function checkUnlock(macid,type='get'){
 							// 获取接近解锁指令信息
 							const getNearUnlockSetCmd=getNearUnlockSet()
 							console.log(getNearUnlockSetCmd,'getNearUnlockSetCmd');
-							writeData(mac_id,getNearUnlockSetCmd)
+							setTimeout(() => {
+							    writeData(macid,getNearUnlockSetCmd)
+							}, 500);
 				}else{
 					uni.showModal({
 						title: '蓝牙配对确认',

+ 25 - 1
js_sdk/wa-permission/permission.js

@@ -502,6 +502,29 @@ function getDeviceType(bluetoothClass) {
   return deviceClass;
 }
 
+//设备蓝牙权限是否开启
+function checkBluetoothPermission() {
+    // #ifdef APP-PLUS
+        // 检查蓝牙是否可用
+        const BluetoothAdapter = plus.android.importClass('android.bluetooth.BluetoothAdapter');
+        const bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
+
+        if (!bluetoothAdapter) {
+            console.log('设备不支持蓝牙');
+            return false;
+        }
+
+        // 检查蓝牙是否已启用
+        if (!bluetoothAdapter.isEnabled()) {
+            console.log('蓝牙未启用');
+            return false;
+        }
+
+        console.log('蓝牙已启用');
+        return true;
+    // #endif
+}
+
 module.exports = {
 	judgeIosPermission: judgeIosPermission,
 	requestAndroidPermission: requestAndroidPermission,
@@ -515,6 +538,7 @@ module.exports = {
 	openAppLockSettings,//前往打开应用锁
 	judgeIosPermissionLocationAlways,
 	judgeIosPermissionLocationAccuracy,
-	getBondedDevices
+	getBondedDevices,
+	checkBluetoothPermission
 
 }

+ 4 - 4
manifest.json

@@ -1,6 +1,6 @@
 {
     "name" : "FRANCO MORINI",
-    "appid" : "__UNI__111A022",
+    "appid" : "__UNI__E67DD80",
     "description" : "",
     "versionName" : "1.3.7",
     "versionCode" : 137,
@@ -42,19 +42,19 @@
                     "<uses-permission android:name=\"android.permission.BATTERY_STATS\"/>",
                     "<uses-permission android:name=\"android.permission.BIND_TV_INPUT\"/>",
                     "<uses-permission android:name=\"android.permission.BLUETOOTH\"/>",
+                    "<uses-permission android:name=\"android.permission.BLUETOOTH_ADMIN\"/>",
+                    "<uses-permission android:name=\"android.permission.CALL_PHONE\"/>",
                     "<uses-permission android:name=\"android.permission.CAMERA\"/>",
                     "<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
                     "<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
                     "<uses-permission android:name=\"android.permission.INTERNET\"/>",
                     "<uses-permission android:name=\"android.permission.MODIFY_AUDIO_SETTINGS\"/>",
-                    "<uses-permission android:name=\"android.permission.CALL_PHONE\"/>",
                     "<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
                     "<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
                     "<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
                     "<uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\"/>",
                     "<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>",
-                    "<uses-permission android:name=\"android.permission.BLUETOOTH\"/>",
-                    "<uses-permission android:name=\"android.permission.FOREGROUND_SERVICE\"/>"
+                    "<uses-permission android:name=\"android.permission.BLUETOOTH\"/>"
                 ],
                 "abiFilters" : [ "armeabi-v7a", "arm64-v8a", "x86" ],
                 "autoSdkPermissions" : false,

+ 10 - 8
mixin/index.js

@@ -78,9 +78,10 @@ export default {
 		closePopup() {
 			this.popupControlShow = false
 		},
-		tapBlueToothCmd(isCarLocation = false) {
-			const car_info = uni.getStorageSync('car_info');
-			if (this.cmdType == 'batteryInfo') {
+		tapBlueToothCmd(_,type){
+			const car_info= uni.getStorageSync('car_info');
+			const isCarLocation = type
+			if(this.cmdType=='batteryInfo'){
 				uni.navigateTo({
 					url: `/pages/batteryDetail/batteryDetail`
 				})
@@ -168,10 +169,10 @@ export default {
 			const me = this
 			const car_info = uni.getStorageSync('car_info');
 			//蓝牙是否已经连接 未连接提示去连接 已连接下发对应指令
-			const isBluetoothConnect = app.globalData.connectionStateChangeFunc[car_info.car_sn]
-			if (isBluetoothConnect) {
-				const isTurnOn = this.contrilList.find(item => item.isTurnOn).isTurnOn == 1
-				console.log(isTurnOn, this.cmdType, this.contrilList);
+			const isBluetoothConnect = app.globalData.nearLockCheck
+			if(isBluetoothConnect){
+				const isTurnOn=this.contrilList.find(item => item.isTurnOn).isTurnOn==1
+				console.log(isTurnOn,this.cmdType,this.contrilList);
 				const bluetoothCommands = {
 					'turnOnOrOff': isTurnOn ? bluetooth.turnOnCar : bluetooth.turnOffCar,
 					'findCar': bluetooth.findCarCmd,
@@ -200,7 +201,8 @@ export default {
 					confirmText: '确定',
 					success: function(res) {
 						if (res.confirm) {
-							if (isCarLocation) {
+							console.log(isCarLocation,'test111');
+							if(isCarLocation){
 								uni.switchTab({
 									url: '/pages/index/index'
 								})

+ 1 - 1
pages.json

@@ -310,7 +310,7 @@
 			"path" : "pages/moreInfo/moreInfo",
 			"style" : 
 			{
-				"navigationBarTitleText" : "",
+				"navigationBarTitleText" : "车辆更多信息",
 				"navigationStyle": "custom"
 			}
 		}

+ 12 - 5
pages/bluetoothUnlock/bluetoothPair.vue

@@ -22,7 +22,7 @@
 
 		<!-- 测试指令!!!别删除 -->
 		<view class="pair-btn" style="bottom: 340rpx;" @tap="nearCloseUnlockBtn">关闭靠近解锁</view>
-		<view class="pair-btn" style="bottom: 240rpx;" @tap="nearUnlockBtn">靠近解锁</view>
+		<!-- <view class="pair-btn" style="bottom: 240rpx;" @tap="nearUnlockBtn">靠近解锁</view> -->
 		<!-- <view class="pair-btn" style="bottom: 140rpx;" @tap="otaUpgrade">OTA升级</view> -->
 		<view class="pair-btn" @tap="initiateBluetoothPairing">开始配对</view>
 		<CenterDialog confirmText="配对" ref="centerDialog" />
@@ -37,6 +37,7 @@
 	import CenterDialog from '@/component/comPopup/CenterDialog.vue';
 	import Notice from '@/component/comPopup/Notice.vue';
 	var bluetooth = require('@/common/bluetooth.js');
+	import permision from "@/js_sdk/wa-permission/permission.js"
 	const DF_CAB_INFO_DONE = 10000; //机柜信息传输完成
 	var app = getApp();
 	var config = require('../../common/config.js');
@@ -62,10 +63,16 @@
 				model_name,
 				car_sn
 			})
-			bluetooth.initBluetooth()
-			//初始化 连接蓝牙  -下发配对指令 -会断开连接-直接再次连接 记得不要提示可以蓝牙断开连接
-			//点击配对-连接蓝牙-调用配对-确认配对  取消 断开蓝牙 不走逻辑
-			this.bluetoothClose()
+			const isOpenBluetoothPermission=permision.checkBluetoothPermission()
+			if(isOpenBluetoothPermission){
+				bluetooth.initBluetooth()
+				//初始化 连接蓝牙  -下发配对指令 -会断开连接-直接再次连接 记得不要提示可以蓝牙断开连接
+				//点击配对-连接蓝牙-调用配对-确认配对  取消 断开蓝牙 不走逻辑
+				this.bluetoothClose()
+			}else{
+				common.showContent('蓝牙未启用,请先打开蓝牙')
+			}
+			
 		},
 		methods: {
 			otaUpgrade(){

+ 1 - 1
pages/carLocation/carLocation.vue

@@ -200,7 +200,7 @@ import googleMap from "@/component/googleMap/googleMap";
 								popText:'闪灯鸣笛',
 								cmdType:'findCar',
 							})
-							me.tapBlueToothCmd(true)
+							me.tapBlueToothCmd(_,true)
 						}
 					},
 					fail: function(res) {},

+ 3 - 3
pages/index/components/AndroidUnlockAuth.vue

@@ -103,9 +103,9 @@ export default {
 
     enablePermissions({ type }) {
 		console.log(type,'type');
-      // if (!this.permisionCheckObj[type]) {
-      //   permision.gotoAppPermissionSetting()
-      // }
+      if (!this.permisionCheckObj[type]) {
+        permision.gotoAppPermissionSetting()
+      }
     },
     linkTo() {
 		// let isOpenAllPermission=false

+ 18 - 14
pages/index/index.vue

@@ -62,7 +62,7 @@
 								:style="{width: (isBluethConnect?32:24)+'rpx',height: '32rpx'}" alt="">
 						</view>
 					</view>
-					<Control :contrilList="contrilList" />
+					<Control :contrilList="contrilList" @toBluetooth="inductiveUnlockHandle"/>
 			
 			
 					<view v-if="car_info.exchange_package_info && car_info.exchange_package_info.activity_time"
@@ -192,6 +192,7 @@
 				isShowPermission:false,//是否打开权限弹窗
 				statusBarHeight:0,
 				isBluethConnect:false, //当前是否蓝牙连接或者配对
+				isOpenAllPermission:false,//所有蓝牙配对所需权限是否已开启
 			};
 		},
 		computed: {},
@@ -250,7 +251,7 @@
 			});
 			// #endif
 			// #ifndef APP
-			// this.init()
+			this.init()
 			// #endif
 		
 		},
@@ -273,6 +274,17 @@
 				this.newsNumFn()
 				this.isLogin = true
 				this.loadUserCarList()
+				
+				//蓝牙配对所需权限  运行小程序需要隐藏
+				const permissionArr=permision.requestAndroidPermissions(this.platform)
+				console.log(permissionArr,'permissionArr');
+				this.setData({
+					authStepList:permissionArr
+				})
+				permissionArr.map(item=>{
+					if(!item.state) this.isOpenAllPermission=true
+				})
+				
 				// if (!this.car_info.car_sn) {
 					
 				// } else {
@@ -329,20 +341,11 @@
 				});
 			},
 			inductiveUnlockHandle() {
-				
+				console.log(!this.isOpenAllPermission,this.isBluethConnect,'this.isBluethConnect');
 				if(this.isBluethConnect){
 					uni.navigateTo({ url: '/pages/bluetoothUnlock/unlockSet' })
 				}else{
-					const permissionArr=permision.requestAndroidPermissions(this.platform)
-					console.log(permissionArr,'permissionArr');
-					this.setData({
-						authStepList:permissionArr
-					})
-					let isOpenAllPermission=false
-					permissionArr.map(item=>{
-						if(!item.state) isOpenAllPermission=true
-					})
-					if(!isOpenAllPermission){
+					if(!this.isOpenAllPermission){
 						common.simpleToast('所需权限开启成功,前往开启蓝牙配对...');
 						uni.navigateTo({ url: '/pages/bluetoothUnlock/bluetoothPair' })
 					}else{
@@ -518,7 +521,8 @@
 					// 否则直接返回米  
 					return distanceMeters.toFixed(0);
 				}
-			}
+			},
+
 
 		}
 	};

+ 1 - 1
pages/moreInfo/moreInfo.vue

@@ -1,6 +1,6 @@
 <template>
 	<view class="container-view">
-		<navBar bgColor="transparent" type="index"></navBar>
+		<!-- <navBar bgColor="transparent" type="index"></navBar> -->
 		<view :style="'padding-top:176rpx;height:0'"></view>
 		<!-- <img src="https://qiniu.bms16.com/Fg8_p7083jpsy8BXG4bR6yMs7jQX" style="width: 100%;height: 526rpx;" alt=""> -->
 		<image src="https://qiniu.bms16.com/Fg8_p7083jpsy8BXG4bR6yMs7jQX" style="width: 100%;height: 526rpx;"