@ -2,8 +2,7 @@
< view class = "content contentBg" >
< view class = "eq" >
< view class = "leftImg" @click.stop ="previewImg(device.devicePic?device.devicePic:formData.img)" >
< image class = "img" :src = "device.devicePic?device.devicePic:formData.img"
mode = "aspectFit" > < / image >
< image class = "img" :src = "device.devicePic?device.devicePic:formData.img" mode = "aspectFit" > < / image >
< / view >
< view class = "rightTxt" >
< view class = "row" >
@ -28,27 +27,42 @@
< text class = "value" > { { device . deviceName } } < / text >
< / view >
< view class = "item" >
< text class = "lbl" > Mac地址 < / text >
< text class = "value" > { { device . deviceMac } } < / text >
< / view >
< text class = "lbl" > Mac地址 < / text >
< text class = "value" > { { device . deviceMac } } < / text >
< / view >
< view class = "item" >
< text class = "lbl" > 蓝牙名称 < / text >
< text class = "value" > { { device . bluetoothName } } < / text >
< / view >
< / view >
< view class = "item" >
< text class = "lbl" > 蓝牙状态 < / text >
< text class = "value" :class = "formData.bleStatu?'green':'red'" > { { formData . bleStatu ? '已连接' : '未连接' } } < / text >
< / view >
< view class = "item" >
< text class = "lbl" > 信道 : { { formData . sta _Channel } } < / text >
< text class = "value green" @click.stop ="ShowChannelEdit()" > 修改 < / text >
< / view >
< / view >
< view class = "warnnig" :class = "formData.sta_SOSType=='sos'?'':'displayNone'"
@click.stop ="showUnWarn('sos_off')" >
< view class = "warnnig" :class = "formData.sta_SOSType=='sos'?'':'displayNone'" @click.stop ="showUnWarn('sos_off')" >
< view > 设备强制报警中 ! < / view >
< view class = "netContent" >
{ { formData . warnTime } } s
< / view >
< / view >
<!-- < view class = "lamp" >
< view class = "title" >
< text > 信道设置 < / text >
< text > { { formData . sta _Channel } } < / text >
< / view >
< / view >
< view class = "lampMode" >
< slider min = "1" max = "125" step = "1" :disabled = "false" :value = "formData.sta_Channel" activeColor = "#bbe600"
backgroundColor = "#686767" block -size = " 20 " block -color = " # ffffffde " @change ="onChannelChanging"
@changing ="onChannelChanging" class = "custom-slider" / >
< / view > -- >
< view class = "lamp" >
< view class = "title" >
@ -85,25 +99,22 @@
< view class = "lamp" >
< view class = "title" >
< text > 单色配组 < / text >
< view @click.stop ="groupSetting({val:'off'} )" >
< image class = "img" src = "/static/images/common/close.png" mode = "aspectFit" > < / image >
< view class = "checkgroup" @click.stop ="groupCheck( )" >
选择配组
< / view >
< / view >
< / view >
< view class = "lampMode" >
< view class = "mode fleft " v-for = "item,index in dic.gropus"
:class = "{active:formData.sta_GroupType===item.val,marginLeft:index%2==1} "
v -on :click.stop = "groupSetting(item,index)" >
< view class = "leftImg" >
< image class = "img" :class = "formData.sta_GroupType!==item.val?'':'displayNone'"
src = "/static/images/4877/lightt.png" mode = "aspectFit" > < / image >
< image class = "img" :class = "formData.sta_GroupType===item.val?'':'displayNone'" :src = "item.activeImg"
mode = "aspectFit" > < / image >
< / view >
< view class = "rightTxt" >
< text class = "bigTxt" > { { item [ 'text' ] } } < / text >
< view class = "colorContent" >
< view v-for = "item,index in dic.groups" class="item "
:class = "{active:item.id===formData.sta_GroupType,marginNoLeft:index%3===0}"
@click.stop ="groupSetting(item,index)" >
< view class = "polygon" :style = "{backgroundColor:item.hex}" >
< / view >
< view class = "text" > { { item . name } } < / view >
< / view >
< / view >
@ -213,19 +224,16 @@
:iconUrl = "Status.Pop.iconUrl" :message = "Status.Pop.message" :buttonText = "Status.Pop.buttonText"
@buttonClick ="HidePop" :visiblePrompt = "Status.Pop.visiblePrompt" :promptTitle = "Status.Pop.promptTitle"
v-model = "Status.Pop.modelValue" @closePop="closePop" :buttonCancelText="Status.Pop.buttonCancelText"
:showCancel = "Status.Pop.showCancel" @cancelPop ="closePop" / >
:showCancel = "Status.Pop.showCancel" @cancelPop ="closePop" :showSlot = "Status.Pop.showSlot" >
< view v-if = "Status.ShowEditChannel" class="popup-prompt" >
< text class = "popup-prompt-title" > 修改信道 < / text >
< input class = "popup-prompt-input" type = "number" placeholder = "1-125的整数"
placeholder -class = " popup -prompt -input -placeHolder " v-model = "formData.sta_Channel" / >
<!-- 下方菜单 -- >
<!-- < BottomSlideMenuPlus :config = "Status.BottomMenu" @close ="closeMenu" @itemClick ="handleItemClick"
@btnClick ="btnClick" >
< view >
< view class = "addIco" >
< view class = "icoContent center" v -on :click.stop = "checkImgUpload()" >
< image mode = "aspectFit" class = "img" src = "/static/images/6155/DeviceDetail/add.png" > < / image >
< / view >
< / view >
< / view >
< / BottomSlideMenuPlus > -- >
< / MessagePopup >
< global-loading ref = "loading" / >
< / view >
@ -244,18 +252,23 @@
request ,
baseURL
} from '../../utils/request' ;
import {
colors as groupColors
} from '@/api/4877/BJQ4877.js' ;
import usrApi from '@/api/670/HBY670.js'
const pagePath = "/pages/4877/BJQ4877" ;
var ble = null ;
var these = null ;
var recei = null ;
var interval = null ;
var slidTime = null ;
export default {
data ( ) {
return {
Status : {
ShowEditChannel : false ,
pageHide : false ,
Pop : {
showPop : false , //是否显示弹窗
@ -276,6 +289,7 @@
okCallback : null ,
buttonCancelText : '' ,
showCancel : false ,
showSlot : false
} ,
BottomMenu : {
show : false ,
@ -327,13 +341,14 @@
macAddress : '' ,
bleStatu : false ,
sta _SOSType : '' , //sos
sta _GroupType : '' , //配组
sta _GroupType : - 1 , //配组
sta _ArrowType : '' , //箭头方向
warnTime : 0
warnTime : 0 ,
sta _Channel : 80
} ,
dic : {
SOS : [ {
text : '声光 报警' ,
text : 'SOS 报警' ,
val : 'sos' ,
img : '/static/images/4877/sg.png' ,
activeImg : '/static/images/4877/sgActive.png'
@ -345,30 +360,7 @@
activeImg : '/static/images/4877/fanActive.png'
}
] ,
grop us : [ {
text : '红配组' ,
val : 'red_group' ,
img : '/static/images/4877/light.png' ,
activeImg : '/static/images/4877/lightActive.png'
} ,
{
text : '蓝配组' ,
val : 'blue_group' ,
img : '/static/images/4877/light.png' ,
activeImg : '/static/images/4877/lightActive.png'
} ,
{
text : '绿配组' ,
val : 'green_group' ,
img : '/static/images/4877/light.png' ,
activeImg : '/static/images/4877/lightActive.png'
} ,
{
text : '黄配组' ,
val : 'yellow_group' ,
img : '/static/images/4877/light.png' ,
activeImg : '/static/images/4877/lightActive.png'
}
group s : [
]
} ,
@ -397,11 +389,14 @@
onUnload ( ) {
console . log ( "页面卸载,释放资源" ) ;
ble . removeAllCallback ( pagePath ) ;
clearInterval ( interval ) ;
} ,
onLoad : function ( ) {
these = this ;
recei = BleReceive . getBleReceive ( ) ;
ble = BleTool . getBleTool ( ) ;
this . dic . gropus = [ ] ;
ble . addReceiveCallback ( this . bleValueNotify , pagePath ) ;
@ -415,7 +410,23 @@
eventChannel . on ( 'detailData' , function ( data ) {
// console.log("收到父页面的参数:" + JSON.stringify(data));
console. log ( "收到父页面的参数:" + JSON . stringify ( data ) ) ;
let checkIds = uni . getStorageSync ( "4877CheckColor_" + data . data . id ) ;
if ( checkIds && checkIds . length ) {
let groups = groupColors . filter ( v => {
let filt = checkIds . find ( id => {
return id === v . id ;
} ) ;
if ( filt ) {
return true ;
}
return false ;
} ) ;
these . dic . groups = groups ;
}
var device = data . data ;
these . device = device ;
let f = ble . data . LinkedList . find ( ( v ) => {
@ -443,7 +454,7 @@
}
these . formData . blename = f . name ? f . name : "Unname" ;
these . formData . deviceName = device . deviceName ;
these . formData . bleStatu = false ;
these . formData . deviceId = f . deviceId ;
ble . LinkBlue ( f . deviceId , f . writeServiceId , f . wirteCharactId , f . notifyCharactId ) . then ( res => {
@ -466,7 +477,71 @@
} ,
methods : {
ShowChannelEdit ( ) {
this . Status . ShowEditChannel = true ;
this . showPop ( {
showPop : true , //是否显示弹窗
popType : 'custom' ,
bgColor : '#383934bd' ,
borderColor : '#BBE600' ,
textColor : '#ffffffde' ,
buttonBgColor : '#BBE600' ,
buttonTextColor : '#232323DE' ,
iconUrl : '' ,
message : '' ,
buttonText : '确定' ,
clickEvt : '' ,
visiblePrompt : false ,
promptTitle : '' ,
modelValue : '' ,
visibleClose : false ,
okCallback : ( ) => {
this . onChannelChanging ( ) ;
this . Status . ShowEditChannel = false ;
} ,
showSlot : true ,
buttonCancelText : '取消' ,
showCancel : true ,
cancelCallback : ( ) => {
this . Status . ShowEditChannel = false ;
}
} ) ;
} ,
onChannelChanging ( ) {
let regex = /^(0|([1-9]\d?)|1[01]\d|12[0-5])$/ ;
if ( ! regex . test ( this . formData . sta _Channel ) ) {
this . showMsg ( "只能输入0-125整数" ) ;
return ;
}
let f = this . getDevice ( ) ;
if ( ! f ) {
this . showBleUnConnect ( ) ;
return ;
}
clearTimeout ( slidTime ) ;
slidTime = setTimeout ( ( ) => {
console . log ( "11111" ) ;
let json = {
ins _channel : this . formData . sta _Channel
}
json = JSON . stringify ( json ) ;
ble . sendString ( f . deviceId , json , f . writeServiceId , f . wirteCharactId , 30 ) . then ( res => {
console . log ( "发送成功" ) ;
this . setBleFormData ( ) ;
} ) . catch ( ex => {
this . showMsg ( ex . msg ) ;
} ) ;
} , 200 )
} ,
ArrowSet ( val ) {
if ( this . formData . sta _SOSType === 'sos' ) {
this . showMsg ( "设备强制报警中,请先关闭报警" )
return ;
}
let f = this . getDevice ( ) ;
if ( ! f ) {
this . showBleUnConnect ( ) ;
@ -486,27 +561,54 @@
this . showMsg ( ex . msg ) ;
} ) ;
} ,
groupSetting ( item , index ) {
groupCheck ( ) {
uni . navigateTo ( {
url : '/pages/4877/BJQ4877CheckColor' ,
events : {
CheckGroupOver : function ( data ) {
debugger ;
let arr = groupColors . filter ( v => {
let f = data . checkIds . find ( item => {
return item === v . id ;
} )
if ( f ) {
return true ;
}
return false ;
} ) ;
these . dic . groups = arr ;
these . CheckGroupOver ( data . allFlag ) ;
}
} ,
success ( res ) {
res . eventChannel . emit ( "CheckGroup" , these . device )
}
} ) ;
} ,
CheckGroupOver ( arr ) { //选择了某些配组
debugger ;
let f = this . getDevice ( ) ;
if ( ! f ) {
this . showBleUnConnect ( ) ;
return ;
}
if ( this . formData . sta _GroupType === item . val ) {
this . formData . sta _GroupType = '' ;
} else {
this . formData . sta _GroupType = item . val ;
}
var json = {
ins _GroupType : this . formData . sta _GroupType
ins _GroupType : arr
}
json = JSON . stringify ( json ) ;
ble . sendString ( f . deviceId , json , f . writeServiceId , f . wirteCharactId , 30 )
. catch ( ex => {
this . showMsg ( ex . msg ) ;
} ) ;
ble . sendString ( f . deviceId , json , f . writeServiceId , f . wirteCharactId , 30 ) . then ( res => {
} ) . catch ( ex => {
this . showMsg ( ex . msg ) ;
} ) ;
} ,
showUnWarn ( val ) {
this . showPop ( {
message : '确定解除声光报警模式?' ,
@ -526,28 +628,57 @@
} ) ;
} ,
sos Setting( item , index ) {
group Setting( item , index ) {
if ( this . formData . sta _SOSType === 'sos' ) {
this . showMsg ( "设备强制报警中,请先关闭报警" )
return ;
}
if ( this . formData . sta _GroupType === item . id ) {
return ;
}
let f = this . getDevice ( ) ;
if ( ! f ) {
this . showBleUnConnect ( ) ;
return ;
}
let groupSet = ( ) => {
setTimeout ( ( ) => {
let buffer = {
ins _statusType : [ item . id ]
}
buffer = JSON . stringify ( buffer ) ;
console . error ( "发送命令:" , buffer ) ;
ble . sendString ( f . deviceId , buffer , f . writeServiceId , f . wirteCharactId , 30 ) . then (
result => {
this . formData . sta _GroupType = item . id ;
this . formData . sta _SOSType = 'sos_off'
console . log ( "配组设置成功" ) ;
} ) ;
} , 0 ) ;
}
groupSet ( ) ;
} ,
sosSetting ( item , index ) {
let f = this . getDevice ( ) ;
if ( ! f ) {
this . showBleUnConnect ( ) ;
return ;
}
let task = ( ) => {
var json = {
ins _SOSType : this . formData . sta _SOSType == item . val ? 'sos_off' : item . val
}
json = JSON . stringify ( json ) ;
console . error ( "发送指令:" , json ) ;
// let f={deviceId:'111111'}
ble . sendString ( f . deviceId , json , f . writeServiceId , f . wirteCharactId , 30 ) . then ( res => {
if ( this. formData . sta _SOSType === item . val ) {
this . formData . sta _SOSType = 'sos_off' ;
} else {
this . formData . sta _SOSType = item . val ;
}
this . formData . sta _GroupType = - 1 ;
this . formData . sta _SOSType = json . ins _SOSType
if ( this . formData . sta _SOSType == 'sos' ) {
this . formData . warnTime = 0 ;
clearInterval ( interval ) ;
@ -560,25 +691,32 @@
} )
. catch ( ex => {
this . showMsg ( ex . msg ) ;
} ) ;
}
if ( item . val === 'sos' ) {
this . showPop ( {
message : '确定开启 声光报警模式?' ,
message : '确定' + ( this . formData . sta _SOSType === 'sos' ? '关闭' : '开启' ) + ' 声光报警模式?' ,
iconUrl : "/static/images/6155/DeviceDetail/uploadErr.png" ,
borderColor : "#e034344d" ,
buttonBgColor : "#E03434" ,
okCallback : task ,
buttonText : "开启" ,
buttonText : ( this . formData . sta _SOSType === 'sos' ? '关闭' : '开启' ) ,
showCancel : true ,
buttonCancelText : '取消'
} ) ;
} else if ( item . val === 'sos_off' ) {
task ( ) ;
} else {
if ( index !== undefined && this . formData . sta _SOSType == 'sos' ) {
this . showUnWarn ( item . val ) ;
if ( this . formData . sta _SOSType === 'sos' ) {
this . showMsg ( "设备强制报警中,请先关闭报警" ) ;
return ;
} else {
task ( ) ;
}
}
@ -753,7 +891,7 @@
return false ;
} ) ;
uni . setStorageSync ( ble . StorageKey , ble . data . LinkedList ) ;
ble . updateCache ( ) ;
} ,
showBleUnConnect ( ) {
@ -1345,7 +1483,7 @@
border - radius : 16 rpx ;
background : rgba ( 26 , 26 , 26 , 1 ) ;
width : 100 % ;
padding : 3 0rpx 0 rpx ;
padding : 1 0rpx 0 rpx ;
}
. modeSetting {
@ -1381,8 +1519,8 @@
}
. modeSetting . arrow . outCircle {
width : 15 0 rpx ;
height : 15 0 rpx ;
width : 12 0 rpx ;
height : 12 0 rpx ;
box - sizing : border - box ;
display : flex ;
flex - direction : row ;
@ -1593,4 +1731,124 @@
justify - content : space - between ;
align - items : center ;
}
. checkgroup {
color : rgba ( 174 , 214 , 0 , 1 ) ;
font - family : PingFang SC ;
font - size : 28 rpx ;
font - weight : 400 ;
letter - spacing : 0.14 px ;
text - align : left ;
}
. colorContent {
display : flex ;
align - content : center ;
justify - content : flex - start ;
justify - items : center ;
flex - direction : row ;
flex - wrap : wrap ;
align - items : center ;
width : 100 % ;
box - sizing : border - box ;
}
. colorContent . polygon {
width : 40 rpx ;
height : 40 rpx ;
border - radius : 8 rpx ;
}
. colorContent . text {
color : rgba ( 255 , 255 , 255 , 0.87 ) ;
font - family : PingFang SC ;
font - size : 30 rpx ;
font - weight : 400 ;
letter - spacing : 2 rpx ;
margin - left : 15 rpx ;
}
. colorContent . item {
background - color : # 1 A1A1A ;
margin - left : 36 rpx ;
width : calc ( calc ( 100 % - 72 rpx ) / 3 ) ;
height : 110 rpx ;
margin - top : 24 rpx ;
box - sizing : border - box ;
padding - left : 25 rpx ;
display : flex ;
flex - direction : row ;
flex - wrap : nowrap ;
justify - content : flex - start ;
align - items : center ;
align - content : center ;
border - width : 1 rpx ;
border - style : solid ;
border - color : # 00000000 ;
border - radius : 8 rpx ;
}
. colorContent . item . active {
border - color : # AED600 ! important ;
}
. colorContent . marginNoLeft {
margin - left : 0 rpx ! important ;
}
. popup - prompt {
width : 100 % ;
box - sizing : border - box ;
padding : 30 rpx 15 % ;
}
. popup - prompt - title {
text - align : center ;
width : 100 % ;
float : left ;
box - sizing : border - box ;
white - space : nowrap ;
color : rgba ( 255 , 255 , 255 , 0.87 ) ;
font - family : PingFang SC ;
font - size : 28 rpx ;
font - weight : 400 ;
line - height : 40 rpx ;
letter - spacing : 0.14 rpx ;
}
. popup - prompt - input {
width : 100 % ;
height : 60 rpx ;
line - height : 60 rpx ;
color : rgba ( 255 , 255 , 255 , 0.87 ) ;
box - sizing : border - box ;
border - bottom : 2 rpx solid rgba ( 255 , 255 , 255 , 0.4 ) ;
font - size : 28 rpx ;
font - weight : 400 ;
letter - spacing : 0.14 px ;
}
. popup - prompt - input - placeHolder {
color : rgba ( 255 , 255 , 255 , 0.4 ) ;
font - family : PingFang SC ;
font - size : 28 rpx ;
font - weight : 400 ;
letter - spacing : 0.14 px ;
text - align : center ;
}
< / style >