尝试解决主分支冲突
This commit is contained in:
66
App.vue
66
App.vue
@ -1,13 +1,11 @@
|
||||
<script>
|
||||
import request from '@/utils/request.js';
|
||||
import bleTool from '@/utils/BleHelper.js';
|
||||
import bleTool from '@/utils/BleHelper.js'
|
||||
import upgrade from '@/utils/update.js'
|
||||
export default {
|
||||
|
||||
onLaunch: function() {
|
||||
var ble = bleTool.getBleTool();
|
||||
|
||||
onLaunch: function() {
|
||||
//以下代码仅在开发时使用,否则会出现不可预知的问题。
|
||||
// uni.clearStorageSync();
|
||||
//清除登陆之外的所有信息;
|
||||
// let store=uni.getStorageInfoSync();
|
||||
// store.keys.forEach((val,index,array)=>{
|
||||
// if(val=="tokenTime"){
|
||||
@ -28,36 +26,46 @@
|
||||
// uni.removeStorageSync(val);
|
||||
// }
|
||||
// });
|
||||
//以上代码仅在开发时使用,否则会出现不可预知的问题。
|
||||
|
||||
|
||||
uni.getSystemInfo({success:function(res){
|
||||
if(res.uniPlatform=='app'){
|
||||
bleTool.getBleTool();
|
||||
upgrade.checkAndUpdateWgt();
|
||||
|
||||
}
|
||||
}});
|
||||
},
|
||||
onShow: function() {
|
||||
console.log('App Show');
|
||||
upgrade.checkAndUpdateWgt("http://114.55.111.217/app/CheckUpdate");
|
||||
|
||||
},
|
||||
onHide: function() {
|
||||
console.log('App Hide')
|
||||
console.log('App Hide');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
@import 'vk-uview-ui/index.scss';
|
||||
uni-slider .uni-slider-handle-wrapper {
|
||||
border-radius: 20rpx;
|
||||
}
|
||||
uni-slider .uni-slider-thumb {
|
||||
width: 66rpx !important;
|
||||
height: 80rpx !important;
|
||||
margin-top: -40rpx !important;
|
||||
border-radius: 16rpx !important;
|
||||
margin-left: -72rpx !important;
|
||||
/* #ifdef APP-ANDROID */
|
||||
//苹果应用以下样式后Slider不可拖动
|
||||
uni-slider .uni-slider-handle-wrapper {
|
||||
border-radius: 20rpx;
|
||||
}
|
||||
uni-slider .uni-slider-thumb {
|
||||
width: 66rpx !important;
|
||||
height: 80rpx !important;
|
||||
margin-top: -40rpx !important;
|
||||
border-radius: 16rpx !important;
|
||||
margin-left: -72rpx !important;
|
||||
|
||||
}
|
||||
uni-slider .uni-slider-handle-wrapper {
|
||||
height: 88rpx;
|
||||
position: relative;
|
||||
}
|
||||
}
|
||||
uni-slider .uni-slider-handle-wrapper {
|
||||
height: 88rpx;
|
||||
position: relative;
|
||||
// }
|
||||
/* #endif */
|
||||
.custom-file-picker .file-picker__box-content {
|
||||
background: rgba(26, 26, 26, 1);
|
||||
border: none !important;
|
||||
@ -84,7 +92,13 @@
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "PingFang SC";
|
||||
src: url("~@/static/fonts/PingFangSC.ttf") format("opentype");
|
||||
}
|
||||
font-family: "PingFang SC";
|
||||
src: url("~@/static/fonts/PingFangSC.ttf") format("opentype");
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "PingFangBold";
|
||||
src: url("~@/static/fonts/PingFangBold.ttf") format("opentype");
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import {request,baseURL} from '@/utils/request'
|
||||
import request, { baseURL } from '@/utils/request'
|
||||
|
||||
function getdata(data,url,method){
|
||||
return new Promise((resolve,reject)=>{
|
||||
@ -14,8 +14,10 @@ function getdata(data,url,method){
|
||||
method: method,
|
||||
data:data
|
||||
}).then((res)=>{
|
||||
console.log("res=",res);
|
||||
resolve(res);
|
||||
}).catch(ex=>{
|
||||
console.log("ex=",ex);
|
||||
reject(ex);
|
||||
});
|
||||
});
|
||||
@ -81,10 +83,18 @@ function sendPic(data){
|
||||
});
|
||||
}
|
||||
|
||||
//设备详情
|
||||
function getDetail(id){
|
||||
return request({
|
||||
url: '/api/xinghan/device/'+id,
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
export default{
|
||||
sendUsr:sendUsr,
|
||||
warnMsg:warnMsg,
|
||||
sendPic:sendPic
|
||||
sendPic:sendPic,
|
||||
getDetail:getDetail
|
||||
}
|
||||
|
||||
|
||||
|
||||
55
api/670/History.js
Normal file
55
api/670/History.js
Normal file
@ -0,0 +1,55 @@
|
||||
import request, { baseURL } from '@/utils/request'
|
||||
|
||||
function getdata(data,url,method){
|
||||
return new Promise((resolve,reject)=>{
|
||||
if(!url){
|
||||
reject('url为空');
|
||||
return;
|
||||
}
|
||||
if(!method){
|
||||
method='POST';
|
||||
}
|
||||
request({
|
||||
url: url,
|
||||
method: method,
|
||||
data:data
|
||||
}).then((res)=>{
|
||||
console.log("res=",res);
|
||||
resolve(res);
|
||||
}).catch(ex=>{
|
||||
console.log("ex=",ex);
|
||||
reject(ex);
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
//获取开关机数据
|
||||
function getSwithData(data){
|
||||
let url="";
|
||||
return getdata(data,url,"POST");
|
||||
}
|
||||
|
||||
//报警信息
|
||||
function getWarnData(data){
|
||||
let url=""
|
||||
return getdata(data,url,"POST");
|
||||
}
|
||||
|
||||
//故障信息
|
||||
function getFaulData(data){
|
||||
let url=""
|
||||
return getdata(data,url,"POST");
|
||||
}
|
||||
|
||||
export default{
|
||||
getSwithData:getSwithData,
|
||||
getWarnData:getWarnData,
|
||||
getFaulData:getFaulData
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -15,16 +15,65 @@ export function resourceSmsCode(params) {
|
||||
data: params
|
||||
})
|
||||
}
|
||||
|
||||
// 退出登录
|
||||
export function Logout(data) {
|
||||
return request({
|
||||
url: '/app/auth/logout',
|
||||
url: '/app/userCenter/logout',
|
||||
method: 'POST',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 注册
|
||||
export function register(data) {
|
||||
return request({
|
||||
url: '/app/auth/register',
|
||||
method: 'POST',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 用户注册短信验证码
|
||||
export function registerSmsCode(data) {
|
||||
return request({
|
||||
url: '/app/auth/registerSmsCode',
|
||||
method: 'GET',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 忘记密码短信验证码
|
||||
export function forgetPasswordSmsCode(data) {
|
||||
return request({
|
||||
url: '/app/auth/forgetPasswordSmsCode',
|
||||
method: 'GET',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 找回密码登录
|
||||
export function forgetPassword(data) {
|
||||
return request({
|
||||
url: '/app/auth/forgetPassword',
|
||||
method: 'POST',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改密码
|
||||
export function updatePassword(data) {
|
||||
return request({
|
||||
url: '/app/userCenter/updatePassword',
|
||||
method: 'POST',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
// 用户注销
|
||||
export function cancelAccount(data) {
|
||||
return request({
|
||||
url: '/app/userCenter/cancelAccount',
|
||||
method: 'POST',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
@ -177,17 +177,19 @@ export default {
|
||||
return styles[this.type][styleType]
|
||||
},
|
||||
handleButtonClick() {
|
||||
console.log('[MessagePopup] Button clicked with value:', this.inputValue)
|
||||
|
||||
this.$emit('buttonClick', this.inputValue)
|
||||
},
|
||||
handleMaskClick() {
|
||||
console.log('[MessagePopup] Mask clicked')
|
||||
|
||||
this.$emit('maskClick')
|
||||
},
|
||||
closeClick(){
|
||||
|
||||
this.$emit('closePop')
|
||||
},
|
||||
handleCancelClick(){
|
||||
|
||||
this.$emit('cancelPop');
|
||||
},
|
||||
handleInput(e) {
|
||||
|
||||
@ -1,194 +1,195 @@
|
||||
<template>
|
||||
<view>
|
||||
<canvas type="2d" canvas-id="reusableCanvas" :width="currentCanvasWidth" :height="currentCanvasHeight"
|
||||
class="offscreen-canvas"></canvas>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "TextToHexV1",
|
||||
props: {
|
||||
txts: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
validator: (value) => value.every(item => typeof item === 'string')
|
||||
},
|
||||
fontSize: {
|
||||
type: Number,
|
||||
default: 16,
|
||||
validator: (value) => value > 0 && value <= 100
|
||||
},
|
||||
bgColor: {
|
||||
type: String,
|
||||
default: "#ffffff"
|
||||
},
|
||||
color: {
|
||||
type: String,
|
||||
default: "#000000"
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 当前Canvas的宽高(动态调整)
|
||||
currentCanvasWidth: 0,
|
||||
currentCanvasHeight: 0,
|
||||
// Canvas上下文(复用)
|
||||
ctx: null
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
validTxts() {
|
||||
return this.txts.filter(line => line.trim() !== '');
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
// 初始化Canvas上下文(只创建一次)
|
||||
this.ctx = uni.createCanvasContext('reusableCanvas', this);
|
||||
},
|
||||
methods: {
|
||||
/**
|
||||
* 估算单行文本所需的Canvas宽度
|
||||
*/
|
||||
calcLineWidth(textLine) {
|
||||
return textLine.length * this.fontSize;
|
||||
},
|
||||
|
||||
/**
|
||||
* 清除Canvas内容
|
||||
*/
|
||||
clearCanvas() {
|
||||
this.ctx.setFillStyle(this.bgColor);
|
||||
this.ctx.fillRect(0, 0, this.currentCanvasWidth, this.currentCanvasHeight);
|
||||
},
|
||||
|
||||
/**
|
||||
* 复用单个Canvas处理所有文本行
|
||||
*/
|
||||
async drawAndGetPixels() {
|
||||
|
||||
let convertCharToMatrix=function(imageData) {
|
||||
// console.log("imgData=",imageData)
|
||||
let matrix = [];
|
||||
|
||||
// 逐行处理
|
||||
for (let y = 0; y < 16; y++) {
|
||||
let byte1 = 0,
|
||||
byte2 = 0;
|
||||
|
||||
// 每行16个像素,分为两个字节
|
||||
for (let x = 0; x < 16; x++) {
|
||||
// 计算像素在imageData中的索引 (RGBA格式)
|
||||
let index = (y * 16 + x) * 4;
|
||||
let red = imageData[index];
|
||||
|
||||
// 黑色像素(R值较低)视为1,白色视为0
|
||||
let isBlack = red < 128;
|
||||
|
||||
if (x < 8) {
|
||||
// 第一个字节(左8位)
|
||||
if (isBlack) {
|
||||
byte1 |= 0x80 >> x; // 从左到右设置位
|
||||
}
|
||||
} else {
|
||||
// 第二个字节(右8位)
|
||||
if (isBlack) {
|
||||
byte2 |= 0x80 >> (x - 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 将字节转换为两位十六进制字符串
|
||||
matrix.push('0x' + byte1.toString(16).padStart(2, '0').toUpperCase());
|
||||
matrix.push('0x' + byte2.toString(16).padStart(2, '0').toUpperCase());
|
||||
}
|
||||
|
||||
return matrix;
|
||||
}
|
||||
|
||||
let drawTxt=async (textLine)=> {
|
||||
let result = {};
|
||||
let ctx = this.ctx;
|
||||
|
||||
// 1. 动态调整Canvas尺寸
|
||||
this.currentCanvasWidth = this.calcLineWidth(textLine);
|
||||
this.currentCanvasHeight = this.fontSize;
|
||||
|
||||
// 2. 清空Canvas(绘制背景)
|
||||
this.clearCanvas();
|
||||
|
||||
// 3. 设置文字样式
|
||||
ctx.setFillStyle(this.color);
|
||||
<template>
|
||||
<view>
|
||||
<canvas type="2d" canvas-id="reusableCanvas" :width="currentCanvasWidth" :height="currentCanvasHeight"
|
||||
class="offscreen-canvas"></canvas>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "TextToHexV1",
|
||||
props: {
|
||||
txts: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
validator: (value) => value.every(item => typeof item === 'string')
|
||||
},
|
||||
fontSize: {
|
||||
type: Number,
|
||||
default: 16,
|
||||
validator: (value) => value > 0 && value <= 100
|
||||
},
|
||||
bgColor: {
|
||||
type: String,
|
||||
default: "#ffffff"
|
||||
},
|
||||
color: {
|
||||
type: String,
|
||||
default: "#000000"
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 当前Canvas的宽高(动态调整)
|
||||
currentCanvasWidth: 0,
|
||||
currentCanvasHeight: 0,
|
||||
// Canvas上下文(复用)
|
||||
ctx: null
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
validTxts() {
|
||||
return this.txts.filter(line => line.trim() !== '');
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
// 初始化Canvas上下文(只创建一次)
|
||||
this.ctx = uni.createCanvasContext('reusableCanvas', this);
|
||||
},
|
||||
methods: {
|
||||
/**
|
||||
* 估算单行文本所需的Canvas宽度
|
||||
*/
|
||||
calcLineWidth(textLine) {
|
||||
return textLine.length * 16;
|
||||
},
|
||||
|
||||
/**
|
||||
* 清除Canvas内容
|
||||
*/
|
||||
clearCanvas() {
|
||||
this.ctx.setFillStyle(this.bgColor);
|
||||
this.ctx.fillRect(0, 0, this.currentCanvasWidth, this.currentCanvasHeight);
|
||||
},
|
||||
|
||||
/**
|
||||
* 复用单个Canvas处理所有文本行
|
||||
*/
|
||||
async drawAndGetPixels() {
|
||||
|
||||
let convertCharToMatrix=function(imageData) {
|
||||
// console.log("imgData=",imageData)
|
||||
let matrix = [];
|
||||
|
||||
// 逐行处理
|
||||
for (let y = 0; y < 16; y++) {
|
||||
let byte1 = 0,
|
||||
byte2 = 0;
|
||||
|
||||
// 每行16个像素,分为两个字节
|
||||
for (let x = 0; x < 16; x++) {
|
||||
// 计算像素在imageData中的索引 (RGBA格式)
|
||||
let index = (y * 16 + x) * 4;
|
||||
let red = imageData[index];
|
||||
|
||||
// 黑色像素(R值较低)视为1,白色视为0
|
||||
let isBlack = red < 128;
|
||||
|
||||
if (x < 8) {
|
||||
// 第一个字节(左8位)
|
||||
if (isBlack) {
|
||||
byte1 |= 0x80 >> x; // 从左到右设置位
|
||||
}
|
||||
} else {
|
||||
// 第二个字节(右8位)
|
||||
if (isBlack) {
|
||||
byte2 |= 0x80 >> (x - 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 将字节转换为两位十六进制字符串
|
||||
matrix.push('0x' + byte1.toString(16).padStart(2, '0').toUpperCase());
|
||||
matrix.push('0x' + byte2.toString(16).padStart(2, '0').toUpperCase());
|
||||
}
|
||||
|
||||
return matrix;
|
||||
}
|
||||
|
||||
let drawTxt=async (textLine)=> {
|
||||
let result = {};
|
||||
let ctx = this.ctx;
|
||||
|
||||
// 1. 动态调整Canvas尺寸
|
||||
this.currentCanvasWidth = this.calcLineWidth(textLine);
|
||||
this.currentCanvasHeight = 16;
|
||||
|
||||
// 2. 清空Canvas(绘制背景)
|
||||
this.clearCanvas();
|
||||
|
||||
// 3. 设置文字样式
|
||||
ctx.setFillStyle(this.color);
|
||||
ctx.setTextBaseline('middle');
|
||||
ctx.setFontSize(this.fontSize);
|
||||
ctx.font = `${this.fontSize}px "PingFang SC", PingFang SC, Arial, sans-serif`;
|
||||
|
||||
// 4. 绘制当前行文本
|
||||
let currentX = 0;
|
||||
let currentY = this.fontSize / 2;
|
||||
for (let j = 0; j < textLine.length; j++) {
|
||||
let char = textLine[j];
|
||||
ctx.fillText(char, currentX, currentY);
|
||||
// 按实际字符宽度计算间距
|
||||
let charWidth = ctx.measureText(char).width;
|
||||
currentX += charWidth;
|
||||
}
|
||||
|
||||
// 5. 异步绘制并获取像素数据(串行处理避免冲突)
|
||||
await new Promise((resolve, reject) => {
|
||||
ctx.draw(false, () => {
|
||||
uni.canvasGetImageData({
|
||||
canvasId: 'reusableCanvas',
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: this.currentCanvasWidth,
|
||||
height: this.currentCanvasHeight,
|
||||
success: res => {
|
||||
|
||||
result={
|
||||
line: textLine,
|
||||
pixelData: res.data,
|
||||
width: this.currentCanvasWidth,
|
||||
height: this.currentCanvasHeight
|
||||
};
|
||||
resolve();
|
||||
},
|
||||
fail: err => {
|
||||
// console.error(`处理第${i+1}行失败:`, err);
|
||||
reject(err)
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
let arr = [];
|
||||
// 循环处理每行文本
|
||||
for (let i = 0; i < this.validTxts.length; i++) {
|
||||
|
||||
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(","));
|
||||
arr.push(linePixls);
|
||||
}
|
||||
|
||||
return arr;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.offscreen-canvas {
|
||||
position: fixed;
|
||||
left: -9999px;
|
||||
top: -9999px;
|
||||
visibility: hidden;
|
||||
}
|
||||
// ctx.setTextAlign('center')
|
||||
ctx.setFontSize(this.fontSize);
|
||||
ctx.font = `${this.fontSize}px "PingFangBold", "PingFang SC", Arial, sans-serif`;
|
||||
|
||||
// 4. 绘制当前行文本
|
||||
let currentX = 0;
|
||||
let currentY = this.fontSize / 2;
|
||||
for (let j = 0; j < textLine.length; j++) {
|
||||
let char = textLine[j];
|
||||
ctx.fillText(char, currentX, currentY);
|
||||
// 按实际字符宽度计算间距
|
||||
let charWidth = ctx.measureText(char).width;
|
||||
currentX += charWidth;
|
||||
}
|
||||
|
||||
// 5. 异步绘制并获取像素数据(串行处理避免冲突)
|
||||
await new Promise((resolve, reject) => {
|
||||
ctx.draw(false, () => {
|
||||
uni.canvasGetImageData({
|
||||
canvasId: 'reusableCanvas',
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: this.currentCanvasWidth,
|
||||
height: this.currentCanvasHeight,
|
||||
success: res => {
|
||||
|
||||
result={
|
||||
line: textLine,
|
||||
pixelData: res.data,
|
||||
width: this.currentCanvasWidth,
|
||||
height: this.currentCanvasHeight
|
||||
};
|
||||
resolve();
|
||||
},
|
||||
fail: err => {
|
||||
// console.error(`处理第${i+1}行失败:`, err);
|
||||
reject(err)
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
let arr = [];
|
||||
// 循环处理每行文本
|
||||
for (let i = 0; i < this.validTxts.length; i++) {
|
||||
|
||||
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(","));
|
||||
arr.push(linePixls);
|
||||
}
|
||||
|
||||
return arr;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.offscreen-canvas {
|
||||
position: fixed;
|
||||
left: -9999px;
|
||||
top: -9999px;
|
||||
visibility: hidden;
|
||||
}
|
||||
</style>
|
||||
@ -2,21 +2,21 @@
|
||||
const config = {
|
||||
// 开发环境
|
||||
development: {
|
||||
BASE_URL: 'http://192.168.110.54:8000',
|
||||
BASE_URL: 'http://192.168.2.34:8000',
|
||||
API_PREFIX: '',
|
||||
// MQTT 配置
|
||||
MQTT_HOST: '47.120.79.150',
|
||||
MQTT_PORT: 8083,
|
||||
MQTT_HOST: 'www.cnxhyc.com',
|
||||
MQTT_PORT: 9083,
|
||||
MQTT_USERNAME: 'admin',
|
||||
MQTT_PASSWORD: '#YtvpSfCNG'
|
||||
MQTT_PASSWORD: '#YtvpSfCNG'
|
||||
},
|
||||
// 生产环境
|
||||
production: {
|
||||
BASE_URL: 'http://192.168.110.54:8000', // https://fuyuanshen.com/backend
|
||||
BASE_URL: 'https://fuyuanshen.com/backend',
|
||||
API_PREFIX: '',
|
||||
// MQTT 配置
|
||||
MQTT_HOST: '47.120.79.150',
|
||||
MQTT_PORT: 8083,
|
||||
MQTT_HOST: 'www.cnxhyc.com',
|
||||
MQTT_PORT: 9084,
|
||||
MQTT_USERNAME: 'admin',
|
||||
MQTT_PASSWORD: '#YtvpSfCNG'
|
||||
}
|
||||
|
||||
4
main.js
4
main.js
@ -1,6 +1,6 @@
|
||||
import App from './App'
|
||||
|
||||
// 引入 uView UI
|
||||
//// 引入 uView UI
|
||||
import uView from 'vk-uview-ui';
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ import {
|
||||
} from 'vue'
|
||||
export function createApp() {
|
||||
const app = createSSRApp(App)
|
||||
|
||||
|
||||
// 使用 uView UI
|
||||
app.use(uView)
|
||||
return {
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
{
|
||||
"name" : "晶全-物联",
|
||||
"name" : "星汉物联",
|
||||
"appid" : "__UNI__A21EF43",
|
||||
"description" : "设备管控",
|
||||
"versionName" : "1.0.9",
|
||||
"versionName" : "1.0.25",
|
||||
"versionCode" : "100",
|
||||
"transformPx" : false,
|
||||
/* 5+App特有相关 */
|
||||
@ -21,8 +21,7 @@
|
||||
"Bluetooth" : {},
|
||||
"Barcode" : {},
|
||||
"Camera" : {},
|
||||
"Record" : {},
|
||||
"VideoPlayer" : {},
|
||||
"OAuth" : {},
|
||||
"Geolocation" : {}
|
||||
},
|
||||
/* 应用发布信息 */
|
||||
@ -157,8 +156,5 @@
|
||||
"enable" : false
|
||||
},
|
||||
"vueVersion" : "2",
|
||||
"locale" : "zh-Hans",
|
||||
"fallbackLocale" : "zh-Hans"
|
||||
"locale" : "auto"
|
||||
}
|
||||
/* 5+App特有相关 */
|
||||
|
||||
|
||||
16
package-lock.json
generated
16
package-lock.json
generated
@ -6,8 +6,10 @@
|
||||
"": {
|
||||
"dependencies": {
|
||||
"axios": "^1.9.0",
|
||||
"blueimp-md5": "^2.19.0",
|
||||
"cordova-sqlite-storage": "^7.0.0",
|
||||
"iconv-lite": "^0.6.3",
|
||||
"mescroll-uni": "^1.3.7",
|
||||
"paho-mqtt": "^1.1.0",
|
||||
"text-encoding": "^0.7.0",
|
||||
"vk-uview-ui": "^1.5.2"
|
||||
@ -28,6 +30,11 @@
|
||||
"proxy-from-env": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/blueimp-md5": {
|
||||
"version": "2.19.0",
|
||||
"resolved": "https://registry.npmjs.org/blueimp-md5/-/blueimp-md5-2.19.0.tgz",
|
||||
"integrity": "sha512-DRQrD6gJyy8FbiE4s+bDoXS9hiW3Vbx5uCdwvcCf3zLHL+Iv7LtGHLpr+GZV8rHG8tK766FGYBwRbu8pELTt+w=="
|
||||
},
|
||||
"node_modules/call-bind-apply-helpers": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
|
||||
@ -268,6 +275,12 @@
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/mescroll-uni": {
|
||||
"version": "1.3.7",
|
||||
"resolved": "https://registry.npmjs.org/mescroll-uni/-/mescroll-uni-1.3.7.tgz",
|
||||
"integrity": "sha512-1pQMtGA+iVRKhfJZZNXdBx05NnthIk6zm3hRbumswSA54eaKOMgpUDb9AQ2+rRdXmS6kLkEYSbW/fkb7/IyoAg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/mime-db": {
|
||||
"version": "1.52.0",
|
||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
|
||||
@ -290,7 +303,8 @@
|
||||
"node_modules/paho-mqtt": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/paho-mqtt/-/paho-mqtt-1.1.0.tgz",
|
||||
"integrity": "sha512-KPbL9KAB0ASvhSDbOrZBaccXS+/s7/LIofbPyERww8hM5Ko71GUJQ6Nmg0BWqj8phAIT8zdf/Sd/RftHU9i2HA=="
|
||||
"integrity": "sha512-KPbL9KAB0ASvhSDbOrZBaccXS+/s7/LIofbPyERww8hM5Ko71GUJQ6Nmg0BWqj8phAIT8zdf/Sd/RftHU9i2HA==",
|
||||
"license": "EPL-1.0"
|
||||
},
|
||||
"node_modules/proxy-from-env": {
|
||||
"version": "1.1.0",
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"axios": "^1.9.0",
|
||||
"blueimp-md5": "^2.19.0",
|
||||
"cordova-sqlite-storage": "^7.0.0",
|
||||
"iconv-lite": "^0.6.3",
|
||||
"paho-mqtt": "^1.1.0",
|
||||
|
||||
577
pages.json
577
pages.json
@ -1,310 +1,283 @@
|
||||
{
|
||||
"pages": [
|
||||
"pages": [
|
||||
// 登录
|
||||
{
|
||||
"path": "pages/common/login/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
"path": "pages/common/login/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
// 注册
|
||||
{
|
||||
"path": "pages/common/register/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
// 忘记密码
|
||||
{
|
||||
"path": "pages/common/forgotPassword/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"path": "pages/common/index/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "pages/BlueTooth/ModeSetting/index",
|
||||
"style" :
|
||||
"path": "pages/common/user/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "我的"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/scan/scan",
|
||||
"style": {
|
||||
"navigationBarTitleText": "扫描"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/qrcode/qrcode",
|
||||
"style": {
|
||||
"navigationBarTitleText": "扫描到的设备"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/send/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "发送信息",
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/userAgreement/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "用户协议"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/privacyAgreement/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "隐私协议"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/aboutUs/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "关于我们"
|
||||
}
|
||||
},
|
||||
// 账号安全
|
||||
{
|
||||
"path": "pages/common/account/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "账户安全"
|
||||
}
|
||||
},
|
||||
// 注销账号
|
||||
{
|
||||
"path": "pages/common/account/deleteAccount/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "注销账号"
|
||||
}
|
||||
},
|
||||
// 修改密码
|
||||
{
|
||||
"path": "pages/common/account/changepassword/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "修改密码"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/6170/deviceControl/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/6170/callPolice/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "报警",
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"path": "pages/210/deviceControl/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/operationVideo/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/addvideo/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
// 操作说明
|
||||
{
|
||||
"path": "pages/common/operatingInstruct/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
// 产品说明
|
||||
{
|
||||
"path": "pages/common/productDes/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/addBLE/addEquip",
|
||||
"style": {
|
||||
"navigationBarTitleText": "扫描设备"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/addBLE/LinkBle",
|
||||
"style": {
|
||||
"navigationBarTitleText": "绑定设备"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/6155/deviceDetail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "HBY 6155"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/6155/ImgCrop",
|
||||
"style": {
|
||||
"navigationBarTitleText": "图像裁剪",
|
||||
"navigationStyle": "custom",
|
||||
"fullscreen": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/map/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "地图"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/allType/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "所有类型"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/allShare/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "所有分享"
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"path": "pages/common/share/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "分享"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/shareDevices/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "分享设备"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/shareManagement/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "分享管理"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/210/onlineDevice/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "联机设备"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/210/addDevice/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "添加联机设备"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/210/historyRecords/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "历史记录"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/210/call/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "呼叫"
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"path": "pages/670/HBY670",
|
||||
"style": {
|
||||
"navigationBarTitleText": "HBY670",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/650/HBY650",
|
||||
"style": {
|
||||
"navigationBarTitleText": "HBY650"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/670/History",
|
||||
"style": {
|
||||
"navigationBarTitleText": "历史记录"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/7305/BJQ7305",
|
||||
"style": {
|
||||
"navigationBarTitleText": "BJQ7305"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
],
|
||||
"tabBar": {
|
||||
"color": "#fff",
|
||||
"selectedColor": "#BBE600",
|
||||
"backgroundColor": "#202020",
|
||||
"list": [{
|
||||
"pagePath": "pages/common/index/index",
|
||||
"text": "我的设备",
|
||||
"iconPath": "/static/tabs/device.png",
|
||||
"selectedIconPath": "/static/tabs/device-HL.png"
|
||||
},
|
||||
{
|
||||
"navigationBarTitleText" : "设备类型"
|
||||
"pagePath": "pages/common/user/index",
|
||||
"text": "我的",
|
||||
"iconPath": "/static/tabs/my.png",
|
||||
"selectedIconPath": "/static/tabs/my-HL.png"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "pages/670/HBY670",
|
||||
"style" :
|
||||
{
|
||||
"navigationBarTitleText" : "HBY670"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
|
||||
{
|
||||
"path": "pages/common/index/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/user/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "我的"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/scan/scan",
|
||||
"style": {
|
||||
"navigationBarTitleText": "扫描"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/qrcode/qrcode",
|
||||
"style": {
|
||||
"navigationBarTitleText": "扫描到的设备"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/send/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "发送信息",
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/userAgreement/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "用户协议"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/privacyAgreement/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "隐私协议"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/aboutUs/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "关于我们"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/6170/deviceControl/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/6170/callPolice/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "报警"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/210/deviceControl/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/operationVideo/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/addvideo/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
// 操作说明
|
||||
{
|
||||
"path": "pages/common/operatingInstruct/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
// 产品说明
|
||||
{
|
||||
"path": "pages/common/productDes/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/addBLE/addEquip",
|
||||
"style": {
|
||||
"navigationBarTitleText": "添加设备"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/addBLE/LinkBle",
|
||||
"style": {
|
||||
"navigationBarTitleText": "扫描到的设备"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/6155/deviceDetail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "HBY 6155"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/6155/ImgCrop",
|
||||
"style": {
|
||||
"navigationBarTitleText": "图像裁剪",
|
||||
"navigationStyle": "custom",
|
||||
"fullscreen": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/650/HBY650",
|
||||
"style": {
|
||||
"navigationBarTitleText": "HBY650"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/map/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "地图"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/allType/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "所有类型"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/6170/allShare/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "所有分享"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/6170/share/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "分享"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/6170/shareDevices/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "分享设备"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/6170/shareManagement/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "分享管理"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/210/onlineDevice/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "联机设备"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/210/addDevice/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "添加联机设备"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/210/historyRecords/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "历史记录"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/210/call/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "呼叫"
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
{
|
||||
"path": "pages/BlueTooth/ModeSetting/VideoSend",
|
||||
"style": {
|
||||
"navigationBarTitleText": "发送视频"
|
||||
|
||||
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/BlueTooth/ModeSetting/VideoSend_1",
|
||||
"style": {
|
||||
"navigationBarTitleText": "发送视频"
|
||||
|
||||
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/BlueTooth/ModeSetting/VideoSend_670",
|
||||
"style": {
|
||||
"navigationBarTitleText": "发送视频"
|
||||
|
||||
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/BlueTooth/ModeSetting/HBY650",
|
||||
"style": {
|
||||
"navigationBarTitleText": "HBY650"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/BlueTooth/ModeSetting/HBY650_1",
|
||||
"style": {
|
||||
"navigationBarTitleText": "HBY650"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/BlueTooth/ModeSetting/ModeSetting",
|
||||
"style": {
|
||||
"navigationBarTitleText": "7307-0.96TFT"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/BlueTooth/ModeSetting/update",
|
||||
"style": {
|
||||
"navigationBarTitleText": "版本更新"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/BlueTooth/ModeSetting/HBY6155",
|
||||
"style": {
|
||||
"navigationBarTitleText": "HBY6155"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/BlueTooth/ModeSetting/HBY6155V1",
|
||||
"style": {
|
||||
"navigationBarTitleText": "HBY6155_V1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/BlueTooth/ModeSetting/HBY670V1",
|
||||
"style": {
|
||||
"navigationBarTitleText": "HBY670"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
],
|
||||
"tabBar": {
|
||||
"color": "#fff",
|
||||
"selectedColor": "#BBE600",
|
||||
"backgroundColor": "#202020",
|
||||
"list": [
|
||||
{
|
||||
"pagePath": "pages/common/index/index",
|
||||
"text": "我的设备",
|
||||
"iconPath": "/static/tabs/device.png",
|
||||
"selectedIconPath": "/static/tabs/device-HL.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/common/user/index",
|
||||
"text": "我的",
|
||||
"iconPath": "/static/tabs/my.png",
|
||||
"selectedIconPath": "/static/tabs/my-HL.png"
|
||||
}
|
||||
]
|
||||
},
|
||||
"globalStyle": {
|
||||
"navigationBarTextStyle": "white",
|
||||
"navigationBarTitleText": "uni-app",
|
||||
"navigationBarBackgroundColor": "#121212",
|
||||
"backgroundColor": "#121212"
|
||||
},
|
||||
"uniIdRouter": {}
|
||||
"globalStyle": {
|
||||
"navigationBarTextStyle": "white",
|
||||
"navigationBarTitleText": "uni-app",
|
||||
"navigationBarBackgroundColor": "#121212",
|
||||
"backgroundColor": "#121212"
|
||||
},
|
||||
"uniIdRouter": {}
|
||||
}
|
||||
@ -35,11 +35,11 @@
|
||||
handleCrop(e) {
|
||||
|
||||
var these = this;
|
||||
|
||||
const eventChannel = these.getOpenerEventChannel();
|
||||
this.Statu = true;
|
||||
console.log("裁剪完成");
|
||||
console.log(e.tempFilePath);
|
||||
//
|
||||
eventChannel.emit('ImgCutOver_Path',e.tempFilePath);
|
||||
const ctx = uni.createCanvasContext('splashCanvas', this);
|
||||
ctx.drawImage(
|
||||
e.tempFilePath,
|
||||
@ -56,9 +56,11 @@
|
||||
height: 80,
|
||||
success: (res) => {
|
||||
// 处理像素数据并发送
|
||||
const eventChannel = these.getOpenerEventChannel();
|
||||
|
||||
console.log("res.data.length="+res.data.length);
|
||||
|
||||
eventChannel.emit('ImgCutOverPath', {
|
||||
picPath: e.tempFilePath
|
||||
});
|
||||
|
||||
eventChannel.emit('ImgCutOver',{piexls:res.data,picPath:e.tempFilePath});
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
<text class="value">{{formData.deviceName}}</text>
|
||||
</view>
|
||||
<view class="item">
|
||||
<text class="lbl">设备状态</text>
|
||||
<text class="lbl">充电状态</text>
|
||||
<text class="value">{{formData.statu}}</text>
|
||||
</view>
|
||||
</view>
|
||||
@ -55,7 +55,7 @@
|
||||
</view>
|
||||
<view class="rightTxt">
|
||||
<text class="bigTxt">主灯模式</text>
|
||||
<text class="smallTxt">强光模式</text>
|
||||
<text class="smallTxt">{{getMode}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="mode marginLeft fleft" v-on:click.stop="ModeSetting('fu')">
|
||||
@ -83,8 +83,8 @@
|
||||
<text class="usrtitle fleft">人员信息登记</text>
|
||||
<view class="btnSend fright" v-on:click.stop="sendUsr">发送</view>
|
||||
<view class="clear"></view>
|
||||
<TextToHex class="TextToHex" ref="textToHex" :txts="formData.textLines" :bgColor="'#000000'"
|
||||
:color="'#FFFFFF'" :fontSize="16" />
|
||||
<TextToHexV1 class="TextToHex" ref="textToHex" :txts="formData.textLines" :bgColor="'#FFFFFF'"
|
||||
:color="'#000000'" :fontSize="14" />
|
||||
</view>
|
||||
|
||||
<view class="item">
|
||||
@ -143,17 +143,26 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import TextToHexVue from '@/components/TextToHex/TextToHex.vue';
|
||||
import TextToHexV1 from '@/components/TextToHex/TextToHexV1.vue';
|
||||
import bleTool from '@/utils/BleHelper.js';
|
||||
|
||||
import usrApi from '@/api/670/HBY670.js'
|
||||
import {
|
||||
showLoading,
|
||||
hideLoading,
|
||||
updateLoading
|
||||
} from '@/utils/loading.js'
|
||||
import BleReceive from '@/utils/BleReceive';
|
||||
|
||||
|
||||
var ble = null;
|
||||
var these = null;
|
||||
var BrighInteval = null;
|
||||
var recei = null;
|
||||
|
||||
export default {
|
||||
components: {
|
||||
TextToHexV1
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
Status: {
|
||||
@ -172,7 +181,8 @@
|
||||
visiblePrompt: false,
|
||||
promptTitle: '设备名称',
|
||||
modelValue: '',
|
||||
visibleClose: false
|
||||
visibleClose: false,
|
||||
okCallback:null
|
||||
},
|
||||
BottomMenu: {
|
||||
show: false,
|
||||
@ -221,10 +231,29 @@
|
||||
liangDu: '100',
|
||||
id: '',
|
||||
deviceId: '',
|
||||
textLines: ['我爱你', '中国', '五星红旗'],
|
||||
textLines: ['', '', ''],
|
||||
mode: ''
|
||||
},
|
||||
|
||||
inteval: 200,
|
||||
device: {
|
||||
id: "",
|
||||
deviceName: "",
|
||||
deviceImei: "",
|
||||
deviceMac: "",
|
||||
communicationMode: 0,
|
||||
devicePic: "",
|
||||
typeName: "",
|
||||
bluetoothName: null,
|
||||
deviceStatus: null,
|
||||
bindingTime: "",
|
||||
onlineStatus: 0,
|
||||
battery: "0",
|
||||
latitude: null,
|
||||
longitude: null,
|
||||
alarmStatus: null,
|
||||
detailPageUrl: "/pages/6155/deviceDetail",
|
||||
showConfirm: false
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
@ -233,7 +262,54 @@
|
||||
},
|
||||
onLoad: function() {
|
||||
these = this;
|
||||
recei = BleReceive.getBleReceive();
|
||||
ble = bleTool.getBleTool();
|
||||
// let bleName = 'FB_Site_UART'; //JQZM-EF4651 FB_Site_UART
|
||||
|
||||
|
||||
// let f = ble.data.LinkedList.find((v) => {
|
||||
// if (v.name == bleName) {
|
||||
// console.log("找到设备了", v);
|
||||
// these.formData.deviceId = v.deviceId;
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
// });
|
||||
|
||||
// let link = () => {
|
||||
// if (bleName == 'FB_Site_UART') {
|
||||
// ble.LinkBlue(f.deviceId, '0000AE30-0000-1000-8000-00805F9B34FB',
|
||||
// '0000AE03-0000-1000-8000-00805F9B34FB', '0000AE02-0000-1000-8000-00805F9B34FB');
|
||||
// } else {
|
||||
// ble.LinkBlue(f.deviceId, '0000FFE0-0000-1000-8000-00805F9B34FB',
|
||||
// '0000FFE1-0000-1000-8000-00805F9B34FB', '0000FFE2-0000-1000-8000-00805F9B34FB');
|
||||
// }
|
||||
|
||||
// }
|
||||
// if (!f) {
|
||||
|
||||
|
||||
// ble.addDeviceFound((res) => {
|
||||
// // console.log("发现新设备", res);
|
||||
// f = res.devices.find((v) => {
|
||||
// return v.name == bleName;
|
||||
// });
|
||||
// if (f) {
|
||||
|
||||
// console.log("找到目标设备了", f);
|
||||
// these.formData.deviceId = f.deviceId;
|
||||
|
||||
// link();
|
||||
|
||||
// ble.StopSearch();
|
||||
// }
|
||||
// });
|
||||
|
||||
// ble.StartSearch();
|
||||
// } else {
|
||||
// link();
|
||||
// }
|
||||
console.log("6155");
|
||||
ble.addReceiveCallback(these.bleValueNotify);
|
||||
let eventChannel = this.getOpenerEventChannel();
|
||||
|
||||
@ -241,7 +317,8 @@
|
||||
|
||||
|
||||
let device = data.data;
|
||||
console.log("收到父页面的参数:" + JSON.stringify(device));
|
||||
these.device = device;
|
||||
|
||||
let f = ble.data.LinkedList.find((v) => {
|
||||
if (v.macAddress == device.deviceMac) {
|
||||
console.log("找到设备了", v);
|
||||
@ -252,13 +329,8 @@
|
||||
});
|
||||
if (!f) {
|
||||
|
||||
|
||||
these.showPop({
|
||||
message: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备",
|
||||
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
});
|
||||
these.getDetail();
|
||||
these.showBleUnConnect();
|
||||
return;
|
||||
}
|
||||
let form = f.formData;
|
||||
@ -276,7 +348,7 @@
|
||||
these.formData.deviceId = f.deviceId;
|
||||
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId);
|
||||
these.setBleFormData();
|
||||
|
||||
these.getDetail();
|
||||
|
||||
|
||||
});
|
||||
@ -306,21 +378,54 @@
|
||||
if (this.formData.RSSI < -85 && this.formData.RSSI >= -100) {
|
||||
remark = '微弱';
|
||||
}
|
||||
},
|
||||
getMode() {
|
||||
let txt = "关闭";
|
||||
if (this.Status.BottomMenu.type == 'fu') {
|
||||
return txt;
|
||||
}
|
||||
switch (this.formData.mode) {
|
||||
case 0:
|
||||
|
||||
|
||||
txt = "强光模式";
|
||||
|
||||
break;
|
||||
case 1:
|
||||
txt = "弱光模式";
|
||||
break;
|
||||
|
||||
case 2:
|
||||
txt = "爆闪模式";
|
||||
break;
|
||||
case 3:
|
||||
txt = "关闭";
|
||||
break;
|
||||
default:
|
||||
txt = "关闭";
|
||||
break;
|
||||
|
||||
}
|
||||
return txt;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getDevice: function() {
|
||||
console.log("LinkedList=", ble.data.LinkedList);
|
||||
console.log("formData=", these.formData);
|
||||
// console.log("LinkedList=", ble.data.LinkedList);
|
||||
// console.log("formData=", these.formData);
|
||||
let f = ble.data.LinkedList.find((v) => {
|
||||
return v.deviceId == these.formData.deviceId;
|
||||
return v.macAddress == these.device.deviceMac;
|
||||
});
|
||||
|
||||
return f;
|
||||
},
|
||||
bleValueNotify: function(receive) {
|
||||
console.log("处理接收到的数据:" + receive);
|
||||
bleValueNotify: function(receive, device, path) {
|
||||
|
||||
let str = recei.ReceiveData(receive, device, path);
|
||||
|
||||
console.log("处理接收到的数据:" + str);
|
||||
return;
|
||||
let data = recei.ReceiveData(receive, device, path);
|
||||
let bytes = receive.bytes;
|
||||
|
||||
if (bytes[0] == 0xFB && bytes[1] == 0x64 && bytes.length >= 8) {
|
||||
@ -383,6 +488,15 @@
|
||||
this.formData.statu = warn;
|
||||
this.formData.xuhang = lightingTime;
|
||||
|
||||
if (batteryLevel <= 20) {
|
||||
this.showPop({
|
||||
message: "设备电量低",
|
||||
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
});
|
||||
}
|
||||
|
||||
this.setBleFormData();
|
||||
} catch (error) {
|
||||
console.log('数据解析错误:', error);
|
||||
@ -416,16 +530,40 @@
|
||||
}
|
||||
});
|
||||
},
|
||||
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);
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
},
|
||||
checkImgUpload: function() {
|
||||
let f = these.getDevice();
|
||||
|
||||
if (!f) {
|
||||
these.showPop({
|
||||
message: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备",
|
||||
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
});
|
||||
these.showBleUnConnect();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -433,10 +571,55 @@
|
||||
var processAndSendImageData = function(pixels) {
|
||||
return new Promise((resolve, reject) => {
|
||||
// 创建RGB565格式的像素数据
|
||||
const rgb565Data = ble.convertToRGB565(pixels);
|
||||
const arr = ble.convertToRGB565(pixels, 'bgr');
|
||||
|
||||
var list = [];
|
||||
let index = 0; // 用于追踪arr的当前位置
|
||||
let packetSize = 2048;
|
||||
let cSize = 248;
|
||||
// 外层循环:7个主要元素(i从1到7)
|
||||
for (let i = 1; i < 8; i++) {
|
||||
let secondLevel = [];
|
||||
let secondCnt = 0;
|
||||
// 中层循环:每个主要元素包含9个子数组(j从1到9)
|
||||
for (let j = 1; j < 10; j++) {
|
||||
// 确定当前子数组的长度:前8个是254,第9个是64
|
||||
|
||||
let thirdLevel = [];
|
||||
|
||||
// 从arr中提取相应数量的元素
|
||||
for (let k = 0; k < cSize && index < arr.length; k++) {
|
||||
|
||||
if (secondCnt == packetSize) {
|
||||
break;
|
||||
}
|
||||
thirdLevel.push(arr[index]);
|
||||
secondCnt++;
|
||||
index++;
|
||||
}
|
||||
|
||||
secondLevel.push(thirdLevel);
|
||||
}
|
||||
list.push(secondLevel);
|
||||
}
|
||||
|
||||
console.log("list=", list);
|
||||
|
||||
let length = 0;
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
const item = list[i];
|
||||
let clength = 0;
|
||||
for (let j = 0; j < item.length; j++) {
|
||||
const element = item[j];
|
||||
console.log("第" + i + "包,第" + j + "小包,长度:" + element.length)
|
||||
length += element.length;
|
||||
clength += element.length;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
// 分包发送
|
||||
sendImagePackets(rgb565Data).then(resolve).catch(reject);
|
||||
sendImagePackets(list).then(resolve).catch(reject);
|
||||
});
|
||||
}
|
||||
|
||||
@ -446,90 +629,116 @@
|
||||
var sendImagePackets = function(imageData) {
|
||||
return new Promise((resolve, reject) => {
|
||||
// 总数据包数
|
||||
const totalPackets = 52;
|
||||
const totalPackets = 7;
|
||||
let currentPacket = 1;
|
||||
let childPacket = 1;
|
||||
let totalChildPacket = 9;
|
||||
|
||||
|
||||
// 发送单个数据包
|
||||
const sendNextPacket = () => {
|
||||
if (currentPacket > totalPackets) {
|
||||
hideLoading(these);
|
||||
these.Status.BottomMenu.show = false;
|
||||
setTimeout(() => {
|
||||
hideLoading(these);
|
||||
these.Status.BottomMenu.show = false;
|
||||
|
||||
these.showPop({
|
||||
message: "上传成功",
|
||||
iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png"
|
||||
});
|
||||
these.showPop({
|
||||
message: "上传成功",
|
||||
iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png",
|
||||
borderColor: '#BBE600',
|
||||
buttonBgColor: '#BBE600'
|
||||
});
|
||||
|
||||
resolve();
|
||||
}, 20000)
|
||||
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
// 计算当前包的数据
|
||||
let packetSize = 250;
|
||||
if (currentPacket <= 51) {
|
||||
packetSize = 250; // 前51个包每个500字节
|
||||
} else {
|
||||
packetSize = 50; // 最后一个包100字节
|
||||
}
|
||||
var packetData = imageData[currentPacket - 1][childPacket - 1];
|
||||
// if (packetData.length == 0) {
|
||||
// hideLoading(these);
|
||||
// these.Status.BottomMenu.show = false;
|
||||
|
||||
// 创建数据包
|
||||
const startIndex = (currentPacket - 1) * packetSize;
|
||||
const endIndex = Math.min(startIndex + packetSize, imageData
|
||||
.length);
|
||||
if (startIndex > endIndex) {
|
||||
return;
|
||||
}
|
||||
const packetData = imageData.slice(startIndex,
|
||||
endIndex); // imageData.subarray(startIndex, endIndex);
|
||||
console.log("imageData.length=" + imageData.length +
|
||||
",startIndex=" +
|
||||
startIndex +
|
||||
",endIndex=" + endIndex + ",数据包长度" + (endIndex -
|
||||
startIndex) +
|
||||
',packetData.length=' + packetData.length);
|
||||
// 构建数据包
|
||||
const bufferSize = 5 + packetData.length * 2; // 头部5字节 + 数据部分
|
||||
const buffer = new ArrayBuffer(bufferSize);
|
||||
const dataView = new DataView(buffer);
|
||||
// these.showPop({
|
||||
// message: "上传成功",
|
||||
// iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png"
|
||||
// });
|
||||
|
||||
// 填充头部
|
||||
dataView.setUint8(0, 0x55); // 帧头
|
||||
dataView.setUint8(1, 0x02); // 帧类型:开机画面
|
||||
dataView.setUint8(2, '0x' + currentPacket.toString(16).padStart(2,
|
||||
'0')); // 包序号
|
||||
// if(packetData.length==250)
|
||||
// {
|
||||
// dataView.setUint8(3, 0x01);
|
||||
// dataView.setUint8(4, 0xFF);
|
||||
// resolve();
|
||||
// return;
|
||||
// }
|
||||
let start = 0;
|
||||
let bufferSize = packetData.length * 2;
|
||||
|
||||
if (packetData.length == 250) {
|
||||
dataView.setUint8(3, 0x01);
|
||||
dataView.setUint8(4, 0xF4);
|
||||
} else {
|
||||
dataView.setUint8(3, 0x00);
|
||||
dataView.setUint8(4, 0x64);
|
||||
if (currentPacket == 7) {
|
||||
if (childPacket > 2 && childPacket < 9) {
|
||||
bufferSize = 496;
|
||||
} else if (childPacket == 9) {
|
||||
bufferSize = 128;
|
||||
}
|
||||
}
|
||||
|
||||
if (childPacket == 1) {
|
||||
bufferSize = bufferSize + 8
|
||||
start = 8;
|
||||
}
|
||||
if (childPacket == 9) { //|| (currentPacket==7 && childPacket==3
|
||||
bufferSize = bufferSize + 1
|
||||
}
|
||||
|
||||
|
||||
//FA 09 10 04 FC 09 [00] [01] + 4096字节+FF 数据格式
|
||||
var buffer = new ArrayBuffer(bufferSize);
|
||||
var dataView = new DataView(buffer);
|
||||
if (childPacket == 1) {
|
||||
dataView.setUint8(0, 0xFA); // 帧头
|
||||
dataView.setUint8(1, 0x09); // 帧头
|
||||
dataView.setUint8(2, 0x10); // 帧头
|
||||
dataView.setUint8(3, 0x04); // 帧头
|
||||
dataView.setUint8(4, 0xFC); // 帧头
|
||||
dataView.setUint8(5, 0x09); // 帧头
|
||||
|
||||
dataView.setUint8(6, 0x00); // 图序号,图片固定0,视频的话要写序号
|
||||
dataView.setUint8(7, currentPacket); //子包序号
|
||||
}
|
||||
|
||||
// 填充数据(每个RGB565值占2字节)
|
||||
for (let i = 0; i < packetData.length; i++) {
|
||||
dataView.setUint16(5 + i * 2, packetData[i], false); // 大端字节序
|
||||
dataView.setUint16(start + i * 2, packetData[i], false); //本包数据,大端字节序
|
||||
}
|
||||
console.log("packetData.length=", packetData.length);
|
||||
console.log("bufferSize=", bufferSize)
|
||||
if (childPacket == 9) { // || (currentPacket==7 && childPacket==3
|
||||
dataView.setUint8(bufferSize - 1, 0xFF);
|
||||
}
|
||||
|
||||
//发送数据包
|
||||
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId,
|
||||
30)
|
||||
.then(() => {
|
||||
console.log("发送一个包完成了");
|
||||
|
||||
let curr = childPacket + (currentPacket - 1) *
|
||||
totalChildPacket;
|
||||
console.log("第" + currentPacket + "大包,第" + childPacket +
|
||||
"小包发送完成,总计:" + curr);
|
||||
updateLoading(these, {
|
||||
text: "正在发送" + currentPacket + "/" +
|
||||
totalPackets
|
||||
text: "正在发送" + curr + "/63"
|
||||
|
||||
})
|
||||
currentPacket++;
|
||||
if (childPacket == 9) {
|
||||
currentPacket++;
|
||||
childPacket = 1;
|
||||
} else {
|
||||
childPacket++;
|
||||
}
|
||||
|
||||
setTimeout(sendNextPacket, 100);
|
||||
}).catch(err => {
|
||||
if (err.code == 10007) {
|
||||
setTimeout(sendNextPacket, 100);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("发送数据包失败了", err);
|
||||
|
||||
these.Status.BottomMenu.show = false;
|
||||
@ -567,7 +776,8 @@
|
||||
|
||||
these.Status.BottomMenu.show = false;
|
||||
setTimeout(function() {
|
||||
processAndSendImageData(data.piexls).catch((ex) => {
|
||||
processAndSendImageData(data.piexls).catch((
|
||||
ex) => {
|
||||
console.log("出现异常", ex);
|
||||
});
|
||||
}, 0)
|
||||
@ -606,10 +816,10 @@
|
||||
text: '强光',
|
||||
icon: '/static/images/6155/DeviceDetail/qiang.png'
|
||||
},
|
||||
{
|
||||
text: '工作光',
|
||||
icon: '/static/images/6155/DeviceDetail/fan.png'
|
||||
},
|
||||
// {
|
||||
// text: '工作光',
|
||||
// icon: '/static/images/6155/DeviceDetail/fan.png'
|
||||
// },
|
||||
{
|
||||
text: '弱光',
|
||||
icon: '/static/images/6155/DeviceDetail/ruo.png'
|
||||
@ -617,7 +827,7 @@
|
||||
{
|
||||
text: '爆闪',
|
||||
icon: '/static/images/6155/DeviceDetail/shan.png'
|
||||
},
|
||||
},
|
||||
{
|
||||
text: '关闭',
|
||||
icon: '/static/images/6155/DeviceDetail/close.png'
|
||||
@ -662,42 +872,40 @@
|
||||
}
|
||||
this.closeMenu();
|
||||
},
|
||||
|
||||
setMode(mode, type) {
|
||||
|
||||
let dataValue = 0;
|
||||
this.setBleFormData();
|
||||
|
||||
|
||||
if (type == 'main') {
|
||||
|
||||
type = 0x04;
|
||||
} else if (type == 'fu') {
|
||||
|
||||
type = 0x05;
|
||||
}
|
||||
|
||||
this.currentMode = mode;
|
||||
|
||||
|
||||
switch (mode) {
|
||||
case 0:
|
||||
dataValue = 0x01;
|
||||
|
||||
|
||||
if (type == 'main') {
|
||||
|
||||
dataValue = 0x01;
|
||||
} else if (type == 'fu') {
|
||||
|
||||
dataValue = 0x04;
|
||||
}
|
||||
|
||||
break;
|
||||
case 1:
|
||||
dataValue = 0x04;
|
||||
break;
|
||||
case 2:
|
||||
dataValue = 0x02;
|
||||
break;
|
||||
case 3:
|
||||
// case 2:
|
||||
// dataValue = 0x02;
|
||||
// break;
|
||||
case 2:
|
||||
dataValue = 0x03;
|
||||
break;
|
||||
case 4:
|
||||
dataValue = 0x00;
|
||||
case 3:
|
||||
dataValue = 0x0B;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
// console.log("dataValue=", dataValue)
|
||||
// 构建数据包
|
||||
var buffer = new ArrayBuffer(6);
|
||||
var dataView = new DataView(buffer);
|
||||
@ -713,12 +921,7 @@
|
||||
// 发送数据
|
||||
|
||||
if (!f) {
|
||||
these.showPop({
|
||||
message: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备",
|
||||
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
});
|
||||
these.showBleUnConnect();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -727,7 +930,8 @@
|
||||
});
|
||||
|
||||
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 30).then(() => {
|
||||
|
||||
this.formData.mode = mode;
|
||||
this.setBleFormData();
|
||||
}).catch((ex) => {
|
||||
these.showPop({
|
||||
message: "发送失败," + ex.msg,
|
||||
@ -771,38 +975,54 @@
|
||||
|
||||
},
|
||||
HidePop: function() {
|
||||
console.log("1111");
|
||||
if (this.Status.Pop.clickEvt == 'SendUsr') {
|
||||
|
||||
}
|
||||
if (this.Status.Pop.okCallback) {
|
||||
this.Status.Pop.okCallback();
|
||||
}
|
||||
this.Status.Pop.showPop = false;
|
||||
},
|
||||
showPop: function(option) {
|
||||
|
||||
hideLoading(this);
|
||||
let defaultCfg = {
|
||||
showHeader: false,
|
||||
headerTxt: "",
|
||||
showHeader: false,
|
||||
showCancel: false,
|
||||
borderColor: '#BBE600',
|
||||
buttonBgColor: '#BBE600',
|
||||
okCallback: null,
|
||||
cancelCallback: null,
|
||||
popType: 'custom',
|
||||
buttonText: '确定',
|
||||
clickEvt: ''
|
||||
};
|
||||
if (!option) {
|
||||
option = {
|
||||
a: 1
|
||||
};
|
||||
|
||||
}
|
||||
let keys = Object.keys(option);
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
let key = keys[i];
|
||||
these.Status.Pop[key] = option[key];
|
||||
this.Status.Pop[key] = option[key];
|
||||
}
|
||||
if (!option.borderColor) {
|
||||
option.borderColor = '#BBE600';
|
||||
option.buttonBgColor = '#BBE600';
|
||||
keys = Object.keys(defaultCfg);
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
let key = keys[i];
|
||||
if (key in option) {
|
||||
continue;
|
||||
}
|
||||
this.Status.Pop[key] = defaultCfg[key];
|
||||
}
|
||||
these.Status.Pop.showPop = true;
|
||||
|
||||
this.Status.Pop.showPop = true;
|
||||
},
|
||||
sendUsr() {
|
||||
let f = this.getDevice();
|
||||
if (!f) {
|
||||
these.showPop({
|
||||
text: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备",
|
||||
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
});
|
||||
these.showBleUnConnect()
|
||||
return;
|
||||
}
|
||||
showLoading(these, {
|
||||
@ -817,8 +1037,8 @@
|
||||
|
||||
let packetSize = rgbdata.length; //每包均分的数量
|
||||
let mode = rgbdata.length % packetSize; //最后一包的数量
|
||||
let cnt = parseInt(rgbdata.length / packetSize) + (mode > 0 ? 1 :
|
||||
0); //总包数量
|
||||
let cnt =
|
||||
1; // parseInt(rgbdata.length / packetSize) + (mode > 0 ? 1 :0); //总包数量
|
||||
let curr = 1; //当前包序号
|
||||
|
||||
let sendNext = () => {
|
||||
@ -831,6 +1051,7 @@
|
||||
let bufferSize = 261;
|
||||
|
||||
console.log("bufferSize=", bufferSize)
|
||||
|
||||
let buffer = new ArrayBuffer(bufferSize);
|
||||
let dataView = new DataView(buffer);
|
||||
let startIndex = (curr - 1) * packetSize;
|
||||
@ -844,7 +1065,7 @@
|
||||
|
||||
let packetData = rgbdata.slice(startIndex,
|
||||
endIndex); //取一片数据发送
|
||||
|
||||
console.log("packetData.length=", packetData.length);
|
||||
let start = 0;
|
||||
if (curr == 1) {
|
||||
dataView.setUint8(0, 0xFA);
|
||||
@ -852,7 +1073,7 @@
|
||||
dataView.setUint8(2, 0x01);
|
||||
dataView.setUint8(3, 0x00);
|
||||
|
||||
// dataView.setUint16(2, str.length, false);
|
||||
|
||||
start = 4;
|
||||
}
|
||||
|
||||
@ -862,8 +1083,8 @@
|
||||
|
||||
dataView.setUint8(bufferSize - 1, 0xFF);
|
||||
|
||||
let inteval = parseInt(this.inteval ? this.inteval : 0);
|
||||
|
||||
let inteval = parseInt(this.inteval ? this.inteval : 50);
|
||||
console.log("inteval=", inteval)
|
||||
ble.sendData(f.deviceId, buffer, f.writeServiceId, f
|
||||
.wirteCharactId, 30).then(() => {
|
||||
|
||||
@ -892,12 +1113,36 @@
|
||||
|
||||
}
|
||||
|
||||
|
||||
var result = await this.$refs.textToHex.drawAndGetPixels();
|
||||
|
||||
console.log("11111");
|
||||
var result = null;
|
||||
try {
|
||||
console.log("this.$refs.textToHex=", this.$refs.textToHex);
|
||||
result = await this.$refs.textToHex.drawAndGetPixels();
|
||||
} catch (ex) {
|
||||
console.log("ex=", ex);
|
||||
}
|
||||
if (!result) {
|
||||
hideLoading(this);
|
||||
return;
|
||||
}
|
||||
console.log("result=", result);
|
||||
result = result.map(level1 => {
|
||||
return level1.flat(Infinity);
|
||||
});
|
||||
console.log("result=", result);
|
||||
|
||||
// var str1="FA 06 01 00 FF FF F7 9F EF 6F EC F7 EA 09 CF FF AF FB EF EB EF EB EC 6B EF EB EC 6B EF EB EF FB EE 63 FF FF FF FF F7 9F EF 6F EC F7 EA 09 CF FF AF FB EF EB EF EB EC 6B EF EB EC 6B EF EB EF FB EE 63 FF FF FF FF F7 FF 81 03 ED BB DD B7 CB CF F3 C7 CD 39 BE FF FE FF C0 03 FE FB FD FB F3 F7 8F 87 FF FF FF FF FE FF FE FF FE FF C0 03 FF FB FD FB FD FB FD FB FD FB FB FB FB FF F7 F7 EF F7 9F 8F FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF"
|
||||
// var str2="FA 07 01 00 FF FF EE DD EE DF EF 5B AB DF AA 03 AE FF AE FF EE 03 EE FF EE FF EE 03 EE FF EE FF EE E3 FF FF FF FF EE DD EE DF EF 5B AB DF AA 03 AE FF AE FF EE 03 EE FF EE FF EE 03 EE FF EE FF EE E3 FF FF FF FF EF 77 EF 73 EF 7F 80 01 EF 7F EF 7F EF 03 E7 3B 8E BB EE D7 EE EF ED E7 ED 9B 8B 7D FF FF FF FF FF FF F7 EF F7 F7 EF F7 DF FB FF FF FF FF FE FF 80 01 FE 7F FD BF FB DF F7 E7 9F F9 FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF"
|
||||
// var str3="FA 08 01 00 FF FF EF DF EC 01 EF FF AB FF AA 03 AA FB AE FB EE 03 EF DF EF DF EE DB ED DF ED DD EF 1F FF FF FF FF EF BF EF 87 81 77 EE F7 EC 03 81 7F EF 7F EF 7F EF 03 81 7F EF 7F EF 7D EF 7D EF 03 FF FF FF FF F9 F1 CF BF DF FF DF FF C1 FF DD 81 DD F7 DD F7 C1 F7 DF 77 FF 77 BF 77 BF 77 FF F7 FF FF FF FF FD FF FD FF FB FF FB FF F0 07 E7 F7 EF F7 D8 07 BF F7 FF F7 F8 07 FF F7 FF F7 FF C7 FF FF FF FF FF FF FF FF FF FF FE FF FE 7F FE 7F FE FF FD BF FD FF FB DF F7 EF EF F7 DF FB BF FD FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF"
|
||||
|
||||
// let arr1=('0x'+(str1.split(' ').join(",0x"))).split(',');
|
||||
// let arr2=('0x'+(str2.split(' ').join(",0x"))).split(',');
|
||||
// let arr3=('0x'+(str3.split(' ').join(",0x"))).split(',');
|
||||
|
||||
// result=[arr1,arr2,arr3];
|
||||
|
||||
|
||||
// console.log("result=",result);
|
||||
|
||||
|
||||
let h3dic = [0x06, 0x07, 0x08];
|
||||
@ -913,9 +1158,9 @@
|
||||
var rgb = result[i];
|
||||
|
||||
try {
|
||||
console.log("1111");
|
||||
// console.log("1111");
|
||||
await sendTxtPackge(rgb, h3dic[i], str);
|
||||
console.log("222222");
|
||||
// console.log("222222");
|
||||
} catch (ex) {
|
||||
flag = false;
|
||||
console.log("33333");
|
||||
@ -929,9 +1174,24 @@
|
||||
hideLoading(these);
|
||||
if (flag) {
|
||||
console.log("发送成功");
|
||||
this.showPop( {
|
||||
message: "发送成功"
|
||||
this.showPop({
|
||||
message: "发送成功",
|
||||
iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png",
|
||||
borderColor: '#BBE600',
|
||||
buttonBgColor: '#BBE600'
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
let json = {
|
||||
deviceId: these.device.id,
|
||||
name: these.formData.textLines[1],
|
||||
position: these.formData.textLines[0],
|
||||
unitName: these.formData.textLines[2],
|
||||
code: ""
|
||||
};
|
||||
usrApi.sendUsr(json)
|
||||
} else {
|
||||
this.showPop({
|
||||
message: "出现异常发送失败",
|
||||
@ -944,7 +1204,22 @@
|
||||
|
||||
setTimeout(task, 0);
|
||||
},
|
||||
getDetail() {
|
||||
var that = this;
|
||||
usrApi.getDetail(this.device.id).then(res => {
|
||||
|
||||
if (res && res.code == 200) {
|
||||
res = res.data;
|
||||
let personnelInfo = res.personnelInfo;
|
||||
if (personnelInfo) {
|
||||
these.formData.textLines[2] = personnelInfo.unitName;
|
||||
these.formData.textLines[1] = personnelInfo.name;
|
||||
these.formData.textLines[0] = personnelInfo.position;
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
ack: function() {
|
||||
|
||||
|
||||
@ -956,23 +1231,25 @@
|
||||
},
|
||||
sliderChange: function(evt) {
|
||||
this.formData.liangDu = evt.detail.value;
|
||||
clearTimeout(BrighInteval)
|
||||
//给蓝牙设备发送信号更新亮度
|
||||
setTimeout(() => {
|
||||
BrighInteval = setTimeout(() => {
|
||||
this.sendBrightness();
|
||||
this.setBleFormData();
|
||||
}, 10);
|
||||
}, 100);
|
||||
},
|
||||
sendBrightness: function() {
|
||||
const buffer = new ArrayBuffer(6);
|
||||
const dataView = new DataView(buffer);
|
||||
let data = '0x' + parseInt(this.formData.liangDu).toString(16);
|
||||
console.log("亮度:" + this.formData.liangDu + ',16进制:' + data);
|
||||
dataView.setUint8(0, 0x55); // 帧头
|
||||
dataView.setUint8(1, 0x01); // 帧类型:亮度调节
|
||||
dataView.setUint8(2, 0x01); // 包序号
|
||||
dataView.setUint8(3, 0x00); // 数据长度
|
||||
dataView.setUint8(4, 0x01); // 数据长度
|
||||
dataView.setUint8(5, data); // 数据
|
||||
dataView.setUint8(0, 0xFA); // 帧头
|
||||
dataView.setUint8(1, 0x05); // 帧类型:亮度调节
|
||||
dataView.setUint8(2, 0x00); // 包序号
|
||||
dataView.setUint8(3, 0x01); // 包序号
|
||||
dataView.setUint8(4, data); // 数据长度
|
||||
dataView.setUint8(5, 0xFF); // 数据长度
|
||||
|
||||
let f = this.getDevice();
|
||||
if (f) {
|
||||
// 发送数据
|
||||
|
||||
@ -188,7 +188,7 @@
|
||||
const statusRes = await getdeviceSTatus({
|
||||
functionMode: 2,
|
||||
batchId,
|
||||
typeName,
|
||||
typeName:'FunctionAccessBatchStatusRule',
|
||||
deviceImei,
|
||||
interval: 500
|
||||
},
|
||||
@ -236,7 +236,7 @@
|
||||
<style scoped>
|
||||
.container {
|
||||
min-height: 100vh;
|
||||
background-color: rgb(18, 18, 18);
|
||||
background-color:rgb(18, 18, 18);
|
||||
box-sizing: border-box;
|
||||
overflow-x: hidden;
|
||||
|
||||
|
||||
@ -545,15 +545,6 @@
|
||||
});
|
||||
return;
|
||||
}
|
||||
// 防重复提交
|
||||
if (this.isProcessing) return;
|
||||
let loadingShown = false;
|
||||
uni.showLoading({
|
||||
title: '处理中...',
|
||||
mask: true
|
||||
});
|
||||
loadingShown = true;
|
||||
this.isProcessing = true
|
||||
if (this.selectedItemIndex === null) return;
|
||||
const selectedItem = this.items[this.selectedItemIndex];
|
||||
let data = {
|
||||
@ -573,15 +564,15 @@
|
||||
})
|
||||
uni.hideLoading();
|
||||
this.lightModeA = false;
|
||||
this.isProcessing = false
|
||||
loadingShown = false
|
||||
//this.isProcessing = false
|
||||
//loadingShown = false
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none'
|
||||
})
|
||||
this.isProcessing = false
|
||||
loadingShown = false
|
||||
//this.isProcessing = false
|
||||
//loadingShown = false
|
||||
uni.hideLoading();
|
||||
}
|
||||
})
|
||||
@ -599,15 +590,6 @@
|
||||
});
|
||||
return;
|
||||
}
|
||||
// 防重复提交
|
||||
if (this.isProcessing) return;
|
||||
let loadingShown = false;
|
||||
uni.showLoading({
|
||||
title: '处理中...',
|
||||
mask: true
|
||||
});
|
||||
loadingShown = true;
|
||||
this.isProcessing = true
|
||||
const instructValue = this.isLaserOn ? 0 : 1;
|
||||
let data = {
|
||||
deviceId: this.computedDeviceId,
|
||||
@ -625,15 +607,11 @@
|
||||
this.isLaserOn = !this.isLaserOn;
|
||||
this.currentlaserMode = this.isLaserOn ? "开启" : "关闭";
|
||||
this.lightModeC = false;
|
||||
this.isProcessing = false
|
||||
loadingShown = false
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none'
|
||||
});
|
||||
this.isProcessing = false
|
||||
loadingShown = false
|
||||
}
|
||||
})
|
||||
},
|
||||
@ -652,11 +630,9 @@
|
||||
sizeType: ['original', 'compressed'],
|
||||
sourceType: ['album', 'camera'],
|
||||
success: (res) => {
|
||||
// 将选择的图片赋值给selectedImage
|
||||
const file = res.tempFiles[0];
|
||||
const fileSize = file.size || 0;
|
||||
if (fileSize > 2 * 1024 * 1024) {
|
||||
console.log(`文件过大: ${fileSize} 字节`); // 调试日志
|
||||
uni.showToast({
|
||||
title: '图片大小不能超过2MB',
|
||||
icon: 'none',
|
||||
@ -664,13 +640,19 @@
|
||||
});
|
||||
return;
|
||||
}
|
||||
this.selectedImage = res.tempFilePaths[0];
|
||||
console.log('选择的图片:', res);
|
||||
},
|
||||
fail: (err) => {
|
||||
uni.showToast({
|
||||
title: '选择图片失败',
|
||||
icon: 'none'
|
||||
let that = this;
|
||||
uni.navigateTo({
|
||||
url: "/pages/6155/ImgCrop",
|
||||
events: {
|
||||
ImgCutOverPath :function (data) {
|
||||
that.selectedImage = data.picPath;
|
||||
}
|
||||
},
|
||||
success(ev) {
|
||||
ev.eventChannel.emit('checkImg', {
|
||||
data: res.tempFiles[0].path,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -725,12 +707,12 @@
|
||||
// 获取设备状态
|
||||
// 4. 获取设备状态
|
||||
let deviceImei = this.itemInfo.deviceImei
|
||||
let typeName = this.itemInfo.typeName
|
||||
//let typeName = this.itemInfo.typeName
|
||||
let batchId = ''
|
||||
const statusRes = await getdeviceSTatus({
|
||||
functionMode: 1,
|
||||
batchId,
|
||||
typeName,
|
||||
typeName: 'FunctionAccessStatusRule',
|
||||
deviceImei,
|
||||
interval: 800
|
||||
},
|
||||
@ -775,7 +757,7 @@
|
||||
// 分享
|
||||
shareUp() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/6170/share/index',
|
||||
url: '/pages/common/share/index',
|
||||
events: {
|
||||
ack: function(data) {}
|
||||
},
|
||||
@ -907,13 +889,13 @@
|
||||
})
|
||||
return
|
||||
}
|
||||
// 4. 获取设备状态
|
||||
// 4. 获取设备状态FunctionAccessBatchStatusRule 批量
|
||||
let deviceImei = this.itemInfo.deviceImei
|
||||
let typeName = this.itemInfo.typeName
|
||||
const statusRes = await getdeviceSTatus({
|
||||
functionMode: 2,
|
||||
batchId,
|
||||
typeName,
|
||||
typeName: 'FunctionAccessBatchStatusRule',
|
||||
deviceImei,
|
||||
interval: 500
|
||||
},
|
||||
@ -991,11 +973,11 @@
|
||||
}
|
||||
// 4. 获取设备状态
|
||||
let deviceImei = this.itemInfo.deviceImei
|
||||
let typeName = this.itemInfo.typeName
|
||||
//let typeName = this.itemInfo.typeName
|
||||
const statusRes = await getdeviceSTatus({
|
||||
functionMode: 2,
|
||||
batchId,
|
||||
typeName,
|
||||
typeName: 'FunctionAccessBatchStatusRule',
|
||||
deviceImei,
|
||||
interval: 500
|
||||
},
|
||||
@ -1178,25 +1160,30 @@
|
||||
// 1设备切换灯光实时返回
|
||||
switch (deviceState[0]) {
|
||||
case 1:
|
||||
this.currentMainMode = this.getMainLightModeLabel(deviceState[
|
||||
1]);
|
||||
this.currentMainMode = this.getMainLightModeLabel(
|
||||
deviceState[
|
||||
1]);
|
||||
this.sliderValue = deviceState[2];
|
||||
this.deviceInfo.batteryRemainingTime = deviceState[3];
|
||||
break;
|
||||
// 12为设备实时上报
|
||||
case 12:
|
||||
this.currentMainMode = this.getMainLightModeLabel(deviceState[
|
||||
1]);
|
||||
this.isLaserOn = deviceState[2] === 1;
|
||||
this.currentMainMode = this.getMainLightModeLabel(
|
||||
deviceState[
|
||||
1]);
|
||||
this.isLaserOn = deviceState[2] === 1; //第3位表示当时激光灯档位
|
||||
this.currentlaserMode = this.isLaserOn ? "开启" : "关闭";
|
||||
if (this.deviceInfo) {
|
||||
this.deviceInfo.batteryPercentage = deviceState[3];
|
||||
this.deviceInfo.chargeState = deviceState[4];
|
||||
this.deviceInfo.batteryRemainingTime = deviceState[5];
|
||||
this.deviceInfo.batteryPercentage = deviceState[
|
||||
3]; //第4位电量百分比
|
||||
this.deviceInfo.chargeState = deviceState[
|
||||
4]; //第5位为充电状态(0没有充电,1正在充电,2为已充满)
|
||||
this.deviceInfo.batteryRemainingTime = deviceState[
|
||||
5]; //第6位200代表电池剩余续航时间200分钟
|
||||
}
|
||||
setTimeout(() => {
|
||||
if (this.deviceInfo.batteryPercentage <
|
||||
20) {
|
||||
if (this.deviceInfo.batteryPercentage < 20 &&
|
||||
this.deviceInfo.chargeState == 0) {
|
||||
this.popupType = 'bettery';
|
||||
this.popupMessage = '请及时充电';
|
||||
this.showPopupFlag = true;
|
||||
@ -1648,7 +1635,7 @@
|
||||
/* 弹窗主体 */
|
||||
.agreement-popup {
|
||||
width: 100%;
|
||||
height: 50%;
|
||||
/* height: 50%; */
|
||||
background-color: rgb(42, 42, 42);
|
||||
border-radius: 60rpx 60rpx 0rpx 0rpx;
|
||||
padding: 40rpx;
|
||||
|
||||
@ -173,6 +173,9 @@
|
||||
hideLoading,
|
||||
updateLoading
|
||||
} from '@/utils/loading.js'
|
||||
import {request,baseURL} from '../../utils/request';
|
||||
|
||||
import usrApi from '@/api/670/HBY670.js'
|
||||
const pagePath = "pages/650/HBY650";
|
||||
var ble = null;
|
||||
var these = null;
|
||||
@ -197,7 +200,8 @@
|
||||
visiblePrompt: false,
|
||||
promptTitle: '设备名称',
|
||||
modelValue: '',
|
||||
visibleClose: false
|
||||
visibleClose: false,
|
||||
okCallback:null
|
||||
},
|
||||
BottomMenu: {
|
||||
show: false,
|
||||
@ -252,14 +256,33 @@
|
||||
cMode: false,
|
||||
modeCurr: 'low',
|
||||
|
||||
company: '黄石消防支队',
|
||||
name: '菜英俊',
|
||||
job: '小队长',
|
||||
id: 'HSXF01061',
|
||||
company: '',
|
||||
name: '',
|
||||
job: '',
|
||||
id: '',
|
||||
iswarn: false
|
||||
},
|
||||
rgb565Data: [],
|
||||
videoHexArray: []
|
||||
videoHexArray: [],
|
||||
device: {
|
||||
id: "",
|
||||
deviceName: "",
|
||||
deviceImei: "",
|
||||
deviceMac: "",
|
||||
communicationMode: 0,
|
||||
devicePic: "",
|
||||
typeName: "",
|
||||
bluetoothName: null,
|
||||
deviceStatus: null,
|
||||
bindingTime: "",
|
||||
onlineStatus: 0,
|
||||
battery: "0",
|
||||
latitude: null,
|
||||
longitude: null,
|
||||
alarmStatus: null,
|
||||
detailPageUrl: "/pages/650/HBY650",
|
||||
showConfirm: false
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
@ -271,6 +294,7 @@
|
||||
these = this;
|
||||
recei = BleReceive.getBleReceive();
|
||||
ble = BleTool.getBleTool();
|
||||
console.log("650")
|
||||
ble.addReceiveCallback(these.bleValueNotify);
|
||||
let eventChannel = this.getOpenerEventChannel();
|
||||
|
||||
@ -278,7 +302,7 @@
|
||||
|
||||
console.log("收到父页面的参数:" + JSON.stringify(data));
|
||||
var device = data.data;
|
||||
|
||||
these.device=device;
|
||||
let f = ble.data.LinkedList.find((v) => {
|
||||
if (v.macAddress == device.deviceMac) {
|
||||
console.log("找到设备了", v);
|
||||
@ -290,12 +314,8 @@
|
||||
if (!f) {
|
||||
|
||||
|
||||
these.showPop({
|
||||
message: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备",
|
||||
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
});
|
||||
these.showBleUnConnect();
|
||||
these.getDetail();
|
||||
return;
|
||||
}
|
||||
let form = f.formData;
|
||||
@ -313,7 +333,7 @@
|
||||
these.formData.deviceId = f.deviceId;
|
||||
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId);
|
||||
these.setBleFormData();
|
||||
|
||||
these.getDetail();
|
||||
|
||||
|
||||
});
|
||||
@ -374,9 +394,9 @@
|
||||
return className;
|
||||
},
|
||||
bleValueNotify: function(receive, device, path) { //订阅消息
|
||||
|
||||
console.log("收到设备的数据", receive)
|
||||
let data = recei.ReceiveData(receive, device, pagePath);
|
||||
console.log("收到设备的数据",data)
|
||||
|
||||
if (data) {
|
||||
if ("staBlue_picture" in data) {
|
||||
//重发图片
|
||||
@ -403,10 +423,10 @@ console.log("收到设备的数据",data)
|
||||
let keys = Object.keys(data);
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
let key = keys[i];
|
||||
if(key in these.formData){
|
||||
these.formData[key] = data[key];
|
||||
if (key in these.formData) {
|
||||
these.formData[key] = data[key];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (these.formData.iswarn) {
|
||||
@ -434,11 +454,28 @@ console.log("收到设备的数据",data)
|
||||
// console.log("LinkedList=", ble.data.LinkedList);
|
||||
// console.log("formData=", these.formData);
|
||||
let f = ble.data.LinkedList.find((v) => {
|
||||
return v.deviceId == these.formData.deviceId;
|
||||
return v.macAddress == these.device.deviceMac;
|
||||
});
|
||||
|
||||
return f;
|
||||
},
|
||||
getDetail() {
|
||||
var that = this;
|
||||
usrApi.getDetail(this.device.id).then(res => {
|
||||
|
||||
if (res && res.code == 200) {
|
||||
res = res.data;
|
||||
let personnelInfo = res.personnelInfo;
|
||||
if (personnelInfo) {
|
||||
that.formData.company = personnelInfo.unitName;
|
||||
that.formData.name = personnelInfo.name;
|
||||
that.formData.job = personnelInfo.position;
|
||||
that.formData.id = personnelInfo.code
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
setBleFormData() {
|
||||
ble.data.LinkedList.find((v) => {
|
||||
if (v.deviceId == these.formData.deviceId) {
|
||||
@ -473,7 +510,7 @@ console.log("收到设备的数据",data)
|
||||
dataValue = 0x65;
|
||||
break;
|
||||
case "close": //关闭
|
||||
dataValue = 0x68;
|
||||
dataValue = 0x64;
|
||||
break;
|
||||
case true: //开灯
|
||||
dataValue = 0x6E;
|
||||
@ -533,12 +570,7 @@ console.log("收到设备的数据",data)
|
||||
these.setBleFormData();
|
||||
});
|
||||
} else {
|
||||
these.showPop({
|
||||
message: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备",
|
||||
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
});
|
||||
these.showBleUnConnect();
|
||||
hideLoading(these);
|
||||
}
|
||||
}
|
||||
@ -547,6 +579,34 @@ console.log("收到设备的数据",data)
|
||||
|
||||
|
||||
},
|
||||
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;
|
||||
@ -606,11 +666,12 @@ console.log("收到设备的数据",data)
|
||||
iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png",
|
||||
});
|
||||
if (!ReSendNo) {
|
||||
setTimeout(()=>{
|
||||
these.HoldYouHand("transmit complete", 0, f.deviceId, f
|
||||
setTimeout(() => {
|
||||
these.HoldYouHand("transmit complete", 0, f
|
||||
.deviceId, f
|
||||
.writeServiceId, f.wirteCharactId);
|
||||
},500);
|
||||
|
||||
}, 500);
|
||||
|
||||
}
|
||||
|
||||
resolve();
|
||||
@ -635,7 +696,7 @@ console.log("收到设备的数据",data)
|
||||
const packetData = these.rgb565Data.slice(startIndex,
|
||||
endIndex);
|
||||
// 构建数据包
|
||||
const bufferSize =505;// 5 + packetData.length * 2; // 头部5字节 + 数据部分
|
||||
const bufferSize = 505; // 5 + packetData.length * 2; // 头部5字节 + 数据部分
|
||||
const buffer = new ArrayBuffer(bufferSize);
|
||||
const dataView = new DataView(buffer);
|
||||
|
||||
@ -771,18 +832,20 @@ console.log("收到设备的数据",data)
|
||||
this.totalPackets = totalPackets;
|
||||
// 发送单个数据包
|
||||
const sendNextVideoPacket = () => {
|
||||
console.log("准备发送一段数据");
|
||||
console.log("准备发送一段数据");
|
||||
if (currentPacket > totalPackets) {
|
||||
if (!ReSendNo) {
|
||||
setTimeout(()=>{
|
||||
these.HoldYouHand("transmit complete", 0, f.deviceId, f
|
||||
.writeServiceId, f.wirteCharactId).then(()=>{
|
||||
setTimeout(() => {
|
||||
these.HoldYouHand("transmit complete", 0, f
|
||||
.deviceId, f
|
||||
.writeServiceId, f.wirteCharactId).then(
|
||||
() => {
|
||||
console.log("全部发送完毕")
|
||||
}).catch((ex)=>{
|
||||
console.log("出现异常",ex);
|
||||
});
|
||||
},500);
|
||||
|
||||
}).catch((ex) => {
|
||||
console.log("出现异常", ex);
|
||||
});
|
||||
}, 500);
|
||||
|
||||
}
|
||||
these.Status.BottomMenu.show = false;
|
||||
hideLoading(these);
|
||||
@ -793,7 +856,7 @@ console.log("收到设备的数据",data)
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
resolve();
|
||||
|
||||
@ -837,10 +900,10 @@ console.log("收到设备的数据",data)
|
||||
}
|
||||
|
||||
let inteval = 50;
|
||||
console.log("开始发送一段视频"); //
|
||||
console.log("开始发送一段视频"); //
|
||||
ble.sendData(f.deviceId, buffer, f.writeServiceId, f
|
||||
.wirteCharactId, 10).then(() => {
|
||||
|
||||
|
||||
updateLoading(these, {
|
||||
text: "正在发送:" + currentPacket + "/" +
|
||||
totalPackets
|
||||
@ -902,13 +965,28 @@ console.log("收到设备的数据",data)
|
||||
let p1 = these.HoldYouHand("video transmit start", 2200, f.deviceId, f.writeServiceId,
|
||||
f.wirteCharactId);
|
||||
let p2 = new Promise((succ, err) => {
|
||||
|
||||
const token = uni.getStorageSync('token');
|
||||
const clientid = uni.getStorageSync('clientID');
|
||||
if (!token) {
|
||||
err({
|
||||
code: 401,
|
||||
msg: "请先登陆后再试"
|
||||
});
|
||||
hideLoading(these);
|
||||
return;
|
||||
}
|
||||
|
||||
uni.uploadFile({
|
||||
url: 'http://114.55.111.217/video/upload',
|
||||
// url: baseURL+"app/video/upload",
|
||||
filePath: videoPath,
|
||||
name: 'file',
|
||||
header: {
|
||||
"Method": "POST",
|
||||
"Content-Type": "multipart/form-data"
|
||||
"Content-Type": "multipart/form-data",
|
||||
"Authorization": 'Bearer ' + token,
|
||||
"clientid": clientid
|
||||
},
|
||||
timeout: 600000,
|
||||
fail: (ex) => {
|
||||
@ -1067,9 +1145,12 @@ console.log("收到设备的数据",data)
|
||||
if (this.Status.Pop.clickEvt == 'SendUsr') {
|
||||
|
||||
}
|
||||
|
||||
console.log("1111");
|
||||
|
||||
this.Status.Pop.showPop = false;
|
||||
if(this.Status.Pop.okCallback){
|
||||
this.Status.Pop.okCallback();
|
||||
}
|
||||
},
|
||||
showPop: function(option) {
|
||||
|
||||
@ -1103,12 +1184,7 @@ console.log("收到设备的数据",data)
|
||||
|
||||
let f = this.getDevice();
|
||||
if (!f) {
|
||||
these.showPop({
|
||||
message: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备",
|
||||
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
});
|
||||
these.showBleUnConnect();
|
||||
return;
|
||||
}
|
||||
showLoading(this, {
|
||||
@ -1127,14 +1203,15 @@ console.log("收到设备的数据",data)
|
||||
// console.log("currentPacket=",currentPacket);
|
||||
// 发送单个数据包
|
||||
const sendNextPacket = () => {
|
||||
|
||||
|
||||
if (currentPacket > totalPackets) {
|
||||
if (!ReSendNo) {
|
||||
setTimeout(()=>{
|
||||
these.HoldYouHand("transmit complete", 0, f.deviceId, f.writeServiceId, f
|
||||
.wirteCharactId);
|
||||
},500);
|
||||
|
||||
setTimeout(() => {
|
||||
these.HoldYouHand("transmit complete", 0, f.deviceId, f
|
||||
.writeServiceId, f
|
||||
.wirteCharactId);
|
||||
}, 500);
|
||||
|
||||
}
|
||||
|
||||
these.showPop({
|
||||
@ -1155,6 +1232,16 @@ console.log("收到设备的数据",data)
|
||||
visibleClose: true
|
||||
});
|
||||
these.setBleFormData();
|
||||
|
||||
|
||||
let json = {
|
||||
deviceId: these.device.id,
|
||||
name: these.formData.company,
|
||||
position: these.formData.name,
|
||||
unitName: these.formData.job,
|
||||
code: these.formData.id
|
||||
};
|
||||
usrApi.sendUsr(json)
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1163,7 +1250,7 @@ console.log("收到设备的数据",data)
|
||||
let arr = gbk.encode(text)
|
||||
let gbkData = gbk.arr2hex(arr);
|
||||
|
||||
|
||||
|
||||
// 构建数据包
|
||||
const bufferSize = 5 + gbkData.length / 2; // 头部4字节 + 数据部分
|
||||
const buffer = new ArrayBuffer(bufferSize);
|
||||
@ -1174,7 +1261,7 @@ console.log("收到设备的数据",data)
|
||||
dataView.setUint8(1, 0x03); // 帧类型:文字
|
||||
dataView.setUint8(2, currentPacket.toString(16)); // 包序号
|
||||
dataView.setUint16(3, (text.length * 2).toString(16)); // 数据长度
|
||||
|
||||
|
||||
// 填充数据
|
||||
let index = 0;
|
||||
for (var i = 0; i < gbkData.length; i += 2) {
|
||||
@ -1182,8 +1269,8 @@ console.log("收到设备的数据",data)
|
||||
dataView.setUint8(5 + index, value);
|
||||
index++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// 发送数据包
|
||||
|
||||
|
||||
@ -1219,7 +1306,7 @@ console.log("收到设备的数据",data)
|
||||
}
|
||||
|
||||
|
||||
if(ReSendNo){
|
||||
if (ReSendNo) {
|
||||
sendText(ReSendNo);
|
||||
return;
|
||||
}
|
||||
@ -1261,16 +1348,26 @@ console.log("收到设备的数据",data)
|
||||
}
|
||||
console.log("开始握手");
|
||||
|
||||
ble.sendData(deviceid, buffer, serviceid, characid, 10).then(
|
||||
() => {
|
||||
setTimeout(() => {
|
||||
console.log("握手成功并完成了等待");
|
||||
resolve(true);
|
||||
}, pauseTime);
|
||||
}).catch(err => {
|
||||
console.log("握手没有成功", )
|
||||
reject(err);
|
||||
});
|
||||
let send = () => {
|
||||
ble.sendData(deviceid, buffer, serviceid, characid, 10).then(
|
||||
() => {
|
||||
setTimeout(() => {
|
||||
console.log("握手成功并完成了等待");
|
||||
resolve(true);
|
||||
}, pauseTime);
|
||||
}).catch(err => {
|
||||
if (err.code == 10007) {
|
||||
send();
|
||||
} else {
|
||||
console.log("握手没有成功", err)
|
||||
reject(err);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
send();
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
1514
pages/670/HBY670.vue
1514
pages/670/HBY670.vue
File diff suppressed because it is too large
Load Diff
446
pages/670/History.vue
Normal file
446
pages/670/History.vue
Normal file
@ -0,0 +1,446 @@
|
||||
<template>
|
||||
<view class="content contentBg">
|
||||
<view class="topTip">
|
||||
<view class="item" @click="tabChange(0)" :class="Status.tabIndex===0?'active':''">开机</view>
|
||||
<view class="item" @click="tabChange(1)" :class="Status.tabIndex===1?'active':''">报警</view>
|
||||
<view class="item" @click="tabChange(2)" :class="Status.tabIndex===2?'active':''">故障</view>
|
||||
</view>
|
||||
<view class="tabs">
|
||||
|
||||
<view class="tab" :class="Status.tabIndex===0?'active':''">
|
||||
<view class="li" v-for="item,index in SwithData">
|
||||
<view>
|
||||
<view class="label">开机时间</view>
|
||||
<view class="value">{{item['open']}}</view>
|
||||
</view>
|
||||
<view class="marginTop10">
|
||||
<view class="label">关机时间</view>
|
||||
<view class="value">{{item['close']}}</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
<view class="tab" :class="Status.tabIndex===1?'active':''">
|
||||
<view class="li warn" v-for="item,index in WarnData">
|
||||
<view class="row">
|
||||
<view class="label">报警事项:</view>
|
||||
<view class="value red">{{item['evtName']}}</view>
|
||||
</view>
|
||||
<view class="marginTop10 row">
|
||||
<view class="label">报警地点:</view>
|
||||
<view class="value">{{item['address']}}</view>
|
||||
</view>
|
||||
<view class="marginTop10 row">
|
||||
<view class="label">报警时间:</view>
|
||||
<view class="value">{{item['open']}}</view>
|
||||
</view>
|
||||
<view class="marginTop10 row">
|
||||
<view class="label">解除时间:</view>
|
||||
<view class="value">{{item['close']}}</view>
|
||||
</view>
|
||||
<view class="marginTop10 row">
|
||||
<view class="label">报警时长:</view>
|
||||
<view class="value">{{item['time']}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="tab" :class="Status.tabIndex===2?'active':''">
|
||||
|
||||
<view class="li warn" v-for="item,index in FaultData">
|
||||
<view class="row">
|
||||
<view class="label">故障部位:</view>
|
||||
<view class="value red">{{item['evtName']}}</view>
|
||||
</view>
|
||||
|
||||
<view class="marginTop10 row">
|
||||
<view class="label">故障时间:</view>
|
||||
<view class="value">{{item['open']}}</view>
|
||||
</view>
|
||||
<view class="marginTop10 row">
|
||||
<view class="label">处理时间:</view>
|
||||
<view class="value">{{item['close']}}</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<global-loading ref="loading"></global-loading>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Common from '@/utils/Common.js';
|
||||
import api from '@/api/670/History.js'
|
||||
import {
|
||||
showLoading,
|
||||
hideLoading,
|
||||
updateLoading
|
||||
} from '@/utils/loading.js'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
Status: {
|
||||
tabIndex: 1
|
||||
},
|
||||
device: {},
|
||||
SwithData: [], //开关机的数据
|
||||
FaultData: [], //故障数据
|
||||
WarnData: [], //报警数据
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
var these = this;
|
||||
let channel = this.getOpenerEventChannel();
|
||||
channel.on('detailData', function(opt) {
|
||||
console.log("我收到你的数据了,谢谢你。", opt.data);
|
||||
these.device = opt.data;
|
||||
these.tabChange(these.Status.tabIndex, true);
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
loadWarnData() { //加载报警数据
|
||||
var these = this;
|
||||
let promise1 = new Promise((resolve, reject) => {
|
||||
let arr = [];
|
||||
let endDate = new Date();
|
||||
|
||||
arr.push({
|
||||
evtName: '环境存在漏电电源',
|
||||
address: '湖北省武汉市洪山区关山街道国际企业中心聚星楼',
|
||||
open: Common.DateFormat(endDate),
|
||||
time: '00:00:59'
|
||||
});
|
||||
for (var i = 1; i < 10; i++) {
|
||||
arr.push({
|
||||
evtName: '环境存在漏电电源',
|
||||
address: '湖北省武汉市洪山区关山街道国际企业中心聚星楼',
|
||||
open: Common.DateFormat(endDate.setHours(i * -24)),
|
||||
time: '00:00:59'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
let item = new Date(arr[i].open);
|
||||
let close = Common.DateFormat(item.setHours(4));
|
||||
arr[i].close = close;
|
||||
|
||||
}
|
||||
resolve(arr);
|
||||
});
|
||||
let promise2 = new Promise((resolve, reject) => {
|
||||
api.getWarnData(this.device).then((res) => {
|
||||
resolve(res);
|
||||
}).catch((ex) => {
|
||||
console.log("获取数据异常", ex);
|
||||
reject(ex);
|
||||
});
|
||||
});
|
||||
|
||||
Promise.allSettled([promise1, promise2]).then(results => {
|
||||
if (results[1].status == 'fulfilled') {
|
||||
these.WarnData = results[1].value;
|
||||
} else {
|
||||
these.WarnData = results[0].value;
|
||||
}
|
||||
|
||||
});
|
||||
},
|
||||
loadSwithData() { //加载开关机数据
|
||||
var these = this;
|
||||
let promise1 = new Promise((resolve, reject) => {
|
||||
let arr = [];
|
||||
let endDate = new Date();
|
||||
|
||||
arr.push({
|
||||
open: Common.DateFormat(endDate)
|
||||
});
|
||||
for (var i = 1; i < 10; i++) {
|
||||
arr.push({
|
||||
open: Common.DateFormat(endDate.setHours(i * -24))
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
let item = new Date(arr[i].open);
|
||||
let close = Common.DateFormat(item.setHours(4));
|
||||
arr[i].close = close;
|
||||
|
||||
}
|
||||
resolve(arr);
|
||||
});
|
||||
|
||||
|
||||
let promise2 = new Promise((resolve, reject) => {
|
||||
api.getSwithData(this.device).then((res) => {
|
||||
resolve(res);
|
||||
}).catch((ex) => {
|
||||
console.log("获取数据异常", ex);
|
||||
reject(ex);
|
||||
});
|
||||
});
|
||||
|
||||
Promise.allSettled([promise1, promise2]).then(results => {
|
||||
if (results[1].status == 'fulfilled') {
|
||||
these.SwithData = results[1].value;
|
||||
} else {
|
||||
these.SwithData = results[0].value;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
},
|
||||
loadFaultData() { //加载故障数据
|
||||
var these = this;
|
||||
let promise1 = new Promise((resolve, reject) => {
|
||||
let arr = [];
|
||||
let endDate = new Date();
|
||||
|
||||
let dic = ['报警灯', '蜂鸣器', '电池', '蓝牙模块', '定位器', '4G模块'];
|
||||
arr.push({
|
||||
evtName: '报警灯',
|
||||
|
||||
open: Common.DateFormat(endDate),
|
||||
|
||||
});
|
||||
for (var i = 1; i < 10; i++) {
|
||||
arr.push({
|
||||
evtName: dic[i % 6],
|
||||
|
||||
open: Common.DateFormat(endDate.setHours(i * -24)),
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
let item = new Date(arr[i].open);
|
||||
let close = Common.DateFormat(item.setHours(72), "yyyy-MM-dd");
|
||||
arr[i].close = close;
|
||||
|
||||
}
|
||||
resolve(arr);
|
||||
});
|
||||
|
||||
let promise2 = new Promise((resolve, reject) => {
|
||||
api.getFaulData(this.device).then((res) => {
|
||||
resolve(res);
|
||||
}).catch((ex) => {
|
||||
console.log("获取数据异常", ex);
|
||||
reject(ex);
|
||||
});
|
||||
});
|
||||
|
||||
Promise.allSettled([promise1, promise2]).then(results => {
|
||||
if (results[1].status == 'fulfilled') {
|
||||
these.FaultData = results[1].value;
|
||||
} else {
|
||||
these.FaultData = results[0].value;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
tabChange(index, ispostback) {
|
||||
if (this.Status.tabIndex === index && !ispostback) {
|
||||
return;
|
||||
}
|
||||
this.Status.tabIndex = index;
|
||||
showLoading(this);
|
||||
let promise = new Promise((resolve, reject) => {
|
||||
try {
|
||||
if (index === 0) {
|
||||
this.loadSwithData();
|
||||
} else if (index === 1) {
|
||||
this.loadWarnData();
|
||||
} else if (index === 2) {
|
||||
this.loadFaultData();
|
||||
}
|
||||
} catch (error) {
|
||||
//TODO handle the exception
|
||||
} finally {
|
||||
hideLoading(this);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.tab .warn .value {
|
||||
padding-left: 10rpx;
|
||||
}
|
||||
|
||||
.tab .warn .value.red {
|
||||
color: rgba(224, 52, 52, 1) !important;
|
||||
}
|
||||
|
||||
.tab .warn .row {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: nowrap;
|
||||
align-content: center;
|
||||
justify-content: flex-start;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.marginTop10 {
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.tab .li .value {
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
width: calc(100% - 110rpx);
|
||||
height: auto;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.tab .li .label {
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
white-space: nowrap;
|
||||
width: 110rpx;
|
||||
|
||||
}
|
||||
|
||||
.tab .li {
|
||||
font-family: 'PingFang SC';
|
||||
font-size: 24rpx;
|
||||
font-weight: 400;
|
||||
line-height: 35rpx;
|
||||
letter-spacing: 0.14rpx;
|
||||
|
||||
width: 100%;
|
||||
border-radius: 16rpx;
|
||||
margin-top: 24rpx;
|
||||
background: rgba(26, 26, 26, 1);
|
||||
box-sizing: border-box;
|
||||
padding: 20rpx 30rpx;
|
||||
}
|
||||
|
||||
.tab.active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.tab {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.tabs {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.topTip .item.active {
|
||||
color: rgba(187, 230, 0, 1) !important;
|
||||
font-size: 36rpx !important;
|
||||
|
||||
}
|
||||
|
||||
.topTip .item.active::before {
|
||||
background: rgba(187, 230, 0, 1);
|
||||
}
|
||||
|
||||
.topTip .item::before {
|
||||
content: "";
|
||||
width: 50%;
|
||||
height: 4px;
|
||||
border-radius: 31px;
|
||||
position: absolute;
|
||||
background: #00000000;
|
||||
bottom: -10px;
|
||||
left: 25%;
|
||||
}
|
||||
|
||||
.topTip .item {
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
font-family: 'PingFang SC';
|
||||
font-size: 28rpx;
|
||||
font-weight: 400;
|
||||
letter-spacing: 0.14rpx;
|
||||
position: relative;
|
||||
|
||||
}
|
||||
|
||||
.topTip {
|
||||
padding: 30rpx 0rpx;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: nowrap;
|
||||
align-content: center;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
position: sticky;
|
||||
background-color: #121212;
|
||||
height: 110rpx;
|
||||
z-index: 9999;
|
||||
margin-top: -30rpx;
|
||||
}
|
||||
|
||||
/* #ifdef H5 */
|
||||
/* 仅在 H5 平台生效的样式 */
|
||||
.topTip {
|
||||
top: 44px;
|
||||
|
||||
}
|
||||
|
||||
/* #endif */
|
||||
|
||||
/* #ifdef APP-PLUS */
|
||||
/* 仅在 App 平台生效的样式 */
|
||||
.topTip {
|
||||
top: 0rpx;
|
||||
}
|
||||
|
||||
/* #endif */
|
||||
|
||||
.content {
|
||||
padding: 30rpx;
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
min-height: 100vh;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.contentBg {
|
||||
background-color: #121212;
|
||||
color: #ffffffde;
|
||||
}
|
||||
|
||||
.fleft {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.fright {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.clear {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.displayNone {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.p100 {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.center {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: nowrap;
|
||||
align-content: center;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
||||
1738
pages/7305/BJQ7305.vue
Normal file
1738
pages/7305/BJQ7305.vue
Normal file
File diff suppressed because it is too large
Load Diff
145
pages/common/account/changepassword/index.vue
Normal file
145
pages/common/account/changepassword/index.vue
Normal file
@ -0,0 +1,145 @@
|
||||
<template>
|
||||
<div class="pageContent">
|
||||
<view class="content">
|
||||
<view class='ver_item'>
|
||||
<input type="password" v-model="password" placeholder="请输入密码" class="input" />
|
||||
</view>
|
||||
<view class='ver_item'>
|
||||
<input type="password" v-model="surePassword" placeholder="请输入确认密码" class="input" />
|
||||
</view>
|
||||
<button class="login-btn" @click="handleLogin">
|
||||
确认
|
||||
</button>
|
||||
</view>
|
||||
<!-- 成功提示弹框 -->
|
||||
<CustomPopup :show="showPopupFlag" :title="popupTitle" :message="popupMessage"
|
||||
icon="/static/images/common/sendSucc.png" :confirm-text="popupConfirmText" :show-cancel="false"
|
||||
@confirm="onPopupConfirm" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import CustomPopup from '@/components/CustomPopup/CustomPopup.vue'
|
||||
import md5 from 'blueimp-md5'
|
||||
import {
|
||||
updatePassword
|
||||
} from '@/api/common/login.js';
|
||||
export default {
|
||||
components: {
|
||||
CustomPopup
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
password: "",
|
||||
surePassword: "",
|
||||
showPopupFlag: false,
|
||||
popupTitle: '',
|
||||
popupMessage: '修改成功!',
|
||||
popupConfirmText: '确认',
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 确认
|
||||
async handleLogin() {
|
||||
if (!this.password.trim()) {
|
||||
return uni.showToast({
|
||||
title: "请输入密码",
|
||||
icon: "none",
|
||||
duration: 1500
|
||||
});
|
||||
return false
|
||||
}
|
||||
if (!this.surePassword.trim()) {
|
||||
return uni.showToast({
|
||||
title: "请输入确认密码",
|
||||
icon: "none",
|
||||
duration: 1500
|
||||
});
|
||||
return false
|
||||
}
|
||||
if (this.password.trim() !== this.surePassword.trim()) {
|
||||
return uni.showToast({
|
||||
title: "两次密码输入不一致",
|
||||
icon: "none",
|
||||
duration: 1500
|
||||
});
|
||||
return false
|
||||
}
|
||||
try {
|
||||
uni.showLoading({
|
||||
title: '加载中...'
|
||||
})
|
||||
// 调用忘记密码接口
|
||||
const res = await updatePassword({
|
||||
password: md5(this.password)
|
||||
})
|
||||
if (res.code == 200) {
|
||||
uni.hideLoading()
|
||||
this.showPopupFlag = true
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
uni.showToast({
|
||||
title: error.msg || '登录失败',
|
||||
icon: 'none'
|
||||
});
|
||||
uni.hideLoading()
|
||||
}
|
||||
},
|
||||
// 确认
|
||||
onPopupConfirm(){
|
||||
uni.navigateBack()
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.pageContent {
|
||||
background-color: rgb(18, 18, 18);
|
||||
height: 100vh;
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.content_con {
|
||||
position: absolute;
|
||||
top: 220rpx;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
left: 30rpx;
|
||||
font-size: 60rpx;
|
||||
}
|
||||
|
||||
.input {
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
||||
height: 80rpx;
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
margin-top: 50rpx;
|
||||
}
|
||||
|
||||
.ver_item {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.switch-flex {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-top: 40rpx;
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
}
|
||||
|
||||
.switch-login {
|
||||
color: rgb(187, 230, 0);
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.login-btn {
|
||||
margin-top: 200rpx;
|
||||
background-color: rgb(187, 230, 0);
|
||||
color: rgb(35, 35, 35);
|
||||
border-radius: 50rpx;
|
||||
}
|
||||
</style>
|
||||
122
pages/common/account/deleteAccount/index.vue
Normal file
122
pages/common/account/deleteAccount/index.vue
Normal file
@ -0,0 +1,122 @@
|
||||
<template>
|
||||
<view class="cancel-account-page">
|
||||
<view class="content">
|
||||
<view class="warning-icon">
|
||||
<text class="icon-text">!</text>
|
||||
</view>
|
||||
|
||||
<view class="tip-text">
|
||||
注销账号后账号将永久失效且不可恢复,并将放弃以下权益与服务
|
||||
</view>
|
||||
<view class="rights-list">
|
||||
<view class="right-item">1. 账号将无法登录;</view>
|
||||
<view class="right-item">2. 设备数据将全部清除;</view>
|
||||
<view class="right-item">3. 个人资料等内容永久失效;</view>
|
||||
</view>
|
||||
|
||||
<!-- 确认注销按钮 -->
|
||||
<button class="confirm-btn" @click="confirmBtn">确认注销</button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
import {
|
||||
cancelAccount
|
||||
} from '@/api/common/login.js'
|
||||
export default {
|
||||
data() {
|
||||
return {}
|
||||
},
|
||||
methods: {
|
||||
confirmBtn() {
|
||||
let data = {}
|
||||
cancelAccount(data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
uni.showToast({
|
||||
title: '注销成功',
|
||||
icon: 'none'
|
||||
})
|
||||
setTimeout(() => {
|
||||
uni.navigateTo({
|
||||
url: '/pages/common/login/index'
|
||||
})
|
||||
}, 1000)
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
.cancel-account-page {
|
||||
background: rgba(18, 18, 18, 1);
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 60rpx 30rpx;
|
||||
flex: 1;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.warning-icon {
|
||||
width: 100rpx;
|
||||
height: 100rpx;
|
||||
background: rgba(224, 52, 52, 1);
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.icon-text {
|
||||
color: #333;
|
||||
font-size: 48rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.tip-text {
|
||||
color: #fff;
|
||||
font-size: 27rpx;
|
||||
text-align: center;
|
||||
margin-bottom: 40rpx;
|
||||
padding: 40rpx 60rpx;
|
||||
line-height: 40rpx;
|
||||
color: rgba(255, 255, 255, 1);
|
||||
}
|
||||
|
||||
.rights-list {
|
||||
width: 100%;
|
||||
background: rgba(26, 26, 26, 1);
|
||||
padding: 30rpx;
|
||||
border-radius: 16rpx;
|
||||
margin-bottom: 120rpx;
|
||||
}
|
||||
|
||||
.right-item {
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
font-size: 26rpx;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.right-item:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.confirm-btn {
|
||||
width: 80%;
|
||||
color: #fff;
|
||||
font-size: 30rpx;
|
||||
border-radius: 91px;
|
||||
background: rgba(224, 52, 52, 1);
|
||||
position: absolute;
|
||||
bottom: 50rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
</style>
|
||||
85
pages/common/account/index.vue
Normal file
85
pages/common/account/index.vue
Normal file
@ -0,0 +1,85 @@
|
||||
<template>
|
||||
<div class="pageContent">
|
||||
<view class="content">
|
||||
<view class="menu-list">
|
||||
<view class="menu-item" @click="changePassword">
|
||||
<text class="title">修改登录密码</text>
|
||||
<uni-icons type="right" size="25" color="rgba(255, 255, 255, 0.4)" class="uniIcon"></uni-icons>
|
||||
</view>
|
||||
<view class="menu-item" @click="deleteAccount">
|
||||
<view class="title">注销账号</view>
|
||||
<view class="menu_zx"> 注销后无法恢复,请谨慎操作</view>
|
||||
<uni-icons type="right" size="25" color="rgba(255, 255, 255, 0.4)" class="uniIcon"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {}
|
||||
},
|
||||
methods: {
|
||||
// 修改密码
|
||||
changePassword() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/common/account/changepassword/index'
|
||||
})
|
||||
},
|
||||
// 注销账号
|
||||
deleteAccount() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/common/account/deleteAccount/index'
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.pageContent {
|
||||
background-color: rgb(18, 18, 18);
|
||||
height: 100vh;
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.menu-item {
|
||||
font-size: 32rpx;
|
||||
color: rgb(255, 255, 255);
|
||||
padding: 30rpx 0;
|
||||
border-bottom: 1rpx solid rgba(255, 255, 255, 0.04);
|
||||
align-items: center;
|
||||
background: rgba(26, 26, 26, 1);
|
||||
position: relative;
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
|
||||
.menu-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.title {
|
||||
padding-left: 20rpx;
|
||||
padding-top: -8rpx;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.uniIcon {
|
||||
position: absolute;
|
||||
right: 50rpx;
|
||||
top: 30%;
|
||||
}
|
||||
|
||||
.user-right {
|
||||
margin-left: 30rpx;
|
||||
}
|
||||
|
||||
.menu_zx {
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
font-size: 28rpx;
|
||||
padding-left: 20rpx;
|
||||
padding-top: 8rpx;
|
||||
}
|
||||
</style>
|
||||
@ -8,18 +8,24 @@
|
||||
<view class="deviceName">
|
||||
蓝牙名:{{device.name}}
|
||||
</view>
|
||||
<view class="deviceName">
|
||||
状态:{{deviceStatu}}
|
||||
</view>
|
||||
<view class="deviceName">
|
||||
设备名:{{device.deviceName}}
|
||||
</view>
|
||||
<view class="deviceId">
|
||||
ID:{{device.deviceId}}
|
||||
设备Mac:{{device.macAddress}}
|
||||
</view>
|
||||
<view class="deviceId">
|
||||
设备IMEI:{{device.imei}}
|
||||
</view>
|
||||
<view class="bound" v-bind:class="boundStatu">
|
||||
{{Statu.boundRemark}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="btnLink" @click="Link()">
|
||||
连接
|
||||
绑定
|
||||
</view>
|
||||
|
||||
<global-loading ref="loading" />
|
||||
@ -34,17 +40,20 @@
|
||||
hideLoading,
|
||||
updateLoading
|
||||
} from '@/utils/loading.js';
|
||||
|
||||
const pagePath="pages/common/addBLE/LinkBle";
|
||||
|
||||
|
||||
const pagePath = "pages/common/addBLE/LinkBle";
|
||||
|
||||
var these = null;
|
||||
var eventChannel = null;
|
||||
var ble = null;
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
Statu: {
|
||||
bound: null
|
||||
bound: null,
|
||||
timeInteval:null,
|
||||
isSearch:false
|
||||
},
|
||||
device: {
|
||||
"deviceId": "",
|
||||
@ -56,8 +65,11 @@
|
||||
|
||||
],
|
||||
"linkStatu": false,
|
||||
"macAddress": ""
|
||||
}
|
||||
"macAddress": "",
|
||||
"communicationMode":"",
|
||||
"imei":""
|
||||
},
|
||||
serverDevice:null
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@ -70,100 +82,154 @@
|
||||
} else {
|
||||
return "red";
|
||||
}
|
||||
},
|
||||
deviceStatu:function(){
|
||||
if(!this.device.name){
|
||||
return "";
|
||||
}
|
||||
if(!this.device.macAddress){
|
||||
return '等待设备上报Mac地址';
|
||||
}
|
||||
|
||||
if(!this.device.deviceName ){
|
||||
if(this.Statu.isSearch){
|
||||
return "无效设备";
|
||||
}else{
|
||||
if(this.Statu.timeInteval===null){
|
||||
return "等待查询设备"
|
||||
}else{
|
||||
return "正在查询设备";
|
||||
}
|
||||
}
|
||||
}else{
|
||||
return "找到有效设备"
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
},
|
||||
onBackPress() {
|
||||
|
||||
onUnload() {
|
||||
console.log("返回时断开蓝牙连接,取消订阅");
|
||||
ble.disconnectDevice(these.device.deviceId);
|
||||
ble.removeReceiveCallback(pagePath);
|
||||
},
|
||||
onUnload() {
|
||||
ble.removeReceiveCallback(pagePath);
|
||||
},
|
||||
onLoad(option) {
|
||||
these = this;
|
||||
ble = bleTool.getBleTool();
|
||||
ble.addReceiveCallback((receive,f,path) => {
|
||||
console.log("LinkBle")
|
||||
ble.addReceiveCallback((receive, f, path) => {
|
||||
console.log("收到设备消息,", receive);
|
||||
if (these.device.deviceId == receive.deviceId) {
|
||||
console.log("11111");
|
||||
|
||||
console.log("11111:",receive);
|
||||
these.device.imei=f.imei;
|
||||
if (receive.bytes[0] == 0xFC || receive.str.indexOf('mac address:') == 0) {
|
||||
if (f && f.macAddress) {
|
||||
these.device.macAddress = f.macAddress;
|
||||
console.log("222222");
|
||||
console.log("222222");
|
||||
these.Statu.isSearch=false;
|
||||
these.initDevice();
|
||||
}
|
||||
}
|
||||
}
|
||||
},pagePath);
|
||||
}, pagePath);
|
||||
eventChannel = this.getOpenerEventChannel();
|
||||
eventChannel.on('LinkItem', function(data) {
|
||||
console.log("data=", data);
|
||||
let f = ble.data.LinkedList.find((v) => {
|
||||
return v.deviceId = data.deviceId;
|
||||
return v.deviceId == data.deviceId;
|
||||
});
|
||||
if (f) {
|
||||
these.device = Object.assign({}, these.device, f);
|
||||
console.log("获取到设备", f);
|
||||
let keys = Object.keys(f);
|
||||
keys.forEach((v, index) => {
|
||||
these.device[v] = f[v];
|
||||
})
|
||||
// console.log("LinkedList=", ble.data.LinkedList)
|
||||
// console.log("f=", f);
|
||||
// console.log("获取到设备", these.device);
|
||||
if (f.macAddress) {
|
||||
these.device.macAddress = f.macAddress;
|
||||
|
||||
these.initDevice();
|
||||
}
|
||||
} else {
|
||||
console.log("未获取到设备");
|
||||
}
|
||||
})
|
||||
|
||||
let inteval = setInterval(this.initDevice, 5000);
|
||||
},
|
||||
methods: {
|
||||
|
||||
initDevice: function() {
|
||||
showLoading(these, {
|
||||
text: '正在获取设备信息'
|
||||
});
|
||||
request({
|
||||
url: '/app/device/getDeviceInfoByDeviceMac',
|
||||
method: 'GET',
|
||||
data: {
|
||||
deviceMac: these.device.macAddress
|
||||
}
|
||||
}).then(res => {
|
||||
console.log("获取设备信息", res);
|
||||
if (res && res.code == 200) {
|
||||
let data = res.data;
|
||||
if (data) {
|
||||
let keys = Object.keys(data);
|
||||
ble.data.LinkedList.find((v) => {
|
||||
if(v.deviceId = these.device.deviceId){
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
let key = keys[i];
|
||||
v[key] = data[key];
|
||||
console.log("key="+key);
|
||||
console.log("value="+data[key]);
|
||||
|
||||
|
||||
these.$set(these.device, key, data[key]);
|
||||
|
||||
}
|
||||
|
||||
ble.setBleData();
|
||||
}
|
||||
});
|
||||
|
||||
console.log("device=",these.device);
|
||||
console.log("LinkedList=",ble.data.LinkedList);
|
||||
|
||||
if(!these.device.macAddress){
|
||||
return;
|
||||
}
|
||||
clearTimeout(this.Statu.timeInteval);
|
||||
|
||||
this.Statu.timeInteval = setTimeout(() => {
|
||||
this.Statu.isSearch=true;
|
||||
showLoading(these, {
|
||||
text: '正在获取设备信息'
|
||||
});
|
||||
console.log("these.device=", these.device);
|
||||
request({
|
||||
url: '/app/device/getDeviceInfoByDeviceMac',
|
||||
method: 'GET',
|
||||
data: {
|
||||
deviceMac: these.device.macAddress
|
||||
}
|
||||
}
|
||||
}).then(res => {
|
||||
|
||||
console.log("获取设备信息", res);
|
||||
if (res && res.code == 200) {
|
||||
let data = res.data;
|
||||
this.serverDevice=data;
|
||||
if (data) {
|
||||
let keys = Object.keys(data);
|
||||
ble.data.LinkedList.find((v) => {
|
||||
if (v.deviceId == these.device.deviceId) {
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
let key = keys[i];
|
||||
// if(!v.device){
|
||||
// v.device={};
|
||||
// }
|
||||
// v.device[key] = data[key];
|
||||
// console.log("key="+key);
|
||||
// console.log("value="+data[key]);
|
||||
|
||||
|
||||
these.$set(these.device, key, data[key]);
|
||||
|
||||
}
|
||||
|
||||
// ble.setBleData();
|
||||
}
|
||||
});
|
||||
|
||||
console.log("device=", these.device);
|
||||
console.log("LinkedList=", ble.data.LinkedList);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}).catch((ex) => {
|
||||
console.log("获取设备出现异常:", ex);
|
||||
}).finally(() => {
|
||||
this.Statu.timeInteval=null;
|
||||
this.Statu.isSearch=false;
|
||||
hideLoading(these);
|
||||
});
|
||||
|
||||
}, 500);
|
||||
|
||||
}).catch((ex) => {
|
||||
console.log("获取设备出现异常:", ex);
|
||||
}).finally(() => {
|
||||
hideLoading(these);
|
||||
});
|
||||
},
|
||||
Link() {
|
||||
// 调用绑定设备接口
|
||||
|
||||
let f = ble.data.LinkedList.find((v) => {
|
||||
return v.deviceId = these.device.deviceId;
|
||||
return v.deviceId == these.device.deviceId;
|
||||
});
|
||||
if (!f) {
|
||||
these.Statu.bound = false;
|
||||
@ -175,11 +241,16 @@
|
||||
these.Statu.boundRemark = "设备上报Mac地址异常";
|
||||
return;
|
||||
}
|
||||
if(!this.device.deviceName){
|
||||
these.Statu.bound = false;
|
||||
these.Statu.boundRemark = "设备未入库";
|
||||
return;
|
||||
}
|
||||
these.Statu.bound = null;
|
||||
these.Statu.boundRemark = "";
|
||||
showLoading(these, {
|
||||
|
||||
text: "连接中..."
|
||||
text: "绑定中..."
|
||||
})
|
||||
let promise = request({
|
||||
url: '/app/device/bind',
|
||||
@ -187,7 +258,7 @@
|
||||
data: {
|
||||
deviceImei: '',
|
||||
deviceMac: these.device.macAddress,
|
||||
communicationMode: '1', //0是4g,1是蓝牙
|
||||
communicationMode: 1, //0是4g,1是蓝牙,2蓝牙&4G
|
||||
}
|
||||
});
|
||||
promise.then((res) => {
|
||||
@ -195,7 +266,23 @@
|
||||
if (res.code == 200) {
|
||||
these.Statu.bound = true;
|
||||
these.Statu.boundRemark = "设备绑定成功!";
|
||||
|
||||
let data=these.serverDevice;
|
||||
let keys = Object.keys(data);
|
||||
ble.data.LinkedList.find((v) => {
|
||||
if (v.deviceId == these.device.deviceId) {
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
let key = keys[i];
|
||||
if(!v.device){
|
||||
v.device={};
|
||||
}
|
||||
v.device[key] = data[key];
|
||||
}
|
||||
|
||||
ble.updateCache();
|
||||
}
|
||||
});
|
||||
|
||||
ble.removeReceiveCallback(pagePath);
|
||||
|
||||
uni.$emit("refreshDeviceList");
|
||||
setTimeout(() => {
|
||||
@ -210,6 +297,7 @@
|
||||
}).catch((ex) => {
|
||||
these.Statu.bound = false;
|
||||
these.Statu.boundRemark = '出现了未知的异常,操作失败';
|
||||
console.log("ex=",ex);
|
||||
}).finally(() => {
|
||||
hideLoading(this);
|
||||
});
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
|
||||
<view class="imgContent center">
|
||||
<view class="img center">
|
||||
<image src="/static/images/bluetooth.png" class="titleIco" mode="aspectFit">
|
||||
<image src="/static/images/common/bluetooth.png" class="titleIco" mode="aspectFit">
|
||||
</image>
|
||||
</view>
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
|
||||
<view class="item " v-for="item, index in PairEquip" v-show="PairEquip.length>0">
|
||||
<view class="leftImg ">
|
||||
<image src="/static/images/BLEAdd/device.png" class="titleIco" mode="aspectFit">
|
||||
<image src="/static/images/common/bluetooth.png" class="titleIco" mode="heightFix">
|
||||
</image>
|
||||
</view>
|
||||
<view class="centertxt ">
|
||||
@ -49,7 +49,7 @@
|
||||
<view class="item" v-on:click="Link(item,index)" v-for="item, index in EquipMents"
|
||||
v-show="!item['linkStatu']">
|
||||
<view class="leftImg ">
|
||||
<image src="/static/images/BLEAdd/device.png" class="titleIco" mode="aspectFit">
|
||||
<image src="/static/images/common/bluetooth.png" class="titleIco" mode="heightFix">
|
||||
</image>
|
||||
</view>
|
||||
<view class="centertxt ">
|
||||
@ -81,8 +81,8 @@
|
||||
</view>
|
||||
</view>
|
||||
</BottomSlideMenuPlus>
|
||||
|
||||
<global-loading ref="loading" />
|
||||
|
||||
<global-loading ref="loading" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@ -94,9 +94,10 @@
|
||||
hideLoading,
|
||||
updateLoading
|
||||
} from '@/utils/loading.js'
|
||||
const pagePath="pages/common/addBLE/addEquip";
|
||||
const pagePath = "pages/common/addBLE/addEquip";
|
||||
var ble = null;
|
||||
var these = null;
|
||||
var eventChannel = null;
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@ -128,7 +129,11 @@
|
||||
|
||||
},
|
||||
PairEquip: [], //已配对设备
|
||||
EquipMents: [] //搜索出来的设备
|
||||
EquipMents: [], //搜索出来的设备
|
||||
device: null,
|
||||
item: {
|
||||
deviceId: ''
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@ -136,28 +141,25 @@
|
||||
},
|
||||
onHide: function() {
|
||||
ble.StopSearch();
|
||||
ble.removeReceiveCallback(pagePath);
|
||||
},
|
||||
onBackPress: (e) => {
|
||||
ble.StopSearch();
|
||||
ble.removeDeviceFound(pagePath);
|
||||
ble.removeReceiveCallback(pagePath);
|
||||
},
|
||||
onUnload(){
|
||||
|
||||
onUnload() {
|
||||
ble.StopSearch();
|
||||
ble.removeDeviceFound(pagePath);
|
||||
ble.removeReceiveCallback(pagePath);
|
||||
},
|
||||
onLoad() {
|
||||
these = this;
|
||||
this.EquipMents = [];
|
||||
ble = bleTool.getBleTool();
|
||||
|
||||
ble.addDeviceFound((arr) => {
|
||||
|
||||
|
||||
arr = arr.devices;
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
|
||||
arr[i].linkStatu = false;
|
||||
if(!arr[i].name){
|
||||
if (!arr[i].name) {
|
||||
continue;
|
||||
}
|
||||
let f = these.EquipMents.find(function(v) {
|
||||
@ -165,41 +167,59 @@
|
||||
});
|
||||
|
||||
if (!f) {
|
||||
|
||||
|
||||
these.EquipMents.push(arr[i]);
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
},pagePath);
|
||||
// console.log("equip=", these.EquipMents)
|
||||
}, pagePath);
|
||||
// console.log("addEquip")
|
||||
ble.addReceiveCallback((receivData, f, path, arr) => {
|
||||
if (f.macAddress && these.device) {
|
||||
showLoading(these, {
|
||||
text: '正在验证设备'
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
these.DeviceVerdict(f.deviceId);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
|
||||
}, pagePath);
|
||||
eventChannel = this.getOpenerEventChannel();
|
||||
|
||||
eventChannel.on('detailData', function(rec) {
|
||||
console.log("接收到父页面的参数:", rec);
|
||||
these.device = rec.data;
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
onShow: function() {
|
||||
|
||||
|
||||
this.EquipMents=[];
|
||||
this.PairEquip=[];
|
||||
ble.StartSearch().catch((ex) => {
|
||||
|
||||
|
||||
// this.EquipMents = [];
|
||||
this.PairEquip = [];
|
||||
ble && ble.StartSearch().then(res=>{
|
||||
console.log("开始搜索成功",res);
|
||||
}).catch((ex) => {
|
||||
console.log("开始搜索出现异常",ex);
|
||||
if (ex.code == 10001) {
|
||||
these.showOpenSetting();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
ble.addReceiveCallback((receivData) => {
|
||||
console.log("收到数据了:", receivData);//数据格式:{bytes:[109,97],str:"",hexs:"FA 01"}
|
||||
console.log("LinkedList=",ble.data.LinkedList);
|
||||
let data=uni.getStorageSync(ble.StorageKey);
|
||||
console.log("data=",data);
|
||||
},pagePath);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
},
|
||||
methods: {
|
||||
isItemLink: function(item, index) {
|
||||
let src = '/static/images/BLEAdd/noLink.png';
|
||||
|
||||
|
||||
if (this.PairEquip && this.PairEquip.length) {
|
||||
if (this.PairEquip.length > 0) {
|
||||
let f = this.PairEquip.find(function(v) {
|
||||
@ -214,7 +234,7 @@
|
||||
}
|
||||
return src;
|
||||
},
|
||||
|
||||
|
||||
|
||||
showOpenSetting: function() {
|
||||
this.Status.BottomMenu.show = true;
|
||||
@ -223,45 +243,121 @@
|
||||
this.Status.BottomMenu.show = false;
|
||||
ble.showBlueSetting(false);
|
||||
},
|
||||
Link: function(item, index) {
|
||||
|
||||
showLoading(this,{
|
||||
text: "正在连接"
|
||||
});
|
||||
setTimeout(() => {
|
||||
let serviceid=null;
|
||||
if(item.advertisServiceUUIDs.length>0){
|
||||
serviceid=item.advertisServiceUUIDs[0];
|
||||
}
|
||||
ble.LinkBlue(item.deviceId,serviceid).then((res) => {
|
||||
let c = these.PairEquip.find(function(v) {
|
||||
return v.deviceId == item.deviceId;
|
||||
});
|
||||
if (!c) {
|
||||
|
||||
these.PairEquip.push(item);
|
||||
DeviceVerdict(deviceId) { //判断是否是目标设备
|
||||
if (these.device) { //从设备详情过来的,回设备详情去
|
||||
let f = ble.data.LinkedList.find(v => {
|
||||
if (v.deviceId == deviceId) {
|
||||
v.device = these.device;
|
||||
return true;
|
||||
}
|
||||
ble.removeReceiveCallback(pagePath);
|
||||
return false;
|
||||
});
|
||||
if (f.macAddress) {
|
||||
|
||||
|
||||
if (f.macAddress != these.device.deviceMac) {
|
||||
ble.disconnectDevice(deviceId);
|
||||
updateLoading(these, {
|
||||
text: "设备Mac地址错误,请重选设备连接"
|
||||
})
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
hideLoading(these);
|
||||
|
||||
ble.updateCache();
|
||||
uni.navigateBack();
|
||||
return true;
|
||||
} else {
|
||||
updateLoading(these, {
|
||||
text: "等待设备上报Mac地址"
|
||||
})
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
Link: function(item) {
|
||||
this.item.deviceId = item.deviceId;
|
||||
showLoading(this, {
|
||||
text: "正在连接:第1次"
|
||||
});
|
||||
|
||||
let index = 1;
|
||||
let total = 5;
|
||||
|
||||
let linkCallback = (res) => {
|
||||
let c = these.PairEquip.find(function(v) {
|
||||
return v.deviceId == item.deviceId;
|
||||
});
|
||||
if (!c) {
|
||||
|
||||
these.PairEquip.push(item);
|
||||
}
|
||||
console.log("连接成功", these.device);
|
||||
if (!these.device) {
|
||||
console.log("跳转到绑定")
|
||||
hideLoading(these);
|
||||
uni.navigateTo({
|
||||
url:"/pages/common/addBLE/LinkBle",
|
||||
events:{
|
||||
|
||||
url: "/pages/common/addBLE/LinkBle",
|
||||
events: {
|
||||
|
||||
},
|
||||
success(res) {
|
||||
|
||||
res.eventChannel.emit('LinkItem', item);
|
||||
|
||||
res.eventChannel.emit('LinkItem', item);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
console.log("验证设备")
|
||||
these.DeviceVerdict(item.deviceId);
|
||||
}
|
||||
let execLink = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
|
||||
if (index > total) {
|
||||
reject({
|
||||
msg: "连接超时"
|
||||
});
|
||||
return;
|
||||
}
|
||||
ble.LinkBlue(item.deviceId).then((res) => {
|
||||
console.log("连接成功");
|
||||
|
||||
resolve(res);
|
||||
}).catch((ex) => {
|
||||
if (index == total) {
|
||||
console.log("连接了N次都没连上");
|
||||
reject(ex);
|
||||
return;
|
||||
}
|
||||
index++;
|
||||
updateLoading(this, {
|
||||
text: ex.msg + ",正在重试第" + index + "次"
|
||||
})
|
||||
execLink().then(resolve).catch(reject);
|
||||
|
||||
})
|
||||
|
||||
}).catch((ex) => {
|
||||
console.log("ex=",ex)
|
||||
uni.showModal({
|
||||
content:"连接失败:"+ex.msg
|
||||
});
|
||||
}).finally(()=>{
|
||||
hideLoading(this);
|
||||
});
|
||||
}, 0);
|
||||
|
||||
}
|
||||
|
||||
execLink().then((res) => {
|
||||
linkCallback(res);
|
||||
}).catch(ex => {
|
||||
console.log("ex=", ex)
|
||||
uni.showModal({
|
||||
content: "连接失败:" + ex.msg
|
||||
});
|
||||
hideLoading(these);
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -436,8 +532,8 @@
|
||||
}
|
||||
|
||||
.list .item .leftImg {
|
||||
width: 100rpx;
|
||||
height: 70rpx;
|
||||
width: 60rpx;
|
||||
height: 60rpx;
|
||||
}
|
||||
|
||||
.list .item .centertxt {
|
||||
@ -469,7 +565,7 @@
|
||||
font-family: "PingFang SC";
|
||||
font-size: 26rpx;
|
||||
font-weight: 400;
|
||||
line-height: 50rpx;
|
||||
line-height: 36rpx;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
@ -478,14 +574,14 @@
|
||||
font-family: "PingFang SC";
|
||||
font-size: 24rpx;
|
||||
font-weight: 400;
|
||||
line-height: 30rpx;
|
||||
line-height: 36rpx;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
|
||||
.list .item .rightIco .img {
|
||||
width: 50rpx;
|
||||
height: 50rpx;
|
||||
width: 45rpx;
|
||||
height: 45rpx;
|
||||
}
|
||||
|
||||
.openBlue {
|
||||
|
||||
@ -139,8 +139,10 @@
|
||||
},
|
||||
// 跳转到详情页面
|
||||
handleFile(item) {
|
||||
let url = item.detailPageUrl;
|
||||
uni.navigateTo({
|
||||
url: "/pages/6170/deviceControl/index",
|
||||
// url: "/pages/6170/deviceControl/index",
|
||||
url:url,
|
||||
success: (res) => {
|
||||
// 页面跳转成功后的回调函数
|
||||
res.eventChannel.emit('detailData', {
|
||||
431
pages/common/forgotPassword/index.vue
Normal file
431
pages/common/forgotPassword/index.vue
Normal file
@ -0,0 +1,431 @@
|
||||
<template>
|
||||
<view class="pageContent">
|
||||
<image src="/static/images/common/login.png" mode="" class="login-bg"></image>
|
||||
<view class="content_con">
|
||||
找回密码
|
||||
</view>
|
||||
<view class="content">
|
||||
<view class='ver_item'>
|
||||
<input type="number" v-model="phone" :maxlength="11" placeholder="请输入手机号" class="input" />
|
||||
</view>
|
||||
<view class='ver_item'>
|
||||
<input type="number" v-model="code" :maxlength="6" placeholder="请输入验证码" class="input" />
|
||||
<button :class="showView?' get_phone_number blue':'get_phone_number grad'"
|
||||
@click="getPhoneCode">{{ isCounting ? `${countdown}s后重新获取` : '获取验证码' }}</button>
|
||||
</view>
|
||||
<view class='ver_item'>
|
||||
<input type="password" v-model="password" placeholder="请设置新密码(6—20个数字或字母)" class="input" />
|
||||
</view>
|
||||
<!-- 登录按钮 -->
|
||||
<button class="login-btn" @click="handleLogin">
|
||||
确定
|
||||
</button>
|
||||
<view class="login-title">已有账号?<text class="gologin" @click="goLogin">去登录</text></view>
|
||||
<!-- 协议勾选 -->
|
||||
<view class="agreement">
|
||||
<view class="custom-checkbox" @click="toggleCheck">
|
||||
<view class="checkbox-icon" :class="{ checked: isChecked }">
|
||||
<uni-icons v-if="isChecked" type="checkmarkempty" size="8" color="#fff"></uni-icons>
|
||||
</view>
|
||||
<text class="checkbox-label">我已认真阅读,理解并同意<a class="agreeT"
|
||||
@click.stop="goToPage('agreement')">《用户服务协议》</a>及<a class="agreeT"
|
||||
@click.stop="goToPage('privacy')">《隐私政策》</a></text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 弹框 -->
|
||||
<view class="agreement-mask" v-if="showAgreement">
|
||||
<!-- 协议弹窗 -->
|
||||
<view class="agreement-popup" @click.stop>
|
||||
<!-- 标题 -->
|
||||
<view class="popup-title">服务协议及隐私政策</view>
|
||||
<!-- 协议内容 -->
|
||||
<view class="popup-content">
|
||||
为了更好的保障您的合法权益,请您阅读并同意以下协议
|
||||
<text class="protocol-link" @click="openProtocol('user')">《用户服务协议》</text>
|
||||
<text class="protocol-link" @click="openProtocol('privacy')">《隐私政策》</text>
|
||||
</view>
|
||||
<!-- 按钮组 -->
|
||||
<view class="popup-buttons">
|
||||
<button class="btn disagree" @click="handleDisagree">不同意</button>
|
||||
<button class="btn agree" @click="handleAgree">同意</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import md5 from 'blueimp-md5'
|
||||
import {
|
||||
forgetPassword,
|
||||
forgetPasswordSmsCode
|
||||
} from '@/api/common/login.js';
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
showView: false,
|
||||
phone: '', //手机号码
|
||||
code: "", //验证码
|
||||
password: '', //密码
|
||||
agreed: false,
|
||||
isCounting: false,
|
||||
countdown: 0,
|
||||
isChecked: true,
|
||||
showAgreement: false, // 控制弹窗显示
|
||||
}
|
||||
},
|
||||
onLoad() {},
|
||||
methods: {
|
||||
// 获取验证码
|
||||
async getPhoneCode() {
|
||||
const phoneNumber = this.phone
|
||||
const myreg = /^1[3456789]\d{9}$/;
|
||||
if (!phoneNumber) {
|
||||
uni.showToast({
|
||||
title: '手机号不能为空',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
});
|
||||
return false;
|
||||
} else if (!myreg.test(phoneNumber)) {
|
||||
uni.showToast({
|
||||
title: '请输入正确的手机号',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
});
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
const res = await forgetPasswordSmsCode({
|
||||
phonenumber: this.phone
|
||||
})
|
||||
if (res.code == 200) {
|
||||
// 更新倒计时状态
|
||||
this.isCounting = true;
|
||||
this.showView = true;
|
||||
this.countdown = 60
|
||||
const timer = setInterval(() => {
|
||||
this.countdown--
|
||||
if (this.countdown <= 0) {
|
||||
clearInterval(timer)
|
||||
this.isCounting = false;
|
||||
this.showView = false;
|
||||
}
|
||||
}, 1000)
|
||||
uni.showToast({
|
||||
title: '验证码已发送',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
|
||||
} catch (error) {}
|
||||
},
|
||||
// 勾选同意
|
||||
toggleCheck() {
|
||||
this.isChecked = !this.isChecked
|
||||
},
|
||||
// 登录
|
||||
goLogin() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/common/login/index'
|
||||
})
|
||||
},
|
||||
// 登录
|
||||
async handleLogin() {
|
||||
if (this.phone == '') {
|
||||
uni.showToast({
|
||||
title: '手机号不能为空',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
return false
|
||||
} else if (this.code == '') {
|
||||
uni.showToast({
|
||||
title: '验证码不能为空',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
return false
|
||||
}
|
||||
if (!this.password) {
|
||||
uni.showToast({
|
||||
title: '请设置新密码',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
});
|
||||
return false
|
||||
}
|
||||
if (!this.isChecked) {
|
||||
this.showAgreement = true
|
||||
return false
|
||||
}
|
||||
try {
|
||||
uni.showLoading({
|
||||
title: '加载中...'
|
||||
})
|
||||
// 调用忘记密码接口
|
||||
const res = await forgetPassword({
|
||||
phonenumber: this.phone,
|
||||
smsCode: this.code,
|
||||
tenantId: '894078', //租户ID
|
||||
password: md5(this.password)
|
||||
})
|
||||
if (res.code == 200) {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '密码修改成功',
|
||||
icon: 'success'
|
||||
})
|
||||
uni.navigateTo({
|
||||
url: '/pages/common/login/index'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('捕获错误:', error);
|
||||
uni.showToast({
|
||||
title: error.msg || '登录失败',
|
||||
icon: 'none'
|
||||
});
|
||||
uni.hideLoading()
|
||||
}
|
||||
},
|
||||
// 跳转到协议页面
|
||||
goToPage(type) {
|
||||
const url = type === 'agreement' ?
|
||||
'/pages/common/userAgreement/index' // 服务协议
|
||||
:
|
||||
'/pages/common/privacyAgreement/index'; // 隐私政策
|
||||
uni.navigateTo({
|
||||
url: url
|
||||
});
|
||||
},
|
||||
|
||||
// 不同意
|
||||
handleDisagree() {
|
||||
this.showAgreement = false
|
||||
},
|
||||
// 同意
|
||||
handleAgree() {
|
||||
this.isChecked = !this.isChecked
|
||||
this.showAgreement = false
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.pageContent {
|
||||
background: rgb(26, 26, 26);
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
.login-bg {
|
||||
background-size: 100% 100%;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.content {
|
||||
height: 70%;
|
||||
width: 100%;
|
||||
background: rgb(26, 26, 26);
|
||||
position: absolute;
|
||||
bottom: 0px;
|
||||
border-radius: 60px 60px 0px 0px;
|
||||
box-sizing: border-box;
|
||||
padding: 30rpx;
|
||||
}
|
||||
|
||||
.content_con {
|
||||
position: absolute;
|
||||
top: 220rpx;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
left: 30rpx;
|
||||
font-size: 60rpx;
|
||||
}
|
||||
|
||||
.input {
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
||||
height: 80rpx;
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
margin-top: 50rpx;
|
||||
}
|
||||
|
||||
.ver_item {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.get_phone_number {
|
||||
position: absolute;
|
||||
right: 0px;
|
||||
color: #999;
|
||||
top: 1rpx;
|
||||
background: rgb(26, 26, 26);
|
||||
border: none;
|
||||
text-align: right;
|
||||
font-size: 28rpx;
|
||||
font-family: PingFangSC-Medium, PingFang SC;
|
||||
}
|
||||
|
||||
.grad {
|
||||
color: rgb(187, 230, 0);
|
||||
}
|
||||
|
||||
.blue {
|
||||
color: rgb(187, 230, 0);
|
||||
}
|
||||
|
||||
.agreement {
|
||||
margin: 50rpx 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
position: absolute;
|
||||
bottom: 8rpx
|
||||
}
|
||||
|
||||
.login-btn {
|
||||
margin-top: 90rpx;
|
||||
background-color: rgb(187, 230, 0);
|
||||
color: rgb(35, 35, 35);
|
||||
border-radius: 50rpx;
|
||||
}
|
||||
|
||||
.login-btn[disabled] {
|
||||
background-color: #ccc;
|
||||
}
|
||||
|
||||
.login-title {
|
||||
text-align: center;
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
padding-top: 20rpx;
|
||||
}
|
||||
|
||||
.gologin {
|
||||
color: rgba(187, 230, 0, 1);
|
||||
}
|
||||
|
||||
.custom-checkbox {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.checkbox-icon {
|
||||
width: 30rpx;
|
||||
height: 30rpx;
|
||||
border: 1px solid rgba(255, 255, 255, 0.87);
|
||||
border-radius: 50rpx;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
|
||||
.checkbox-icon.checked {
|
||||
background-color: #07C160;
|
||||
border-color: #07C160;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.checkbox-label {
|
||||
font-size: 24rpx;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
}
|
||||
|
||||
.agreeT {
|
||||
color: rgb(187, 230, 0);
|
||||
}
|
||||
|
||||
/* 遮罩层 */
|
||||
.agreement-mask {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 999;
|
||||
}
|
||||
|
||||
/* 弹窗主体 */
|
||||
.agreement-popup {
|
||||
width: 80%;
|
||||
background-color: rgba(42, 42, 42);
|
||||
border-radius: 16rpx;
|
||||
padding: 40rpx;
|
||||
box-sizing: border-box;
|
||||
border: 1rpx solid rgba(187, 230, 0, 0.3)
|
||||
}
|
||||
|
||||
/* 标题 */
|
||||
.popup-title {
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
margin-bottom: 30rpx;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
}
|
||||
|
||||
/* 内容文本 */
|
||||
.popup-content {
|
||||
font-size: 30rpx;
|
||||
line-height: 1.6;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
margin-bottom: 50rpx;
|
||||
}
|
||||
|
||||
/* 协议链接 */
|
||||
.protocol-link {
|
||||
color: rgb(187, 230, 0);
|
||||
margin: 0 10rpx;
|
||||
}
|
||||
|
||||
/* 按钮容器 */
|
||||
.popup-buttons {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
/* 通用按钮样式 */
|
||||
.btn {
|
||||
flex: 1;
|
||||
height: 80rpx;
|
||||
line-height: 80rpx;
|
||||
border-radius: 40rpx;
|
||||
font-size: 32rpx;
|
||||
margin: 0 20rpx;
|
||||
}
|
||||
|
||||
/* 不同意按钮 */
|
||||
.disagree {
|
||||
background-color: transparent;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
border: 1px solid rgb(255, 255, 255);
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
/* 同意按钮 */
|
||||
.agree {
|
||||
background-color: rgb(187, 230, 0);
|
||||
color: #232323;
|
||||
border: none;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
</style>
|
||||
@ -144,6 +144,8 @@
|
||||
deviceUnbind, //删除设备
|
||||
deviceReName
|
||||
} from '@/api/common/index.js'
|
||||
import BleHelper from '@/utils/BleHelper.js';
|
||||
var ble=null;
|
||||
export default {
|
||||
onPullDownRefresh() {
|
||||
// 执行下拉刷新时的操作,比如重新获取数据
|
||||
@ -225,7 +227,7 @@
|
||||
break;
|
||||
case 'share':
|
||||
uni.navigateTo({
|
||||
url: "/pages/6170/allShare/index"
|
||||
url: "/pages/common/allShare/index"
|
||||
})
|
||||
break;
|
||||
}
|
||||
@ -388,7 +390,9 @@
|
||||
}, 500);
|
||||
this.deleteShow = false
|
||||
// 关闭所有滑动项
|
||||
this.$refs.swipeAction.closeAll();
|
||||
this.$refs.swipeAction.closeAll();
|
||||
|
||||
ble && ble.DropDevice(data.id);
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
@ -486,6 +490,10 @@
|
||||
// 列表跳转
|
||||
handleFile(item) {
|
||||
let url = item.detailPageUrl;
|
||||
// console.log("url=",url);
|
||||
// if(!url){
|
||||
//url="/pages/670/HBY670"
|
||||
// }
|
||||
uni.navigateTo({
|
||||
url: url,
|
||||
events: {
|
||||
@ -498,6 +506,8 @@
|
||||
deviceType: this.tabs[this.activeTab].id || '',
|
||||
apiType: 'listA' //标识,根据这个参数,区分普通详情,分享跳转详情,查不一样的权限信息
|
||||
});
|
||||
},fail(ex) {
|
||||
console.log("ex=",ex);
|
||||
}
|
||||
})
|
||||
},
|
||||
@ -549,6 +559,7 @@
|
||||
console.log('列表收到消息了么');
|
||||
this.onIntall()
|
||||
});
|
||||
ble=BleHelper.getBleTool();
|
||||
},
|
||||
beforeDestroy() {
|
||||
// 组件销毁前移除监听器
|
||||
|
||||
@ -8,11 +8,26 @@
|
||||
<view class='ver_item'>
|
||||
<input type="number" v-model="phone" :maxlength="11" placeholder="请输入手机号" class="input" />
|
||||
</view>
|
||||
<view class='ver_item'>
|
||||
<view class='ver_item' v-if="isCodeLogin">
|
||||
<input type="number" v-model="code" :maxlength="6" placeholder="请输入验证码" class="input" />
|
||||
<button :class="showView?' get_phone_number blue':'get_phone_number grad'"
|
||||
@click="getPhoneCode">{{ isCounting ? `${countdown}s后重新获取` : '获取验证码' }}</button>
|
||||
</view>
|
||||
<view class='ver_item' v-else>
|
||||
<input type="password" v-model="password" placeholder="请输入密码" class="input" />
|
||||
</view>
|
||||
<view class="switch-flex">
|
||||
<view class="switch-login" @click="switchLogin">
|
||||
{{ isCodeLogin ? '密码登录' : '验证码登录' }}
|
||||
</view>
|
||||
<view v-if="!isCodeLogin" @click="forgotPassword">忘记密码</view>
|
||||
</view>
|
||||
<!-- 登录按钮 -->
|
||||
<button class="login-btn" @click="handleLogin">
|
||||
登录
|
||||
</button>
|
||||
<view class="login-title">没有账号?<text class="gologin" @click="goLogin">去注册</text></view>
|
||||
|
||||
<!-- 协议勾选 -->
|
||||
<view class="agreement">
|
||||
<view class="custom-checkbox" @click="toggleCheck">
|
||||
@ -24,10 +39,6 @@
|
||||
@click.stop="goToPage('privacy')">《隐私政策》</a></text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 登录按钮 -->
|
||||
<button class="login-btn" @click="handleLogin">
|
||||
登录
|
||||
</button>
|
||||
</view>
|
||||
<!-- 弹框 -->
|
||||
<view class="agreement-mask" v-if="showAgreement">
|
||||
@ -52,6 +63,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import md5 from 'blueimp-md5'
|
||||
import {
|
||||
login,
|
||||
resourceSmsCode
|
||||
@ -60,39 +72,50 @@
|
||||
data() {
|
||||
return {
|
||||
showView: false,
|
||||
phone: '17671332251', //手机号码
|
||||
phone: '13800138002', //手机号码
|
||||
code: "123456", //验证码
|
||||
password: "",
|
||||
agreed: false,
|
||||
isCounting: false,
|
||||
countdown: 0,
|
||||
isChecked: true,
|
||||
showAgreement: false, // 控制弹窗显示
|
||||
isCodeLogin: false,
|
||||
}
|
||||
},
|
||||
onLoad(){
|
||||
if(uni.getStorageSync("token") && uni.getStorageSync("clientID")){//免登陆
|
||||
|
||||
let time=uni.getStorageSync("tokenTime");
|
||||
if(!time){
|
||||
time=0;
|
||||
onLoad() {
|
||||
if (uni.getStorageSync("token") && uni.getStorageSync("clientID")) { //免登陆
|
||||
let time = uni.getStorageSync("tokenTime");
|
||||
if (!time) {
|
||||
time = 0;
|
||||
}
|
||||
let currTime=new Date().getTime();
|
||||
if(currTime<time){
|
||||
let currTime = new Date().getTime();
|
||||
if (currTime < time) {
|
||||
console.log("登陆过,并且没过期,自动进入设备页");
|
||||
uni.switchTab({
|
||||
url: '/pages/common/index/index'
|
||||
});
|
||||
return;
|
||||
}else{
|
||||
} else {
|
||||
//token过期了
|
||||
uni.removeStorageSync("token")
|
||||
uni.removeStorageSync("clientID")
|
||||
uni.removeStorageSync("tokenTime")
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 验证码密码切换
|
||||
switchLogin() {
|
||||
this.isCodeLogin = !this.isCodeLogin;
|
||||
// 切换时重置相关输入和状态
|
||||
this.code = "";
|
||||
this.password = "";
|
||||
this.isCounting = false;
|
||||
this.countdown = 0;
|
||||
this.showView = false;
|
||||
},
|
||||
// 获取验证码
|
||||
async getPhoneCode() {
|
||||
const phoneNumber = this.phone
|
||||
@ -146,6 +169,18 @@
|
||||
toggleCheck() {
|
||||
this.isChecked = !this.isChecked
|
||||
},
|
||||
// 去登录
|
||||
goLogin() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/common/register/index'
|
||||
})
|
||||
},
|
||||
// 忘记密码
|
||||
forgotPassword() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/common/forgotPassword/index'
|
||||
})
|
||||
},
|
||||
// 登录
|
||||
async handleLogin() {
|
||||
if (this.phone == '') {
|
||||
@ -155,64 +190,74 @@
|
||||
duration: 1000
|
||||
})
|
||||
return false
|
||||
} else if (this.code == '') {
|
||||
uni.showToast({
|
||||
title: '验证码不能为空',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
return false
|
||||
}
|
||||
if (this.isCodeLogin) {
|
||||
if (this.code == '') {
|
||||
uni.showToast({
|
||||
title: '验证码不能为空',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
return false
|
||||
}
|
||||
} else {
|
||||
if (this.password == '') {
|
||||
uni.showToast({
|
||||
title: '密码不能为空',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
return false
|
||||
}
|
||||
}
|
||||
if (!this.isChecked) {
|
||||
this.showAgreement = true
|
||||
return false
|
||||
}
|
||||
try {
|
||||
|
||||
|
||||
console.log('44444');
|
||||
|
||||
uni.showLoading({
|
||||
title: '登录中...'
|
||||
})
|
||||
// 调用登录接口
|
||||
const res = await login({
|
||||
let loginParams = {
|
||||
phonenumber: this.phone,
|
||||
smsCode: this.code,
|
||||
tenantId: '894078' //租户ID
|
||||
})
|
||||
tenantId: '894078' // 租户ID
|
||||
};
|
||||
if (this.isCodeLogin) {
|
||||
loginParams.smsCode = this.code;
|
||||
//登录方式 1:手机验证码登录 2:密码登录
|
||||
loginParams.loginType=1
|
||||
} else {
|
||||
loginParams.loginPassword = md5(this.password);
|
||||
loginParams.loginType=2
|
||||
}
|
||||
// 调用登录接口
|
||||
const res = await login(loginParams)
|
||||
if (res.code == 200) {
|
||||
console.log(res, 'ressss');
|
||||
uni.hideLoading();
|
||||
uni.setStorageSync('token', res.data.access_token); // 缓存token
|
||||
uni.setStorageSync('clientID', res.data.client_id); // 缓存token
|
||||
uni.setStorageSync('tokenTime',new Date().getTime()+86400000);//过期时间
|
||||
uni.hideLoading()
|
||||
uni.setStorageSync('token', res.data.access_token) // 缓存token
|
||||
uni.setStorageSync('clientID', res.data.client_id) // 缓存token
|
||||
uni.setStorageSync('tokenTime', new Date().getTime() + 86400000); //过期时间
|
||||
uni.showToast({
|
||||
title: '登录成功',
|
||||
icon: 'success'
|
||||
})
|
||||
uni.switchTab({
|
||||
url: '/pages/common/index/index'
|
||||
});
|
||||
|
||||
// uni.navigateTo({
|
||||
// url:"/pages/BlueTooth/ModeSetting/index"
|
||||
// });
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
title: res.msg || '服务器异常,请稍后重试',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
uni.hideLoading()
|
||||
console.log('捕获错误:', error);
|
||||
uni.showToast({
|
||||
title: error.msg,
|
||||
title: error.msg || '登录失败',
|
||||
icon: 'none'
|
||||
});
|
||||
uni.hideLoading()
|
||||
}
|
||||
|
||||
},
|
||||
// 跳转到协议页面
|
||||
goToPage(type) {
|
||||
@ -281,6 +326,20 @@
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.switch-flex {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-top: 40rpx;
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
}
|
||||
|
||||
.switch-login {
|
||||
color: rgb(187, 230, 0);
|
||||
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
|
||||
.get_phone_number {
|
||||
position: absolute;
|
||||
right: 0px;
|
||||
@ -307,10 +366,12 @@
|
||||
align-items: center;
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
position: absolute;
|
||||
bottom: 8rpx
|
||||
}
|
||||
|
||||
.login-btn {
|
||||
margin-top: 150rpx;
|
||||
margin-top: 90rpx;
|
||||
background-color: rgb(187, 230, 0);
|
||||
color: rgb(35, 35, 35);
|
||||
border-radius: 50rpx;
|
||||
@ -320,6 +381,16 @@
|
||||
background-color: #ccc;
|
||||
}
|
||||
|
||||
.login-title {
|
||||
text-align: center;
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
padding-top: 20rpx;
|
||||
}
|
||||
|
||||
.gologin {
|
||||
color: rgba(187, 230, 0, 1);
|
||||
}
|
||||
|
||||
.custom-checkbox {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@ -89,14 +89,29 @@
|
||||
} catch (error) {}
|
||||
}
|
||||
},
|
||||
},
|
||||
onLoad(options) {
|
||||
if (options.deviceId) {
|
||||
this.deviceId = decodeURIComponent(options.deviceId);
|
||||
} else {
|
||||
this.deviceId = '未获取到设备ID';
|
||||
}
|
||||
},
|
||||
// 处理返回键
|
||||
onBackPress() {
|
||||
// 如果绑定成功了,返回时也要刷新首页
|
||||
if (this.isSuccess) {
|
||||
uni.$emit('refreshDeviceList');
|
||||
}
|
||||
return false; // 允许正常返回
|
||||
},
|
||||
// 页面卸载时处理
|
||||
onUnload() {
|
||||
// 如果绑定成功了,卸载时也要刷新首页
|
||||
if (this.isSuccess) {
|
||||
uni.$emit('refreshDeviceList');
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
if (options.deviceId) {
|
||||
this.deviceId = decodeURIComponent(options.deviceId);
|
||||
} else {
|
||||
this.deviceId = '未获取到设备ID';
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
433
pages/common/register/index.vue
Normal file
433
pages/common/register/index.vue
Normal file
@ -0,0 +1,433 @@
|
||||
<template>
|
||||
<view class="pageContent">
|
||||
<image src="/static/images/common/login.png" mode="" class="login-bg"></image>
|
||||
<view class="content_con">
|
||||
欢迎注册
|
||||
</view>
|
||||
<view class="content">
|
||||
<view class='ver_item'>
|
||||
<input type="number" v-model="phone" :maxlength="11" placeholder="请输入手机号" class="input" />
|
||||
</view>
|
||||
<view class='ver_item'>
|
||||
<input type="number" v-model="code" :maxlength="6" placeholder="请输入验证码" class="input" />
|
||||
<button :class="showView?' get_phone_number blue':'get_phone_number grad'"
|
||||
@click="getPhoneCode">{{ isCounting ? `${countdown}s后重新获取` : '获取验证码' }}</button>
|
||||
</view>
|
||||
<view class='ver_item'>
|
||||
<input type="password" v-model="password" placeholder="请设置密码(6—20个数字或字母)" class="input" />
|
||||
|
||||
</view>
|
||||
|
||||
|
||||
<!-- 登录按钮 -->
|
||||
<button class="login-btn" @click="handleLogin">
|
||||
注册
|
||||
</button>
|
||||
<view class="login-title">已有账号?<text class="gologin" @click="goLogin">去登录</text></view>
|
||||
<!-- 协议勾选 -->
|
||||
<view class="agreement">
|
||||
<view class="custom-checkbox" @click="toggleCheck">
|
||||
<view class="checkbox-icon" :class="{ checked: isChecked }">
|
||||
<uni-icons v-if="isChecked" type="checkmarkempty" size="8" color="#fff"></uni-icons>
|
||||
</view>
|
||||
<text class="checkbox-label">我已认真阅读,理解并同意<a class="agreeT"
|
||||
@click.stop="goToPage('agreement')">《用户服务协议》</a>及<a class="agreeT"
|
||||
@click.stop="goToPage('privacy')">《隐私政策》</a></text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 弹框 -->
|
||||
<view class="agreement-mask" v-if="showAgreement">
|
||||
<!-- 协议弹窗 -->
|
||||
<view class="agreement-popup" @click.stop>
|
||||
<!-- 标题 -->
|
||||
<view class="popup-title">服务协议及隐私政策</view>
|
||||
<!-- 协议内容 -->
|
||||
<view class="popup-content">
|
||||
为了更好的保障您的合法权益,请您阅读并同意以下协议
|
||||
<text class="protocol-link" @click="openProtocol('user')">《用户服务协议》</text>
|
||||
<text class="protocol-link" @click="openProtocol('privacy')">《隐私政策》</text>
|
||||
</view>
|
||||
<!-- 按钮组 -->
|
||||
<view class="popup-buttons">
|
||||
<button class="btn disagree" @click="handleDisagree">不同意</button>
|
||||
<button class="btn agree" @click="handleAgree">同意</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import md5 from 'blueimp-md5'
|
||||
import {
|
||||
register,
|
||||
registerSmsCode
|
||||
} from '@/api/common/login.js';
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
showView: false,
|
||||
phone: '', //手机号码
|
||||
code: "", //验证码
|
||||
password: '', //密码
|
||||
agreed: false,
|
||||
isCounting: false,
|
||||
countdown: 0,
|
||||
isChecked: true,
|
||||
showAgreement: false, // 控制弹窗显示
|
||||
}
|
||||
},
|
||||
onLoad() {},
|
||||
methods: {
|
||||
// 获取验证码
|
||||
async getPhoneCode() {
|
||||
const phoneNumber = this.phone
|
||||
const myreg = /^1[3456789]\d{9}$/;
|
||||
if (!phoneNumber) {
|
||||
uni.showToast({
|
||||
title: '手机号不能为空',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
});
|
||||
return false;
|
||||
} else if (!myreg.test(phoneNumber)) {
|
||||
uni.showToast({
|
||||
title: '请输入正确的手机号',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
});
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
const res = await registerSmsCode({
|
||||
phonenumber: this.phone
|
||||
})
|
||||
if (res.code == 200) {
|
||||
// 更新倒计时状态
|
||||
this.isCounting = true;
|
||||
this.showView = true;
|
||||
this.countdown = 60
|
||||
const timer = setInterval(() => {
|
||||
this.countdown--
|
||||
if (this.countdown <= 0) {
|
||||
clearInterval(timer)
|
||||
this.isCounting = false;
|
||||
this.showView = false;
|
||||
}
|
||||
}, 1000)
|
||||
uni.showToast({
|
||||
title: '验证码已发送',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
|
||||
} catch (error) {}
|
||||
},
|
||||
// 勾选同意
|
||||
toggleCheck() {
|
||||
this.isChecked = !this.isChecked
|
||||
},
|
||||
// 登录
|
||||
goLogin() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/common/login/index'
|
||||
})
|
||||
},
|
||||
// 登录
|
||||
async handleLogin() {
|
||||
if (this.phone == '') {
|
||||
uni.showToast({
|
||||
title: '手机号不能为空',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
return false
|
||||
} else if (this.code == '') {
|
||||
uni.showToast({
|
||||
title: '验证码不能为空',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
return false
|
||||
} else if (!this.password) {
|
||||
uni.showToast({
|
||||
title: '请设置密码',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
});
|
||||
return false
|
||||
}
|
||||
if (!this.isChecked) {
|
||||
this.showAgreement = true
|
||||
return false
|
||||
}
|
||||
try {
|
||||
uni.showLoading({
|
||||
title: '注册中...'
|
||||
})
|
||||
// 调用登录接口
|
||||
const res = await register({
|
||||
phonenumber: this.phone,
|
||||
smsCode: this.code,
|
||||
tenantId: '894078', //租户ID
|
||||
password: md5(this.password)
|
||||
})
|
||||
if (res.code == 200) {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '注册成功',
|
||||
icon: 'success'
|
||||
})
|
||||
uni.navigateTo({
|
||||
url: '/pages/common/login/index'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg || '服务器异常,请稍后重试',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('捕获错误:', error);
|
||||
uni.showToast({
|
||||
title: error.msg || '登录失败',
|
||||
icon: 'none'
|
||||
});
|
||||
uni.hideLoading()
|
||||
}
|
||||
},
|
||||
// 跳转到协议页面
|
||||
goToPage(type) {
|
||||
const url = type === 'agreement' ?
|
||||
'/pages/common/userAgreement/index' // 服务协议
|
||||
:
|
||||
'/pages/common/privacyAgreement/index'; // 隐私政策
|
||||
uni.navigateTo({
|
||||
url: url
|
||||
});
|
||||
},
|
||||
|
||||
// 不同意
|
||||
handleDisagree() {
|
||||
this.showAgreement = false
|
||||
},
|
||||
// 同意
|
||||
handleAgree() {
|
||||
this.isChecked = !this.isChecked
|
||||
this.showAgreement = false
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.pageContent {
|
||||
background: rgb(26, 26, 26);
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
.login-bg {
|
||||
background-size: 100% 100%;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.content {
|
||||
height: 70%;
|
||||
width: 100%;
|
||||
background: rgb(26, 26, 26);
|
||||
position: absolute;
|
||||
bottom: 0px;
|
||||
border-radius: 60px 60px 0px 0px;
|
||||
box-sizing: border-box;
|
||||
padding: 30rpx;
|
||||
}
|
||||
|
||||
.content_con {
|
||||
position: absolute;
|
||||
top: 220rpx;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
left: 30rpx;
|
||||
font-size: 60rpx;
|
||||
}
|
||||
|
||||
.input {
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
||||
height: 80rpx;
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
margin-top: 50rpx;
|
||||
}
|
||||
|
||||
.ver_item {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.get_phone_number {
|
||||
position: absolute;
|
||||
right: 0px;
|
||||
color: #999;
|
||||
top: 1rpx;
|
||||
background: rgb(26, 26, 26);
|
||||
border: none;
|
||||
text-align: right;
|
||||
font-size: 28rpx;
|
||||
font-family: PingFangSC-Medium, PingFang SC;
|
||||
}
|
||||
|
||||
.grad {
|
||||
color: rgb(187, 230, 0);
|
||||
}
|
||||
|
||||
.blue {
|
||||
color: rgb(187, 230, 0);
|
||||
}
|
||||
|
||||
.agreement {
|
||||
margin: 50rpx 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
position: absolute;
|
||||
bottom: 8rpx
|
||||
}
|
||||
|
||||
.login-btn {
|
||||
margin-top: 90rpx;
|
||||
background-color: rgb(187, 230, 0);
|
||||
color: rgb(35, 35, 35);
|
||||
border-radius: 50rpx;
|
||||
}
|
||||
|
||||
.login-btn[disabled] {
|
||||
background-color: #ccc;
|
||||
}
|
||||
|
||||
.login-title {
|
||||
text-align: center;
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
padding-top: 20rpx;
|
||||
}
|
||||
|
||||
.gologin {
|
||||
color: rgba(187, 230, 0, 1);
|
||||
}
|
||||
|
||||
.custom-checkbox {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.checkbox-icon {
|
||||
width: 30rpx;
|
||||
height: 30rpx;
|
||||
border: 1px solid rgba(255, 255, 255, 0.87);
|
||||
border-radius: 50rpx;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
|
||||
.checkbox-icon.checked {
|
||||
background-color: #07C160;
|
||||
border-color: #07C160;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.checkbox-label {
|
||||
font-size: 24rpx;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
}
|
||||
|
||||
.agreeT {
|
||||
color: rgb(187, 230, 0);
|
||||
}
|
||||
|
||||
/* 遮罩层 */
|
||||
.agreement-mask {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 999;
|
||||
}
|
||||
|
||||
/* 弹窗主体 */
|
||||
.agreement-popup {
|
||||
width: 80%;
|
||||
background-color: rgba(42, 42, 42);
|
||||
border-radius: 16rpx;
|
||||
padding: 40rpx;
|
||||
box-sizing: border-box;
|
||||
border: 1rpx solid rgba(187, 230, 0, 0.3)
|
||||
}
|
||||
|
||||
/* 标题 */
|
||||
.popup-title {
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
margin-bottom: 30rpx;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
}
|
||||
|
||||
/* 内容文本 */
|
||||
.popup-content {
|
||||
font-size: 30rpx;
|
||||
line-height: 1.6;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
margin-bottom: 50rpx;
|
||||
}
|
||||
|
||||
/* 协议链接 */
|
||||
.protocol-link {
|
||||
color: rgb(187, 230, 0);
|
||||
margin: 0 10rpx;
|
||||
}
|
||||
|
||||
/* 按钮容器 */
|
||||
.popup-buttons {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
/* 通用按钮样式 */
|
||||
.btn {
|
||||
flex: 1;
|
||||
height: 80rpx;
|
||||
line-height: 80rpx;
|
||||
border-radius: 40rpx;
|
||||
font-size: 32rpx;
|
||||
margin: 0 20rpx;
|
||||
}
|
||||
|
||||
/* 不同意按钮 */
|
||||
.disagree {
|
||||
background-color: transparent;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
border: 1px solid rgb(255, 255, 255);
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
/* 同意按钮 */
|
||||
.agree {
|
||||
background-color: rgb(187, 230, 0);
|
||||
color: #232323;
|
||||
border: none;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
</style>
|
||||
@ -157,7 +157,7 @@ export default {
|
||||
const statusRes = await getdeviceSTatus({
|
||||
functionMode: 2,
|
||||
batchId,
|
||||
typeName,
|
||||
typeName:'FunctionAccessBatchStatusRule',
|
||||
deviceImei,
|
||||
interval: 500
|
||||
},
|
||||
|
||||
@ -1,98 +1,98 @@
|
||||
<template>
|
||||
<view class="share">
|
||||
<!-- 内容区域 -->
|
||||
<view class="content">
|
||||
<!-- 分享设备 -->
|
||||
<view class="section" @click="shareDevice">
|
||||
<text class="section-title">分享设备</text>
|
||||
</view>
|
||||
<!-- 分享管理 -->
|
||||
<view class="section" @click="shareManagement">
|
||||
<text class="section-title">分享管理</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
itemInfo:""
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 分享设备
|
||||
shareDevice(){
|
||||
uni.navigateTo({
|
||||
url: '/pages/6170/shareDevices/index',
|
||||
events: {
|
||||
ack: function(data) {}
|
||||
},
|
||||
success: (res) => {
|
||||
res.eventChannel.emit('shareDevice', {
|
||||
data: this.itemInfo,
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
// 分享管理
|
||||
shareManagement(){
|
||||
uni.navigateTo({
|
||||
url: '/pages/6170/shareManagement/index',
|
||||
events: {
|
||||
ack: function(data) {}
|
||||
},
|
||||
success: (res) => {
|
||||
res.eventChannel.emit('shareManagement', {
|
||||
data: this.itemInfo,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
const eventChannel = this.getOpenerEventChannel();
|
||||
// 监听 'shareDevice' 事件,获取传过来的数据
|
||||
eventChannel.on('share', (data) => {
|
||||
console.log(data,'datat');
|
||||
this.itemInfo = data.data;
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.share {
|
||||
padding: 30rpx;
|
||||
background: #121212;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.status-bar {
|
||||
/* 根据实际情况设置状态栏高度 */
|
||||
width: 100%;
|
||||
height: 20px;
|
||||
background-color: #f3f3f3;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 20px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.content {
|
||||
width: 100%;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.section {
|
||||
margin-bottom: 20px;
|
||||
padding:50rpx;
|
||||
border-radius: 16rpx;
|
||||
background: rgba(26, 26, 26, 1);
|
||||
text-align: center;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
width: 100%;
|
||||
}
|
||||
<template>
|
||||
<view class="share">
|
||||
<!-- 内容区域 -->
|
||||
<view class="content">
|
||||
<!-- 分享设备 -->
|
||||
<view class="section" @click="shareDevice">
|
||||
<text class="section-title">分享设备</text>
|
||||
</view>
|
||||
<!-- 分享管理 -->
|
||||
<view class="section" @click="shareManagement">
|
||||
<text class="section-title">分享管理</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
itemInfo:""
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 分享设备
|
||||
shareDevice(){
|
||||
uni.navigateTo({
|
||||
url: '/pages/common/shareDevices/index',
|
||||
events: {
|
||||
ack: function(data) {}
|
||||
},
|
||||
success: (res) => {
|
||||
res.eventChannel.emit('shareDevice', {
|
||||
data: this.itemInfo,
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
// 分享管理
|
||||
shareManagement(){
|
||||
uni.navigateTo({
|
||||
url: '/pages/common/shareManagement/index',
|
||||
events: {
|
||||
ack: function(data) {}
|
||||
},
|
||||
success: (res) => {
|
||||
res.eventChannel.emit('shareManagement', {
|
||||
data: this.itemInfo,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
const eventChannel = this.getOpenerEventChannel();
|
||||
// 监听 'shareDevice' 事件,获取传过来的数据
|
||||
eventChannel.on('share', (data) => {
|
||||
console.log(data,'datat');
|
||||
this.itemInfo = data.data;
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.share {
|
||||
padding: 30rpx;
|
||||
background: #121212;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.status-bar {
|
||||
/* 根据实际情况设置状态栏高度 */
|
||||
width: 100%;
|
||||
height: 20px;
|
||||
background-color: #f3f3f3;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 20px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.content {
|
||||
width: 100%;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.section {
|
||||
margin-bottom: 20px;
|
||||
padding:50rpx;
|
||||
border-radius: 16rpx;
|
||||
background: rgba(26, 26, 26, 1);
|
||||
text-align: center;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
@ -69,6 +69,7 @@
|
||||
deviceShareCode,
|
||||
deviceShareAdd
|
||||
} from '@/api/6170/share.js'
|
||||
import Common from '@/utils/Common.js'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@ -205,6 +206,7 @@
|
||||
deviceId: this.itemInfo.id,
|
||||
permission: selectedPermissions.join(',')
|
||||
})
|
||||
|
||||
if (res.code == 200) {
|
||||
this.shareShow = true
|
||||
uni.hideLoading()
|
||||
@ -227,7 +229,7 @@
|
||||
handleBtn() {
|
||||
this.shareShow = false
|
||||
uni.navigateTo({
|
||||
url: '/pages/6170/allShare/index'
|
||||
url: '/pages/common/allShare/index'
|
||||
})
|
||||
},
|
||||
},
|
||||
@ -237,6 +239,7 @@
|
||||
eventChannel.on('shareDevice', (data) => {
|
||||
console.log(data, 'data1t111');
|
||||
this.itemInfo = data.data;
|
||||
this.permissions=Common.getPermissions(this.itemInfo.persissonType);
|
||||
})
|
||||
}
|
||||
};
|
||||
@ -96,8 +96,10 @@
|
||||
},
|
||||
// 跳转分享详情
|
||||
handleFile(item) {
|
||||
let url = item.detailPageUrl;
|
||||
console.log(item,'item');
|
||||
uni.navigateTo({
|
||||
url: "/pages/6170/deviceControl/index",
|
||||
url: url,
|
||||
success: (res) => {
|
||||
// 页面跳转成功后的回调函数
|
||||
res.eventChannel.emit('detailData', {
|
||||
@ -6,7 +6,7 @@
|
||||
<image src="/static/images/common/logo.png" class="logo"></image>
|
||||
</view>
|
||||
<view class="user-right">
|
||||
<view class="user-title">武汉研创</view>
|
||||
<view class="user-title">武汉星汉</view>
|
||||
<view class="ID">ID:123456</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -27,6 +27,11 @@
|
||||
<text class="title">关于我们</text>
|
||||
<uni-icons type="right" size="25" color="rgba(255, 255, 255, 0.4)" class="uniIcon"></uni-icons>
|
||||
</view>
|
||||
<view class="menu-item" @click="account">
|
||||
<image src="/static/images/common/wm.png" class="icon"></image>
|
||||
<text class="title">账号安全</text>
|
||||
<uni-icons type="right" size="25" color="rgba(255, 255, 255, 0.4)" class="uniIcon"></uni-icons>
|
||||
</view>
|
||||
<view class="btn_footer">
|
||||
<button class="logout" @click="logout">退出登录</button>
|
||||
</view>
|
||||
@ -110,6 +115,12 @@
|
||||
uni.navigateTo({
|
||||
url: '/pages/common/aboutUs/index'
|
||||
})
|
||||
},
|
||||
// 账户安全
|
||||
account(){
|
||||
uni.navigateTo({
|
||||
url: '/pages/common/account/index'
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
BIN
static/fonts/PingFangBold.ttf
Normal file
BIN
static/fonts/PingFangBold.ttf
Normal file
Binary file not shown.
BIN
static/images/common/msg.png
Normal file
BIN
static/images/common/msg.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
@ -1,8 +1,8 @@
|
||||
|
||||
var isReady=false;var onReadyCallbacks=[];
|
||||
var isServiceReady=false;var onServiceReadyCallbacks=[];
|
||||
var __uniConfig = {"pages":["pages/650/HBY650","pages/common/login/index","pages/common/index/index","pages/common/user/index","pages/common/scan/scan","pages/common/qrcode/qrcode","pages/common/send/index","pages/common/userAgreement/index","pages/common/privacyAgreement/index","pages/common/aboutUs/index","pages/6170/deviceControl/index","pages/common/operationVideo/index","pages/common/addvideo/index","pages/common/operatingInstruct/index","pages/common/productDes/index","pages/common/addBLE/addEquip","pages/common/addBLE/LinkBle","pages/6155/deviceDetail","pages/6155/ImgCrop","pages/common/map/index"],"window":{"navigationBarTextStyle":"white","navigationBarTitleText":"uni-app","navigationBarBackgroundColor":"#121212","backgroundColor":"#121212"},"tabBar":{"color":"#fff","selectedColor":"#BBE600","backgroundColor":"#202020","list":[{"pagePath":"pages/common/index/index","text":"我的设备","iconPath":"/static/tabs/device.png","selectedIconPath":"/static/tabs/device-HL.png"},{"pagePath":"pages/common/user/index","text":"我的","iconPath":"/static/tabs/my.png","selectedIconPath":"/static/tabs/my-HL.png"}]},"darkmode":false,"nvueCompiler":"uni-app","nvueStyleCompiler":"uni-app","renderer":"auto","splashscreen":{"alwaysShowBeforeRender":true,"autoclose":false},"appname":"JingQuan","compilerVersion":"4.75","entryPagePath":"pages/650/HBY650","networkTimeout":{"request":60000,"connectSocket":60000,"uploadFile":60000,"downloadFile":60000}};
|
||||
var __uniRoutes = [{"path":"/pages/650/HBY650","meta":{"isQuit":true},"window":{"navigationBarTitleText":"HBY650"}},{"path":"/pages/common/login/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/index/index","meta":{"isQuit":true,"isTabBar":true},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/user/index","meta":{"isQuit":true,"isTabBar":true},"window":{"navigationBarTitleText":"我的"}},{"path":"/pages/common/scan/scan","meta":{},"window":{"navigationBarTitleText":"扫描"}},{"path":"/pages/common/qrcode/qrcode","meta":{},"window":{"navigationBarTitleText":"扫描到的设备"}},{"path":"/pages/common/send/index","meta":{},"window":{"navigationBarTitleText":"发送信息"}},{"path":"/pages/common/userAgreement/index","meta":{},"window":{"navigationBarTitleText":"用户协议"}},{"path":"/pages/common/privacyAgreement/index","meta":{},"window":{"navigationBarTitleText":"隐私协议"}},{"path":"/pages/common/aboutUs/index","meta":{},"window":{"navigationBarTitleText":"关于我们"}},{"path":"/pages/6170/deviceControl/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/operationVideo/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/addvideo/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/operatingInstruct/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/productDes/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/addBLE/addEquip","meta":{},"window":{"navigationBarTitleText":"添加设备"}},{"path":"/pages/common/addBLE/LinkBle","meta":{},"window":{"navigationBarTitleText":"扫描到的设备"}},{"path":"/pages/6155/deviceDetail","meta":{},"window":{"navigationBarTitleText":"HBY 6155"}},{"path":"/pages/6155/ImgCrop","meta":{},"window":{"navigationBarTitleText":"图像裁剪","navigationStyle":"custom","fullscreen":true}},{"path":"/pages/common/map/index","meta":{},"window":{"navigationBarTitleText":"地图"}}];
|
||||
var __uniConfig = {"pages":["pages/common/login/index","pages/common/index/index","pages/common/user/index","pages/common/scan/scan","pages/common/qrcode/qrcode","pages/common/send/index","pages/common/userAgreement/index","pages/common/privacyAgreement/index","pages/common/aboutUs/index","pages/6170/deviceControl/index","pages/6170/callPolice/index","pages/210/deviceControl/index","pages/common/operationVideo/index","pages/common/addvideo/index","pages/common/operatingInstruct/index","pages/common/productDes/index","pages/common/addBLE/addEquip","pages/common/addBLE/LinkBle","pages/6155/deviceDetail","pages/6155/ImgCrop","pages/common/map/index","pages/common/allType/index","pages/6170/allShare/index","pages/6170/share/index","pages/6170/shareDevices/index","pages/6170/shareManagement/index","pages/210/onlineDevice/index","pages/210/addDevice/index","pages/210/historyRecords/index","pages/210/call/index","pages/BlueTooth/ModeSetting/index","pages/BlueTooth/ModeSetting/VideoSend","pages/BlueTooth/ModeSetting/VideoSend_1","pages/BlueTooth/ModeSetting/VideoSend_670","pages/BlueTooth/ModeSetting/HBY650","pages/BlueTooth/ModeSetting/HBY650_1","pages/BlueTooth/ModeSetting/ModeSetting","pages/BlueTooth/ModeSetting/update","pages/BlueTooth/ModeSetting/HBY6155","pages/BlueTooth/ModeSetting/HBY6155V1","pages/BlueTooth/ModeSetting/HBY670V1","pages/670/HBY670","pages/650/HBY650","pages/670/History","pages/BlueTooth/ModeSetting/4877","pages/7305/BJQ7305"],"window":{"navigationBarTextStyle":"white","navigationBarTitleText":"uni-app","navigationBarBackgroundColor":"#121212","backgroundColor":"#121212"},"tabBar":{"color":"#fff","selectedColor":"#BBE600","backgroundColor":"#202020","list":[{"pagePath":"pages/common/index/index","text":"我的设备","iconPath":"/static/tabs/device.png","selectedIconPath":"/static/tabs/device-HL.png"},{"pagePath":"pages/common/user/index","text":"我的","iconPath":"/static/tabs/my.png","selectedIconPath":"/static/tabs/my-HL.png"}]},"darkmode":false,"nvueCompiler":"uni-app","nvueStyleCompiler":"uni-app","renderer":"auto","splashscreen":{"alwaysShowBeforeRender":true,"autoclose":false},"appname":"星汉物联","compilerVersion":"4.75","entryPagePath":"pages/common/login/index","networkTimeout":{"request":60000,"connectSocket":60000,"uploadFile":60000,"downloadFile":60000}};
|
||||
var __uniRoutes = [{"path":"/pages/common/login/index","meta":{"isQuit":true},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/index/index","meta":{"isQuit":true,"isTabBar":true},"window":{"navigationStyle":"custom","enablePullDownRefresh":true}},{"path":"/pages/common/user/index","meta":{"isQuit":true,"isTabBar":true},"window":{"navigationBarTitleText":"我的"}},{"path":"/pages/common/scan/scan","meta":{},"window":{"navigationBarTitleText":"扫描"}},{"path":"/pages/common/qrcode/qrcode","meta":{},"window":{"navigationBarTitleText":"扫描到的设备"}},{"path":"/pages/common/send/index","meta":{},"window":{"navigationBarTitleText":"发送信息","enablePullDownRefresh":true}},{"path":"/pages/common/userAgreement/index","meta":{},"window":{"navigationBarTitleText":"用户协议"}},{"path":"/pages/common/privacyAgreement/index","meta":{},"window":{"navigationBarTitleText":"隐私协议"}},{"path":"/pages/common/aboutUs/index","meta":{},"window":{"navigationBarTitleText":"关于我们"}},{"path":"/pages/6170/deviceControl/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/6170/callPolice/index","meta":{},"window":{"navigationBarTitleText":"报警","enablePullDownRefresh":true}},{"path":"/pages/210/deviceControl/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/operationVideo/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/addvideo/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/operatingInstruct/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/productDes/index","meta":{},"window":{"navigationStyle":"custom"}},{"path":"/pages/common/addBLE/addEquip","meta":{},"window":{"navigationBarTitleText":"扫描设备"}},{"path":"/pages/common/addBLE/LinkBle","meta":{},"window":{"navigationBarTitleText":"绑定设备"}},{"path":"/pages/6155/deviceDetail","meta":{},"window":{"navigationBarTitleText":"HBY 6155"}},{"path":"/pages/6155/ImgCrop","meta":{},"window":{"navigationBarTitleText":"图像裁剪","navigationStyle":"custom","fullscreen":true}},{"path":"/pages/common/map/index","meta":{},"window":{"navigationBarTitleText":"地图"}},{"path":"/pages/common/allType/index","meta":{},"window":{"navigationBarTitleText":"所有类型"}},{"path":"/pages/6170/allShare/index","meta":{},"window":{"navigationBarTitleText":"所有分享"}},{"path":"/pages/6170/share/index","meta":{},"window":{"navigationBarTitleText":"分享"}},{"path":"/pages/6170/shareDevices/index","meta":{},"window":{"navigationBarTitleText":"分享设备"}},{"path":"/pages/6170/shareManagement/index","meta":{},"window":{"navigationBarTitleText":"分享管理"}},{"path":"/pages/210/onlineDevice/index","meta":{},"window":{"navigationBarTitleText":"联机设备"}},{"path":"/pages/210/addDevice/index","meta":{},"window":{"navigationBarTitleText":"添加联机设备"}},{"path":"/pages/210/historyRecords/index","meta":{},"window":{"navigationBarTitleText":"历史记录"}},{"path":"/pages/210/call/index","meta":{},"window":{"navigationBarTitleText":"呼叫"}},{"path":"/pages/BlueTooth/ModeSetting/index","meta":{},"window":{"navigationBarTitleText":"设备类型"}},{"path":"/pages/BlueTooth/ModeSetting/VideoSend","meta":{},"window":{"navigationBarTitleText":"发送视频"}},{"path":"/pages/BlueTooth/ModeSetting/VideoSend_1","meta":{},"window":{"navigationBarTitleText":"发送视频"}},{"path":"/pages/BlueTooth/ModeSetting/VideoSend_670","meta":{},"window":{"navigationBarTitleText":"发送视频"}},{"path":"/pages/BlueTooth/ModeSetting/HBY650","meta":{},"window":{"navigationBarTitleText":"HBY650"}},{"path":"/pages/BlueTooth/ModeSetting/HBY650_1","meta":{},"window":{"navigationBarTitleText":"HBY650"}},{"path":"/pages/BlueTooth/ModeSetting/ModeSetting","meta":{},"window":{"navigationBarTitleText":"7307-0.96TFT"}},{"path":"/pages/BlueTooth/ModeSetting/update","meta":{},"window":{"navigationBarTitleText":"版本更新"}},{"path":"/pages/BlueTooth/ModeSetting/HBY6155","meta":{},"window":{"navigationBarTitleText":"HBY6155"}},{"path":"/pages/BlueTooth/ModeSetting/HBY6155V1","meta":{},"window":{"navigationBarTitleText":"HBY6155_V1"}},{"path":"/pages/BlueTooth/ModeSetting/HBY670V1","meta":{},"window":{"navigationBarTitleText":"HBY670"}},{"path":"/pages/670/HBY670","meta":{},"window":{"navigationBarTitleText":"HBY670","navigationStyle":"custom"}},{"path":"/pages/650/HBY650","meta":{},"window":{"navigationBarTitleText":"HBY650"}},{"path":"/pages/670/History","meta":{},"window":{"navigationBarTitleText":"历史记录"}},{"path":"/pages/BlueTooth/ModeSetting/4877","meta":{},"window":{"navigationBarTitleText":""}},{"path":"/pages/7305/BJQ7305","meta":{},"window":{"navigationBarTitleText":"BJQ7305"}}];
|
||||
__uniConfig.onReady=function(callback){if(__uniConfig.ready){callback()}else{onReadyCallbacks.push(callback)}};Object.defineProperty(__uniConfig,"ready",{get:function(){return isReady},set:function(val){isReady=val;if(!isReady){return}const callbacks=onReadyCallbacks.slice(0);onReadyCallbacks.length=0;callbacks.forEach(function(callback){callback()})}});
|
||||
__uniConfig.onServiceReady=function(callback){if(__uniConfig.serviceReady){callback()}else{onServiceReadyCallbacks.push(callback)}};Object.defineProperty(__uniConfig,"serviceReady",{get:function(){return isServiceReady},set:function(val){isServiceReady=val;if(!isServiceReady){return}const callbacks=onServiceReadyCallbacks.slice(0);onServiceReadyCallbacks.length=0;callbacks.forEach(function(callback){callback()})}});
|
||||
service.register("uni-app-config",{create(a,b,c){if(!__uniConfig.viewport){var d=b.weex.config.env.scale,e=b.weex.config.env.deviceWidth,f=Math.ceil(e/d);Object.assign(__uniConfig,{viewport:f,defaultFontSize:Math.round(f/20)})}return{instance:{__uniConfig:__uniConfig,__uniRoutes:__uniRoutes,global:void 0,window:void 0,document:void 0,frames:void 0,self:void 0,location:void 0,navigator:void 0,localStorage:void 0,history:void 0,Caches:void 0,screen:void 0,alert:void 0,confirm:void 0,prompt:void 0,fetch:void 0,XMLHttpRequest:void 0,WebSocket:void 0,webkit:void 0,print:void 0}}}});
|
||||
|
||||
34438
unpackage/dist/dev/app-plus/app-service.js
vendored
34438
unpackage/dist/dev/app-plus/app-service.js
vendored
File diff suppressed because one or more lines are too long
31124
unpackage/dist/dev/app-plus/app-view.js
vendored
31124
unpackage/dist/dev/app-plus/app-view.js
vendored
File diff suppressed because one or more lines are too long
2
unpackage/dist/dev/app-plus/manifest.json
vendored
2
unpackage/dist/dev/app-plus/manifest.json
vendored
File diff suppressed because one or more lines are too long
@ -1,5 +1,19 @@
|
||||
import receivTool from "@/utils/BleReceive.js"
|
||||
var recei = null;
|
||||
const serviceDic = [ //合作供应商的蓝牙主服务
|
||||
{
|
||||
"serviceId": "0000FFE0-0000-1000-8000-00805F9B34FB",
|
||||
"writeId": "0000FFE1-0000-1000-8000-00805F9B34FB",
|
||||
"notifyId": "0000FFE2-0000-1000-8000-00805F9B34FB"
|
||||
},
|
||||
{
|
||||
"serviceId": "0000AE30-0000-1000-8000-00805F9B34FB",
|
||||
"writeId": "0000AE03-0000-1000-8000-00805F9B34FB",
|
||||
"notifyId": "0000AE02-0000-1000-8000-00805F9B34FB"
|
||||
}
|
||||
|
||||
];
|
||||
|
||||
class BleHelper {
|
||||
constructor() {
|
||||
this.StorageKey = "linkedDevices";
|
||||
@ -26,7 +40,10 @@ class BleHelper {
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
this.linkAllDevices();
|
||||
this.OpenBlue().then(()=>{
|
||||
this.linkAllDevices();
|
||||
});
|
||||
|
||||
}, 10);
|
||||
this.data = {
|
||||
isOpenBlue: false, //蓝牙模块是否开启
|
||||
@ -40,9 +57,9 @@ class BleHelper {
|
||||
onDeviceFound: [], //发现新设备的事件
|
||||
receivDataCallback: [] //接收到数据的事件
|
||||
}
|
||||
this.addReceiveCallback((a,b,c)=>{
|
||||
recei.ReceiveData(a,b,c);
|
||||
}, "BleReceiveData");
|
||||
// this.addReceiveCallback((a, b, c) => {
|
||||
// recei.ReceiveData(a, b, c);
|
||||
// }, "BleReceiveData");
|
||||
this.dic = {
|
||||
errRemarks: [{
|
||||
key: '10000',
|
||||
@ -104,18 +121,51 @@ class BleHelper {
|
||||
}
|
||||
}
|
||||
|
||||
DropDevice(bleId, deviceId) {
|
||||
let flag = false;
|
||||
for (var i = 0; i < this.data.LinkedList.length; i++) {
|
||||
let item = this.data.LinkedList[i];
|
||||
if (bleId) {
|
||||
if (item.deviceId == bleId) {
|
||||
this.data.LinkedList.splice(i, 1);
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
|
||||
} else {
|
||||
if (item.device && item.device.id) {
|
||||
this.data.LinkedList.splice(i, 1);
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (flag) {
|
||||
this.updateCache();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
updateCache() {
|
||||
// console.log("this.StorageKey=", this.StorageKey)
|
||||
uni.setStorageSync(this.StorageKey, this.data.LinkedList);
|
||||
}
|
||||
|
||||
linkAllDevices() {
|
||||
console.log("模块启动时,自动连接已连接过的设备", this.data.LinkedList);
|
||||
// console.log("模块启动时,自动连接已连接过的设备", this.data.LinkedList);
|
||||
|
||||
if (this.data.LinkedList && this.data.LinkedList.length > 0) {
|
||||
for (var i = 0; i < this.data.LinkedList.length; i++) {
|
||||
let device = this.data.LinkedList[i];
|
||||
console.log("自动连接:" + device.deviceId);
|
||||
this.LinkBlue(device.deviceId, device.writeServiceId, device.wirteCharactId, device
|
||||
.notifyCharactId);
|
||||
// console.log("自动连接绑定过的设备:" + device.deviceId);
|
||||
if (device.macAddress && device.device && device.device.id) {
|
||||
this.LinkBlue(device.deviceId, device.writeServiceId, device.wirteCharactId, device
|
||||
.notifyCharactId);
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
console.log("无设备连接");
|
||||
// console.log("无设备连接");
|
||||
}
|
||||
}
|
||||
|
||||
@ -128,7 +178,7 @@ class BleHelper {
|
||||
}
|
||||
|
||||
const currentPage = pages[pages.length - 1];
|
||||
console.log("currentPage=", currentPage.route);
|
||||
// console.log("currentPage=", currentPage.route);
|
||||
return currentPage.route;
|
||||
}
|
||||
|
||||
@ -139,7 +189,7 @@ class BleHelper {
|
||||
key = new Date().getTime();
|
||||
}
|
||||
if (key) {
|
||||
console.log("key=" + key);
|
||||
// console.log("key=" + key);
|
||||
let f = this.cfg.onDeviceFound.findIndex((v) => {
|
||||
return v.key == key;
|
||||
});
|
||||
@ -159,7 +209,7 @@ class BleHelper {
|
||||
let key = currKey ? currKey : this.getCurrentPagePath();
|
||||
|
||||
if (key) {
|
||||
console.log("key=" + key);
|
||||
// console.log("key=" + key);
|
||||
let f = this.cfg.onDeviceFound.findIndex((v) => {
|
||||
return v.key == key;
|
||||
});
|
||||
@ -181,7 +231,7 @@ class BleHelper {
|
||||
key = new Date().getTime();
|
||||
}
|
||||
if (key) {
|
||||
console.log("订阅消息回调,key=" + key);
|
||||
// console.log("订阅消息回调,key=" + key);
|
||||
let f = this.cfg.receivDataCallback.findIndex((v) => {
|
||||
return v.key == key;
|
||||
});
|
||||
@ -202,7 +252,7 @@ class BleHelper {
|
||||
removeReceiveCallback(currKey) {
|
||||
let key = currKey ? currKey : this.getCurrentPagePath();
|
||||
if (key) {
|
||||
console.log("移除消息回调:" + key);
|
||||
// console.log("移除消息回调:" + key);
|
||||
let f = this.cfg.receivDataCallback.findIndex((v) => {
|
||||
return v.key == key;
|
||||
});
|
||||
@ -320,6 +370,7 @@ class BleHelper {
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
if (this.data.available) {
|
||||
console.log("蓝牙模块是可用状态");
|
||||
resolve({
|
||||
available: this.data.available,
|
||||
discovering: this.data.discovering
|
||||
@ -327,6 +378,7 @@ class BleHelper {
|
||||
return;
|
||||
}
|
||||
if (!this.data.isOpenBlue) {
|
||||
console.log("蓝牙模块未打开");
|
||||
resolve({
|
||||
available: false,
|
||||
discovering: false
|
||||
@ -335,12 +387,13 @@ class BleHelper {
|
||||
}
|
||||
uni.getBluetoothAdapterState({
|
||||
success: (info) => {
|
||||
this.data.available=info.available;
|
||||
this.data.discovering=info.discovering;
|
||||
console.log("蓝牙状态获取成功,",info)
|
||||
this.data.available = info.available;
|
||||
this.data.discovering = info.discovering;
|
||||
resolve(info);
|
||||
},
|
||||
fail: (ex1) => {
|
||||
////console.log("ex1", ex1);
|
||||
console.log("蓝牙状态获取失败", ex1);
|
||||
let res1 = {
|
||||
available: false,
|
||||
discovering: false
|
||||
@ -360,18 +413,18 @@ class BleHelper {
|
||||
resolve(false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
uni.openBluetoothAdapter({
|
||||
success: (args) => {
|
||||
console.log("蓝牙初始化成功:" + JSON.stringify(args));
|
||||
// console.log("蓝牙初始化成功:" + JSON.stringify(args));
|
||||
this.data.isOpenBlue = true;
|
||||
this.data.available=true;
|
||||
this.data.available = true;
|
||||
resolve(true);
|
||||
|
||||
if (this.data.isSubscribe) { //整个App生命周期,只订阅一次
|
||||
return;
|
||||
}
|
||||
console.log("开始订阅各类变化消息");
|
||||
// console.log("开始订阅各类变化消息");
|
||||
this.data.isSubscribe = true;
|
||||
|
||||
|
||||
@ -381,23 +434,26 @@ class BleHelper {
|
||||
}
|
||||
|
||||
uni.onBluetoothAdapterStateChange((state) => {
|
||||
console.log('蓝牙状态发生变化:' + JSON.stringify(state));
|
||||
this.data.available = state.available;
|
||||
this.data.discovering = state.discovering;
|
||||
if (this.data.available && this.data
|
||||
.isOpenBlue) { //蓝牙状态再次可用,重连所有设备
|
||||
|
||||
// console.log('蓝牙状态发生变化:' + JSON.stringify(state));
|
||||
if (this.data.available !== state.available) {
|
||||
this.data.available = state.available;
|
||||
this.data.discovering = state.discovering;
|
||||
if (this.data.available && this.data
|
||||
.isOpenBlue) { //蓝牙状态再次可用,重连所有设备
|
||||
this.linkAllDevices();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!state.available) { //蓝牙状态不可用了,将所有设备标记为断开连接
|
||||
this.data.LinkedList.filter((v) => {
|
||||
v.Linked = false;
|
||||
v.notifyState = false;
|
||||
return true;
|
||||
});
|
||||
uni.setStorageSync(this.StorageKey, this.data
|
||||
.LinkedList);
|
||||
|
||||
this.updateCache();
|
||||
}
|
||||
});
|
||||
|
||||
@ -406,7 +462,7 @@ class BleHelper {
|
||||
if (!res.connected) {
|
||||
|
||||
console.log("蓝牙连接已断开", res);
|
||||
this.data.LinkedList.find((v) => {
|
||||
let f=this.data.LinkedList.find((v) => {
|
||||
if (v.deviceId == res.deviceId) {
|
||||
v.Linked = false;
|
||||
v.notifyState = false;
|
||||
@ -414,15 +470,16 @@ class BleHelper {
|
||||
}
|
||||
return false;
|
||||
});
|
||||
uni.setStorageSync(this.StorageKey, this.data
|
||||
.LinkedList);
|
||||
this.updateCache();
|
||||
console.log("尝试5次恢复连接");
|
||||
this.LinkBlue(res.deviceId,f.writeServiceId,f.wirteCharactId,f.notifyCharactId,5)
|
||||
} else {
|
||||
console.log("蓝牙连接已恢复,", res);
|
||||
console.log("蓝牙连接已恢复,", res);
|
||||
}
|
||||
});
|
||||
|
||||
uni.onBluetoothDeviceFound((devices) => {
|
||||
// ////console.log("发现新设备:" + JSON.stringify(devices));
|
||||
console.log("发现新设备:" + JSON.stringify(devices));
|
||||
this.data.searchList = this.data.searchList.concat(
|
||||
devices);
|
||||
if (this.cfg.onDeviceFound) {
|
||||
@ -437,9 +494,9 @@ class BleHelper {
|
||||
|
||||
uni.onBLECharacteristicValueChange((receive) => {
|
||||
//订阅消息
|
||||
console.log("收到订阅消息",receive);
|
||||
let f=this.data.LinkedList.find((v) => {
|
||||
return v.deviceId == receive.deviceId;
|
||||
console.log("收到订阅消息", receive);
|
||||
let f = this.data.LinkedList.find((v) => {
|
||||
return v.deviceId == receive.deviceId;
|
||||
})
|
||||
let dataView = new DataView(receive.value);
|
||||
|
||||
@ -458,24 +515,49 @@ class BleHelper {
|
||||
// 将每个字节转换为对应的字符
|
||||
str += String.fromCharCode(uint8Array[i]);
|
||||
}
|
||||
|
||||
let header = "mac address:";
|
||||
if (str.indexOf(header) == 0) { //650以文本传输mac
|
||||
|
||||
console.log("str=", str);
|
||||
this.data.LinkedList.find((v) => {
|
||||
if (v.deviceId == receive
|
||||
.deviceId) {
|
||||
v.macAddress = str.replace(
|
||||
let macStr = str.replace(
|
||||
header, "");
|
||||
// console.log("收到mac地址:", str)
|
||||
if (macStr.includes(':')) {
|
||||
v.macAddress = macStr;
|
||||
} else {
|
||||
v.macAddress = macStr
|
||||
.replace(
|
||||
/(.{2})/g, '$1:')
|
||||
.slice(0, -1)
|
||||
}
|
||||
str = header + v.macAddress;
|
||||
console.log("收到mac地址:", v
|
||||
.macAddress)
|
||||
}
|
||||
});
|
||||
uni.setStorageSync(this.StorageKey, this.data
|
||||
.LinkedList);
|
||||
this.updateCache();
|
||||
}
|
||||
|
||||
if (str.indexOf('imei:') == 0) {
|
||||
let imei = str.split(':')[1];
|
||||
|
||||
|
||||
this.data.LinkedList.find((v) => {
|
||||
if (v.deviceId == receive
|
||||
.deviceId) {
|
||||
v.imei=imei;
|
||||
}
|
||||
});
|
||||
this.updateCache();
|
||||
|
||||
}
|
||||
|
||||
if (bytes[0] == 0xFC) { //6155以0xFC开头代表mac地址
|
||||
// console.log("收到mac地址:", bytes)
|
||||
console.log("收到mac地址:", bytes)
|
||||
if (bytes.length >= 7) {
|
||||
console.log("hexs=", hexs);
|
||||
let mac = hexs.slice(1, 7).join(":")
|
||||
.toUpperCase();
|
||||
this.data.LinkedList.find((v) => {
|
||||
@ -485,12 +567,12 @@ class BleHelper {
|
||||
// console.log("收到mac地址:", str)
|
||||
}
|
||||
});
|
||||
uni.setStorageSync(this.StorageKey, this
|
||||
.data.LinkedList);
|
||||
this.updateCache();
|
||||
}
|
||||
}
|
||||
console.log("str=", str);
|
||||
} catch (ex) {
|
||||
////console.log("将数据转文本失败", ex);
|
||||
console.log("将数据转文本失败", ex);
|
||||
}
|
||||
let recData = {
|
||||
deviceId: receive.deviceId,
|
||||
@ -500,23 +582,40 @@ class BleHelper {
|
||||
str: str,
|
||||
hexs: hexs
|
||||
};
|
||||
console.log("监听到特征值:" + JSON.stringify(recData));
|
||||
if (this.cfg.receivDataCallback) {
|
||||
// console.log("监听到特征值:" + JSON.stringify(recData));
|
||||
try {
|
||||
if (this.cfg.receivDataCallback) {
|
||||
|
||||
if (this.cfg.receivDataCallback.length > 0) {
|
||||
if (this.cfg.receivDataCallback.length > 0) {
|
||||
|
||||
let path = this.getCurrentPagePath();
|
||||
|
||||
this.cfg.receivDataCallback.forEach((rec) => {
|
||||
let path = this.getCurrentPagePath();
|
||||
console.log("有人订阅消息")
|
||||
this.cfg.receivDataCallback.forEach((
|
||||
rec) => {
|
||||
console.log("有人订阅消息111", )
|
||||
if (rec.callback) {
|
||||
try {
|
||||
rec.callback(recData, f,
|
||||
path, this.cfg
|
||||
.receivDataCallback
|
||||
);
|
||||
} catch (err) {
|
||||
console.log("订阅消息出现异常",
|
||||
err);
|
||||
}
|
||||
|
||||
if (rec.callback) {
|
||||
rec.callback(recData, f, path);
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
} else {
|
||||
console.log("无人订阅消息");
|
||||
}
|
||||
} else {
|
||||
console.log("无人订阅receivDataCallback,不处理数据");
|
||||
}
|
||||
} else {
|
||||
console.log("无人订阅receivDataCallback,不处理数据");
|
||||
} catch (ex) {
|
||||
console.log("ex=", ex);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
@ -582,22 +681,43 @@ class BleHelper {
|
||||
var these = this;
|
||||
//开始搜索
|
||||
var Search = () => {
|
||||
console.log("Search........");
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.startBluetoothDevicesDiscovery({
|
||||
services: [],
|
||||
allowDuplicatesKey: true,
|
||||
success: (res) => {
|
||||
//console.log('开始搜索蓝牙设备成功');
|
||||
resolve(res);
|
||||
//只搜索合作供应商的服务id
|
||||
let serviceIds = serviceDic.map(v => {
|
||||
return v.serviceId
|
||||
});
|
||||
|
||||
},
|
||||
fail: (err) => {
|
||||
console.log(`搜索蓝牙设备失败:`, err);
|
||||
//搜索一个服务id的设备,循环调用
|
||||
let RunSearch = (serviceId) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.startBluetoothDevicesDiscovery({
|
||||
services:serviceId? [serviceId]:[],
|
||||
allowDuplicatesKey: true,
|
||||
success: (res) => {
|
||||
//console.log('开始搜索蓝牙设备成功');
|
||||
resolve(res);
|
||||
|
||||
reject(this.getError(err));
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
console.log(`搜索蓝牙设备失败:`, err);
|
||||
|
||||
reject(this.getError(err));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
|
||||
});
|
||||
|
||||
|
||||
@ -606,13 +726,15 @@ class BleHelper {
|
||||
|
||||
|
||||
return this.OpenBlue().then((res) => {
|
||||
console.log("蓝牙适配器状态", res)
|
||||
// console.log("蓝牙适配器状态", res)
|
||||
|
||||
return Search();
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//停止搜索
|
||||
StopSearch() {
|
||||
return new Promise((resolve, reject) => {
|
||||
@ -656,21 +778,26 @@ class BleHelper {
|
||||
|
||||
//订阅消息
|
||||
subScribe(deviceId, state) {
|
||||
console.log("开始订阅消息");
|
||||
return new Promise((resolve, reject) => {
|
||||
setTimeout(() => {
|
||||
|
||||
let c = this.data.LinkedList.find((v) => {
|
||||
return v.deviceId == deviceId;
|
||||
});
|
||||
|
||||
if (state) {
|
||||
if (c.notifyState) {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
}
|
||||
console.log("c=", c);
|
||||
let startSubScribe = (id, serviceId, characteristicId) => {
|
||||
|
||||
return new Promise((succ, err) => {
|
||||
let startSubScribe = (id, serviceId, characteristicId) => {
|
||||
console.log("serviceId=", serviceId);
|
||||
console.log("characteristicId=", characteristicId);
|
||||
let p1 = new Promise((succ, err) => {
|
||||
|
||||
uni.notifyBLECharacteristicValueChange({
|
||||
deviceId: id,
|
||||
serviceId: serviceId,
|
||||
@ -688,7 +815,10 @@ class BleHelper {
|
||||
v.notifyState = state;
|
||||
}
|
||||
});
|
||||
succ();
|
||||
// console.log("success SubScribe");
|
||||
succ(
|
||||
res
|
||||
); //见了鬼了,有时候执行了succ但promise永远pending了
|
||||
},
|
||||
fail: (ex) => {
|
||||
|
||||
@ -696,40 +826,70 @@ class BleHelper {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
let p2 = new Promise((succ, err) => {
|
||||
setTimeout(() => {
|
||||
err({
|
||||
code: -1
|
||||
});
|
||||
}, 50);
|
||||
});
|
||||
return new Promise((succ, err) => {
|
||||
Promise.race([p1, p2]).then(succ).catch(ex => {
|
||||
if (ex.code == -1) {
|
||||
succ();
|
||||
return;
|
||||
}
|
||||
err(ex);
|
||||
})
|
||||
});
|
||||
|
||||
}
|
||||
let promies = new Array();
|
||||
for (var i = 0; i < c.Characteristics.length; i++) {
|
||||
let item = c.Characteristics[i];
|
||||
let serviceId = item.serviceId;
|
||||
let characteristicId = item.uuid;
|
||||
if (c.Characteristics && c.Characteristics.length) {
|
||||
for (var i = 0; i < c.Characteristics.length; i++) {
|
||||
let item = c.Characteristics[i];
|
||||
let serviceId = item.serviceId;
|
||||
let characteristicId = item.uuid;
|
||||
|
||||
if (item.properties.notify) {
|
||||
promies.push(startSubScribe(deviceId, serviceId, characteristicId));
|
||||
if (item.properties.notify) {
|
||||
promies.push(startSubScribe(deviceId, serviceId, characteristicId));
|
||||
|
||||
}
|
||||
}
|
||||
}else{
|
||||
promies.push(startSubScribe(c.deviceId, c.notifyServiceid, c.notifyCharactId));
|
||||
}
|
||||
if (promies.length > 0) {
|
||||
Promise.allSettled(promies).then((results) => {
|
||||
|
||||
if (promies.length > 0) {
|
||||
|
||||
|
||||
Promise.allSettled(promies).then((results) => {
|
||||
|
||||
results.forEach((result, index) => {
|
||||
if (result.status === "fulfilled") {
|
||||
//console.log(`操作${index + 1}成功:`, result.value);
|
||||
// console.log(`操作${index + 1}成功:`, result.value);
|
||||
} else {
|
||||
// console.log(`操作${index + 1}失败:`, result.reason
|
||||
// .message);
|
||||
// console.log(`操作${index + 1}失败:`, result.reason
|
||||
// .message);
|
||||
}
|
||||
});
|
||||
|
||||
// console.log("订阅消息成功");
|
||||
resolve();
|
||||
}).catch((ex) => {
|
||||
console.log("ex=",ex);
|
||||
reject(ex);
|
||||
}).finally(() => {
|
||||
// console.log("finally")
|
||||
});
|
||||
} else {
|
||||
console.log("没有特征需要订阅");
|
||||
resolve();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}, 20);
|
||||
}, 800);
|
||||
|
||||
});
|
||||
}
|
||||
@ -755,17 +915,44 @@ class BleHelper {
|
||||
v.services = res.services;
|
||||
}
|
||||
});
|
||||
uni.setStorageSync(this.StorageKey,
|
||||
this.data.LinkedList);
|
||||
//this.updateCache();
|
||||
|
||||
var promises = [];
|
||||
let s = null;
|
||||
let se = res.services.find((v) => {
|
||||
return v.uuid.indexOf(targetServiceId) > -1;
|
||||
|
||||
s = serviceDic.find(k => {
|
||||
|
||||
return k.serviceId == v.uuid;
|
||||
})
|
||||
if (s) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
// return v.uuid.indexOf(targetServiceId) > -1;
|
||||
});
|
||||
|
||||
if (se) {
|
||||
promises.push(this.getFeatrus(id, se.uuid, writeCharId,
|
||||
notifyCharId));
|
||||
console.log("合作供应商的",s)
|
||||
this.data.LinkedList.find((v) => {
|
||||
if (v.deviceId == id) {
|
||||
v.writeServiceId = s.serviceId;
|
||||
v.wirteCharactId = s.writeId;
|
||||
v.notifyServiceid = s.serviceId;
|
||||
v.notifyCharactId = s.notifyId;
|
||||
}
|
||||
});
|
||||
this.updateCache();
|
||||
|
||||
//合作供应商的设备,直接订阅消息,不走发现特征了
|
||||
promises.push(this.subScribe(id, true));
|
||||
|
||||
// promises.push(this.getFeatrus(id, se.uuid, writeCharId,
|
||||
// notifyCharId));
|
||||
|
||||
|
||||
} else {
|
||||
console.log("预设的蓝牙服务和特征中找不到");
|
||||
for (var i = 0; i < res.services.length; i++) {
|
||||
let service = res.services[i];
|
||||
promises.push(this.getFeatrus(id, service.uuid,
|
||||
@ -784,13 +971,19 @@ class BleHelper {
|
||||
|
||||
Promise.all(promises)
|
||||
.then(results => {
|
||||
if (!s) {
|
||||
//非指定供应商的设备,走订阅消息
|
||||
return this.subScribe(id, true);
|
||||
} else {
|
||||
//指定供应商的设备已经订阅过了
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
return this.subScribe(id, true);
|
||||
})
|
||||
.then((res) => {
|
||||
console.log('设备连接成功,初始化完成', res);
|
||||
console.log("LinkedList=", this.data
|
||||
console.log('设备连接成功,初始化完成', this.data
|
||||
.LinkedList);
|
||||
|
||||
resolve();
|
||||
})
|
||||
.catch(error => {
|
||||
@ -836,28 +1029,47 @@ class BleHelper {
|
||||
deviceId: id,
|
||||
serviceId: serviceId,
|
||||
success: (res) => {
|
||||
|
||||
console.log("获取到特征:" + JSON.stringify(res));
|
||||
res.characteristics.forEach((v) => {
|
||||
v.serviceId = serviceId;
|
||||
});
|
||||
// res.characteristics.forEach((v) => {
|
||||
// v.serviceId = serviceId;
|
||||
// });
|
||||
|
||||
//写特征
|
||||
let writeChar = res.characteristics.find(char => {
|
||||
return char.uuid.indexOf(writeCharId) > -1
|
||||
let fe = serviceDic.find(v => {
|
||||
return v.serviceId == serviceId && v.writeId == char
|
||||
.uuid;
|
||||
})
|
||||
// return char.uuid.indexOf(writeCharId) > -1
|
||||
if (fe) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
if (!writeChar) {
|
||||
writeChar = res.characteristics.find(char => {
|
||||
return char.properties.write;
|
||||
});
|
||||
}
|
||||
// if (!writeChar) {
|
||||
// writeChar = res.characteristics.find(char => {
|
||||
// return char.properties.write;
|
||||
// });
|
||||
// }
|
||||
//通知特征
|
||||
let notiChar = res.characteristics.find(char => {
|
||||
return char.uuid.indexOf(notifyCharId) > -1;
|
||||
let fe = serviceDic.find(v => {
|
||||
return v.serviceId == serviceId && v.notifyId ==
|
||||
char.uuid;
|
||||
})
|
||||
// return char.uuid.indexOf(writeCharId) > -1
|
||||
if (fe) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
// return char.uuid.indexOf(notifyCharId) > -1;
|
||||
});
|
||||
if (!notiChar) {
|
||||
notiChar = res.characteristics.find(char => {
|
||||
return char.properties.notify;
|
||||
});
|
||||
}
|
||||
// if (!notiChar) {
|
||||
// notiChar = res.characteristics.find(char => {
|
||||
// return char.properties.notify;
|
||||
// });
|
||||
// }
|
||||
this.data.LinkedList.find(function(v) {
|
||||
if (v.deviceId == id) {
|
||||
if (!v.Characteristics) {
|
||||
@ -896,7 +1108,7 @@ class BleHelper {
|
||||
|
||||
|
||||
|
||||
uni.setStorageSync(this.StorageKey, this.data.LinkedList);
|
||||
this.updateCache();
|
||||
resolve(res);
|
||||
},
|
||||
fail: (ex) => {
|
||||
@ -909,9 +1121,11 @@ class BleHelper {
|
||||
}
|
||||
|
||||
//连接某个设备
|
||||
LinkBlue(deviceId, targetServiceId, writeCharId, notifyCharId) {
|
||||
|
||||
LinkBlue(deviceId, targetServiceId, writeCharId, notifyCharId, maxRetries) {
|
||||
|
||||
if (maxRetries === undefined) {
|
||||
maxRetries = 0; // 最大重试次数
|
||||
}
|
||||
if (!writeCharId) {
|
||||
writeCharId = "xxxx"; // "FFE1";
|
||||
}
|
||||
@ -936,74 +1150,95 @@ class BleHelper {
|
||||
|
||||
//连接设备
|
||||
var linkDevice = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
if (fIndex > -1 && f?.Linked) {
|
||||
console.log("当前已连接,跳过其他步骤")
|
||||
resolve(false);
|
||||
return;
|
||||
}
|
||||
if(!this.data.available){
|
||||
reject(this.getError({code:10001}));
|
||||
return;
|
||||
}
|
||||
console.log("正在连接" + deviceId);
|
||||
uni.createBLEConnection({
|
||||
deviceId: deviceId,
|
||||
timeout: 3000,
|
||||
success: (info) => {
|
||||
|
||||
console.log("新连接成功", this.data.LinkedList);
|
||||
this.getLinkBlue().then((arr) => {
|
||||
let cr = arr.devices.find(c => {
|
||||
if (c.deviceId == deviceId) {
|
||||
c.Linked = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
});
|
||||
if (fIndex > -1) {
|
||||
this.data.LinkedList[fIndex].Linked = true;
|
||||
} else {
|
||||
this.data.LinkedList.push(cr);
|
||||
}
|
||||
|
||||
uni.setStorageSync(this.StorageKey, this.data
|
||||
.LinkedList);
|
||||
|
||||
let os = plus.os.name;
|
||||
if (os == 'android') {
|
||||
uni.setBLEMTU({
|
||||
deviceId: deviceId,
|
||||
mtu: 512,
|
||||
success: (mtu) => {
|
||||
|
||||
////console.log("mtu设置成功");
|
||||
},
|
||||
fail: () => {
|
||||
////console.log("mtu设置失败")
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
resolve(true);
|
||||
|
||||
}).catch((ex) => {
|
||||
|
||||
reject(this.getError(ex));
|
||||
});
|
||||
// 添加重试次数限制
|
||||
let retryCount = 0;
|
||||
|
||||
|
||||
},
|
||||
fail: (ex) => {
|
||||
ex = this.getError(ex)
|
||||
console.log("蓝牙连接失败" + JSON.stringify(ex));
|
||||
reject(ex);
|
||||
const connect = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (fIndex > -1 && f?.Linked) {
|
||||
// console.log("当前已连接,跳过其他步骤");
|
||||
resolve(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.data.available) {
|
||||
reject(this.getError({
|
||||
code: 10001
|
||||
}));
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("正在连接" + deviceId);
|
||||
uni.createBLEConnection({
|
||||
deviceId: deviceId,
|
||||
timeout: 30000,
|
||||
success: (info) => {
|
||||
console.log("新连接成功", this.data.LinkedList);
|
||||
this.getLinkBlue().then((arr) => {
|
||||
let cr = arr.devices.find(c => {
|
||||
if (c.deviceId == deviceId) {
|
||||
c.Linked = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
if (fIndex > -1) {
|
||||
this.data.LinkedList[fIndex].Linked = true;
|
||||
} else {
|
||||
this.data.LinkedList.push(cr);
|
||||
}
|
||||
|
||||
this.updateCache();
|
||||
console.log("LinkedList=", this.data
|
||||
.LinkedList);
|
||||
|
||||
// 处理 MTU 设置
|
||||
if (plus.os.name === 'Android') {
|
||||
uni.setBLEMTU({
|
||||
deviceId: deviceId,
|
||||
mtu: 512,
|
||||
success: (mtu) => {
|
||||
|
||||
resolve(true);
|
||||
},
|
||||
fail: () => {
|
||||
console.log("mtu设置失败");
|
||||
resolve(
|
||||
true
|
||||
); // MTU设置失败不影响连接成功
|
||||
}
|
||||
});
|
||||
} else {
|
||||
resolve(true);
|
||||
}
|
||||
}).catch((ex) => {
|
||||
reject(this.getError(ex));
|
||||
});
|
||||
},
|
||||
fail: (ex) => {
|
||||
ex = this.getError(ex);
|
||||
console.log("蓝牙" + deviceId + "连接失败" + JSON.stringify(ex));
|
||||
|
||||
// 连接超时后自动重试
|
||||
if (ex.code === 10012 && retryCount < maxRetries) {
|
||||
retryCount++;
|
||||
console.log(`重试连接 (${retryCount}/${maxRetries})`);
|
||||
// 使用 setTimeout 避免递归调用栈溢出
|
||||
setTimeout(() => {
|
||||
connect().then(resolve).catch(reject);
|
||||
}, 1000); // 延迟1秒后重试
|
||||
} else {
|
||||
reject(ex);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return connect();
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -1013,19 +1248,32 @@ class BleHelper {
|
||||
////console.log("2222222");
|
||||
return linkDevice(deviceId);
|
||||
}).then((res) => {
|
||||
////console.log("11111111");
|
||||
|
||||
if (res) { //新连接
|
||||
// console.log("11111111");
|
||||
if (fIndex == -1) {
|
||||
console.log("开始获取服务", targetServiceId)
|
||||
// console.log("开始获取服务", targetServiceId)
|
||||
return this.getService(deviceId, targetServiceId, writeCharId,
|
||||
notifyCharId); //获取服务
|
||||
notifyCharId); //获取服务
|
||||
} else {
|
||||
if (!f.notifyState) {
|
||||
this.subScribe(deviceId, true);
|
||||
if (f.wirteCharactId && f.notifyCharactId) {
|
||||
if (!f.notifyState) {
|
||||
// console.log("开始订阅特征");
|
||||
this.subScribe(deviceId, true);
|
||||
} else {
|
||||
console.log("不订阅消息");
|
||||
}
|
||||
return Promise.resolve(true);
|
||||
} else {
|
||||
console.log("开始获取服务", targetServiceId)
|
||||
return this.getService(deviceId, targetServiceId, writeCharId,
|
||||
notifyCharId);
|
||||
}
|
||||
return Promise.resolve(true);
|
||||
|
||||
|
||||
}
|
||||
} else { //已连接过,直接订阅消息
|
||||
} else { //已连接过,直接订阅消息
|
||||
// console.log("11111111");
|
||||
if (fIndex > -1 && f && !f.notifyState) {
|
||||
|
||||
this.subScribe(deviceId, true);
|
||||
@ -1034,13 +1282,13 @@ class BleHelper {
|
||||
}
|
||||
|
||||
}).then(() => {
|
||||
|
||||
// console.log("then.....");
|
||||
|
||||
setTimeout(() => {
|
||||
resolve();
|
||||
}, 500);
|
||||
}).catch((ex) => {
|
||||
////console.log("出现异常", ex);
|
||||
console.log("出现异常", ex);
|
||||
reject(ex);
|
||||
});
|
||||
});
|
||||
@ -1156,7 +1404,7 @@ class BleHelper {
|
||||
characteristicId: device.wirteCharactId,
|
||||
value: buffer,
|
||||
success: () => {
|
||||
console.log("发送数据成功");
|
||||
// console.log("发送数据成功");
|
||||
succ();
|
||||
},
|
||||
fail: (ex) => {
|
||||
@ -1181,7 +1429,7 @@ class BleHelper {
|
||||
}
|
||||
|
||||
Promise.race([timeOut(ms), promise]).then(resolve).catch((ex) => {
|
||||
console.log("ex=", ex);
|
||||
// console.log("ex=", ex);
|
||||
if (ex.code == -1) {
|
||||
resolve(ex);
|
||||
} else {
|
||||
@ -1244,7 +1492,7 @@ class BleHelper {
|
||||
let a = pixels[i + 3];
|
||||
|
||||
if (type == 'bgr') {
|
||||
result[index++] = (b >> 3) | ((g & 0xFC) << 3) | ((r & 0xF8) << 8);
|
||||
result[index++] = ((b & 0xF8) << 8) | ((g & 0xFC) << 3) | (r >> 3);
|
||||
} else {
|
||||
result[index++] = ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3);
|
||||
}
|
||||
@ -1254,9 +1502,7 @@ class BleHelper {
|
||||
return result;
|
||||
}
|
||||
|
||||
setBleData() {
|
||||
uni.setStorageSync(this.StorageKey, this.data.LinkedList);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
let instance = null;
|
||||
|
||||
@ -44,30 +44,33 @@ class BleReceive {
|
||||
}
|
||||
|
||||
|
||||
ReceiveData(receive,f,path) {
|
||||
if(f && f.macAddress && f.id){
|
||||
ReceiveData(receive,f,path,recArr) {
|
||||
if(f && f.macAddress && f.device && f.device.id){
|
||||
let data={};
|
||||
if(f.detailPageUrl=='/pages/6155/deviceDetail'){
|
||||
console.log("该设备是6155");
|
||||
data= this.Receive_6155(receive,f,path);
|
||||
if(f.device.detailPageUrl=='/pages/6155/deviceDetail'){
|
||||
// console.log("该设备是6155");
|
||||
data= this.Receive_6155(receive,f,path,recArr);
|
||||
}
|
||||
|
||||
if(f.detailPageUrl=='/pages/650/HBY650'){
|
||||
console.log("该设备是650");
|
||||
data= this.Receive_650(receive,f,path);
|
||||
if(f.device.detailPageUrl=='/pages/650/HBY650'){
|
||||
// console.log("该设备是650");
|
||||
data= this.Receive_650(receive,f,path,recArr);
|
||||
}
|
||||
if(f.detailPageUrl=='/pages/670/HBY670'){
|
||||
console.log("该设备是670");
|
||||
data= this.Receive_670(receive,f,path);
|
||||
if(f.device.detailPageUrl=='/pages/670/HBY670'){
|
||||
// console.log("该设备是670");
|
||||
data= this.Receive_670(receive,f,path,recArr);
|
||||
}
|
||||
console.log("收到数据并处理完毕,",data);
|
||||
// console.log("收到数据并处理完毕,",data);
|
||||
return data;
|
||||
}else{
|
||||
console.log("已收到该消息,但无法处理",receive);
|
||||
}
|
||||
console.log("已收到该消息,但无法处理",f);
|
||||
|
||||
return receive;
|
||||
|
||||
}
|
||||
|
||||
Receive_650(receive,f,path) {
|
||||
Receive_650(receive,f,path,recArr) {
|
||||
console.log("通用程序正在处理650的数据",receive);
|
||||
|
||||
var parseData = () => {
|
||||
@ -93,7 +96,7 @@ class BleReceive {
|
||||
staticLevelText = '低档';
|
||||
modeCurr = "low";
|
||||
break;
|
||||
case 0x68:
|
||||
case 0x64:
|
||||
staticLevelText = '关闭';
|
||||
modeCurr = "close";
|
||||
break;
|
||||
@ -250,14 +253,14 @@ class BleReceive {
|
||||
|
||||
}
|
||||
|
||||
Receive_670(receive,f,path){
|
||||
|
||||
Receive_670(receive,f,path,recArr){
|
||||
console.log("pagh=",path);
|
||||
var todo = (bytes) =>{
|
||||
console.log("todo");
|
||||
// console.log("todo",receive);
|
||||
let receiveData = {};
|
||||
if (bytes[0] == 0x55) {
|
||||
try {
|
||||
console.log("todo");
|
||||
// console.log("todo");
|
||||
// 跳过帧头(第一个字节),从第二个字节开始解析
|
||||
let staticLevelByte = bytes[1];
|
||||
let staticLevelText = '';
|
||||
@ -271,11 +274,11 @@ class BleReceive {
|
||||
case 0x67:
|
||||
staticLevelText = 'low';
|
||||
break
|
||||
case 0x68:
|
||||
case 0x64:
|
||||
staticLevelText = 'close';
|
||||
break
|
||||
}
|
||||
console.log("todo");
|
||||
// console.log("todo");
|
||||
// 解析照明档位
|
||||
let lightingLevelByte = bytes[2];
|
||||
let lightingLevelText = lightingLevelByte === 0x6d ? 'hight': lightingLevelByte === 0x6e ? 'low': 'close';
|
||||
@ -287,7 +290,7 @@ class BleReceive {
|
||||
let batteryLevelByte = bytes[5];
|
||||
|
||||
let batteryLevel = Math.max(0, Math.min(100, batteryLevelByte));
|
||||
console.log("todo");
|
||||
// console.log("todo");
|
||||
let warn = bytes[6];
|
||||
if (warn == 0x00) {
|
||||
warn = 'none';
|
||||
@ -304,7 +307,7 @@ class BleReceive {
|
||||
let staticWarn = bytes[7] == 0x01;//静止报警
|
||||
let fourGStrenth = bytes[8]; //4g信号强度
|
||||
let sosTxt = bytes[9] == 0x00 ? 'close' : bytes[9] == 0x01 ? 'sg' : 'rb';
|
||||
console.log("todo");
|
||||
// console.log("todo");
|
||||
receiveData.modeCurr = staticLevelText;
|
||||
receiveData.lightCurr = lightingLevelText;
|
||||
receiveData.xuhang = lightingTime ;
|
||||
@ -313,10 +316,25 @@ class BleReceive {
|
||||
receiveData.staticWarn = staticWarn;
|
||||
receiveData.fourGStrenth = fourGStrenth;
|
||||
receiveData.SOS=sosTxt;
|
||||
|
||||
this.setBleFormData(receiveData,f);
|
||||
console.log("recArr=",recArr);
|
||||
let recCnt=recArr.find(v=>{
|
||||
return v.key == f.device.detailPageUrl;
|
||||
});
|
||||
if(!recCnt){
|
||||
if (this.formData.staticWarn) { //有静止报警
|
||||
uni.showModal({
|
||||
title:"警告",
|
||||
content:"设备静止报警中",
|
||||
showCancel:false
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch(error) {
|
||||
console.log('数据解析错误:', error);
|
||||
}
|
||||
console.log("todo");
|
||||
// console.log("todo");
|
||||
} else {
|
||||
try {
|
||||
let uint8Array = new Uint8Array(receive.value);
|
||||
@ -340,6 +358,7 @@ class BleReceive {
|
||||
console.log('收到纬度:', +this.receiveData.macAddress);
|
||||
} else {
|
||||
try {
|
||||
// console.log("str=",str);
|
||||
let json=JSON.parse(str);
|
||||
if("staBlue_picture" in json){
|
||||
//重发图片
|
||||
@ -372,7 +391,7 @@ class BleReceive {
|
||||
|
||||
} catch (error) {
|
||||
receiveData={};
|
||||
console.log("文本解析失败")
|
||||
// console.log("文本解析失败",error)
|
||||
}
|
||||
}
|
||||
} catch(ex) {
|
||||
@ -380,7 +399,7 @@ class BleReceive {
|
||||
console.log('将数据转文本失败', ex);
|
||||
}
|
||||
}
|
||||
console.log("todo",receiveData);
|
||||
// console.log("todo",receiveData);
|
||||
this.setBleFormData(receiveData,f);
|
||||
return receiveData;
|
||||
}
|
||||
@ -390,8 +409,81 @@ class BleReceive {
|
||||
|
||||
return data;
|
||||
}
|
||||
Receive_6155() {
|
||||
console.log("通用程序正在处理6155的数据");
|
||||
Receive_6155(receive,f,path,recArr) {
|
||||
let bytes=receive.bytes;
|
||||
if (bytes[0] == 0xFB && bytes[1] == 0x64 && bytes.length >= 8) {
|
||||
try {
|
||||
|
||||
let staticLevelByte = bytes[2];
|
||||
let getName = function(type) {
|
||||
let name = "";
|
||||
switch (type) {
|
||||
case 0x02:
|
||||
name = '弱光';
|
||||
break;
|
||||
case 0x04:
|
||||
name = '工作光';
|
||||
break;
|
||||
case 0x01:
|
||||
name = '强光';
|
||||
break;
|
||||
case 0x03:
|
||||
name = '爆闪';
|
||||
break;
|
||||
case 0x00:
|
||||
name = '关闭';
|
||||
break;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
let staticLevelText = getName(staticLevelByte);
|
||||
|
||||
// 解析照明档位
|
||||
let lightingLevelByte = bytes[3];
|
||||
let lightingLevelText = getName(lightingLevelByte);
|
||||
|
||||
|
||||
// 解析剩余电量
|
||||
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 = staticLevelText;
|
||||
formData.fuMode = lightingLevelText;
|
||||
formData.battary = batteryLevel;
|
||||
formData.statu = warn;
|
||||
formData.xuhang = lightingTime;
|
||||
|
||||
if (batteryLevel <= 20) {
|
||||
uni.showModal({
|
||||
content:"设备电量低",
|
||||
title:"提示"
|
||||
});
|
||||
|
||||
}
|
||||
this.setBleFormData(formData,f);
|
||||
return formData;
|
||||
} catch (error) {
|
||||
console.log('数据解析错误:', error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
440
utils/Common.js
440
utils/Common.js
@ -1,218 +1,284 @@
|
||||
var cfg={
|
||||
Version:'Uat',//Dev:开发环境,Uat:Uat环境,Relese正式环境
|
||||
DevApi:'http://192.168.110.54:8000/',//开发环境
|
||||
UatApi:'http://114.55.111.217/',//UAT环境
|
||||
ReleseApi:'http://relese:3169/api/'//Relese环境
|
||||
}
|
||||
import request from "@/utils/request.js";
|
||||
export default {
|
||||
baseURL : cfg.Version=='Dev'?cfg.DevApi:(cfg.Version=='Uat'?cfg.UatApi:cfg.ReleseApi),
|
||||
guid:function generateUUID() {
|
||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
||||
const r = Math.random() * 16 | 0;
|
||||
const v = c === 'x' ? r : (r & 0x3 | 0x8);
|
||||
return v.toString(16);
|
||||
});
|
||||
},
|
||||
alert: function(title, content, callback) {
|
||||
if(!title){
|
||||
title='提示'
|
||||
}
|
||||
if(!content){
|
||||
content=title;
|
||||
}
|
||||
|
||||
uni.showModal({
|
||||
title: title,
|
||||
content: content,
|
||||
success: function(res) {
|
||||
if (res.confirm) {
|
||||
console.log('用户点击确定');
|
||||
} else if (res.cancel) {
|
||||
console.log('用户点击取消');
|
||||
}
|
||||
|
||||
if (callback) {
|
||||
callback(res);
|
||||
}
|
||||
guid: function generateUUID() {
|
||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
||||
const r = Math.random() * 16 | 0;
|
||||
const v = c === 'x' ? r : (r & 0x3 | 0x8);
|
||||
return v.toString(16);
|
||||
});
|
||||
},
|
||||
alert: function(title, content, callback) {
|
||||
if (!title) {
|
||||
title = '提示'
|
||||
}
|
||||
if (!content) {
|
||||
content = title;
|
||||
}
|
||||
|
||||
uni.showModal({
|
||||
title: title,
|
||||
content: content,
|
||||
success: function(res) {
|
||||
if (res.confirm) {
|
||||
console.log('用户点击确定');
|
||||
} else if (res.cancel) {
|
||||
console.log('用户点击取消');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
showLoading:function(title,mask){
|
||||
uni.showLoading({
|
||||
title:title,
|
||||
mask:mask,
|
||||
})
|
||||
},
|
||||
hideLoading:function(){
|
||||
uni.hideLoading();
|
||||
},
|
||||
showToast:function(title,mask,duration,callback){
|
||||
if(!duration){
|
||||
duration=1500;
|
||||
}
|
||||
if(mask==undefined){
|
||||
mask=false;
|
||||
}
|
||||
uni.showToast({
|
||||
title:title,
|
||||
mask:mask,
|
||||
duration:duration,
|
||||
callback:callback,
|
||||
icon: 'none'
|
||||
})
|
||||
},
|
||||
GetData:function(url,data,method,contentType,succ,err,complete){
|
||||
var these=this;
|
||||
if(!url){
|
||||
console.error("url为空");
|
||||
return;
|
||||
}
|
||||
|
||||
if(url.toLowerCase().indexOf('http://')==-1 || url.toLowerCase().indexOf('https://')==-1){
|
||||
if(url.indexOf('/')==0){
|
||||
url=url.substr(1,url.length-1);
|
||||
|
||||
if (callback) {
|
||||
callback(res);
|
||||
}
|
||||
let ServerPath=these.DevApi;
|
||||
if(these.Version==='Dev'){
|
||||
ServerPath=these.DevApi;
|
||||
}
|
||||
else if(these.Version==='Uat'){
|
||||
ServerPath=these.UatApi;
|
||||
}
|
||||
else if(these.Version==='Relese'){
|
||||
ServerPath=these.ReleseApi;
|
||||
}else{
|
||||
these.DevApi
|
||||
}
|
||||
url=ServerPath+url;
|
||||
}
|
||||
|
||||
var these=this;
|
||||
if(!method){
|
||||
method='POST';
|
||||
});
|
||||
},
|
||||
|
||||
showLoading: function(title, mask) {
|
||||
uni.showLoading({
|
||||
title: title,
|
||||
mask: mask,
|
||||
})
|
||||
},
|
||||
hideLoading: function() {
|
||||
uni.hideLoading();
|
||||
},
|
||||
showToast: function(title, mask, duration, callback) {
|
||||
if (!duration) {
|
||||
duration = 1500;
|
||||
}
|
||||
if (mask == undefined) {
|
||||
mask = false;
|
||||
}
|
||||
uni.showToast({
|
||||
title: title,
|
||||
mask: mask,
|
||||
duration: duration,
|
||||
callback: callback,
|
||||
icon: 'none'
|
||||
})
|
||||
},
|
||||
GetData: function(url, data, method, contentType, succ, err, complete) {
|
||||
var these = this;
|
||||
if (!url) {
|
||||
console.error("url为空");
|
||||
return;
|
||||
}
|
||||
|
||||
if (url.toLowerCase().indexOf('http://') == -1 || url.toLowerCase().indexOf('https://') == -1) {
|
||||
if (url.indexOf('/') == 0) {
|
||||
url = url.substr(1, url.length - 1);
|
||||
}
|
||||
method=method.toUpperCase();
|
||||
|
||||
if(!contentType){
|
||||
contentType='application/json;charset=UTF-8';
|
||||
let ServerPath = these.DevApi;
|
||||
if (these.Version === 'Dev') {
|
||||
ServerPath = these.DevApi;
|
||||
} else if (these.Version === 'Uat') {
|
||||
ServerPath = these.UatApi;
|
||||
} else if (these.Version === 'Relese') {
|
||||
ServerPath = these.ReleseApi;
|
||||
} else {
|
||||
these.DevApi
|
||||
}
|
||||
|
||||
these.checkLAN(
|
||||
|
||||
function(){
|
||||
these.showLoading('请稍候..',true);
|
||||
setTimeout(function(){
|
||||
url = ServerPath + url;
|
||||
}
|
||||
|
||||
var these = this;
|
||||
if (!method) {
|
||||
method = 'POST';
|
||||
}
|
||||
method = method.toUpperCase();
|
||||
|
||||
if (!contentType) {
|
||||
contentType = 'application/json;charset=UTF-8';
|
||||
}
|
||||
|
||||
these.checkLAN(
|
||||
|
||||
function() {
|
||||
these.showLoading('请稍候..', true);
|
||||
setTimeout(function() {
|
||||
uni.request({
|
||||
url:url,
|
||||
data:data,
|
||||
header:{
|
||||
"Content-Type":contentType
|
||||
url: url,
|
||||
data: data,
|
||||
header: {
|
||||
"Content-Type": contentType
|
||||
},
|
||||
method:method,
|
||||
timeout:60000,
|
||||
dataType:'json',
|
||||
success:function(json){
|
||||
|
||||
if(succ){
|
||||
method: method,
|
||||
timeout: 60000,
|
||||
dataType: 'json',
|
||||
success: function(json) {
|
||||
|
||||
if (succ) {
|
||||
succ(json);
|
||||
}
|
||||
},
|
||||
fail:function(ex){
|
||||
|
||||
if(err){
|
||||
fail: function(ex) {
|
||||
|
||||
if (err) {
|
||||
err(ex);
|
||||
}
|
||||
},
|
||||
complete:function(){
|
||||
|
||||
if(complete){
|
||||
complete: function() {
|
||||
|
||||
if (complete) {
|
||||
complete();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
},0);
|
||||
|
||||
|
||||
}, 0);
|
||||
|
||||
}
|
||||
|
||||
,function(){
|
||||
|
||||
,
|
||||
function() {
|
||||
these.showToast('无网络连接');
|
||||
});
|
||||
},
|
||||
checkLAN:function(succ,error){
|
||||
uni.getNetworkType({
|
||||
success: (res) => {
|
||||
const networkType = res.networkType;
|
||||
|
||||
|
||||
// 判断网络是否连接
|
||||
if (networkType === 'none') {
|
||||
},
|
||||
checkLAN: function(succ, error) {
|
||||
uni.getNetworkType({
|
||||
success: (res) => {
|
||||
const networkType = res.networkType;
|
||||
|
||||
|
||||
// 判断网络是否连接
|
||||
if (networkType === 'none') {
|
||||
console.error('无网络连接')
|
||||
if(error){
|
||||
error();
|
||||
}
|
||||
}else{
|
||||
if(succ){
|
||||
if (error) {
|
||||
error();
|
||||
}
|
||||
} else {
|
||||
if (succ) {
|
||||
succ();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('获取网络状态失败:', err);
|
||||
if(error){
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('获取网络状态失败:', err);
|
||||
if (error) {
|
||||
error();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
DateFormat: function(date, format) {
|
||||
if(!date){
|
||||
date=new Date();
|
||||
}
|
||||
if(!format){
|
||||
format='yyyy-MM-dd HH:mm:ss';
|
||||
}
|
||||
// 处理参数默认值
|
||||
if (typeof date === 'string' || typeof date === 'number') {
|
||||
date = new Date(date);
|
||||
}
|
||||
date = date instanceof Date ? date : new Date();
|
||||
format = format || 'yyyy-MM-dd';
|
||||
|
||||
// 检查日期是否有效
|
||||
if (isNaN(date.getTime())) {
|
||||
return 'Invalid Date';
|
||||
}
|
||||
|
||||
// 定义格式化映射
|
||||
const formatMap = {
|
||||
'yyyy': date.getFullYear(),
|
||||
'MM': String(date.getMonth() + 1).padStart(2, '0'),
|
||||
'dd': String(date.getDate()).padStart(2, '0'),
|
||||
'HH': String(date.getHours()).padStart(2, '0'),
|
||||
'mm': String(date.getMinutes()).padStart(2, '0'),
|
||||
'ss': String(date.getSeconds()).padStart(2, '0'),
|
||||
'SSS': String(date.getMilliseconds()).padStart(3, '0'),
|
||||
'M': date.getMonth() + 1,
|
||||
'd': date.getDate(),
|
||||
'H': date.getHours(),
|
||||
'm': date.getMinutes(),
|
||||
's': date.getSeconds(),
|
||||
'S': date.getMilliseconds()
|
||||
};
|
||||
|
||||
// 替换格式字符串中的占位符
|
||||
return format.replace(/(yyyy|MM|dd|HH|mm|ss|SSS|M|d|H|m|s|S)/g, (match) => {
|
||||
return formatMap[match];
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
DateFormat: function(date, format) {
|
||||
if (!date) {
|
||||
date = new Date();
|
||||
}
|
||||
if (!format) {
|
||||
format = 'yyyy-MM-dd HH:mm:ss';
|
||||
}
|
||||
// 处理参数默认值
|
||||
if (typeof date === 'string' || typeof date === 'number') {
|
||||
date = new Date(date);
|
||||
}
|
||||
date = date instanceof Date ? date : new Date();
|
||||
format = format || 'yyyy-MM-dd';
|
||||
|
||||
// 检查日期是否有效
|
||||
if (isNaN(date.getTime())) {
|
||||
return 'Invalid Date';
|
||||
}
|
||||
|
||||
// 定义格式化映射
|
||||
const formatMap = {
|
||||
'yyyy': date.getFullYear(),
|
||||
'MM': String(date.getMonth() + 1).padStart(2, '0'),
|
||||
'dd': String(date.getDate()).padStart(2, '0'),
|
||||
'HH': String(date.getHours()).padStart(2, '0'),
|
||||
'mm': String(date.getMinutes()).padStart(2, '0'),
|
||||
'ss': String(date.getSeconds()).padStart(2, '0'),
|
||||
'SSS': String(date.getMilliseconds()).padStart(3, '0'),
|
||||
'M': date.getMonth() + 1,
|
||||
'd': date.getDate(),
|
||||
'H': date.getHours(),
|
||||
'm': date.getMinutes(),
|
||||
's': date.getSeconds(),
|
||||
'S': date.getMilliseconds()
|
||||
};
|
||||
|
||||
// 替换格式字符串中的占位符
|
||||
return format.replace(/(yyyy|MM|dd|HH|mm|ss|SSS|M|d|H|m|s|S)/g, (match) => {
|
||||
return formatMap[match];
|
||||
});
|
||||
},
|
||||
getdeviceShareId(id) {//获取设备分享信息
|
||||
return request({
|
||||
url: `/app/deviceShare/${id}`,
|
||||
method: 'get',
|
||||
})
|
||||
},
|
||||
getPermissions(type) {
|
||||
if (!type) {
|
||||
type='6170';
|
||||
}
|
||||
let array = [{
|
||||
value: "1",
|
||||
label: "灯光模式",
|
||||
checked: false,
|
||||
type: ['210', '6170', '670']
|
||||
},
|
||||
{
|
||||
value: "2",
|
||||
label: "激光模式",
|
||||
checked: false,
|
||||
type: ['210', '6170']
|
||||
},
|
||||
{
|
||||
value: "3",
|
||||
label: "开机画面",
|
||||
checked: false,
|
||||
type: ['210', '6170', '670']
|
||||
},
|
||||
{
|
||||
value: "4",
|
||||
label: "人员信息登记",
|
||||
checked: false,
|
||||
type: ['210', '6170', '670']
|
||||
},
|
||||
{
|
||||
value: "5",
|
||||
label: "发送信息",
|
||||
checked: false,
|
||||
type: ['210', '6170', '670']
|
||||
},
|
||||
{
|
||||
value: "6",
|
||||
label: "产品信息",
|
||||
checked: false,
|
||||
type: ['210', '6170', '670']
|
||||
}, {
|
||||
value: "41",
|
||||
label: "静电探测",
|
||||
checked: false,
|
||||
type: ['670']
|
||||
}, {
|
||||
value: "42",
|
||||
label: "SOS",
|
||||
checked: false,
|
||||
type: ['670']
|
||||
}
|
||||
]
|
||||
|
||||
let arr=[];
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
let item = array[i];
|
||||
if(!item){
|
||||
continue;
|
||||
}
|
||||
if(!item.type){
|
||||
continue;
|
||||
}
|
||||
let typeContais=item.type.find(v=>{
|
||||
return v.includes(type);
|
||||
});
|
||||
if(typeContais){
|
||||
let json={};
|
||||
Object.assign(json,item);
|
||||
arr.push(json);
|
||||
}
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
}
|
||||
@ -1,44 +1,42 @@
|
||||
// utils/loading.js
|
||||
|
||||
// 显示loading
|
||||
// utils/loading.js
|
||||
|
||||
// 显示loading
|
||||
export const showLoading = (ev,options) => {
|
||||
if(!ev){
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
let defaultTxt="请稍候...";
|
||||
if(!options){
|
||||
options={a:1};
|
||||
options={text:defaultTxt};
|
||||
}
|
||||
if(!options.text && options.title){
|
||||
options.text=options.title;
|
||||
}
|
||||
}
|
||||
if(!options.text){
|
||||
options.text="请稍候...";
|
||||
options.text=defaultTxt;
|
||||
}
|
||||
ev.$refs.loading.show(options);
|
||||
|
||||
|
||||
}
|
||||
|
||||
// 隐藏loading
|
||||
}
|
||||
|
||||
// 隐藏loading
|
||||
export const hideLoading = (ev) => {
|
||||
|
||||
if(!ev){
|
||||
return;
|
||||
}
|
||||
ev.$refs.loading.hide();
|
||||
|
||||
|
||||
}
|
||||
|
||||
// 更新loading配置
|
||||
}
|
||||
ev.$refs.loading.hide();
|
||||
|
||||
|
||||
}
|
||||
|
||||
// 更新loading配置
|
||||
export const updateLoading = (ev,options) => {
|
||||
if(!ev){
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(!options){
|
||||
options={a:1};
|
||||
}
|
||||
ev.$refs.loading.update(options)
|
||||
|
||||
}
|
||||
ev.$refs.loading.update(options)
|
||||
|
||||
}
|
||||
@ -1,7 +1,6 @@
|
||||
// 兼容性补丁:为 Paho MQTT 提供 uni-app 环境下的 WebSocket 实现
|
||||
(function(root) {
|
||||
// 如果未能找到全局对象,则无法应用补丁。
|
||||
console.log("root=",root);
|
||||
if (!root) {
|
||||
console.error("MQTT Polyfill: 未能找到全局对象 (global/window/self 均未定义)。");
|
||||
return;
|
||||
@ -118,20 +117,20 @@
|
||||
*/
|
||||
import Paho from 'paho-mqtt';
|
||||
import allConfigs from '../config/index.js';
|
||||
|
||||
// 根据环境选择正确的配置
|
||||
const env = 'production'; //production //开发of线上 改这里就行
|
||||
const config = allConfigs[env];
|
||||
|
||||
const env = 'production'; //production development
|
||||
const envConfig = allConfigs[env];
|
||||
const mqttProtocol = env === 'production' ? 'wss' : 'ws';
|
||||
const useSSL = env === 'production';
|
||||
class MqttClient {
|
||||
constructor() {
|
||||
this.client = null;
|
||||
this.options = {
|
||||
host: config.MQTT_HOST,
|
||||
port: config.MQTT_PORT,
|
||||
host: envConfig.MQTT_HOST,
|
||||
port: envConfig.MQTT_PORT,
|
||||
clientId: 'mqttjs_' + Math.random().toString(16).substr(2, 8),
|
||||
username: config.MQTT_USERNAME,
|
||||
password: config.MQTT_PASSWORD,
|
||||
username: envConfig.MQTT_USERNAME,
|
||||
password: envConfig.MQTT_PASSWORD,
|
||||
};
|
||||
this.onConnectCallback = null;
|
||||
this.messageCallbacks = new Map();
|
||||
@ -166,18 +165,22 @@ class MqttClient {
|
||||
|
||||
this.client.onMessageArrived = (message) => {
|
||||
const topic = message.destinationName;
|
||||
const payload = message.payloadString;
|
||||
// console.log(`收到消息, 主题: ${topic}, 内容: ${payload}`);
|
||||
const payload = message.payloadString;
|
||||
console.log(`收到消息, 主题: ${topic}, 内容: ${payload}`);
|
||||
const potentialJsons = payload.replace(/}\s*{/g, '}|{').split('|');
|
||||
potentialJsons.forEach(jsonString => {
|
||||
if (jsonString.trim() === '') return;
|
||||
if (this.messageCallbacks.has(topic)) {
|
||||
this.messageCallbacks.get(topic)(jsonString,message);
|
||||
this.messageCallbacks.get(topic)(jsonString, message);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
isConnected() {
|
||||
return this.client && this.client.isConnected();
|
||||
}
|
||||
|
||||
connect(onConnectCallback) {
|
||||
if (this.client && this.client.isConnected()) {
|
||||
console.log('MQTT客户端已连接。');
|
||||
@ -187,16 +190,18 @@ class MqttClient {
|
||||
|
||||
this.manualDisconnect = false;
|
||||
this.onConnectCallback = onConnectCallback;
|
||||
|
||||
console.log(`正在连接MQTT: ${this.options.host}:${this.options.port}/mqtt`);
|
||||
|
||||
console.log(`环境识别,http https:${env}`, {
|
||||
connectUrl: `${mqttProtocol}://${this.options.host}:${this.options.port}/mqtt`,
|
||||
useSSL: useSSL,
|
||||
clientId: this.options.clientId
|
||||
});
|
||||
try {
|
||||
const connectOptions = {
|
||||
timeout: 10, // 增加连接超时时间,应对网络波动
|
||||
keepAliveInterval: 30, // 明确设置心跳间隔为30秒
|
||||
userName: this.options.username,
|
||||
password: this.options.password,
|
||||
useSSL: false,
|
||||
useSSL: useSSL, //http ws https wss开启
|
||||
cleanSession: true,
|
||||
onSuccess: () => {
|
||||
console.log('MQTT连接成功');
|
||||
|
||||
@ -1,17 +1,11 @@
|
||||
import config from '../config/index.js';
|
||||
const env = 'production'; //production development //开发of线上 改这里就行
|
||||
const env = 'development'; //production development //开发of线上 改这里就行
|
||||
const BASE = config[env];
|
||||
const request = (options) => {
|
||||
console.log("options"+JSON.stringify(options),BASE.BASE_URL)
|
||||
return new Promise((resolve, reject) => {
|
||||
// 处理GET请求参数
|
||||
let url =options.url;
|
||||
if(url.indexOf('http://')===0 || url.indexOf('https://')===0){
|
||||
url=url;
|
||||
}else{
|
||||
url=BASE.BASE_URL + url;
|
||||
}
|
||||
|
||||
let url = BASE.BASE_URL + options.url;
|
||||
console.log("url"+url)
|
||||
if (options.method === 'GET' && options.data) {
|
||||
// 使用qs序列化参数
|
||||
@ -28,11 +22,11 @@ const request = (options) => {
|
||||
header: options.header || {},
|
||||
timeout: 30000,
|
||||
success: (res) => {
|
||||
console.log("请求成功",res);
|
||||
// console.log("res=",res);
|
||||
resolve(res.data);
|
||||
},
|
||||
fail: (err) => {
|
||||
console.log("请求失败",err);
|
||||
console.log("ex=",err);
|
||||
reject(err);
|
||||
}
|
||||
};
|
||||
|
||||
179
utils/update.js
179
utils/update.js
@ -1,65 +1,156 @@
|
||||
import request, {
|
||||
baseURL
|
||||
} from '@/utils/request.js'
|
||||
|
||||
/**
|
||||
* 检查并执行wgt热更新
|
||||
* @param {String} updateUrl - 检查更新的接口地址
|
||||
*/
|
||||
function checkAndUpdateWgt(updateUrl) {
|
||||
if(!plus){
|
||||
if (!plus) {
|
||||
return;
|
||||
}
|
||||
// 显示加载提示
|
||||
|
||||
let urls = ['http://114.55.111.217/app/CheckUpdate', 'https://t3v3e2xsjv.by.takin.cc/app/CheckUpdate'];
|
||||
|
||||
|
||||
|
||||
|
||||
// 1. 获取当前应用版本信息
|
||||
plus.runtime.getProperty(plus.runtime.appid, (widgetInfo) => {
|
||||
const currentVersion = widgetInfo.version;
|
||||
console.log("当前版本:" + currentVersion);
|
||||
// 2. 调用后端接口检查是否有更新
|
||||
uni.request({
|
||||
url: updateUrl,
|
||||
method: 'GET',
|
||||
data: {
|
||||
currentVersion: currentVersion,
|
||||
platform: uni.getSystemInfoSync().platform
|
||||
},
|
||||
success: (res) => {
|
||||
uni.hideLoading();
|
||||
console.log("res=", res)
|
||||
if (res.statusCode === 200) {
|
||||
|
||||
const updateInfo = res.data.data;
|
||||
if (!updateInfo.hasUpdate) {
|
||||
return;
|
||||
}
|
||||
// 3. 显示更新提示
|
||||
uni.showModal({
|
||||
title: '检测到更新',
|
||||
content: updateInfo.description || '有新版本可用,是否立即更新?',
|
||||
confirmText: '立即更新',
|
||||
cancelText: '稍后更新',
|
||||
success: (modalRes) => {
|
||||
if (modalRes.confirm) {
|
||||
downloadAndInstallWgt(updateInfo.downloadUrl);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '当前已是最新版本',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
|
||||
|
||||
let callbck = (res) => {
|
||||
uni.hideLoading();
|
||||
// console.log("检查更新成功=", res)
|
||||
if (res.statusCode === 200) {
|
||||
|
||||
const updateInfo = res.data.data;
|
||||
if (!updateInfo.hasUpdate) {
|
||||
return;
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
uni.hideLoading();
|
||||
// 3. 显示更新提示
|
||||
uni.showModal({
|
||||
title: '检测到更新',
|
||||
content: updateInfo.description || '有新版本可用,是否立即更新?',
|
||||
confirmText: '立即更新',
|
||||
cancelText: '稍后更新',
|
||||
success: (modalRes) => {
|
||||
if (modalRes.confirm) {
|
||||
downloadAndInstallWgt(updateInfo.downloadUrl);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '检查更新失败',
|
||||
title: '当前已是最新版本',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
console.error('检查更新失败:', err);
|
||||
}
|
||||
};
|
||||
|
||||
let Update = (url) => {
|
||||
console.log("url=",url);
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.request({
|
||||
url: url,
|
||||
method: 'GET',
|
||||
data: {
|
||||
currentVersion: currentVersion,
|
||||
platform: uni.getSystemInfoSync().platform,
|
||||
appId:"xhyc"
|
||||
},
|
||||
success: (res) => {
|
||||
// console.log("res=>",res)
|
||||
res.type='1';
|
||||
resolve(res);
|
||||
},
|
||||
fail: (err) => {
|
||||
console.log("err=",err);
|
||||
reject(err);
|
||||
},
|
||||
complete:()=>{
|
||||
console.log("complete");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
let Callback1 = (res) => {
|
||||
console.log("检查版本更新:", res);
|
||||
let os = plus.os.name.toLowerCase();
|
||||
if (res.code != 200) {
|
||||
return;
|
||||
}
|
||||
let f = res.data.find(v => {
|
||||
if (v.dictLabel.toLowerCase() == os) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
if (f) {
|
||||
if (f.dictValue == currentVersion) {
|
||||
return;
|
||||
}
|
||||
|
||||
uni.showModal({
|
||||
title: '检测到更新',
|
||||
content: '当前版本“' + currentVersion + '”,发现新版本“' + f.dictValue + '”,是否立即更新?',
|
||||
confirmText: '立即更新',
|
||||
cancelText: '稍后更新',
|
||||
success: (modalRes) => {
|
||||
if (modalRes.confirm) {
|
||||
downloadAndInstallWgt(f.remark);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
let Update1 = () => {
|
||||
return request({
|
||||
url: '/app/auth/version',
|
||||
method: 'get'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
let promises = [];
|
||||
for (var i = 0; i < urls.length; i++) {
|
||||
promises.push(Update(urls[i]));
|
||||
}
|
||||
promises.push(Update1());
|
||||
|
||||
Promise.allSettled(promises).then(results => {
|
||||
let length = results.length;
|
||||
let flag=false;
|
||||
for (var i = 0; i < length; i++) {
|
||||
console.log('results['+i+']=',results[i]);
|
||||
if (results[i].status == 'fulfilled' && results[i].value.type==='1' && !flag ) {
|
||||
flag=true;
|
||||
callbck(results[i].value)
|
||||
|
||||
// break;
|
||||
}
|
||||
|
||||
if(results[i].status == 'fulfilled' && results[i].value.type!=='1' && !flag){
|
||||
flag=true;
|
||||
Callback1(results[i].value);
|
||||
// break;
|
||||
}
|
||||
}
|
||||
if(!flag){
|
||||
console.log("检查更新失败了");
|
||||
}else{
|
||||
console.log("检查更新成功");
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@ -69,8 +160,8 @@ function checkAndUpdateWgt(updateUrl) {
|
||||
*/
|
||||
function downloadAndInstallWgt(wgtUrl) {
|
||||
// 显示下载进度
|
||||
var wating=plus.nativeUI.showWaiting({
|
||||
title:"下载中0%"
|
||||
var wating = plus.nativeUI.showWaiting({
|
||||
title: "下载中0%"
|
||||
});
|
||||
// uni.showLoading({
|
||||
// title: '更新下载中...',
|
||||
@ -143,7 +234,7 @@ function downloadAndInstallWgt(wgtUrl) {
|
||||
// 监听下载进度
|
||||
downloadTask.onProgressUpdate((progress) => {
|
||||
console.log('下载进度: ' + progress.progress + '%');
|
||||
wating.setTitle("下载中"+ progress.progress + '%');
|
||||
wating.setTitle("下载中" + progress.progress + '%');
|
||||
// 可以在这里更新自定义进度条
|
||||
});
|
||||
}
|
||||
|
||||
@ -16,6 +16,11 @@ axios@^1.9.0:
|
||||
form-data "^4.0.0"
|
||||
proxy-from-env "^1.1.0"
|
||||
|
||||
blueimp-md5@^2.19.0:
|
||||
version "2.19.0"
|
||||
resolved "https://registry.npmjs.org/blueimp-md5/-/blueimp-md5-2.19.0.tgz"
|
||||
integrity sha512-DRQrD6gJyy8FbiE4s+bDoXS9hiW3Vbx5uCdwvcCf3zLHL+Iv7LtGHLpr+GZV8rHG8tK766FGYBwRbu8pELTt+w==
|
||||
|
||||
call-bind-apply-helpers@^1.0.1, call-bind-apply-helpers@^1.0.2:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz"
|
||||
|
||||
Reference in New Issue
Block a user