1
0
forked from dyf/APP

尝试解决主分支冲突

This commit is contained in:
liub
2025-09-24 08:35:34 +08:00
50 changed files with 61143 additions and 13869 deletions

View File

@ -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});

View File

@ -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) {
// 发送数据

View File

@ -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;

View File

@ -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;

View File

@ -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();
});

File diff suppressed because it is too large Load Diff

446
pages/670/History.vue Normal file
View 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

File diff suppressed because it is too large Load Diff

View 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>

View 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>

View 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>

View File

@ -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);
});

View File

@ -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 {

View File

@ -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', {

View 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>

View File

@ -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() {
// 组件销毁前移除监听器

View File

@ -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;

View File

@ -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>

View 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>

View File

@ -157,7 +157,7 @@ export default {
const statusRes = await getdeviceSTatus({
functionMode: 2,
batchId,
typeName,
typeName:'FunctionAccessBatchStatusRule',
deviceImei,
interval: 500
},

View File

@ -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>

View File

@ -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);
})
}
};

View File

@ -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', {

View File

@ -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'
})
}
},
}