diff --git a/App.vue b/App.vue
index 4d86eee..35e20f9 100644
--- a/App.vue
+++ b/App.vue
@@ -53,6 +53,9 @@
},
onHide: function() {
console.log('App Hide');
+ },
+ onError(ex) {
+ console.error("出现了未知的异常",ex);
}
}
diff --git a/api/common/index.js b/api/common/index.js
index 469ba65..dd8f26f 100644
--- a/api/common/index.js
+++ b/api/common/index.js
@@ -17,6 +17,13 @@ export function deviceTypeList(params) {
})
}
+export function typeAll(){
+ return request({
+ url: '/app/xinghan/device/typeAll',
+ method: 'get'
+ });
+}
+
// 删除设备列表接口
export function deviceUnbind(id) {
return request({
diff --git a/components/TextToHex/TextToHexV1.vue b/components/TextToHex/TextToHexV1.vue
index 36bfc99..d3237ad 100644
--- a/components/TextToHex/TextToHexV1.vue
+++ b/components/TextToHex/TextToHexV1.vue
@@ -229,12 +229,12 @@
let linePixls = [];
let item = this.validTxts[i];
- console.log("item=",item);
+
for (var j = 0; j < item.length; j++) {
let result = await drawTxt(item[j]);
linePixls.push(convertCharToMatrix(result.pixelData));
}
- console.log("hexs=",linePixls.join(","));
+ // console.log("hexs=",linePixls.join(","));
arr.push(linePixls);
}
diff --git a/config/index.js b/config/index.js
index e9edc18..6ec3377 100644
--- a/config/index.js
+++ b/config/index.js
@@ -2,7 +2,7 @@
const config = {
// 开发环境
development: {
- BASE_URL: 'http://139.224.253.23:8000',
+ BASE_URL: 'http://192.168.110.57:8000',//http://139.224.253.23:8000
API_PREFIX: '',
// MQTT 配置
MQTT_HOST: 'www.cnxhyc.com',
diff --git a/main.js b/main.js
index 1a815db..5086650 100644
--- a/main.js
+++ b/main.js
@@ -6,13 +6,13 @@ import uView from 'vk-uview-ui';
// #ifndef VUE3
import Vue from 'vue'
-import store from './store/store';
+
import './uni.promisify.adaptor'
Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
- store,
+
...App
})
Vue.use(uView)
diff --git a/manifest.json b/manifest.json
index 35807b5..6dadd96 100644
--- a/manifest.json
+++ b/manifest.json
@@ -2,7 +2,7 @@
"name" : "星汉物联",
"appid" : "__UNI__A21EF43",
"description" : "设备管控",
- "versionName" : "1.0.8",
+ "versionName" : "1.0.12",
"versionCode" : "100",
"transformPx" : false,
/* 5+App特有相关 */
@@ -99,23 +99,7 @@
},
"push" : {
"unipush" : {
- "version" : "2",
- "offline" : true,
- "hms" : {},
- "oppo" : {},
- "vivo" : {},
- "mi" : {},
- "meizu" : {},
- "honor" : {},
- "icons" : {
- "small" : {
- "xxhdpi" : "unpackage/res/icons/72x72.png",
- "xhdpi" : "unpackage/res/icons/48x48.png",
- "hdpi" : "unpackage/res/icons/36x36.png",
- "mdpi" : "unpackage/res/icons/24x24.png",
- "ldpi" : "unpackage/res/icons/18x18.png"
- }
- }
+ "offline" : false
}
}
},
diff --git a/package.json b/package.json
index a9f52da..c46cb0b 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
"dependencies": {
"axios": "^1.9.0",
"blueimp-md5": "^2.19.0",
- "paho-mqtt": "^1.1.0",
+ "paho-mqtt": "^1.1.0",
"vk-uview-ui": "^1.5.2"
}
}
diff --git a/pages.json b/pages.json
index 9e6f30d..acfd99c 100644
--- a/pages.json
+++ b/pages.json
@@ -339,6 +339,7 @@
"path" : "pages/102/HBY102",
"style" :
{
+ "navigationStyle": "custom",
"navigationBarTitleText" : "HBY102"
}
},
@@ -362,6 +363,27 @@
{
"navigationBarTitleText" : "HBY018A"
}
+ },
+ {
+ "path" : "pages/6107/BJQ6107",
+ "style" :
+ {
+ "navigationBarTitleText" : "BJQ6107"
+ }
+ },
+ {
+ "path" : "pages/6155/BJQ6155",
+ "style" :
+ {
+ "navigationBarTitleText" : "BJQ6155"
+ }
+ },
+ {
+ "path" : "pages/102/HBY102_History",
+ "style" :
+ {
+ "navigationStyle": "custom"
+ }
}
diff --git a/pages/100/HBY100.vue b/pages/100/HBY100.vue
index af2d4d9..2d0e757 100644
--- a/pages/100/HBY100.vue
+++ b/pages/100/HBY100.vue
@@ -255,10 +255,7 @@
hideLoading,
updateLoading
} from '@/utils/loading.js'
- import {
- request,
- baseURL
- } from '../../utils/request';
+import request, { baseURL } from '@/utils/request.js';
import Common from '@/utils/Common.js'
const pagePath = "/pages/100/HBY100";
diff --git a/pages/102/HBY102.vue b/pages/102/HBY102.vue
index ff9220c..4379aef 100644
--- a/pages/102/HBY102.vue
+++ b/pages/102/HBY102.vue
@@ -1,5 +1,26 @@
+
+
+
+
+
+ {{Status.navbar.title}}
+
+
+
+
+
+ {{item.math>9?'9+':item.math}}
+
+
+
+
+
+
+
+
@@ -16,7 +37,8 @@
- {{formData.sta_charge?dic.sta_charge[formData.sta_charge+'']:"未充电" }}
+ {{formData.sta_charge?dic.sta_charge[formData.sta_charge+'']:"未充电" }}
+
设备状态
@@ -46,7 +68,7 @@
-->
-
+
闯入报警!
{{item.name}}
@@ -161,9 +183,9 @@
-
+
-
+
@@ -223,30 +245,30 @@
show: false,
showHeader: true,
menuItems: [{
- text: '2M',
- value:'status_2M',
- icon: ''
- },
- {
- text: '4M',
- value:'status_4M',
- icon: ''
- },
- {
- text: '7M',
- value:'status_7M',
- icon: ''
- },
- {
- text: '10M',
- value:'status_10M',
- icon: ''
- },
- {
- text: '关闭',
- value:'status_off',
- icon: ''
- }
+ text: '2M',
+ value: 'status_2M',
+ icon: ''
+ },
+ {
+ text: '4M',
+ value: 'status_4M',
+ icon: ''
+ },
+ {
+ text: '7M',
+ value: 'status_7M',
+ icon: ''
+ },
+ {
+ text: '10M',
+ value: 'status_10M',
+ icon: ''
+ },
+ {
+ text: '关闭',
+ value: 'status_off',
+ icon: ''
+ }
],
activeIndex: -1,
bgColor: '#2a2a2a',
@@ -269,6 +291,21 @@
showClose: false
},
usrToggle: false,
+ navbar: {
+ icons: [{
+ src: '/static/images/common/history.png',
+ callback: this.gotoHistory,
+ math: 0
+ },
+ {
+ src: '/static/images/common/shape.png',
+ callback: this.gotoShare
+ }
+ ],
+ title: 'HBY102'
+
+ },
+ apiType: ''
},
formData: {
img: '/static/images/common/HBY102.png',
@@ -281,13 +318,13 @@
statu: '',
sta_address: '',
bleStatu: false,
- sta_charge:'',
+ sta_charge: '',
sta_LedType: '',
sta_RadarType: '',
sta_Online: '',
warnTime: '',
sta_sosadd: "",
- sta_sosName:'',
+ sta_sosName: '',
sta_IntrusTime: ''
},
@@ -300,7 +337,8 @@
show: true,
img: '/static/images/100/light.png',
activeImg: '/static/images/100/lightActive.png',
- group: 'sta_LedType'
+ group: 'sta_LedType',
+ permission: '1'
},
{
key: 'led_low_flash',
@@ -308,7 +346,8 @@
show: true,
img: '/static/images/102/lowFlash.png',
activeImg: '/static/images/102/lowFlashActive.png',
- group: 'sta_LedType'
+ group: 'sta_LedType',
+ permission: '1'
},
{
key: 'led_steady',
@@ -316,7 +355,8 @@
show: true,
img: '/static/images/102/liting.png',
activeImg: '/static/images/102/litingActive.png',
- group: 'sta_LedType'
+ group: 'sta_LedType',
+ permission: '1'
},
{
key: 'status_on',
@@ -324,7 +364,8 @@
show: true,
img: '/static/images/102/redar.png',
activeImg: '/static/images/102/redarActive.png',
- group: 'sta_RadarType'
+ group: 'sta_RadarType',
+ permission: '48'
},
{
key: 'E49_on',
@@ -332,7 +373,8 @@
show: true,
img: '/static/images/102/line.png',
activeImg: '/static/images/102/lineActive.png',
- group: 'sta_Online'
+ group: 'sta_Online',
+ permission: '49'
},
{
key: 'led_off',
@@ -377,7 +419,8 @@
showConfirm: false
},
groupDevices: [],
- warnDevices:[]
+ warnDevices: [],
+ permissions: []
}
},
@@ -404,9 +447,20 @@
eventChannel.on('detailData', function(data) {
- // console.log("收到父页面的参数:" + JSON.stringify(data));
+ console.log("收到父页面的参数:" + JSON.stringify(data));
var device = data.data;
+ these.Status.apiType = data.apiType;
+ if (data.apiType !== 'listA') {
+ Common.getdeviceShareId(data.data.id).then(res => {
+ if (res.code == 200) {
+ if (res.data.permission) {
+ these.permissions = res.data.permission.split(',');
+ }
+ }
+ });
+ }
these.device = device;
+ these.getWarns();
let f = ble.data.LinkedList.find((v) => {
if (v.macAddress == device.deviceMac) {
// console.log("找到设备了", v);
@@ -452,34 +506,181 @@
},
onShow() {
this.Status.pageHide = false;
+ this.getLinkedCnt();
},
computed: {
- Distance:function(){
- let f=this.Status.BottomMenu.menuItems.find((item,index)=>{
-
- return item.value===this.formData.sta_RadarType;
-
-
+ Distance: function() {
+ let f = this.Status.BottomMenu.menuItems.find((item, index) => {
+
+ return item.value === this.formData.sta_RadarType;
+
+
});
- if(f){
+ if (f) {
return f.text;
}
return '关闭';
},
- activeIndex:function(){
- let active=4;
- let f=this.Status.BottomMenu.menuItems.find((item,index)=>{
-
- if(item.value===this.formData.sta_RadarType){
- active=index;
+ activeIndex: function() {
+ let active = 4;
+ let f = this.Status.BottomMenu.menuItems.find((item, index) => {
+
+ if (item.value === this.formData.sta_RadarType) {
+ active = index;
}
});
return active;
}
},
methods: {
+ getLinkedCnt() {//获取在线设备的数量
+ let f = this.getDevice();
+ // #ifdef APP-PLUS
+ if (!f) {
+ return;
+ }
+ // #endif
+ // #ifdef H5
+ f = {
+ deviceId: '12345'
+ }
+ // #endif
+
+
+ if (ble) {
+ let buffer = {
+ ins_Quantity: "query"
+ };
+ ble.sendString(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 30).then(res=>{
+ setTimeout(()=>{
+ this.getWarns();
+ },1500);
+ }).catch(()=>{
+ this.getWarns();
+ })
+ }
+
+
+ },
+ getWarns() {
+ return new Promise((resolve, reject) => {
+ if (!these.device.id) {
+ return;
+ }
+
+ let warnKey = "102_" + these.device.id + "_warning";
+ let linkKey = "102_" + these.device.id + "_linked";
+ let p1 = new Promise((succ, err) => {
+ uni.getStorage({
+ key: warnKey,
+ success(res) {
+ let data = res.data;
+ let fs = data.filter(v => {
+ return !v.read
+ });
+ succ(fs);
+ },
+ fail(ex) {
+ err(null);
+ }
+ });
+ });
+
+ let p2 = new Promise((succ, err) => {
+ uni.getStorage({
+ key: linkKey,
+ success(res) {
+ console.error("获取到联机数据",res);
+ let data = res.data;
+ let fs = data.filter(v => {
+ return !v.read
+ });
+ console.error("未读联机数据",fs);
+ succ(fs);
+ },
+ fail(ex) {
+ err(null);
+ }
+ });
+ });
+
+ Promise.allSettled([p1, p2]).then(results => {
+ let fs = [];
+
+ if (results[0].status == 'fulfilled') {
+ fs=fs.concat(results[0].value);
+ }
+ if (results[1].status == 'fulfilled') {
+ fs=fs.concat(results[1].value);
+ }
+console.error("获取到未读消息",fs);
+ these.$set(these.Status.navbar.icons[0], "math", fs.length);
+ });
+
+
+ });
+
+ },
+
+ gotoHistory(item, s) {
+
+ uni.navigateTo({
+ url: '/pages/102/HBY102_History',
+ success: (res) => {
+ res.eventChannel.emit('detailData', {
+ data: these.device
+ });
+ }
+ });
+
+ },
+ gotoShare(item, s) {
+ uni.navigateTo({
+ url: '/pages/common/share/index',
+ events: {
+ ack: function(data) {}
+ },
+ success: (res) => {
+ let json = {
+ persissonType: '102'
+ };
+ Object.assign(json, this.device);
+ res.eventChannel.emit('share', {
+ data: json
+ });
+ }
+ })
+ },
+ handleRightClick(item, s) {
+ if (item && item.callback) {
+ item.callback(item, s);
+ } else {
+ uni.showModal({
+ content: '敬请期待'
+ })
+
+ }
+ },
+ navigatorBack() {
+ uni.navigateBack();
+ },
actionSett(item, index) {
+
+ if (!this.permissions.includes(item.permission) && this.Status.apiType !== 'listA') {
+
+ this.showPop({
+ message: '无操作权限',
+ iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
+ borderColor: "#e034344d",
+ buttonBgColor: "#E03434",
+ okCallback: null,
+ buttonText: "确定"
+ })
+ return;
+ }
+
+
if (item.group == 'sta_LedType') {
this.sosSetting(item, index);
return;
@@ -488,7 +689,7 @@
if (item.group == 'sta_RadarType') {
// this.toggleRedar(item, index);
- this.showRedarSetting(item,index);
+ this.showRedarSetting(item, index);
return;
}
@@ -555,24 +756,24 @@
},
- showRedarSetting(){
- this.Status.BottomMenu.show=true;
- this.Status.BottomMenu.showBtn=false;
-
- this.Status.BottomMenu.title="感应距离设置";
-
- this.Status.BottomMenu.textAlign="center";
-
- this.Status.BottomMenu.showMask=true;
- this.Status.BottomMenu.activeIndex=this.activeIndex;
+ showRedarSetting() {
+ this.Status.BottomMenu.show = true;
+ this.Status.BottomMenu.showBtn = false;
+
+ this.Status.BottomMenu.title = "感应距离设置";
+
+ this.Status.BottomMenu.textAlign = "center";
+
+ this.Status.BottomMenu.showMask = true;
+ this.Status.BottomMenu.activeIndex = this.activeIndex;
},
- btnClick(item,index){
- this.Status.BottomMenu.show=false;
- console.log("选中的项:"+index+",值:"+JSON.stringify(item));
- this.toggleRedar(item,index);
+ btnClick(item, index) {
+ this.Status.BottomMenu.show = false;
+ console.log("选中的项:" + index + ",值:" + JSON.stringify(item));
+ this.toggleRedar(item, index);
},
- closeActionSheet(){
- this.Status.BottomMenu.show=false;
+ closeActionSheet() {
+ this.Status.BottomMenu.show = false;
},
toggleRedar(item, index) { //雷达启停
let f = this.getDevice();
@@ -601,7 +802,7 @@
.then(res => {
debugger;
this.formData.sta_RadarType = val;
- this.Status.BottomMenu.activeIndex=index;
+ this.Status.BottomMenu.activeIndex = index;
these.setBleFormData();
resolve();
})
@@ -642,6 +843,19 @@
sosSetting(item, isOk) {
+ if (!this.permissions.includes('46') && this.Status.apiType !== 'listA') {
+
+ this.showPop({
+ message: '无操作权限',
+ iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
+ borderColor: "#e034344d",
+ buttonBgColor: "#E03434",
+ okCallback: null,
+ buttonText: "确定"
+ })
+ return;
+ }
+
if (item.key == 'led_alarm' && this.formData.sta_LedType == 'led_alarm') {
return;
}
@@ -817,59 +1031,66 @@
let json = recei.ReceiveData(receive, device, pagePath, recArr);
console.log("json=", json)
+ setTimeout(()=>{
+ this.getWarns();
+ },500);
-
-
- let active=-1;
- let f=this.Status.BottomMenu.menuItems.find((item,index)=>{
-
- if(item.value===json.sta_RadarType){
- active=index;
+
+ let active = -1;
+ let f = this.Status.BottomMenu.menuItems.find((item, index) => {
+
+ if (item.value === json.sta_RadarType) {
+ active = index;
}
});
- this.Status.BottomMenu.activeIndex=active;
+ this.Status.BottomMenu.activeIndex = active;
let msg = [];
- if (json.sta_PowerPercent <= 20 && (json.sta_charge===0 || json.sta_charge==='0')) {
+ if (json.sta_PowerPercent <= 20 && (json.sta_charge === 0 || json.sta_charge === '0')) {
msg.push("设备电量低");
}
-
- if(json.sta_sosadd_off){//某个设备解除报警
- this.warnDevices.filter((d,index)=>{
- if(d.mac===json.sta_sosadd_off){
- this.warnDevices.splice(index,1);
+
+ if (json.sta_sosadd_off) { //某个设备解除报警
+ this.warnDevices.filter((d, index) => {
+ if (d.mac === json.sta_sosadd_off) {
+ this.warnDevices.splice(index, 1);
}
});
}
-
-
+
+
let keys = Object.keys(json);
-
+
keys.forEach(key => {
if (key in this.formData) {
// console.log("key=",key+",value=",json[key]);
this.formData[key] = json[key];
}
});
-
- if (json.sta_sosadd) {//某个设备闯入报警
- console.log("查询设备中",json.sta_sosadd);
+
+ if (json.sta_sosadd) { //某个设备闯入报警
+ console.log("查询设备中", json.sta_sosadd);
this.searchDevice(json.sta_sosadd).catch(ex => {}).then(dev => {
console.log("dev=", dev);
- let d=this.warnDevices.find(v=>{return v.mac===json.sta_sosadd});
- let deviceName="";
+ let d = this.warnDevices.find(v => {
+ return v.mac === json.sta_sosadd
+ });
+ let deviceName = "";
if (dev) {
// this.formData.sta_sosName=dev.deviceName;
msg.push('"' + dev.deviceName + '"闯入报警中');
- deviceName=dev.deviceName;
-
+ deviceName = dev.deviceName;
+
} else {
msg.push('闯入报警中');
// this.formData.sta_sosName="";
}
- if(!d){
- this.warnDevices.push({mac:json.sta_sosadd,name:deviceName});
+ if (!d) {
+ this.warnDevices.push({
+ mac: json.sta_sosadd,
+ name: deviceName
+ });
}
this.showMsg(msg.join(','));
});
@@ -898,7 +1119,7 @@
},
getWarDevice(macStr) {
- console.log("macStr=",macStr);
+ console.log("macStr=", macStr);
if (macStr) {
if (!macStr.includes(':')) {
@@ -1158,6 +1379,11 @@
\ No newline at end of file
diff --git a/pages/102/HBY102_History.vue b/pages/102/HBY102_History.vue
new file mode 100644
index 0000000..fc8fd88
--- /dev/null
+++ b/pages/102/HBY102_History.vue
@@ -0,0 +1,1327 @@
+
+
+
+
+
+
+
+ {{ Status.navbar.title }}
+
+
+
+
+
+ 连接记录
+
+ 报警记录
+
+
+
+
+
+
+
+ 全部报警
+
+ 闯入报警
+
+ 强制报警
+
+
+
+
+
+
+
+
+
+
+
+ 设备数量
+ {{item.linkEqs.length}}
+
+
+
+ 设备名称
+ {{dev.linkName?dev.linkName:dev.linkMac}}
+
+
+
+
+
+
+
+
+ {{item.warnType}}
+ {{item.warnName?item.warnName:item.warnMac}}
+
+ {{DateFormat(item.warnTime,'yyyy/MM/dd')}}
+ {{DateFormat(item.warnTime,'HH:mm:ss')}}
+
+
+
+
+
+
+
+
+
+ 月份选择
+ 自定义时间
+
+
+
+
+ 近三个月
+ 近一个月
+ 自定义
+
+
+
+
+
+ {{filter.start}}
+
+
+ 一
+
+
+ {{filter.end}}
+
+
+
+
+
+
+
+
+
+ {{ item }}年
+
+
+ {{ item }}月
+
+
+ {{ item }}日
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pages/210/HBY210.vue b/pages/210/HBY210.vue
index ad2cdb1..9e6f65f 100644
--- a/pages/210/HBY210.vue
+++ b/pages/210/HBY210.vue
@@ -228,7 +228,7 @@
:key="index"
>
@@ -356,9 +356,7 @@
laserModeSettings, //激光模式设置
mapReverseGeocoding //地图逆解析
} from '@/api/6170/deviceControl.js'
- import {
- getDeviceId
- } from '../../store/BLETools';
+
import {
baseURL,
getToken,
diff --git a/pages/4877/BJQ4877.vue b/pages/4877/BJQ4877.vue
index ac72311..d0fcd77 100644
--- a/pages/4877/BJQ4877.vue
+++ b/pages/4877/BJQ4877.vue
@@ -107,7 +107,7 @@
-
@@ -125,15 +125,15 @@
箭头模式
- 箭头朝向
+ 朝向/颜色
-
+
@@ -141,10 +141,10 @@
- 红色朝前
+ 朝左
-
+
@@ -153,10 +153,37 @@
mode="aspectFit">
- 绿色朝后
+ 朝右
+
+
+
+
+
+
+
+
+
+
+ 红色
+
+
+
+
+
+
+
+ 绿色
+
+
+
+
+
+
@@ -248,14 +275,11 @@
hideLoading,
updateLoading
} from '@/utils/loading.js'
- import {
- request,
- baseURL
- } from '../../utils/request';
+import request, { baseURL } from '@/utils/request.js';
import {
colors as groupColors
} from '@/api/4877/BJQ4877.js';
-
+
import MqTool from '@/utils/MqHelper.js'
const pagePath = "/pages/4877/BJQ4877";
@@ -265,7 +289,7 @@
var recei = null;
var interval = null;
var slidTime = null;
- var mq=null;
+ var mq = null;
export default {
data() {
return {
@@ -346,7 +370,11 @@
sta_GroupType: -1, //配组
sta_ArrowType: '', //箭头方向
warnTime: 0,
- sta_Channel: 80
+ sta_Channel: 31,
+ sta_ArrowMode:'',
+ groups: [
+
+ ]
},
dic: {
SOS: [{
@@ -361,10 +389,8 @@
img: '/static/images/4877/fan.png',
activeImg: '/static/images/4877/fanActive.png'
}
- ],
- groups: [
-
]
+
},
device: {
id: "",
@@ -391,19 +417,19 @@
onUnload() {
console.log("页面卸载,释放资源");
ble.removeAllCallback(pagePath);
- if(mq){
- mq.unSubscribes();
- mq.disconnect();
+ if (mq) {
+ mq.unSubscribes();
+ mq.disconnect();
}
- ble=null;
- mq=null;
+ ble = null;
+ mq = null;
clearInterval(interval);
},
onLoad: function() {
these = this;
recei = BleReceive.getBleReceive();
ble = BleTool.getBleTool();
- mq=MqTool.getMqTool();
+ mq = MqTool.getMqTool();
this.dic.gropus = [];
@@ -433,19 +459,28 @@
return false;
});
- these.dic.groups = groups;
+ these.formData.groups = groups;
}
var device = data.data;
these.device = device;
-
- let arr=[{topic:'C/4877_Groups_'+these.device.id,callback:these.getCheckedColors}];
- mq.init().then(res=>{
- mq.subscribes(arr).catch(ex=>{
- console.error("ex=",ex);
+
+ let arr = [{
+ topic: 'C/4877_Groups_' + these.device.id,
+ callback: these.getCheckedColors
+ }
+ // ,
+ // {
+ // topic: 'C/4877_Channel_' + these.device.id,
+ // callback: these.getChannel
+ // }
+ ];
+ mq.init().then(res => {
+ mq.subscribes(arr).catch(ex => {
+ console.error("ex=", ex);
});
})
-
+
let f = ble.data.LinkedList.find((v) => {
if (v.macAddress == device.deviceMac) {
// console.log("找到设备了", v);
@@ -474,8 +509,8 @@
these.formData.bleStatu = false;
these.formData.deviceId = f.deviceId;
- these.formData.warnTime=null;
- these.formData.sta_SOSType='sos_off';
+ these.formData.warnTime = null;
+ these.formData.sta_SOSType = 'sos_off';
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
these.formData.bleStatu = true;
});
@@ -496,38 +531,53 @@
},
methods: {
- getCheckedColors(rec){
- console.error("收到MQ消息:",rec);
- try{
-
- let str=rec.receive.payloadString;
- let arr=JSON.parse(str);
-
-
- let groups = groupColors.filter((v,index) => {
- if(arr[index]===1){
- return true;
- }
- return false;
- });
-
- these.dic.groups = groups;
-
- let checks = groups.map(item => {
- return item.id
- });
-
- uni.setStorage({
- key: "4877CheckColor_" + this.device.id,
- data: checks
- });
-
-
- }catch(err){
-
+ getChannel(rec) {
+ console.error("收到MQ信道保留消息:", rec);
+ try {
+
+ let str = rec.receive.payloadString;
+ let json = JSON.parse(str);
+ if('ins_channel' in json){
+ this.formData.sta_Channel=json.ins_channel;
+ these.setBleFormData();
+ }
+
+ } catch (err) {
+
}
-
-
+ },
+ getCheckedColors(rec) {
+ console.error("收到MQ消息:", rec);
+ try {
+
+ let str = rec.receive.payloadString;
+ let arr = JSON.parse(str);
+
+
+ let groups = groupColors.filter((v, index) => {
+ if (arr[index] === 1) {
+ return true;
+ }
+ return false;
+ });
+
+ these.formData.groups = groups;
+ console.error("groups=",these.formData.groups);
+ let checks = groups.map(item => {
+ return item.id
+ });
+
+ uni.setStorage({
+ key: "4877CheckColor_" + this.device.id,
+ data: checks
+ });
+
+
+ } catch (err) {
+
+ }
+
+
},
ShowChannelEdit() {
this.Status.ShowEditChannel = true;
@@ -547,15 +597,15 @@
promptTitle: '',
modelValue: '',
visibleClose: false,
- okCallback: ()=>{
+ okCallback: () => {
this.onChannelChanging();
- this.Status.ShowEditChannel=false;
+ this.Status.ShowEditChannel = false;
},
showSlot: true,
buttonCancelText: '取消',
showCancel: true,
- cancelCallback:()=>{
- this.Status.ShowEditChannel=false;
+ cancelCallback: () => {
+ this.Status.ShowEditChannel = false;
}
});
},
@@ -566,7 +616,7 @@
return;
}
let f = this.getDevice();
-
+
if (!f) {
this.showBleUnConnect();
return;
@@ -580,6 +630,14 @@
json = JSON.stringify(json);
ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30).then(res => {
console.log("发送成功");
+
+ // mq.sendData('C/4877_Channel_' + these.device.id, JSON.stringify(json), true).then(
+ // res => {
+ // console.log("发送成功,", res)
+ // }).catch(err => {
+ // console.error("err=", err);
+ // });
+
this.setBleFormData();
}).catch(ex => {
this.showMsg(ex.msg);
@@ -587,6 +645,31 @@
}, 200)
+ },
+ ArrowModeSet(val) {
+ if (this.formData.sta_SOSType === 'sos') {
+ this.showMsg("设备强制报警中,请先关闭报警")
+ return;
+ }
+
+ let f = this.getDevice();
+ if (!f) {
+ this.showBleUnConnect();
+ return;
+ }
+ if (this.formData.sta_ArrowMode === val) {
+ return;
+ }
+
+ var json = {
+ ins_right_side: val
+ }
+ json = JSON.stringify(json);
+ ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30).then(res => {
+ this.formData.sta_ArrowMode = val;
+ }).catch(ex => {
+ this.showMsg(ex.msg);
+ });
},
ArrowSet(val) {
if (this.formData.sta_SOSType === 'sos') {
@@ -631,7 +714,7 @@
return false;
});
- these.dic.groups = arr;
+ these.formData.groups = arr;
these.CheckGroupOver(data.allFlag);
}
},
@@ -648,17 +731,17 @@
return;
}
- mq.sendData('C/4877_Groups_'+these.device.id,JSON.stringify(arr),true).then(res=>{
- console.log("发送成功,",res)
- }).catch(err=>{
- console.error("err=",err);
+ mq.sendData('C/4877_Groups_' + these.device.id, JSON.stringify(arr), true).then(res => {
+ console.log("发送成功,", res)
+ }).catch(err => {
+ console.error("err=", err);
});
var json = {
ins_GroupType: arr
}
json = JSON.stringify(json);
ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30).then(res => {
-
+ this.setBleFormData();
}).catch(ex => {
this.showMsg(ex.msg);
});
@@ -672,11 +755,11 @@
// borderColor: "#e034344d",
// buttonBgColor: "#E03434",
// okCallback: () => {
- clearInterval(interval);
+ clearInterval(interval);
- this.sosSetting({
- val: val
- });
+ this.sosSetting({
+ val: val
+ });
// },
// buttonText: "解除",
// showCancel: true,
@@ -715,21 +798,21 @@
}
groupSet();
},
- SOSEvt(){
+ SOSEvt() {
if (this.formData.sta_SOSType == 'sos') {
- this.formData.sta_ArrowType='arrow_off';
+ this.formData.sta_ArrowType = 'arrow_off';
this.formData.warnTime = 0;
clearInterval(interval);
interval = setInterval(() => {
this.formData.warnTime += 1;
}, 1000)
- }else{
+ } else {
clearInterval(interval);
- interval=null;
+ interval = null;
this.formData.warnTime = 0;
}
},
-
+
sosSetting(item, index) {
let f = this.getDevice();
@@ -750,7 +833,7 @@
ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30).then(res => {
this.formData.sta_GroupType = -1;
this.formData.sta_SOSType = json.ins_SOSType
-
+
these.SOSEvt();
})
@@ -759,9 +842,9 @@
});
}
-
-
- let confirmTask=()=>{
+
+
+ let confirmTask = () => {
this.showPop({
message: '确定' + (this.formData.sta_SOSType === 'sos' ? '关闭' : '开启') + '声光报警模式?',
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
@@ -777,14 +860,14 @@
confirmTask();
} else if (item.val === 'sos_off') {
-
- if(this.formData.sta_SOSType === 'sos'){
+
+ if (this.formData.sta_SOSType === 'sos') {
confirmTask();
- }else{
+ } else {
task();
}
-
-
+
+
} else {
if (this.formData.sta_SOSType === 'sos') {
@@ -922,14 +1005,14 @@
this.formData[key] = data[key];
}
});
-
-
+
+
let msg = [];
if (data.sta_SOSType == 'sos') {
msg.push("设备声光报警中");
-
+
}
- if('sta_SOSType' in data){
+ if ('sta_SOSType' in data) {
these.SOSEvt();
}
if (data.sta_PowerPercent <= 20) {
@@ -1566,7 +1649,7 @@
border-radius: 16rpx;
background: rgba(26, 26, 26, 1);
width: 100%;
- padding: 10rpx 0rpx;
+ padding: 20rpx 0rpx;
}
.modeSetting {
@@ -1600,7 +1683,22 @@
letter-spacing: 0.14rpx;
}
+
+
+ .modeSetting .arrow .outCircle .text {
+ margin-top:0rpx !important;
+
+
+ }
+
+.arrowContent .line {
+ width:calc(100% - 60rpx);
+
+ height: 0rpx;
+ border-bottom:1px solid #ffffff30;
+ margin: 30rpx ;
+}
.modeSetting .arrow .outCircle {
width: 120rpx;
height: 120rpx;
@@ -1632,6 +1730,8 @@
align-items: center;
}
+
+
.modeSetting .arrow.active .outCircle {
border: 4rpx solid rgba(174, 214, 0, 1);
padding: 4rpx;
@@ -1642,6 +1742,35 @@
border-radius: 50%;
}
+
+
+ .modeSetting .arrow.redactive .outCircle {
+ border: 4rpx solid #EC2A2A;
+ padding: 4rpx;
+ }
+
+ .modeSetting .arrow.redactive .item {
+ background: #EC2A2A;
+ border-radius: 50%;
+
+ }
+
+ .modeSetting .arrow.greenactive .outCircle {
+ border: 4rpx solid #00BD00;
+ padding: 4rpx;
+ }
+
+ .modeSetting .arrow.greenactive .item {
+ background: #00BD00;
+ border-radius: 50%;
+
+ }
+
+ .modeSetting .arrow.redactive .item .text,
+ .modeSetting .arrow.greenactive .item .text{
+ color:#FFFFFFde !important;
+ }
+
.modeSetting .item .img {
width: 52rpx;
diff --git a/pages/4877/BJQ4877V1.vue b/pages/4877/BJQ4877V1.vue
index 6b197bd..ee7108c 100644
--- a/pages/4877/BJQ4877V1.vue
+++ b/pages/4877/BJQ4877V1.vue
@@ -240,10 +240,7 @@
hideLoading,
updateLoading
} from '@/utils/loading.js'
- import {
- request,
- baseURL
- } from '../../utils/request';
+import request, { baseURL } from '@/utils/request.js';
import usrApi from '@/api/670/HBY670.js'
const pagePath = "/pages/4877/BJQ4877";
diff --git a/pages/6107/BJQ6107.vue b/pages/6107/BJQ6107.vue
new file mode 100644
index 0000000..609be9a
--- /dev/null
+++ b/pages/6107/BJQ6107.vue
@@ -0,0 +1,1968 @@
+
+
+
+
+
+
+
+
+
+
+
+ {{formData.sta_PowerPercent}}%
+ 电量
+
+
+
+
+
+ {{formData.sta_charge?dic.sta_charge[formData.sta_charge+'']:"未充电" }}
+
+ 设备状态
+
+
+
+
+
+
+
+ 设备名称
+ {{device.deviceName}}
+
+
+ Mac地址
+ {{device.deviceMac}}
+
+
+ 蓝牙名称
+ {{device.bluetoothName}}
+
+
+ 蓝牙状态
+ {{formData.bleStatu?'已连接':'未连接'}}
+
+
+
+
+
+
+
+
+
+ 灯光模式
+
+
+
+
+
+
+
+
+
+
+
+
+ {{item.name}}
+
+
+
+
+
+
+
+
+
+ 强光
+
+
+
+ 工作光
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 红蓝警示
+
+
+
+
+
+
+
+
+ 语音播报
+
+
+
+
+
+
+
+
+
+
+ {{formData.isPlay?'正在播放':'播放语音'}}
+
+
+
+
+
+
+
+
+
+ 语音管理
+
+
+
+
+
+
+
+
+
+
+ 音量调节
+
+
+
+
+
+
+
+
+
+ 人员信息登记
+
+
+
+
+
+
+
+
+
+
+ 发送
+
+
+
+ 单位:
+
+
+
+ 姓名:
+
+
+
+ 职位:
+
+
+
+ ID号:
+
+
+
+
+
+
+
+
+
+ 产品信息
+
+
+
+ 产品参数
+
+
+
+ 操作说明
+
+
+
+ 操作视频
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 音量
+
+
+ {{formData.volumn}}%
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pages/6155/BJQ6155.vue b/pages/6155/BJQ6155.vue
new file mode 100644
index 0000000..b4ad2a2
--- /dev/null
+++ b/pages/6155/BJQ6155.vue
@@ -0,0 +1,2166 @@
+
+
+
+
+
+
+
+
+
+
+
+ {{formData.battary}}%
+ 电量
+
+
+
+
+
+ {{formData.xuhang}}
+ 续航时间
+
+
+
+
+
+
+
+ 设备名称
+ {{device.deviceName}}
+
+
+ Mac地址
+ {{device.deviceMac}}
+
+
+ 设备状态
+ {{formData.statu}}
+
+
+ 蓝牙名称
+ {{device.bluetoothName}}
+
+
+ 蓝牙状态
+ {{formData.bleStatu?'已连接':'未连接'}}
+
+
+
+
+ 灯光亮度
+ {{formData.liangDu}}%
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 主灯模式
+ {{getMode('main')}}
+
+
+
+
+
+
+
+ 辅灯模式
+ {{getMode('fu')}}
+
+
+
+
+
+
+
+ 开机画面
+ 上传
+
+
+
+
+
+
+
+ 开机视频
+ 上传
+
+
+
+
+
+
+ 人员信息登记
+ 发送
+
+
+
+
+
+ 单位:
+
+
+
+ 部门:
+
+
+
+ 姓名:
+
+
+
+
+
+ 产品信息
+
+
+
+ 产品参数
+
+
+
+ 操作说明
+
+
+
+ 操作视频
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pages/6155/ImgCrop.vue b/pages/6155/ImgCrop.vue
index 048727f..c6209ea 100644
--- a/pages/6155/ImgCrop.vue
+++ b/pages/6155/ImgCrop.vue
@@ -4,7 +4,7 @@
+ @crop="handleCrop" :areaScale="0.1" :minScale="0.1" :gpu="true">
diff --git a/pages/6331/BJQ6331.vue b/pages/6331/BJQ6331.vue
index 300a0c4..2df7f36 100644
--- a/pages/6331/BJQ6331.vue
+++ b/pages/6331/BJQ6331.vue
@@ -234,10 +234,7 @@
hideLoading,
updateLoading
} from '@/utils/loading.js'
- import {
- request,
- baseURL
- } from '../../utils/request';
+import request, { baseURL } from '@/utils/request.js';
import usrApi from '@/api/670/HBY670.js'
const pagePath = "pages/6331/BJQ6331";
diff --git a/pages/650/HBY650.vue b/pages/650/HBY650.vue
index c5be0eb..6c63309 100644
--- a/pages/650/HBY650.vue
+++ b/pages/650/HBY650.vue
@@ -56,6 +56,10 @@
+
+ 前置
+
低档
@@ -68,10 +72,14 @@
@click="MainModeSetting('hight','staticBattery')">
高档
-
关闭
-
+ -->
@@ -181,10 +189,7 @@
hideLoading,
updateLoading
} from '@/utils/loading.js'
- import {
- request,
- baseURL
- } from '../../utils/request';
+import request, { baseURL } from '@/utils/request.js';
import usrApi from '@/api/670/HBY670.js'
const pagePath = "/pages/650/HBY650";
@@ -335,6 +340,7 @@
these.showBleUnConnect();
+ console.error("111111");
these.getDetail();
return;
}
@@ -348,13 +354,14 @@
}
these.formData.blename = f.name ? f.name : "Unname";
these.formData.deviceName = device.deviceName;
-
+
these.formData.bleStatu = false;
these.formData.deviceId = f.deviceId;
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
these.formData.bleStatu = true;
});
these.setBleFormData();
+ console.error("222222");
these.getDetail();
@@ -566,7 +573,7 @@
getDetail() {
var that = this;
usrApi.getDetail(this.device.id).then(res => {
- console.log("res=", res);
+ console.log("获取人员信息=", res);
if (res && res.code == 200) {
res = res.data;
let personnelInfo = res.personnelInfo;
@@ -575,8 +582,24 @@
that.formData.name = personnelInfo.name;
that.formData.job = personnelInfo.position;
that.formData.id = personnelInfo.code
+ return;
}
}
+ let phone = uni.getStorageSync('phone');
+ if (phone === '17671332251') {
+ console.log("default=",that.device);
+ that.formData.company = '湖北消防总队';
+ that.formData.name = '胡红军';
+ that.formData.job = '中队长';
+ let arr=that.device.bluetoothName.split('-');
+ if(arr.length>1){
+ that.formData.id =arr[arr.length-1];
+ }else{
+ that.formData.id =that.device.bluetoothName;
+ }
+
+ }
+
});
},
@@ -594,16 +617,19 @@
},
MainModeSetting: function(type, byteType) {
if (this.formData.modeCurr == type) {
- return;
+ type = 'close';
}
showLoading(this, {
text: "请稍候..."
});
let task = () => {
- this.formData.modeCurr = type;
+
let dataValue = 0x00;
let btype = 0x00;
switch (type) {
+ case "smalllow":
+ dataValue = 0x68;
+ break;
case "low": //低档
dataValue = 0x67;
break;
@@ -655,8 +681,7 @@
// 发送数据
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 10).then(() => {
-
-
+ this.formData.modeCurr = type;
console.log("发送成功了");
}).catch((ex) => {
@@ -1084,10 +1109,12 @@
hideLoading(these);
return;
}
-
+ console.log("baseURL=", baseURL);
+ console.log("token", token);
+ console.log("clientID", clientid);
uni.uploadFile({
// url: 'http://114.55.111.217/video/upload',
- url: baseURL + "app/video/upload",
+ url: baseURL + "/app/video/upload",
filePath: videoPath,
name: 'file',
header: {
@@ -1115,6 +1142,7 @@
let res = arr[1];
res = JSON.parse(res.data);
+
if (res.data) {
these.videoHexArray = res.data;
updateLoading(these, {
diff --git a/pages/670/HBY670.vue b/pages/670/HBY670.vue
index 6c6f871..0142f06 100644
--- a/pages/670/HBY670.vue
+++ b/pages/670/HBY670.vue
@@ -1,10 +1,21 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
@@ -90,8 +101,7 @@
-
+
设备强制报警中!
{{Status.staticWarn.time}}s
@@ -219,8 +229,8 @@
-
+
@@ -294,11 +304,8 @@
hideLoading,
updateLoading
} from '@/utils/loading.js'
- import {
- request,
- baseURL
- } from '../../utils/request';
- import lnglatConvert from '@/utils/wgs84_to_gcj02.js'
+ import request, { baseURL } from '@/utils/request.js';
+ import lnglatConvert from '@/utils/wgs84_to_gcj02.js';
const pagePath = "/pages/670/HBY670";
var ble = null;
@@ -560,6 +567,11 @@
},
methods: {
+ prevPage() {
+ uni.navigateBack({
+
+ })
+ },
deviceRecovry(res) {
if (this.Status.pageHide) {
return;
@@ -679,20 +691,24 @@
});
},
gotoMap() {
- let lnglat = lnglatConvert.wgs84_to_gcj02(this.formData.Lon, this.formData.Lat);
- this.detailData.longitude = lnglat[0];
- this.detailData.latitude = lnglat[1];
- uni.navigateTo({
- url: '/pages/common/map/index',
- events: {
- ack: function(data) {}
- },
- success: (res) => {
- res.eventChannel.emit('Map', {
- data: this.detailData
- });
- }
- })
+ let promise = lnglatConvert.wgs84_to_gcj02(this.formData.Lon, this.formData.Lat);
+ promise.then(lnglat => {
+
+ this.detailData.longitude = lnglat[0];
+ this.detailData.latitude = lnglat[1];
+ uni.navigateTo({
+ url: '/pages/common/map/index',
+ events: {
+ ack: function(data) {}
+ },
+ success: (res) => {
+ res.eventChannel.emit('Map', {
+ data: this.detailData
+ });
+ }
+ })
+ });
+
},
getDetail() {
var that = this;
@@ -799,7 +815,7 @@
return className;
},
handleRightClick: function(s, e) {
-
+
if (s === 0) {
console.log("消息");
uni.navigateTo({
@@ -832,8 +848,8 @@
},
initMQ() {
-
- return new Promise((resolve, reject) => {
+
+ return new Promise((resolve, reject) => {
if (mqttClient) {
// console.log("无需再次初始化")
resolve();
@@ -869,7 +885,8 @@
if (keys.indexOf('sta_BreakNews') > -
1) { //紧急通知
if (json.sta_BreakNews ===
- 'I get it') // && this.Status.msgOkTime && this.Status.msgOkIntval){
+ 'I get it'
+ ) // && this.Status.msgOkTime && this.Status.msgOkIntval){
{
these.showPop({
showPop: true,
@@ -973,9 +990,9 @@
if ("sta_SOSGrade" in json) {
let sosText = json.sta_SOSGrade === 2 ? 'rb' : json.sta_SOSGrade === 1 ? "sg" : "close";
receiveData.SOS = sosText;
-
- receiveData.qzwarn=sosText==='sg';
-
+
+ receiveData.qzwarn = sosText === 'sg';
+
}
if ("sta_ShakeBit" in json) {
@@ -1059,14 +1076,14 @@
if (this.formData.imei) {
this.initMQ();
}
- let msgs=[];
- if(this.formData.qzwarn){
+ let msgs = [];
+ if (this.formData.qzwarn) {
msgs.push("设备强制报警中");
}
if (this.formData.staticWarn) { //有静止报警
msgs.push("设备静止报警中");
}
- if(msgs.length>0){
+ if (msgs.length > 0) {
this.showPop({
message: msgs.join(";"),
iconUrl: "/static/images/6155/DeviceDetail/warnning.png",
@@ -1076,7 +1093,7 @@
clickEvt: "staticWarn"
});
}
-
+
this.setBleFormData();
},
@@ -3320,4 +3337,13 @@
.net.active {
background: #FFFFFF !important;
}
+
+ .navbarRight .img{
+ width: 35rpx;
+ height: 35rpx;
+ margin-right: 20rpx;
+ }
+ .uni-navbar--fixed{
+ top:0rpx;
+ }
\ No newline at end of file
diff --git a/pages/7305/BJQ7305.vue b/pages/7305/BJQ7305.vue
index 1f3a581..24d58e5 100644
--- a/pages/7305/BJQ7305.vue
+++ b/pages/7305/BJQ7305.vue
@@ -483,8 +483,9 @@
if (this.Status.pageHide) {
return;
}
+
let json = recei.ReceiveData(receive, device, path, recArr);
-
+ console.log("收到消息:",receive.hexs);
if (!json) {
return;
}
diff --git a/pages/common/addBLE/LinkBle.vue b/pages/common/addBLE/LinkBle.vue
index 82c2791..ca79c68 100644
--- a/pages/common/addBLE/LinkBle.vue
+++ b/pages/common/addBLE/LinkBle.vue
@@ -46,7 +46,7 @@
var these = null;
var eventChannel = null;
var ble = null;
-
+ var inteval=null;
export default {
data() {
return {
@@ -118,7 +118,7 @@
onUnload() {
console.log("返回取消订阅");
-
+ clearInterval(inteval);
ble.removeAllCallback(pagePath);
},
onLoad(option) {
@@ -226,7 +226,7 @@
}
})
- let inteval = setInterval(this.initDevice, 10000);
+ inteval = setInterval(this.initDevice, 10000);
}
@@ -291,6 +291,7 @@
}
}
});
+ clearInterval(inteval);
} else {
deviceInvalid();
}
diff --git a/pages/common/addBLE/addEquip.vue b/pages/common/addBLE/addEquip.vue
index 4a6022e..c9b31ee 100644
--- a/pages/common/addBLE/addEquip.vue
+++ b/pages/common/addBLE/addEquip.vue
@@ -120,6 +120,7 @@
var ble = null;
var these = null;
var eventChannel = null;
+
export default {
data() {
return {
@@ -334,7 +335,7 @@
//搜索到新设备的回调 (Always active)
ble.addDeviceFound((arr) => {
- console.log("--- 收到原始扫描数据 ---", JSON.stringify(arr));
+ // console.log("--- 收到原始扫描数据 ---", JSON.stringify(arr));
if (these.Status.isPageHidden) {
return;
}
@@ -343,7 +344,7 @@
}
arr = arr.devices;
- console.log(`本次扫描批次发现 ${arr.length} 个设备`);
+ // console.log(`本次扫描批次发现 ${arr.length} 个设备`);
for (var i = 0; i < arr.length; i++) {
let device = arr[i];
@@ -351,9 +352,9 @@
let f = these.EquipMents.find((v, index) => {
if (v.deviceId == device.deviceId) {
- console.log(
- `更新设备信号: ${device.name || device.deviceId}, RSSI: ${device.RSSI}`
- );
+ // console.log(
+ // `更新设备信号: ${device.name || device.deviceId}, RSSI: ${device.RSSI}`
+ // );
these.$set(these.EquipMents[index], 'RSSI', device.RSSI);
return true;
}
@@ -361,7 +362,7 @@
});
if (!f) {
- console.log("+++ 发现新设备,准备添加到列表:", JSON.stringify(device));
+ // console.log("+++ 发现新设备,准备添加到列表:", JSON.stringify(device));
if (these.device && these.device.bluetoothName && device.name) {
if (these.device.bluetoothName === device.name || (device.name && device.name
@@ -417,27 +418,32 @@
//收到设备的消息回调
ble.addReceiveCallback((receivData, f, path, arr) => {
- console.log("000000");
+ console.log("000000",receivData);
if (these.Status.isPageHidden) {
return;
}
- console.log("1111111");
- if (f.macAddress && these.device) {
- console.log("222222");
- clearInterval(this.Status.intval);
- this.Status.intval = null;
- this.Status.time = null;
-
- showLoading(these, {
- text: '正在验证设备'
- });
-
- setTimeout(() => {
- these.DeviceVerdict(f.deviceId);
- }, 0);
+ if(receivData.bytes[0]===0xFC && receivData.hexs.length>=7){
+ console.log("22222222");
}
+ if(receivData.str.indexOf('mac address:')>-1 || receivData.str.indexOf('sta_address')>-1
+ || (receivData.bytes[0]===0xFC && receivData.bytes.length>=7))
+ {
+ console.log("1111111");
+ if (f.macAddress && these.device) {
+ console.log("222222");
+ clearInterval(this.Status.intval);
+ this.Status.intval = null;
+ this.Status.time = null;
+ showLoading(these, {
+ text: '正在验证设备'
+ });
+ setTimeout(() => {
+ these.DeviceVerdict(f.deviceId);
+ }, 0);
+ }
+ }
}, pagePath);
}
}
@@ -452,7 +458,7 @@
}
startValidDevice();
- these.refreshBleList();
+
});
},
@@ -502,6 +508,8 @@
});
},
async refreshBleList() {
+
+
const systemInfo = uni.getSystemInfoSync();
if (systemInfo.uniPlatform == 'web') {
return;
@@ -520,37 +528,42 @@
return;
}
}
-
- ble.StopSearch().finally(() => {
-
- let disconnectPromises = [];
- if (ble.data && ble.data.LinkedList) {
- ble.data.LinkedList.forEach(device => {
- console.log(`Requesting disconnect for ${device.deviceId}`);
- disconnectPromises.push(ble.disconnectDevice(device.deviceId));
- });
- }
-
- Promise.allSettled(disconnectPromises).finally(() => {
-
- these.EquipMents = [];
- these.PairEquip = [];
-
- ble.StartSearch().then(result => {
- console.log("Fresh scan started successfully.");
- }).catch(err => {
- console.error("Failed to start fresh scan:", err);
- if (err.code === 10001) {
- these.showOpenSetting();
- } else {
- uni.showModal({
- title: '提示',
- content: '开始搜索失败:' + err.msg
- });
- }
+
+
+
+ ble.StopSearch().finally(() => {
+
+ let disconnectPromises = [];
+ if (ble.data && ble.data.LinkedList) {
+ ble.data.LinkedList.forEach(device => {
+ console.log(`Requesting disconnect for ${device.deviceId}`);
+ disconnectPromises.push(ble.disconnectDevice(device.deviceId));
+ });
+ }
+
+ Promise.allSettled(disconnectPromises).finally(() => {
+
+ these.EquipMents = [];
+ these.PairEquip = [];
+
+ ble.StartSearch().then(result => {
+ console.log("Fresh scan started successfully.");
+ }).catch(err => {
+ console.error("Failed to start fresh scan:", err);
+ if (err.code === 10001) {
+ these.showOpenSetting();
+ } else {
+ uni.showModal({
+ title: '提示',
+ content: '开始搜索失败:' + err.msg
+ });
+ }
+ });
});
});
- });
+
+
+
},
isItemLink: function(item, index) {
let src = '/static/images/BLEAdd/noLink.png';
@@ -599,8 +612,6 @@
if (index > -1) {
this.PairEquip.splice(index, 1);
}
-
-
}
console.log("f=", f);
@@ -708,8 +719,8 @@
});
return;
}
- console.log("验证设备")
- these.DeviceVerdict(item.deviceId);
+ // console.log("验证设备")
+ // these.DeviceVerdict(item.deviceId);
}
let execLink = () => {
return new Promise((resolve, reject) => {
diff --git a/pages/common/allType/index.vue b/pages/common/allType/index.vue
index b2555f8..9c8567f 100644
--- a/pages/common/allType/index.vue
+++ b/pages/common/allType/index.vue
@@ -2,9 +2,9 @@
-
+
-
+
{{ item.typeName }}
@@ -20,30 +20,130 @@
diff --git a/uni_modules/uni-icons/components/uni-icons/uni-icons.vue b/uni_modules/uni-icons/components/uni-icons/uni-icons.vue
index 7da5356..1bd3d5e 100644
--- a/uni_modules/uni-icons/components/uni-icons/uni-icons.vue
+++ b/uni_modules/uni-icons/components/uni-icons/uni-icons.vue
@@ -85,8 +85,8 @@
}
},
methods: {
- _onClick() {
- this.$emit('click')
+ _onClick(e) {
+ this.$emit('click', e)
}
}
}
@@ -107,4 +107,4 @@
text-decoration: none;
text-align: center;
}
-
+
\ No newline at end of file
diff --git a/uni_modules/uni-icons/package.json b/uni_modules/uni-icons/package.json
index 6b681b4..60e45f0 100644
--- a/uni_modules/uni-icons/package.json
+++ b/uni_modules/uni-icons/package.json
@@ -1,7 +1,7 @@
{
"id": "uni-icons",
"displayName": "uni-icons 图标",
- "version": "2.0.10",
+ "version": "2.0.12",
"description": "图标组件,用于展示移动端常见的图标,可自定义颜色、大小。",
"keywords": [
"uni-ui",
@@ -11,12 +11,14 @@
],
"repository": "https://github.com/dcloudio/uni-ui",
"engines": {
- "HBuilderX": "^3.2.14"
+ "HBuilderX": "^3.2.14",
+ "uni-app": "^4.08",
+ "uni-app-x": "^4.61"
},
"directories": {
"example": "../../temps/example_temps"
},
-"dcloudext": {
+ "dcloudext": {
"sale": {
"regular": {
"price": "0.00"
@@ -34,56 +36,76 @@
"permissions": "无"
},
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
- "type": "component-vue"
+ "type": "component-vue",
+ "darkmode": "x",
+ "i18n": "x",
+ "widescreen": "x"
},
"uni_modules": {
- "dependencies": ["uni-scss"],
+ "dependencies": [
+ "uni-scss"
+ ],
"encrypt": [],
"platforms": {
"cloud": {
- "tcb": "y",
- "aliyun": "y",
- "alipay": "n"
+ "tcb": "x",
+ "aliyun": "x",
+ "alipay": "x"
},
"client": {
- "App": {
- "app-vue": "y",
- "app-nvue": "y",
- "app-uvue": "y"
+ "uni-app": {
+ "vue": {
+ "vue2": "√",
+ "vue3": "√"
+ },
+ "web": {
+ "safari": "√",
+ "chrome": "√"
+ },
+ "app": {
+ "vue": "√",
+ "nvue": "-",
+ "android": {
+ "extVersion": "",
+ "minVersion": "29"
+ },
+ "ios": "√",
+ "harmony": "√"
+ },
+ "mp": {
+ "weixin": "√",
+ "alipay": "√",
+ "toutiao": "√",
+ "baidu": "√",
+ "kuaishou": "-",
+ "jd": "-",
+ "harmony": "-",
+ "qq": "√",
+ "lark": "-"
+ },
+ "quickapp": {
+ "huawei": "√",
+ "union": "√"
+ }
},
- "H5-mobile": {
- "Safari": "y",
- "Android Browser": "y",
- "微信浏览器(Android)": "y",
- "QQ浏览器(Android)": "y"
- },
- "H5-pc": {
- "Chrome": "y",
- "IE": "y",
- "Edge": "y",
- "Firefox": "y",
- "Safari": "y"
- },
- "小程序": {
- "微信": "y",
- "阿里": "y",
- "百度": "y",
- "字节跳动": "y",
- "QQ": "y",
- "钉钉": "y",
- "快手": "y",
- "飞书": "y",
- "京东": "y"
- },
- "快应用": {
- "华为": "y",
- "联盟": "y"
- },
- "Vue": {
- "vue2": "y",
- "vue3": "y"
+ "uni-app-x": {
+ "web": {
+ "safari": "√",
+ "chrome": "√"
+ },
+ "app": {
+ "android": {
+ "extVersion": "",
+ "minVersion": "29"
+ },
+ "ios": "√",
+ "harmony": "√"
+ },
+ "mp": {
+ "weixin": "√"
+ }
}
}
}
}
-}
+}
\ No newline at end of file
diff --git a/uni_modules/uni-nav-bar/changelog.md b/uni_modules/uni-nav-bar/changelog.md
new file mode 100644
index 0000000..ebe3473
--- /dev/null
+++ b/uni_modules/uni-nav-bar/changelog.md
@@ -0,0 +1,60 @@
+## 1.3.17(2025-09-03)
+- 修复 内部样式问题
+## 1.3.16(2025-08-18)
+- 修复 微信小程序 fixed 下避让胶囊,优化标题居中,默认showMenuButtonWidth 不开启下,右侧插槽会被 胶囊覆盖
+- 新增 showMenuButtonWidth 右侧是否避让胶囊,即 显示区域为胶囊左侧,默认不开启,开启后会导致标题不在页面水平居中
+## 1.3.15(2025-06-24)
+- 适配微信小程序固定导航栏时,右侧插槽避让胶囊按钮
+## 1.3.14(2024-10-15)
+- 修复 微信小程序中的getSystemInfo警告
+## 1.3.11(2023-03-29)
+- 修复 自定义状态栏高度闪动BUG
+## 1.3.10(2023-03-29)
+- 修复 暗黑模式下边线颜色错误的bug
+## 1.3.9(2022-10-13)
+- 修复 条件编译错误的bug
+## 1.3.8(2022-10-12)
+- 修复 nvue 环境 fixed 为 true 的情况下,无法置顶的 bug
+## 1.3.7(2022-08-11)
+- 修复 nvue 环境下 fixed 为 true 的情况下,无法置顶的 bug
+## 1.3.6(2022-06-30)
+- 修复 组件示例中插槽用法无法显示内容的bug
+## 1.3.5(2022-05-24)
+- 新增 stat 属性 ,可开启统计title 上报 ,仅使用了title 属性且项目开启了uni统计生效
+## 1.3.4(2022-01-24)
+- 更新 组件示例
+## 1.3.3(2022-01-24)
+- 新增 left-width/right-width属性 ,可修改左右两侧的宽度
+## 1.3.2(2022-01-18)
+- 修复 在vue下,标题不垂直居中的bug
+## 1.3.1(2022-01-18)
+- 修复 height 属性类型错误
+## 1.3.0(2022-01-18)
+- 新增 height 属性,可修改组件高度
+- 新增 dark 属性可可开启暗黑模式
+- 优化 标题字数过多显示省略号
+- 优化 插槽,插入内容可完全覆盖
+## 1.2.1(2022-01-10)
+- 修复 color 属性不生效的bug
+## 1.2.0(2021-11-19)
+- 优化 组件UI,并提供设计资源,详见:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource)
+- 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-nav-bar](https://uniapp.dcloud.io/component/uniui/uni-nav-bar)
+## 1.1.0(2021-07-30)
+- 组件兼容 vue3,如何创建vue3项目,详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834)
+## 1.0.11(2021-05-12)
+- 新增 组件示例地址
+## 1.0.10(2021-04-30)
+- 修复 在nvue下fixed为true,宽度不能撑满的Bug
+## 1.0.9(2021-04-21)
+- 优化 添加依赖 uni-icons, 导入后自动下载依赖
+## 1.0.8(2021-04-14)
+- uni-ui 修复 uni-nav-bar 当 fixed 属性为 true 时铺不满屏幕的 bug
+
+## 1.0.7(2021-02-25)
+- 修复 easycom 下,找不到 uni-status-bar 的bug
+
+## 1.0.6(2021-02-05)
+- 优化 组件引用关系,通过uni_modules引用组件
+
+## 1.0.5(2021-02-05)
+- 调整为uni_modules目录规范
diff --git a/uni_modules/uni-nav-bar/components/uni-nav-bar/uni-nav-bar.vue b/uni_modules/uni-nav-bar/components/uni-nav-bar/uni-nav-bar.vue
new file mode 100644
index 0000000..c627d86
--- /dev/null
+++ b/uni_modules/uni-nav-bar/components/uni-nav-bar/uni-nav-bar.vue
@@ -0,0 +1,383 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/uni_modules/uni-nav-bar/components/uni-nav-bar/uni-status-bar.vue b/uni_modules/uni-nav-bar/components/uni-nav-bar/uni-status-bar.vue
new file mode 100644
index 0000000..92aa589
--- /dev/null
+++ b/uni_modules/uni-nav-bar/components/uni-nav-bar/uni-status-bar.vue
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
diff --git a/uni_modules/uni-nav-bar/package.json b/uni_modules/uni-nav-bar/package.json
new file mode 100644
index 0000000..f9ede85
--- /dev/null
+++ b/uni_modules/uni-nav-bar/package.json
@@ -0,0 +1,106 @@
+{
+ "id": "uni-nav-bar",
+ "displayName": "uni-nav-bar 自定义导航栏",
+ "version": "1.3.17",
+ "description": "自定义导航栏组件,主要用于头部导航。",
+ "keywords": [
+ "uni-ui",
+ "导航",
+ "导航栏",
+ "自定义导航栏"
+],
+ "repository": "https://github.com/dcloudio/uni-ui",
+ "engines": {
+ "HBuilderX": "",
+ "uni-app": "^4.07",
+ "uni-app-x": ""
+ },
+ "directories": {
+ "example": "../../temps/example_temps"
+ },
+ "dcloudext": {
+ "sale": {
+ "regular": {
+ "price": "0.00"
+ },
+ "sourcecode": {
+ "price": "0.00"
+ }
+ },
+ "contact": {
+ "qq": ""
+ },
+ "declaration": {
+ "ads": "无",
+ "data": "无",
+ "permissions": "无"
+ },
+ "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
+ "type": "component-vue",
+ "darkmode": "x",
+ "i18n": "x",
+ "widescreen": "x"
+ },
+ "uni_modules": {
+ "dependencies": [
+ "uni-scss",
+ "uni-icons"
+ ],
+ "encrypt": [],
+ "platforms": {
+ "cloud": {
+ "tcb": "x",
+ "aliyun": "x",
+ "alipay": "x"
+ },
+ "client": {
+ "uni-app": {
+ "vue": {
+ "vue2": "√",
+ "vue3": "√"
+ },
+ "web": {
+ "safari": "√",
+ "chrome": "√"
+ },
+ "app": {
+ "vue": "√",
+ "nvue": "√",
+ "android": "√",
+ "ios": "√",
+ "harmony": "√"
+ },
+ "mp": {
+ "weixin": "√",
+ "alipay": "√",
+ "toutiao": "√",
+ "baidu": "√",
+ "kuaishou": "-",
+ "jd": "-",
+ "harmony": "-",
+ "qq": "√",
+ "lark": "-"
+ },
+ "quickapp": {
+ "huawei": "√",
+ "union": "√"
+ }
+ },
+ "uni-app-x": {
+ "web": {
+ "safari": "-",
+ "chrome": "-"
+ },
+ "app": {
+ "android": "-",
+ "ios": "-",
+ "harmony": "-"
+ },
+ "mp": {
+ "weixin": "-"
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/uni_modules/uni-nav-bar/readme.md b/uni_modules/uni-nav-bar/readme.md
new file mode 100644
index 0000000..3934b32
--- /dev/null
+++ b/uni_modules/uni-nav-bar/readme.md
@@ -0,0 +1,15 @@
+
+
+## NavBar 导航栏
+> **组件名:uni-nav-bar**
+> 代码块: `uNavBar`
+
+导航栏组件,主要用于头部导航。
+
+### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-nav-bar)
+#### 如使用过程中有任何问题,或者您对uni-ui有一些好的建议,欢迎加入 uni-ui 交流群:871950839
+
+
+
+
+
diff --git a/utils/BleHelper.js b/utils/BleHelper.js
index aa6677f..ea7f675 100644
--- a/utils/BleHelper.js
+++ b/utils/BleHelper.js
@@ -56,7 +56,7 @@ class BleHelper {
isOpenBlue: false, //蓝牙模块是否开启
available: false, //蓝牙状态是否可用
discovering: false, //蓝牙是否正在搜索
- searchList: [], //已搜索到的设备列表,
+
isSubscribe: false, //是否开启了订阅
LinkedList: linkedDevices, //已连接的设备列表
platform: systemInfo.uniPlatform,
@@ -71,9 +71,10 @@ class BleHelper {
stateRecoveryCallback: [], //蓝牙适配器恢复可用事件
stateBreakCallback: [] //蓝牙适配器不可用事件
}
- this.addReceiveCallback((receive, f, path, recArr) => {
- recei.ReceiveData(receive, f, path, recArr);
- }, "BleReceiveData");
+ //蓝牙模块不再订阅,改到首页订阅
+ // this.addReceiveCallback((receive, f, path, recArr) => {
+ // recei.ReceiveData(receive, f, path, recArr);
+ // }, "BleReceiveData");
setTimeout(() => {
this.OpenBlue().then(() => {
@@ -229,8 +230,12 @@ class BleHelper {
}
if (key) {
// console.log("key=" + key);
- let f = this.cfg[type].findIndex((v) => {
- return v.key == key;
+ let f =-1;
+
+ this.cfg[type].find((v,index) => {
+ if(v.key == key){
+ f=index;
+ }
});
if (f > -1) {
// this.cfg[type][f].callback = callback;
@@ -253,8 +258,11 @@ class BleHelper {
if (key) {
// console.log("key=" + key);
- let f = this.cfg[type].findIndex((v) => {
- return v.key == key;
+ let f =-1;
+ this.cfg[type].find((v,index) => {
+ if(v.key == key){
+ f=index;
+ }
});
if (f > -1) {
this.cfg[type].splice(f, 1);
@@ -268,8 +276,31 @@ class BleHelper {
}
-
-
+ //获取某个事件的所有订阅者,但不包含某些订阅者
+ getCfgAllKeys(type,retains){
+ if(!retains){
+ retains=[];
+ }
+ if(!Array.isArray(retains)){
+ retains=[retains];
+ }
+ let keys=null;
+ for (let index = 0; index < this.cfg[type]; index++) {
+ let ele = this.cfg[type];
+ let f=retains.find(v=>{
+ return v.toLowerCase()==ele.key.toLowerCase();
+ });
+ if(!f){
+ if(!keys){
+ keys=[ele.key];
+ }else{
+ keys.push(ele.key);
+ }
+
+ }
+ }
+ return keys;
+ }
//设置蓝牙恢复连接的回调
addRecoveryCallback(callback, currKey) {
@@ -280,6 +311,17 @@ class BleHelper {
removeRecoveryCallback(currKey) {
this.removeCallback(currKey, 'recoveryCallback');
}
+ //移除所有蓝牙恢复连接的回调,但不包括currkey
+ removeAllRecoveryCallback(currKey) {
+ let keys=this.getCfgAllKeys('recoveryCallback',currKey);
+ if(keys){
+ for (let i = 0; i < keys.length; i++) {
+ let key = keys[i];
+ this.removeRecoveryCallback(key);
+ }
+ }
+
+ }
//设置蓝牙断开连接的回调
addDisposeCallback(callback, currKey) {
@@ -290,6 +332,16 @@ class BleHelper {
removeDisposeCallback(currKey) {
this.removeCallback(currKey, 'bleDisposeCallback');
}
+ removeAllDisposeCallback(currKey) {
+ let keys=this.getCfgAllKeys('bleDisposeCallback',currKey);
+ if(keys){
+ for (let i = 0; i < keys.length; i++) {
+ let key = keys[i];
+ this.removeDisposeCallback(key);
+ }
+ }
+
+ }
//设置发现新设备的回调
@@ -301,6 +353,16 @@ class BleHelper {
removeDeviceFound(currKey) {
this.removeCallback(currKey, 'onDeviceFound');
}
+ removeAllDeviceFound(currKey) {
+ let keys=this.getCfgAllKeys('onDeviceFound',currKey);
+ if(keys){
+ for (let i = 0; i < keys.length; i++) {
+ let key = keys[i];
+ this.removeDeviceFound(key);
+ }
+ }
+
+ }
//添加接收到数据的回调
addReceiveCallback(callback, currKey) {
@@ -311,6 +373,16 @@ class BleHelper {
removeReceiveCallback(currKey) {
this.removeCallback(currKey, 'receivDataCallback');
}
+ removeAllReceiveCallback(currKey) {
+ let keys=this.getCfgAllKeys('receivDataCallback',currKey);
+ if(keys){
+ for (let i = 0; i < keys.length; i++) {
+ let key = keys[i];
+ this.removeReceiveCallback(key);
+ }
+ }
+
+ }
//添加蓝牙不可用的回调
addStateBreakCallback(callback, currKey) {
@@ -321,7 +393,16 @@ class BleHelper {
removeStateBreakCallback(currKey) {
this.removeCallback(currKey, 'stateBreakCallback');
}
-
+ removeAllStateBreakCallback(currKey) {
+ let keys=this.getCfgAllKeys('stateBreakCallback',currKey);
+ if(keys){
+ for (let i = 0; i < keys.length; i++) {
+ let key = keys[i];
+ this.removeStateBreakCallback(key);
+ }
+ }
+
+ }
//设置蓝牙适配器恢复可用的回调
addStateRecoveryCallback(callback, currKey) {
@@ -332,6 +413,16 @@ class BleHelper {
removeStateRecoveryCallback(currKey) {
this.removeCallback(currKey, 'stateRecoveryCallback');
}
+ removeAllStateRecoveryCallback(currKey) {
+ let keys=this.getCfgAllKeys('stateRecoveryCallback',currKey);
+ if(keys){
+ for (let i = 0; i < keys.length; i++) {
+ let key = keys[i];
+ this.removeStateRecoveryCallback(key);
+ }
+ }
+
+ }
//清除所有事件回调
removeAllCallback(currKey) {
@@ -342,7 +433,15 @@ class BleHelper {
this.removeStateRecoveryCallback(currKey);
this.removeStateBreakCallback(currKey);
}
-
+ //清除所有事件回调,不包含retain
+ removeAllCallbackByRetain(retain) {
+ this.removeAllDeviceFound(retain)
+ this.removeAllDisposeCallback(retain);
+ this.removeAllReceiveCallback(retain);
+ this.removeAllRecoveryCallback(retain);
+ this.removeAllStateRecoveryCallback(retain);
+ this.removeAllStateBreakCallback(retain);
+ }
getError(ex) {
let code = ex.code;
@@ -681,7 +780,6 @@ class BleHelper {
if (this.cfg.receivDataCallback.length > 0) {
- let path = this.getCurrentPagePath();
// console.log("有人订阅消息")
this.cfg.receivDataCallback.forEach((
rec) => {
@@ -690,7 +788,7 @@ class BleHelper {
try {
// console.log("正在处理订阅消息",rec);
rec.callback(recData, f,
- path, this.cfg
+ rec.key, this.cfg
.receivDataCallback
);
// console.log("处理订阅消息完毕");
@@ -784,21 +882,24 @@ class BleHelper {
}
BleConnChange() {
+ let stateTimeout=null;
uni.onBLEConnectionStateChange((res) => {
- console.log("蓝牙连接状态变化了", res);
+
+
// 检查状态是否真的发生了变化
let ble = this.data.LinkedList.find(dev => {
return res.deviceId === dev.deviceId;
});
if (ble) {
if (ble.Linked === res.connected) {
+ console.error("专业给UniApp填坑,蓝牙连接状态重复回调");
return;
}
}
+ console.log("蓝牙连接状态变化了", res);
-
-
- setTimeout(() => {
+ clearTimeout(stateTimeout);
+ stateTimeout=setTimeout(() => {
if (!res.connected) {
console.error("蓝牙已断开", res);
let f = this.data.LinkedList.find((
@@ -851,7 +952,7 @@ class BleHelper {
console.log("蓝牙连接已恢复", res);
}
- }, 0);
+ }, 50);
});
}
@@ -881,8 +982,7 @@ class BleHelper {
return;
}
res.devices = arr;
- this.data.searchList = this.data.searchList.concat(
- res);
+
if (this.cfg.onDeviceFound) {
if (this.cfg.onDeviceFound.length > 0) {
this.cfg.onDeviceFound.forEach((found) => {
@@ -907,7 +1007,7 @@ class BleHelper {
this.data.available = false;
this.data.discovering = false;
this.data.isOpenBlue = false;
- this.data.searchList = [];
+
return Promise.resolve();
}
@@ -924,7 +1024,7 @@ class BleHelper {
this.data.available = false;
this.data.discovering = false;
this.data.isOpenBlue = false;
- this.data.searchList = [];
+
resolve();
},
fail: (ex) => {
@@ -959,20 +1059,15 @@ class BleHelper {
if (this.data.platform == 'web') {
return Promise.resolve({});
}
- this.data.searchList = [];
+
var these = this;
//开始搜索
var Search = () => {
- //只搜索合作供应商的服务id
- let serviceIds = serviceDic.map(v => {
- return v.serviceId
- });
- //搜索一个服务id的设备,循环调用
- let RunSearch = (serviceId) => {
+ let RunSearch = () => {
return new Promise((resolve, reject) => {
uni.startBluetoothDevicesDiscovery({
- services: serviceId ? [serviceId] : [],
+ services:[],
allowDuplicatesKey: true,
success: (res) => {
console.log('开始搜索蓝牙设备成功');
@@ -992,14 +1087,8 @@ class BleHelper {
return new Promise((resolve, reject) => {
let promises = [];
- // for (let i = 0; i < serviceIds.length; i++) {
-
- // promises.push(RunSearch(serviceIds[i]));
-
- // }
promises.push(RunSearch());
Promise.all(promises).then(resolve).catch(reject);
-
});
@@ -1278,7 +1367,6 @@ class BleHelper {
} else
-
{
console.error("预设的蓝牙服务和特征中找不到");
for (var i = 0; i < res.services.length; i++) {
@@ -1297,7 +1385,7 @@ class BleHelper {
});
} else {
- Promise.all(promises)
+ Promise.allSettled(promises)
.then(results => {
console.log("results= ", results);
if (!s) {
@@ -1512,12 +1600,23 @@ class BleHelper {
timeout: 30000,
success: (info) => {
//释放连接锁
+
delete this.data.connectingDevices[deviceId];
console.log("新连接成功", this.data.LinkedList);
+
+ // 处理 MTU 设置
+ if (plus.os.name === 'Android') {
+ this.setMtu(deviceId).catch(ex => {
+ console.error("mtu设置失败=", ex);
+ });
+ }
+
this.getLinkBlue().then((arr) => {
+ let linkId=new Date().getTime();//本次连接的id
let cr = arr.devices.find(c => {
if (c.deviceId == deviceId) {
c.Linked = true;
+ c.linkId=linkId
return true;
}
return false;
@@ -1525,6 +1624,7 @@ class BleHelper {
if (fIndex > -1) {
this.data.LinkedList[fIndex].Linked = true;
+ this.data.LinkedList[fIndex].linkId=linkId;
} else {
this.data.LinkedList.push(cr);
}
@@ -1558,12 +1658,7 @@ class BleHelper {
});
}
- // 处理 MTU 设置
- if (plus.os.name === 'Android') {
- this.setMtu(deviceId).catch(ex => {
- console.error("mtu设置失败=", ex);
- });
- }
+
resolve(true);
}).catch((ex) => {
@@ -1970,5 +2065,6 @@ export default {
}
return instance;
- }
-}
\ No newline at end of file
+ },
+ constService:serviceDic
+}
diff --git a/utils/BleReceive.js b/utils/BleReceive.js
index 20107b1..b31a44b 100644
--- a/utils/BleReceive.js
+++ b/utils/BleReceive.js
@@ -1,18 +1,21 @@
+import Common from '@/utils/Common.js'
+
class BleReceive {
constructor() {
this.StorageKey = "linkedDevices";
this.HandlerMap = {
'/pages/6155/deviceDetail': this.Receive_6155.bind(this),
+ '/pages/6155/BJQ6155': this.Receive_6155_XH.bind(this),
'/pages/7305/BJQ7305': this.Receive_6155.bind(this),
'/pages/650/HBY650': this.Receive_650.bind(this),
'/pages/670/HBY670': this.Receive_670.bind(this),
- '/pages/4877/BJQ4877': this.Receive_4877.bind(this),
+ '/pages/4877/BJQ4877': this.Receive_4877.bind(this),
'/pages/100/HBY100': this.Receive_100.bind(this),
- '/pages/102/HBY102':this.Receive_102.bind(this)
+ '/pages/102/HBY102': this.Receive_102.bind(this)
};
}
-
+
setBleFormData(data, f) {
if (data) {
let linkedList = uni.getStorageSync(this.StorageKey);
@@ -59,7 +62,7 @@ class BleReceive {
if (handler) {
let data = handler(receive, f, path, recArr);
- // console.log("设备"+f.device.deviceName+"收到消息,数据:", data);
+ // console.log("设备"+f.device.deviceName+"收到消息,数据:", data);
return data;
} else {
console.error("已收到消息,但无指定处理程序, deviceUrl:", f.device.detailPageUrl, "可用handlers:", keys);
@@ -99,6 +102,10 @@ class BleReceive {
staticLevelText = '低档';
modeCurr = "low";
break;
+ case 0x68:
+ staticLevelText = '前置';
+ modeCurr = "smalllow";
+ break;
case 0x64:
staticLevelText = '关闭';
modeCurr = "close";
@@ -162,7 +169,7 @@ class BleReceive {
if (iswarn) {
uni.showModal({
- content: "'"+f.device.deviceName+"'环境存在漏电电源",
+ content: "'" + f.device.deviceName + "'环境存在漏电电源",
title: "警告",
success(res) {
if (res.confirm) {
@@ -258,7 +265,7 @@ class BleReceive {
Receive_670(receive, f, path, recArr) {
// console.log("pagh=", path);
var todo = (bytes) => {
- console.log("todo",receive);
+ console.log("todo", receive);
let receiveData = {};
if (bytes[0] == 0x55) {
try {
@@ -319,7 +326,7 @@ class BleReceive {
receiveData.staticWarn = staticWarn;
receiveData.fourGStrenth = fourGStrenth;
receiveData.SOS = sosTxt;
- receiveData.qzwarn = sosTxt==='sg';
+ receiveData.qzwarn = sosTxt === 'sg';
this.setBleFormData(receiveData, f);
console.log("recArr=", recArr);
let recCnt = recArr.find(v => {
@@ -327,22 +334,22 @@ class BleReceive {
.replace(/\//g, "").toLowerCase();
});
if (!recCnt) {
- let msgs=[];
- if(receiveData.qzwarn){
+ let msgs = [];
+ if (receiveData.qzwarn) {
msgs.push("声光报警中");
}
if (staticWarn) { //有静止报警
msgs.push("静止报警中");
}
- if(msgs.length>0){
- msgs="设备'"+f.device.deviceName+msgs.join(";");
+ if (msgs.length > 0) {
+ msgs = "设备'" + f.device.deviceName + msgs.join(";");
uni.showModal({
title: "警告",
- content:msgs,
+ content: msgs,
showCancel: false
});
}
-
+
}
} catch (error) {
console.error('数据解析错误:', error);
@@ -418,44 +425,132 @@ class BleReceive {
return data;
}
-
+
+ Receive_6155_XH(receive, f, path, recArr) {
+ let bytes = receive.bytes;
+ if (bytes[0] == 0xFB && bytes[1] == 0x64 && bytes.length >= 8) {
+ try {
+
+ let light = null;
+ let mode = null;
+
+ if (bytes[2] === 0x01 && bytes[3] === 0x00) {
+ light = 0;
+ mode = 'main';
+ } else if (bytes[2] === 0x02 && bytes[3] === 0x00) {
+ light = 1;
+ mode = 'main';
+ } else if (bytes[2] === 0x00 && bytes[3] === 0x01) {
+ light = 2;
+ mode = 'main';
+ } else if (bytes[2] === 0x03 && bytes[3] === 0x00) {
+ light = 0;
+ mode = 'fu';
+ } else if (bytes[2] === 0x04 && bytes[3] === 0x00) {
+ light = 1;
+ mode = 'fu';
+ }
+ if (bytes[2] === 0x05 && bytes[3] === 0x00) {
+ light = 3;
+ }
+
+
+ // 解析剩余电量
+ let batteryLevelByte = bytes[4];
+ // 电量百分比范围检查
+ let batteryLevel = Math.max(0, Math.min(100, batteryLevelByte));
+
+
+
+
+ //充电状态
+ let warn = bytes[5];
+ if (warn == 0x00) {
+ warn = '未充电';
+ } else if (warn == 0x01) {
+ warn = '充电中';
+ }
+
+ // 解析剩余照明时间(第三和第四字节,小端序)
+ let lightingTime = "";
+ let HH = Math.max(0, Math.min(100, bytes[6]));
+ let mm = Math.max(0, Math.min(100, bytes[7]));
+ lightingTime = HH + "小时" + mm + "分钟";
+ let formData = {};
+ formData.mode = mode;
+ formData.light = light;
+
+ formData.battary = batteryLevel;
+ formData.statu = warn;
+ formData.xuhang = lightingTime;
+
+
+ let recCnt = recArr.find(v => {
+
+ return v.key.replace(/\//g, "").toLowerCase() === f.device.detailPageUrl.replace(/\//g,
+ '').toLowerCase();
+
+
+
+ });
+ if (!recCnt) {
+ if (batteryLevel <= 20) {
+ // 会弹出两个框,暂且注释掉这段代码
+ uni.showModal({
+ content: "设备'" + f.device.deviceName + "'电量低",
+ title: "提示"
+ });
+ }
+ }
+
+
+ this.setBleFormData(formData, f);
+ return formData;
+ } catch (error) {
+ console.log('7305数据解析错误:', error);
+ return null;
+ }
+ }
+ return null;
+ }
+
Receive_6155(receive, f, path, recArr) {
let bytes = receive.bytes;
if (bytes[0] == 0xFB && bytes[1] == 0x64 && bytes.length >= 8) {
try {
-
- let getName = function(type,) {
+
+ let getName = function(type, ) {
let name = "";
switch (type) {
case 0x01:
// name = '强光';
- name=0;
+ name = 0;
break;
case 0x02:
// name = '弱光';
- name=1;
+ name = 1;
break;
case 0x03:
- // name = '爆闪';
- name=2;
- break;
+ // name = '爆闪';
+ name = 2;
+ break;
case 0x04:
- name = 0;//泛光
+ name = 0; //泛光
break;
case 0x0A:
- name = 1;//强光&泛光
+ name = 1; //强光&泛光
break;
-
-
+
+
default:
// name = '关闭';
- name=null;
+ name = null;
break;
}
return name;
}
-
+
let staticLevelText = getName(bytes[2]);
// 解析照明档位
@@ -484,26 +579,27 @@ class BleReceive {
let mm = Math.max(0, Math.min(100, bytes[7]));
lightingTime = HH + "小时" + mm + "分钟";
let formData = {};
- formData.mode = (bytes[2]===0x00 || bytes[2]===0x0B)?'fu':'main';
- formData.light=formData.mode=='fu'?lightingLevelText:staticLevelText;
-
- formData.battary = batteryLevel;
+ formData.mode = (bytes[2] === 0x00 || bytes[2] === 0x0B) ? 'fu' : 'main';
+ formData.light = formData.mode == 'fu' ? lightingLevelText : staticLevelText;
+
+ formData.battary = batteryLevel;
formData.statu = warn;
formData.xuhang = lightingTime;
-
-
+
+
let recCnt = recArr.find(v => {
- return v.key.replace(/\//g, "").toLowerCase() === f.device.detailPageUrl.replace(/\//g, '').toLowerCase();
+ return v.key.replace(/\//g, "").toLowerCase() === f.device.detailPageUrl.replace(/\//g,
+ '').toLowerCase();
+
-
});
if (!recCnt) {
if (batteryLevel <= 20) {
- // 会弹出两个框,暂且注释掉这段代码
+ // 会弹出两个框,暂且注释掉这段代码
uni.showModal({
- content: "设备'"+f.device.deviceName+"'电量低",
+ content: "设备'" + f.device.deviceName + "'电量低",
title: "提示"
});
}
@@ -520,102 +616,231 @@ class BleReceive {
return null;
}
- Receive_4877(receive,f,path,recArr){
- let receiveData={};
-
+ Receive_4877(receive, f, path, recArr) {
+ let receiveData = {};
+
try {
-
+
// console.log("str=",receive.str);
receiveData = JSON.parse(receive.str);
-
- let recCnt = recArr.find(v => {
- return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
- .replace(/\//g, "").toLowerCase();
- });
- if (!recCnt) {
- if (receiveData.sta_PowerPercent<=20) {
- uni.showModal({
- title: "提示",
- content: "设备'"+f.device.deviceName+"'电量低",
- showCancel: false
- });
- }
+
+ let recCnt = recArr.find(v => {
+ return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
+ .replace(/\//g, "").toLowerCase();
+ });
+ if (!recCnt) {
+ if (receiveData.sta_PowerPercent <= 20) {
+ uni.showModal({
+ title: "提示",
+ content: "设备'" + f.device.deviceName + "'电量低",
+ showCancel: false
+ });
}
+ }
} catch (error) {
receiveData = {};
- console.log("文本解析失败",error)
+ console.log("文本解析失败", error)
}
return receiveData;
-
+
}
-
- Receive_100(receive,f,path,recArr){
- let receiveData={};
-
+
+ Receive_100(receive, f, path, recArr) {
+ let receiveData = {};
+
try {
-
- // console.log("str=",receive.str);
+
+ // console.log("str=",receive.str);
receiveData = JSON.parse(receive.str);
-
- let recCnt = recArr.find(v => {
- return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
- .replace(/\//g, "").toLowerCase();
- });
- if (!recCnt) {
- if (receiveData.sta_battery<=20) {
- uni.showModal({
- title: "提示",
- content: "设备'"+f.device.deviceName+"'电量低",
- showCancel: false
- });
- }
+
+ let recCnt = recArr.find(v => {
+ return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
+ .replace(/\//g, "").toLowerCase();
+ });
+ if (!recCnt) {
+ if (receiveData.sta_battery <= 20) {
+ uni.showModal({
+ title: "提示",
+ content: "设备'" + f.device.deviceName + "'电量低",
+ showCancel: false
+ });
}
+ }
} catch (error) {
receiveData = {};
- console.log("文本解析失败",error)
+ console.log("文本解析失败", error)
}
return receiveData;
-
+
}
-
-
- Receive_102(receive,f,path,recArr){
- let receiveData={};
-
+
+
+ Receive_102(receive, f, path, recArr) {
+ let receiveData = {};
+
try {
-
- // console.log("str=",receive.str);
+ console.log("订阅消息者:", path);
+ console.log("设备收到消息:", f);
+ console.log("消息内容:", receive);
receiveData = JSON.parse(receive.str);
-
- let recCnt = recArr.find(v => {
- return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
- .replace(/\//g, "").toLowerCase();
- });
- if (!recCnt) {
- if (receiveData.sta_PowerPercent<=20) {
- uni.showModal({
- title: "提示",
- content: "设备'"+f.device.deviceName+"'电量低",
- showCancel: false
- });
- }
- if (receiveData.sta_Intrusion===1) {
- uni.showModal({
- title: "提示",
- content: "闯入报警中",
- showCancel: false
- });
- }
-
+
+ let recCnt = recArr.find(v => {
+ return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
+ .replace(/\//g, "").toLowerCase();
+ });
+ if (!recCnt) {
+ if (receiveData.sta_PowerPercent <= 20) {
+ uni.showModal({
+ title: "提示",
+ content: "设备'" + f.device.deviceName + "'电量低",
+ showCancel: false
+ });
}
+ if (receiveData.sta_Intrusion === 1) {
+ uni.showModal({
+ title: "提示",
+ content: "闯入报警中",
+ showCancel: false
+ });
+ }
+
+ }
+
+
+
+ if (f.device && path === "pages/common/index") { //仅在首页订阅此操作
+ console.error("1111111111");
+ let linkKey = "102_" + f.device.id + "_linked";
+ let warnKey = "102_" + f.device.id + "_warning";
+ let time = new Date(); //Common.DateFormat(new Date(),'yyyy-MM-dd HH:mmss');
+
+ if (receiveData.sta_tomac) { //某个设备上线了
+
+ if (receiveData.sta_tomac.indexOf(':') == -1) {
+ receiveData.sta_tomac = receiveData.sta_tomac.replace(/(.{2})/g, '$1:').slice(0, -
+ 1); //mac地址自动补:
+ }
+ uni.getStorageInfo({
+ success: function(res) {
+
+ let arr = [];
+ let linked = {
+ linkId: f.linkId,
+ read: false,
+ linkEqs: [{
+ linkTime: time,
+ linkMac: f.macAddress
+ }, {
+ linkTime: time,
+ linkMac: receiveData.sta_tomac
+ }]
+ };
+ if (res.keys.includes(linkKey)) {
+ arr = uni.getStorageSync(linkKey);
+ }
+ if (arr.length == 0) {
+ arr.unshift(linked);
+
+ } else {
+ let dev = arr.find(v => {
+ if (v.linkId == f.linkId) {
+ let vl = v.linkEqs.find(cvl => {
+ if(cvl.linkMac === receiveData.sta_tomac){
+ v.read=false;
+ cvl.linkTime=time;
+ return true;
+ }
+ return false;
+ });
+ if (!vl) {
+ v.linkEqs.push({
+ linkTime: time,
+ linkMac: receiveData.sta_tomac
+ });
+ }
+ return vl;
+ }
+ return false;
+ });
+ if (!dev) {
+ arr.unshift(linked);
+ }
+
+ }
+ console.error("某个设备上线了", arr)
+ uni.setStorage({
+ key: linkKey,
+ data: arr
+ });
+
+
+ }
+ });
+ }
+
+ let warnArrs = [];
+ let guid = Common.guid();
+ if (receiveData.sta_sosadd) { //某个设备闯入报警
+ console.error("某个设备闯入报警");
+ if (receiveData.sta_sosadd.indexOf(':') == -1) {
+ receiveData.sta_sosadd = receiveData.sta_sosadd.replace(/(.{2})/g, '$1:').slice(0, -
+ 1); //mac地址自动补:
+ }
+ warnArrs.push({
+ linkId: f.linkId,
+ read: false,
+ key: guid,
+ warnType: "闯入报警",
+ warnMac: receiveData.sta_sosadd,
+ warnTime: time,
+ warnName: ""
+ });
+
+ }
+
+ if (receiveData.sta_LedType === 'led_alarm' || receiveData.ins_LedType === 'led_alarm') { //强制报警
+ console.error("强制报警了", f);
+ warnArrs.push({
+ linkId: f.linkId,
+ read: false,
+ key: guid,
+ warnType: "强制报警",
+ warnMac: f.macAddress,
+ warnTime: time,
+ warnName: ""
+ });
+ }
+
+ if (warnArrs.length > 0) {
+ uni.getStorageInfo({
+ success: function(res) {
+ let arr = [];
+ if (res.keys.includes(warnKey)) {
+ arr = uni.getStorageSync(warnKey);
+ arr = warnArrs.concat(arr);
+ } else {
+ arr = warnArrs
+ }
+ uni.setStorage({
+ key: warnKey,
+ data: arr
+ });
+
+ }
+ });
+
+ }
+ }
+
+
} catch (error) {
receiveData = {};
- console.log("文本解析失败",error)
+ console.log("文本解析失败", error)
}
return receiveData;
-
+
}
-
+
}
diff --git a/utils/Common.js b/utils/Common.js
index 76d313b..6fab65e 100644
--- a/utils/Common.js
+++ b/utils/Common.js
@@ -218,7 +218,7 @@ export default {
value: "1",
label: "灯光模式",
checked: false,
- type: ['6170', '670']
+ type: ['6170', '670','102']
},
{
value: "2",
@@ -282,7 +282,7 @@ export default {
value: "46",
label: "手动报警",
checked: false,
- type: ['210']
+ type: ['210','102']
},
{
value: "47",
@@ -290,6 +290,18 @@ export default {
checked: false,
type: ['210']
},
+ {
+ value: "48",
+ label: "物体感应",
+ checked: false,
+ type: ['102']
+ },
+ {
+ value: "49",
+ label: "联机模式",
+ checked: false,
+ type: ['102']
+ },
]
let arr = [];
diff --git a/utils/wgs84_to_gcj02.js b/utils/wgs84_to_gcj02.js
index 0f9baa4..ddb73d9 100644
--- a/utils/wgs84_to_gcj02.js
+++ b/utils/wgs84_to_gcj02.js
@@ -1,4 +1,3 @@
-
//地标 转 国测 常量
var x_PI = (3.14159265358979324 * 3000.0) / 180.0;
var PI = 3.1415926535897932384626;
@@ -8,115 +7,241 @@ var ee = 0.00669342162296594323; //椭球的偏心率。
//判断是否在国内,在中国国内的经纬度才需要做偏移
function out_of_china(lng, lat) {
- return (
- lng < 72.004 ||
- lng > 137.8347 ||
- (lat < 0.8293 || lat > 55.8271 || false)
- );
+ return (
+ lng < 72.004 ||
+ lng > 137.8347 ||
+ (lat < 0.8293 || lat > 55.8271 || false)
+ );
}
//转化经度
function transformlng(lng, lat) {
- var ret =
- 300.0 +
- lng +
- 2.0 * lat +
- 0.1 * lng * lng +
- 0.1 * lng * lat +
- 0.1 * Math.sqrt(Math.abs(lng));
- ret +=
- ((20.0 * Math.sin(6.0 * lng * PI) +
- 20.0 * Math.sin(2.0 * lng * PI)) *
- 2.0) /
- 3.0;
- ret +=
- ((20.0 * Math.sin(lng * PI) +
- 40.0 * Math.sin((lng / 3.0) * PI)) *
- 2.0) /
- 3.0;
- ret +=
- ((150.0 * Math.sin((lng / 12.0) * PI) +
- 300.0 * Math.sin((lng / 30.0) * PI)) *
- 2.0) /
- 3.0;
- return ret;
+ var ret =
+ 300.0 +
+ lng +
+ 2.0 * lat +
+ 0.1 * lng * lng +
+ 0.1 * lng * lat +
+ 0.1 * Math.sqrt(Math.abs(lng));
+ ret +=
+ ((20.0 * Math.sin(6.0 * lng * PI) +
+ 20.0 * Math.sin(2.0 * lng * PI)) *
+ 2.0) /
+ 3.0;
+ ret +=
+ ((20.0 * Math.sin(lng * PI) +
+ 40.0 * Math.sin((lng / 3.0) * PI)) *
+ 2.0) /
+ 3.0;
+ ret +=
+ ((150.0 * Math.sin((lng / 12.0) * PI) +
+ 300.0 * Math.sin((lng / 30.0) * PI)) *
+ 2.0) /
+ 3.0;
+ return ret;
}
//转化纬度
function transformlat(lng, lat) {
- var ret =
- -100.0 +
- 2.0 * lng +
- 3.0 * lat +
- 0.2 * lat * lat +
- 0.1 * lng * lat +
- 0.2 * Math.sqrt(Math.abs(lng));
- ret +=
- ((20.0 * Math.sin(6.0 * lng * PI) +
- 20.0 * Math.sin(2.0 * lng * PI)) *
- 2.0) /
- 3.0;
- ret +=
- ((20.0 * Math.sin(lat * PI) +
- 40.0 * Math.sin((lat / 3.0) * PI)) *
- 2.0) /
- 3.0;
- ret +=
- ((160.0 * Math.sin((lat / 12.0) * PI) +
- 320 * Math.sin((lat * PI) / 30.0)) *
- 2.0) /
- 3.0;
- return ret;
+ var ret = -100.0 +
+ 2.0 * lng +
+ 3.0 * lat +
+ 0.2 * lat * lat +
+ 0.1 * lng * lat +
+ 0.2 * Math.sqrt(Math.abs(lng));
+ ret +=
+ ((20.0 * Math.sin(6.0 * lng * PI) +
+ 20.0 * Math.sin(2.0 * lng * PI)) *
+ 2.0) /
+ 3.0;
+ ret +=
+ ((20.0 * Math.sin(lat * PI) +
+ 40.0 * Math.sin((lat / 3.0) * PI)) *
+ 2.0) /
+ 3.0;
+ ret +=
+ ((160.0 * Math.sin((lat / 12.0) * PI) +
+ 320 * Math.sin((lat * PI) / 30.0)) *
+ 2.0) /
+ 3.0;
+ return ret;
}
+//经纬度互相转换
+function convertByNet(lng,lat,from){
+
+ return new Promise((resolve, reject) => {
+ if(!from){
+ from='wgs84'
+ }
+ let url = 'https://openapi.lddgo.net/base/gtool/api/v1/CoordinateTransform'
+ uni.request({
+ url: url,
+ method: 'POST',
+ timeout: 10000,
+ header:{
+ 'content-type':'application/json;charset=UTF-8'
+ },
+ data:
+ {
+ "from": "wgs84",
+ "coordinateList": [
+ {
+ "sourceLng": lng,
+ "sourceLat": lat
+ }
+ ]
+ }
+ ,
+ dataType: 'json',
+ success(res) {
+ if (res.statusCode == 200) {
+
+ if (res.data.code===0) {
+ console.log("坐标转换接口成功", res);
+ let lnglag=res.data.data.coordinateList[0];
+ resolve([lnglag.gLng,lnglag.gLat]);
+ return;
+ }
+
+ }
+ console.error("坐标转换异常", res);
+ resolve(null)
+
+ },
+ fail(err) {
+ console.error("坐标转换接口出现异常", err);
+ resolve(null);
+ }
+ })
+ });
+ }
-//wgs84 to gcj02 地球坐标系 转 火星坐标系
- function wgs84_to_gcj02(lng, lat) {
- if (out_of_china(lng, lat)) {
- return [lng, lat];
- } else {
- var dlat = transformlat(lng - 105.0, lat - 35.0);
- var dlng = transformlng(lng - 105.0, lat - 35.0);
- var radlat = (lat / 180.0) * PI;
- var magic = Math.sin(radlat);
- magic = 1 - ee * magic * magic;
- var sqrtmagic = Math.sqrt(magic);
- dlat =
- (dlat * 180.0) /
- (((a * (1 - ee)) / (magic * sqrtmagic)) * PI);
- dlng =
- (dlng * 180.0) / ((a / sqrtmagic) * Math.cos(radlat) * PI);
- var mglat = lat + dlat;
- var mglng = lng + dlng;
+function wgs84_to_gcj02_old(lng, lat) {
+ if (out_of_china(lng, lat)) {
+ return [lng, lat];
+ } else {
+ var dlat = transformlat(lng - 105.0, lat - 35.0);
+ var dlng = transformlng(lng - 105.0, lat - 35.0);
+ var radlat = (lat / 180.0) * PI;
+ var magic = Math.sin(radlat);
+ magic = 1 - ee * magic * magic;
+ var sqrtmagic = Math.sqrt(magic);
+ dlat =
+ (dlat * 180.0) /
+ (((a * (1 - ee)) / (magic * sqrtmagic)) * PI);
+ dlng =
+ (dlng * 180.0) / ((a / sqrtmagic) * Math.cos(radlat) * PI);
+ var mglat = lat + dlat;
+ var mglng = lng + dlng;
- return [mglng, mglat];
- }
+ return [mglng, mglat];
+ }
+}
+//wgs84 to gcj02 wgs84转gcj02,返回Promise
+function wgs84_to_gcj02(lng, lat) {
+
+ //调用高德的接口进行坐标转换
+ let convertByGD = () => {
+ return new Promise((resolve, reject) => {
+ let url = 'https://restapi.amap.com/v3/assistant/coordinate/convert?locations=' + lng + ',' +
+ lat + '&coordsys=gps&output=json&key=ca3af8a20d628897020893892bda5ae4'
+ uni.request({
+ url: url,
+ method: 'GET',
+ timeout: 10000,
+ dataType: 'json',
+ success(res) {
+ if (res.statusCode == 200) {
+
+ if (res.data.status == "1" && res.data.infocode=='10000') {
+ console.log("坐标转换接口成功", res);
+ resolve(res.data.locations.split(','));
+ return;
+ }
+
+ }
+ console.error("坐标转换异常", res);
+ resolve(null)
+
+ },
+ fail(err) {
+ console.error("坐标转换接口出现异常", err);
+ resolve(null);
+ }
+ })
+ });
+
+ }
+
+
+ let convertOrains=()=>{
+ let newLnglat=wgs84_to_gcj02_old(lng,lat);
+ return Promise.resolve(newLnglat);
+ }
+
+ let task=()=>{
+ return new Promise((resolve,reject)=>{
+
+ let promises=[convertByGD(),convertByNet(lng,lat),convertOrains()];
+ Promise.allSettled(promises).then(
+ res=>{
+ for (let i = 0; i < res.length; i++) {
+ let item = res[i];
+ if(item.status==='fulfilled' && item.value){
+ resolve(item.value);
+ break;
+ }
+ }
+ }
+ );
+ });
+ }
+
+
+ return task();
}
//gcj02 to wgs84 火星坐标系 转 地球坐标系
- function gcj02_to_wgs84(lng, lat) {
- if (out_of_china(lng, lat)) {
- return [lng, lat]
- }
- else {
- var dlat = transformlat(lng - 105.0, lat - 35.0);
- var dlng = transformlng(lng - 105.0, lat - 35.0);
- var radlat = lat / 180.0 * PI;
- var magic = Math.sin(radlat);
- magic = 1 - ee * magic * magic;
- var sqrtmagic = Math.sqrt(magic);
- dlat = (dlat * 180.0) / ((a * (1 - ee)) / (magic * sqrtmagic) * PI);
- dlng = (dlng * 180.0) / (a / sqrtmagic * Math.cos(radlat) * PI);
- var mglat = lat + dlat;
- var mglng = lng + dlng;
- return [lng * 2 - mglng, lat * 2 - mglat]
- }
+function gcj02_to_wgs84_old(lng, lat) {
+ if (out_of_china(lng, lat)) {
+ return [lng, lat]
+ } else {
+ var dlat = transformlat(lng - 105.0, lat - 35.0);
+ var dlng = transformlng(lng - 105.0, lat - 35.0);
+ var radlat = lat / 180.0 * PI;
+ var magic = Math.sin(radlat);
+ magic = 1 - ee * magic * magic;
+ var sqrtmagic = Math.sqrt(magic);
+ dlat = (dlat * 180.0) / ((a * (1 - ee)) / (magic * sqrtmagic) * PI);
+ dlng = (dlng * 180.0) / (a / sqrtmagic * Math.cos(radlat) * PI);
+ var mglat = lat + dlat;
+ var mglng = lng + dlng;
+ return [lng * 2 - mglng, lat * 2 - mglat]
+ }
+}
+
+//gcj02转wgs84
+function gcj02_to_wgs84(lng, lat){
+
+ let task=()=>{
+ return new Promise((resolve,reject)=>{
+
+ convertByNet(lng,lat,'gcj02').then(res=>{
+ if(res){
+ resolve(res);
+ return;
+ }
+ resolve(gcj02_to_wgs84_old(lng,lat));
+ })
+
+ });
+ }
+
+ return task();
}
export default {
- gcj02_to_wgs84,
- wgs84_to_gcj02
-}
-
-
-
+ gcj02_to_wgs84,
+ wgs84_to_gcj02
+}
\ No newline at end of file