常规小优化
This commit is contained in:
@ -10,7 +10,7 @@
|
||||
<view slot="right">
|
||||
<view class="navbarRight center">
|
||||
<view class="imgContent" :class="{'visibilityHidden':Status.apiType!=item.apiType}"
|
||||
@click.stop="handleRightClick(item,index)" v-for="item,index in Status.navbar.icons">
|
||||
@click.stop="handleRightClick(item,index)" v-for="item,index in Status.navbar.icons">
|
||||
<image class="img" :src="item.src" mode="aspectFit"></image>
|
||||
<view class="baber" v-if="item.math">{{item.math>9?'9+':item.math}}</view>
|
||||
</view>
|
||||
@ -74,8 +74,8 @@
|
||||
|
||||
<view class="slider-container">
|
||||
<slider min="1" max="100" step="1" :disabled="false" :value="formData.liangDu" activeColor="#bbe600"
|
||||
backgroundColor="#00000000" block-size="20" block-color="#ffffffde" @change="sliderChange" @changing="sliderChanging"
|
||||
class="custom-slider" />
|
||||
backgroundColor="#00000000" block-size="20" block-color="#ffffffde" @change="sliderChange"
|
||||
@changing="sliderChanging" class="custom-slider" />
|
||||
|
||||
</view>
|
||||
</view>
|
||||
@ -124,33 +124,33 @@
|
||||
<view class="btnSend fright" v-on:click.stop="sendUsr">发送</view>
|
||||
<view class="clear"></view>
|
||||
<TextToHexV1 class="TextToHex" ref="textToHex" :txts="formData.textLines" :bgColor="'#FFFFFF'"
|
||||
:color="'#000000'" :fontSize="16" />
|
||||
:color="'#000000'" :fontSize="15" />
|
||||
</view>
|
||||
|
||||
<view class="item">
|
||||
<text class="lbl">单位:</text>
|
||||
<input class="value" v-model.trim="formData.textLines[0]" placeholder="请输入单位" maxlength="8"
|
||||
placeholder-class="usrplace" />
|
||||
placeholder-class="usrplace" />
|
||||
</view>
|
||||
<view class="item">
|
||||
<text class="lbl">部门:</text>
|
||||
<input class="value" v-model.trim="formData.textLines[1]" placeholder="请输入姓名" maxlength="8"
|
||||
placeholder-class="usrplace" />
|
||||
placeholder-class="usrplace" />
|
||||
</view>
|
||||
<view class="item">
|
||||
<text class="lbl">姓名:</text>
|
||||
<input class="value" v-model.trim="formData.textLines[2]" placeholder="请输入职位" maxlength="8"
|
||||
placeholder-class="usrplace" />
|
||||
placeholder-class="usrplace" />
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<ProParams :id="device.id"></ProParams>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- 下方菜单 -->
|
||||
<BottomSlideMenuPlus :config="Status.BottomMenu" @close="closeMenu" @itemClick="handleItemClick"
|
||||
@btnClick="btnClick">
|
||||
@btnClick="btnClick">
|
||||
<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>
|
||||
@ -180,14 +180,14 @@
|
||||
} from '@/utils/request.js';
|
||||
|
||||
var pagePath = "/pages/6155/BJQ6155";
|
||||
import {
|
||||
MsgSuccess,
|
||||
MsgError,
|
||||
MsgClose,
|
||||
MsgWarning,
|
||||
showPop,
|
||||
MsgInfo
|
||||
} from '@/utils/MsgPops.js'
|
||||
import {
|
||||
MsgSuccess,
|
||||
MsgError,
|
||||
MsgClose,
|
||||
MsgWarning,
|
||||
showPop,
|
||||
MsgInfo
|
||||
} from '@/utils/MsgPops.js'
|
||||
|
||||
var ble = null;
|
||||
var these = null;
|
||||
@ -343,6 +343,7 @@
|
||||
},
|
||||
onLoad: function() {
|
||||
these = this;
|
||||
this.initWatch();
|
||||
recei = BleReceive.getBleReceive();
|
||||
ble = bleTool.getBleTool();
|
||||
|
||||
@ -400,10 +401,10 @@
|
||||
these.formData.bleStatu = 'connecting';
|
||||
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
|
||||
these.formData.bleStatu = true;
|
||||
}).catch(ex => {
|
||||
these.formData.bleStatu = 'err';
|
||||
MsgError("连接错误:" + ex.msg, "确定", these);
|
||||
});;
|
||||
}).catch(ex => {
|
||||
these.formData.bleStatu = 'err';
|
||||
MsgError("连接错误:" + ex.msg, "确定", these);
|
||||
});;
|
||||
these.setBleFormData();
|
||||
these.getDetail();
|
||||
|
||||
@ -423,10 +424,10 @@
|
||||
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
|
||||
console.log("连接成功")
|
||||
these.formData.bleStatu = true;
|
||||
}).catch(ex => {
|
||||
these.formData.bleStatu = 'err';
|
||||
MsgError("连接错误:" + ex.msg, "确定", these);
|
||||
});;
|
||||
}).catch(ex => {
|
||||
these.formData.bleStatu = 'err';
|
||||
MsgError("连接错误:" + ex.msg, "确定", these);
|
||||
});;
|
||||
}
|
||||
},
|
||||
onBackPress(e) {
|
||||
@ -453,6 +454,19 @@
|
||||
|
||||
},
|
||||
methods: {
|
||||
initWatch() {
|
||||
this.$watch('formData.battary', (newVal, oldVal) => {
|
||||
if (newVal <= 20 && this.formData.statu == 0x00) {
|
||||
this.showPop({
|
||||
message: "设备电量低",
|
||||
iconUrl: "/static/images/common/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
bleStatuToggle() {
|
||||
let f = this.getDevice();
|
||||
if (!f) {
|
||||
@ -473,7 +487,7 @@
|
||||
these.formData.bleStatu = true;
|
||||
}).catch(ex => {
|
||||
these.formData.bleStatu = 'err';
|
||||
MsgError("连接错误:" + ex.msg, "确定", these);
|
||||
MsgError("连接错误:" + ex.msg, "确定", these);
|
||||
});
|
||||
return;
|
||||
}
|
||||
@ -635,7 +649,7 @@
|
||||
updateLoading(these, {
|
||||
text: ex.msg
|
||||
});
|
||||
MsgError("连接错误:" + ex.msg, "确定", these);
|
||||
MsgError("连接错误:" + ex.msg, "确定", these);
|
||||
}).finally(() => {
|
||||
setTimeout(() => {
|
||||
hideLoading(these);
|
||||
@ -690,17 +704,10 @@
|
||||
these.$forceUpdate();
|
||||
// console.log("更新后的电量:", these.formData.battary);
|
||||
|
||||
if (this.formData.battary <= 20) {
|
||||
this.showPop({
|
||||
message: "设备电量低",
|
||||
iconUrl: "/static/images/common/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
|
||||
|
||||
showBleUnConnect() {
|
||||
this.showPop({
|
||||
message: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备",
|
||||
@ -708,7 +715,7 @@
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
buttonText: '去连接',
|
||||
buttonTextColor: '#FFFFFFde',
|
||||
buttonTextColor: '#FFFFFFde',
|
||||
okCallback: function() {
|
||||
// console.log("1111");
|
||||
uni.navigateTo({
|
||||
@ -740,13 +747,13 @@
|
||||
return;
|
||||
}
|
||||
let os = plus.os.name;
|
||||
|
||||
|
||||
// 分包发送图片数据
|
||||
var sendImagePackets = function(ReSendNo) {
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
// 总数据包数
|
||||
let totalPackets = os=='Android'?52:200;
|
||||
let totalPackets = os == 'Android' ? 52 : 200;
|
||||
let currentPacket = 1;
|
||||
|
||||
if (ReSendNo) {
|
||||
@ -779,7 +786,7 @@
|
||||
|
||||
// 计算当前包的数据
|
||||
let packetSize = os == 'Android' ? 250 : 64;
|
||||
|
||||
|
||||
|
||||
// 创建数据包
|
||||
let startIndex = (currentPacket - 1) * packetSize;
|
||||
@ -791,7 +798,7 @@
|
||||
let packetData = these.rgb565Data.slice(startIndex,
|
||||
endIndex);
|
||||
// 构建数据包
|
||||
let bufferSize = packetData.length * 2+5; // 头部5字节 + 数据部分
|
||||
let bufferSize = packetData.length * 2 + 5; // 头部5字节 + 数据部分
|
||||
let buffer = new ArrayBuffer(bufferSize);
|
||||
let dataView = new DataView(buffer);
|
||||
|
||||
@ -799,13 +806,13 @@
|
||||
dataView.setUint8(0, os == 'Android' ? 0x55 : 0x56); // 帧头
|
||||
dataView.setUint8(1, 0x02); // 帧类型:开机画面
|
||||
dataView.setUint8(2, currentPacket); // 包序号
|
||||
dataView.setUint16(3, packetData.length*2,false);
|
||||
|
||||
dataView.setUint16(3, packetData.length * 2, false);
|
||||
|
||||
// 填充数据(每个RGB565值占2字节)
|
||||
for (let i = 0; i < packetData.length; i++) {
|
||||
dataView.setUint16(5 + i * 2, packetData[i], false); // 大端字节序
|
||||
}
|
||||
|
||||
|
||||
//发送数据包
|
||||
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId,
|
||||
10).then(() => {
|
||||
@ -817,7 +824,8 @@
|
||||
})
|
||||
currentPacket++;
|
||||
|
||||
setTimeout(sendNextPacket,os=='Android'? these.inteval:these.inteval/2);
|
||||
setTimeout(sendNextPacket, os == 'Android' ? these
|
||||
.inteval : these.inteval / 2);
|
||||
}).catch(err => {
|
||||
console.log("发送数据包失败了" + JSON.stringify(err));
|
||||
if (err.code == '10007') {
|
||||
@ -865,7 +873,7 @@
|
||||
uni.chooseImage({
|
||||
count: 1,
|
||||
sizeType: ['original', 'compressed'],
|
||||
sourceType: ['album','camera'],
|
||||
sourceType: ['album', 'camera'],
|
||||
success: function(res) {
|
||||
uni.navigateTo({
|
||||
url: "/pages/common/ImgCrop/ImgCrop",
|
||||
@ -878,9 +886,9 @@
|
||||
console.log("data=", data);
|
||||
these.Status.BottomMenu.show = false;
|
||||
these.rgb565Data = Common.convertToRGB565(data.piexls);
|
||||
console.log("1111111111")
|
||||
console.log("1111111111")
|
||||
setTimeout(function() {
|
||||
console.log("1111111111")
|
||||
console.log("1111111111")
|
||||
sendImagePackets().catch(() => {
|
||||
|
||||
});
|
||||
@ -915,8 +923,8 @@ console.log("1111111111")
|
||||
})
|
||||
return;
|
||||
}
|
||||
let os=plus.os.name;
|
||||
// os='Android';
|
||||
let os = plus.os.name;
|
||||
// os='Android';
|
||||
let f = these.getDevice();
|
||||
|
||||
if (!f) {
|
||||
@ -936,7 +944,7 @@ console.log("1111111111")
|
||||
return new Promise((resolve, reject) => {
|
||||
if (f) {
|
||||
// 总数据包数
|
||||
var totalPackets =os=='Android' ? 1536 : 6000; //36;
|
||||
var totalPackets = os == 'Android' ? 1536 : 6000; //36;
|
||||
|
||||
let currentPacket = 1;
|
||||
console.log("发送数据准备中,总共" + totalPackets);
|
||||
@ -949,30 +957,33 @@ console.log("1111111111")
|
||||
const sendNextVideoPacket = () => {
|
||||
// console.log("准备发送一段数据");
|
||||
if (currentPacket > totalPackets) {
|
||||
updateLoading(these,{text:'发送完毕,正在处理'})
|
||||
updateLoading(these, {
|
||||
text: '发送完毕,正在处理'
|
||||
})
|
||||
if (!ReSendNo) {
|
||||
setTimeout(() => {
|
||||
|
||||
ble.sendString(f.deviceId, "transmit complete", f.writeServiceId, f.wirteCharactId, 20)
|
||||
|
||||
ble.sendString(f.deviceId, "transmit complete", f
|
||||
.writeServiceId, f.wirteCharactId, 20)
|
||||
.then(
|
||||
() => {
|
||||
console.log("全部发送完毕")
|
||||
|
||||
|
||||
hideLoading(these);
|
||||
these.showPop({
|
||||
showPop: true,
|
||||
message: "上传成功",
|
||||
iconUrl: "/static/images/common/success.png"
|
||||
});
|
||||
|
||||
|
||||
}).catch((ex) => {
|
||||
console.log("出现异常", ex);
|
||||
});
|
||||
}, os=='Android'?500:15000);
|
||||
}, os == 'Android' ? 500 : 15000);
|
||||
|
||||
}
|
||||
these.Status.BottomMenu.show = false;
|
||||
|
||||
|
||||
these.videoHexArray = null;
|
||||
resolve();
|
||||
|
||||
@ -980,7 +991,7 @@ console.log("1111111111")
|
||||
}
|
||||
|
||||
// 计算当前包的数据
|
||||
let packetSize =os=='Android'? 500:128;
|
||||
let packetSize = os == 'Android' ? 500 : 128;
|
||||
|
||||
|
||||
// 创建数据包
|
||||
@ -996,28 +1007,29 @@ console.log("1111111111")
|
||||
|
||||
// 构建数据包
|
||||
////console.log("packetData.length"+packetData.length);
|
||||
const bufferSize =packetSize+4; // 头部5字节 + 数据部分
|
||||
const bufferSize = packetSize + 4; // 头部5字节 + 数据部分
|
||||
const buffer = new ArrayBuffer(bufferSize);
|
||||
const dataView = new DataView(buffer);
|
||||
|
||||
|
||||
|
||||
|
||||
// 填充头部
|
||||
dataView.setUint8(0, os=='Android'?0x55:0x56); // 帧头
|
||||
dataView.setUint8(0, os == 'Android' ? 0x55 : 0x56); // 帧头
|
||||
dataView.setUint8(1, 0x04); // 帧类型:开机画面
|
||||
dataView.setUint16(2, currentPacket,false); // 包序号
|
||||
|
||||
dataView.setUint16(2, currentPacket, false); // 包序号
|
||||
|
||||
for (let i = 0; i < packetData.length; i++) {
|
||||
dataView.setUint8(4 + i, parseInt(packetData[i],16));
|
||||
dataView.setUint8(4 + i, parseInt(packetData[i], 16));
|
||||
}
|
||||
|
||||
let inteval = os=='Android'? 100:40;
|
||||
let inteval = os == 'Android' ? 100 : 40;
|
||||
|
||||
ble.sendData(f.deviceId, buffer, f.writeServiceId, f
|
||||
.wirteCharactId, 10).then(() => {
|
||||
|
||||
|
||||
updateLoading(these, {
|
||||
text: "正在发送:" +currentPacket+'/'+totalPackets
|
||||
text: "正在发送:" + currentPacket + '/' +
|
||||
totalPackets
|
||||
})
|
||||
|
||||
currentPacket++;
|
||||
@ -1187,7 +1199,7 @@ console.log("1111111111")
|
||||
}).catch((ex1) => {
|
||||
//console.log("出现了异常", ex1)
|
||||
}).finally(() => {
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@ -1753,7 +1765,7 @@ console.log("1111111111")
|
||||
});
|
||||
|
||||
},
|
||||
sliderChanging(evt){
|
||||
sliderChanging(evt) {
|
||||
this.formData.liangDu = evt.detail.value;
|
||||
},
|
||||
sliderChange: function(evt) {
|
||||
@ -1806,8 +1818,8 @@ console.log("1111111111")
|
||||
|
||||
dataView.setUint8(0, 0x55); // 帧头
|
||||
dataView.setUint8(1, 0x07); // 帧类型:亮度调节
|
||||
dataView.setUint8(2, 0x01);
|
||||
dataView.setUint8(3, 0x00);
|
||||
dataView.setUint8(2, 0x01);
|
||||
dataView.setUint8(3, 0x00);
|
||||
dataView.setUint8(4, 0x01); //
|
||||
dataView.setUint8(5, liangDu); // 数据
|
||||
|
||||
@ -2186,7 +2198,7 @@ console.log("1111111111")
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
.slider-container {
|
||||
padding: 0px;
|
||||
|
||||
Reference in New Issue
Block a user