670增加去连接蓝牙,其它体验问题小调整

This commit is contained in:
liub
2025-09-25 09:59:37 +08:00
parent 497cce1e45
commit 17e76f9fa8
10 changed files with 340 additions and 160 deletions

View File

@ -124,7 +124,7 @@
:borderColor="Status.Pop.borderColor" :textColor="Status.Pop.textColor"
:buttonBgColor="Status.Pop.buttonBgColor" :buttonTextColor="Status.Pop.buttonTextColor"
:iconUrl="Status.Pop.iconUrl" :message="Status.Pop.message" :buttonText="Status.Pop.buttonText"
@buttonClick="HidePop" :visiblePrompt="Status.Pop.visiblePrompt" :promptTitle="Status.Pop.promptTitle"
@buttonClick="HidePop" @closePop="closePop" :visiblePrompt="Status.Pop.visiblePrompt" :promptTitle="Status.Pop.promptTitle"
v-model="Status.Pop.modelValue" />
<!-- 下方菜单 -->
@ -538,7 +538,7 @@
buttonBgColor: "#E03434",
buttonText: '去连接',
okCallback: function() {
console.log("1111");
// console.log("1111");
uni.navigateTo({
url: "/pages/common/addBLE/addEquip",
events: {
@ -974,8 +974,15 @@
})
},
closePop: function() {
this.Status.Pop.showPop = false;
if (this.Status.Pop.cancelCallback) {
this.Status.Pop.cancelCallback();
}
},
HidePop: function() {
console.log("1111");
// console.log("1111");
if (this.Status.Pop.clickEvt == 'SendUsr') {
}

View File

@ -146,7 +146,7 @@
:buttonBgColor="Status.Pop.buttonBgColor" :buttonTextColor="Status.Pop.buttonTextColor"
:iconUrl="Status.Pop.iconUrl" :message="Status.Pop.message" :buttonText="Status.Pop.buttonText"
@buttonClick="HidePop" :visiblePrompt="Status.Pop.visiblePrompt" :promptTitle="Status.Pop.promptTitle"
v-model="Status.Pop.modelValue" />
v-model="Status.Pop.modelValue" @closePop="closePop" />
<!-- 下方菜单 -->
<BottomSlideMenuPlus :config="Status.BottomMenu" @close="closeMenu" @itemClick="handleItemClick"
@ -173,7 +173,10 @@
hideLoading,
updateLoading
} from '@/utils/loading.js'
import {request,baseURL} from '../../utils/request';
import {
request,
baseURL
} from '../../utils/request';
import usrApi from '@/api/670/HBY670.js'
const pagePath = "pages/650/HBY650";
@ -201,7 +204,7 @@
promptTitle: '设备名称',
modelValue: '',
visibleClose: false,
okCallback:null
okCallback: null
},
BottomMenu: {
show: false,
@ -302,7 +305,7 @@
console.log("收到父页面的参数:" + JSON.stringify(data));
var device = data.data;
these.device=device;
these.device = device;
let f = ble.data.LinkedList.find((v) => {
if (v.macAddress == device.deviceMac) {
console.log("找到设备了", v);
@ -462,9 +465,9 @@
getDetail() {
var that = this;
usrApi.getDetail(this.device.id).then(res => {
if (res && res.code == 200) {
res = res.data;
res = res.data;
let personnelInfo = res.personnelInfo;
if (personnelInfo) {
that.formData.company = personnelInfo.unitName;
@ -475,7 +478,7 @@
}
});
},
setBleFormData() {
ble.data.LinkedList.find((v) => {
if (v.deviceId == these.formData.deviceId) {
@ -579,34 +582,36 @@
},
showBleUnConnect(){
this.showPop({
message: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备",
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
buttonText:'去连接',
okCallback:function(){
console.log("1111");
uni.navigateTo({
url:"/pages/common/addBLE/addEquip",
events: {
BindOver: function(data) {
console.log(data)
}
},
success: function(res) {
// 通过eventChannel向被打开页面传送数据
res.eventChannel.emit('detailData', { data: these.device })
},
fail(ex){
console.log("跳转失败",ex);
}
})
showBleUnConnect() {
this.showPop({
message: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备",
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
buttonText: '去连接',
okCallback: function() {
console.log("1111");
uni.navigateTo({
url: "/pages/common/addBLE/addEquip",
events: {
BindOver: function(data) {
console.log(data)
}
});
},
},
success: function(res) {
// 通过eventChannel向被打开页面传送数据
res.eventChannel.emit('detailData', {
data: these.device
})
},
fail(ex) {
console.log("跳转失败", ex);
}
})
}
});
},
LampToggle: function() {
this.formData.cMode = !this.formData.cMode;
@ -1141,6 +1146,13 @@
this.Status.BottomMenu.activeIndex = index;
},
closePop: function() {
this.Status.Pop.showPop = false;
if (this.Status.Pop.cancelCallback) {
this.Status.Pop.cancelCallback();
}
},
HidePop: function() {
if (this.Status.Pop.clickEvt == 'SendUsr') {
@ -1148,7 +1160,7 @@
console.log("1111");
this.Status.Pop.showPop = false;
if(this.Status.Pop.okCallback){
if (this.Status.Pop.okCallback) {
this.Status.Pop.okCallback();
}
},
@ -1232,10 +1244,10 @@
visibleClose: true
});
these.setBleFormData();
let json = {
deviceId: these.device.id,
deviceId: these.device.id,
name: these.formData.company,
position: these.formData.name,
unitName: these.formData.job,

View File

@ -247,7 +247,8 @@
:buttonBgColor="Status.Pop.buttonBgColor" :buttonTextColor="Status.Pop.buttonTextColor"
:iconUrl="Status.Pop.iconUrl" :message="Status.Pop.message" :buttonText="Status.Pop.buttonText"
@buttonClick="HidePop" @closePop="closePop" @cancelPop="closePop" :visiblePrompt="Status.Pop.visiblePrompt"
:promptTitle="Status.Pop.promptTitle" v-model="Status.Pop.modelValue" />
:promptTitle="Status.Pop.promptTitle" v-model="Status.Pop.modelValue" :showCancel="Status.Pop.showCancel"
:buttonCancelText="Status.Pop.buttonCancelText" />
<!-- 下方菜单 -->
<BottomSlideMenuPlus :config="Status.BottomMenu" @close="closeMenu" @itemClick="handleItemClick"
@ -311,15 +312,19 @@
},
Pop: {
showPop: false, //是否显示弹窗
popType: 'custom',
bgColor: '#383934bd',
borderColor: '#BBE600',
textColor: '#ffffffde',
buttonBgColor: '#BBE600',
buttonTextColor: '#232323DE',
iconUrl: '',
message: '您确定要这样做吗?',
buttonText: '确定',
showCancel: false,
buttonCancelText: '取消',
clickEvt: '',
visiblePrompt: false,
promptTitle: '设备名称',
@ -485,6 +490,7 @@
return false;
});
if (!f) {
these.showBleUnConnect();
these.getDetail();
return;
}
@ -516,6 +522,40 @@
},
methods: {
showBleUnConnect() {
this.showPop({
message: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备",
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
buttonText: '去连接',
showCancel: true,
cancelCallback: () => {
this.closePop();
},
okCallback: function() {
console.log("1111");
uni.navigateTo({
url: "/pages/common/addBLE/addEquip",
events: {
BindOver: function(data) {
console.log(data)
}
},
success: function(res) {
// 通过eventChannel向被打开页面传送数据
res.eventChannel.emit('detailData', {
data: these.device
})
},
fail(ex) {
console.log("跳转失败", ex);
}
})
}
});
},
gotoMap() {
this.detailData.longitude = this.formData.Lon;
this.detailData.latitude = this.formData.Lat;
@ -545,12 +585,16 @@
that.formData.address = res.address;
let personnelInfo = res.personnelInfo;
if (personnelInfo) {
that.formData.company = personnelInfo.unitName;
that.formData.usrname = personnelInfo.name;
that.formData.company = personnelInfo.name;
that.formData.usrname = personnelInfo.unitName;
that.formData.job = personnelInfo.position;
that.formData.usrid = personnelInfo.code
}
that.formData.imei=res.deviceImei;
these.device.deviceImei=res.deviceImei;
if(that.formData.imei){
that.initMQ();
}
let dic = {
"3": "hight",
"2": "center",
@ -670,7 +714,7 @@
return new Promise((resolve, reject) => {
if (mqttClient) {
console.log("无需再次初始化")
// console.log("无需再次初始化")
resolve();
return;
}
@ -735,7 +779,10 @@
qos: 1
});
if (flag) {
resolve();
resolve({
code: 200,
msg: 'MQTT直连发送成功'
});
return;
}
console.log("MQTT未连接无法发布消息")
@ -994,6 +1041,7 @@
});
} else {
requestSend();
these.showBleUnConnect();
}
}
@ -1062,7 +1110,7 @@
} else {
requestCloseSOS();
these.showBleUnConnect();
}
}
@ -1138,13 +1186,31 @@
ins_SOSGrade: [dic.mqtt[type]]
};
let requestSend = () => {
this.sendMQ(json).then((res) => {
console.log("4g发送成功");
json.deviceId = these.device.id;
json.deviceImei = these.device.deviceImei;
api.sendSos(json);
let message = {
instructValue: json.ins_SOSGrade[0]
};
message.deviceId = these.device.id;
message.deviceImei = these.device.deviceImei;
let requestSend = () => {
message.isBluetooth = false;
api.sendSos(message).then((res) => {
console.log("res=>", res);
if (res && res.code == 200) {
console.log("接口发送SOS指令成功");
return Promise.resolve({
code: 200,
msg: '操作成功'
});
} else {
return this.sendMQ(json);
}
}).then((res) => {
console.log("res=", res);
}).catch((ex) => {
console.log("ex=", ex);
these.showPop({
@ -1179,17 +1245,19 @@
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 10).then(
() => {
console.log("蓝牙发送成功了");
hideLoading(these);
these.setBleFormData();
message.isBluetooth = true;
api.sendSos(message);
}).catch((ex) => {
//使用4G发送
console.log("蓝牙发送失败,转4g发送", ex);
requestSend();
});
} else {
console.log("找不到蓝牙设备");
requestSend();
these.showBleUnConnect();
}
}
@ -1367,6 +1435,7 @@
} else {
console.log("找不到蓝牙设备使用4G发送")
requestSend();
these.showBleUnConnect();
}
}
@ -1745,37 +1814,9 @@
var sendVideo = (videoPath) => {
let f = these.getDevice();
if (!f) {
these.showPop({
message: "蓝牙未连接,请连接后再试",
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
buttonText: '去连接',
okCallback: function() {
console.log("1111");
uni.navigateTo({
url: "/pages/common/addBLE/addEquip",
events: {
BindOver: function(data) {
console.log(data)
}
},
success: function(res) {
// 通过eventChannel向被打开页面传送数据
res.eventChannel.emit('detailData', {
data: these.device
})
},
fail(ex) {
console.log("跳转失败", ex);
}
})
}
});
these.showBleUnConnect();
return;
}
let uploadVideo = () => {
@ -2014,6 +2055,8 @@
cancelCallback: null,
popType: 'custom',
buttonText: '确定',
showCancel: false,
buttonCancelText: '取消',
clickEvt: ''
};
if (!option) {
@ -2102,6 +2145,7 @@
if (!f) {
//走4G通道
requestSend();
these.showBleUnConnect();
return;
}
showLoading(this, {

View File

@ -124,7 +124,7 @@
:borderColor="Status.Pop.borderColor" :textColor="Status.Pop.textColor"
:buttonBgColor="Status.Pop.buttonBgColor" :buttonTextColor="Status.Pop.buttonTextColor"
:iconUrl="Status.Pop.iconUrl" :message="Status.Pop.message" :buttonText="Status.Pop.buttonText"
@buttonClick="HidePop" :visiblePrompt="Status.Pop.visiblePrompt" :promptTitle="Status.Pop.promptTitle"
@buttonClick="HidePop" @closePop="closePop" :visiblePrompt="Status.Pop.visiblePrompt" :promptTitle="Status.Pop.promptTitle"
v-model="Status.Pop.modelValue" />
<!-- 下方菜单 -->
@ -972,6 +972,13 @@
})
},
closePop: function() {
this.Status.Pop.showPop = false;
if (this.Status.Pop.cancelCallback) {
this.Status.Pop.cancelCallback();
}
},
HidePop: function() {
console.log("1111");
if (this.Status.Pop.clickEvt == 'SendUsr') {

View File

@ -102,6 +102,8 @@
data() {
return {
Status: {
intval: null,
time: null,
BottomMenu: {
show: false,
showHeader: false,
@ -152,7 +154,7 @@
these = this;
this.EquipMents = [];
ble = bleTool.getBleTool();
ble.addDeviceFound((arr) => {
arr = arr.devices;
@ -173,11 +175,15 @@
}
}
// console.log("equip=", these.EquipMents)
// console.log("equip=", these.EquipMents)
}, pagePath);
// console.log("addEquip")
ble.addReceiveCallback((receivData, f, path, arr) => {
if (f.macAddress && these.device) {
clearInterval(this.Status.intval);
this.Status.intval = null;
this.Status.time = null;
showLoading(these, {
text: '正在验证设备'
});
@ -202,10 +208,10 @@
// this.EquipMents = [];
this.PairEquip = [];
ble && ble.StartSearch().then(res=>{
console.log("开始搜索成功",res);
ble && ble.StartSearch().then(res => {
console.log("开始搜索成功", res);
}).catch((ex) => {
console.log("开始搜索出现异常",ex);
console.log("开始搜索出现异常", ex);
if (ex.code == 10001) {
these.showOpenSetting();
}
@ -244,6 +250,8 @@
ble.showBlueSetting(false);
},
DeviceVerdict(deviceId) { //判断是否是目标设备
console.log("deviceid=", deviceId);
console.log("these.device=", these.device)
if (these.device) { //从设备详情过来的,回设备详情去
let f = ble.data.LinkedList.find(v => {
if (v.deviceId == deviceId) {
@ -252,15 +260,32 @@
}
return false;
});
let removeLink=()=>{
ble.subScribe(deviceId,false);//取消订阅消息
ble.DropDevice(deviceId);//从缓存中删除该设备
ble.disconnectDevice(deviceId);//断开与该设备的连接
let index=this.PairEquip.findIndex(function(v) {
return v.deviceId == deviceId;
});
if(index>-1){
this.PairEquip.splice(index,1);
}
}
console.log("f=", f);
if (f.macAddress) {
if (f.macAddress != these.device.deviceMac) {
ble.disconnectDevice(deviceId);
removeLink();
updateLoading(these, {
text: "设备Mac地址错误,请重选设备连接"
})
});
setTimeout(() => {
hideLoading(these);
}, 1000)
return;
}
@ -270,9 +295,44 @@
uni.navigateBack();
return true;
} else {
updateLoading(these, {
text: "等待设备上报Mac地址"
})
this.Status.time = 30;
this.Status.intval = null;
this.Status.intval = setInterval(() => {
this.Status.time = this.Status.time-1;
if (this.Status.time < 0) {
clearInterval(this.Status.intval)
this.Status.intval = null;
this.Status.time = null;
f = ble.data.LinkedList.find(v => {
if (v.deviceId == deviceId) {
v.device = these.device;
return true;
}
return false;
});
if(!f.macAddress){
removeLink();
updateLoading(these, {
text: "出现错误,未收到设备Mac地址"
});
setTimeout(()=>{
hideLoading(these)
},1000);
}
return;
}
updateLoading(these, {
text: "等待设备上报Mac地址," + these.Status.time + 's'
});
}, 1000);
return undefined;
}
}

View File

@ -83,7 +83,7 @@ export default {
id: marker.deviceImei, // 适配deviceId字段
latitude: lat,
longitude: lng,
iconPath: marker.devicePic || '/static/images/common/device.png',
iconPath: marker.devicePic || '/static/images/common/mapLocation.png',
width: 40,
height: 40,
anchor: {x: 0.5, y: 0.5}, // 锚点在中心