修改7305人员信息取模组件,文本自动居中

This commit is contained in:
liub
2026-03-19 09:13:48 +08:00
parent ede41f68fd
commit 61f00e1cbf
8 changed files with 405 additions and 222 deletions

View File

@ -75,7 +75,7 @@
<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="sliderChange" class="custom-slider" />
class="custom-slider" />
</view>
</view>
@ -129,17 +129,17 @@
<view class="item">
<text class="lbl">单位</text>
<input class="value" v-model.trim="formData.textLines[0]" placeholder="请输入单位"
<input class="value" v-model.trim="formData.textLines[0]" placeholder="请输入单位" maxlength="8"
placeholder-class="usrplace" />
</view>
<view class="item">
<text class="lbl">部门</text>
<input class="value" v-model.trim="formData.textLines[1]" placeholder="请输入姓名"
<input class="value" v-model.trim="formData.textLines[1]" placeholder="请输入姓名" maxlength="8"
placeholder-class="usrplace" />
</view>
<view class="item">
<text class="lbl">姓名</text>
<input class="value" v-model.trim="formData.textLines[2]" placeholder="请输入职位"
<input class="value" v-model.trim="formData.textLines[2]" placeholder="请输入职位" maxlength="8"
placeholder-class="usrplace" />
</view>
@ -286,7 +286,7 @@
light: null,
bleStatu: ''
},
inteval: 80,
inteval: 150,
device: {
id: "",
deviceName: "",
@ -426,15 +426,15 @@
},
onShow() {
this.Status.pageHide = false;
let f=this.getDevice();
if(f){
these.formData.bleStatu = 'connecting';
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
console.log("连接成功")
these.formData.bleStatu = true;
});
}
let f = this.getDevice();
if (f) {
these.formData.bleStatu = 'connecting';
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
console.log("连接成功")
these.formData.bleStatu = true;
});
}
},
onBackPress(e) {
@ -594,9 +594,9 @@
// return;
// }
if (res.deviceId == these.formData.deviceId) {
if(res.device){
if (res.device) {
these.formData.bleStatu = 'connecting';
}else{
} else {
this.formData.bleStatu = false;
}
setTimeout(() => {
@ -768,14 +768,14 @@
these.showBleUnConnect();
return;
}
let os = plus.os.name;
// 分包发送图片数据
var sendImagePackets = function(ReSendNo) {
return new Promise((resolve, reject) => {
// 总数据包数
let totalPackets = 52;
let totalPackets = os=='Android'?52:200;
let currentPacket = 1;
if (ReSendNo) {
@ -794,19 +794,20 @@
message: "上传成功",
iconUrl: "/static/images/common/success.png",
});
setTimeout(()=>{
ble.sendString(f.deviceId, "transmit complete", f.writeServiceId, f
.wirteCharactId);
},1000);
setTimeout(() => {
ble.sendString(f.deviceId, "transmit complete", f
.writeServiceId, f
.wirteCharactId);
}, 1000);
these.rgb565Data = null;
resolve();
return;
}
// 计算当前包的数据
let packetSize = 250;
let packetSize = os == 'Android' ? 250 : 64;
// if (currentPacket <= 51) {
// packetSize = 250; // 前51个包每个500字节
// } else {
@ -814,77 +815,59 @@
// }
// 创建数据包
const startIndex = (currentPacket - 1) * packetSize;
const endIndex = Math.min(startIndex + packetSize, these.rgb565Data
let startIndex = (currentPacket - 1) * packetSize;
let endIndex = Math.min(startIndex + packetSize, these.rgb565Data
.length);
if (startIndex > endIndex) {
return;
}
const packetData = these.rgb565Data.slice(startIndex,
let packetData = these.rgb565Data.slice(startIndex,
endIndex);
// 构建数据包
const bufferSize = 505; // 5 + packetData.length * 2; // 头部5字节 + 数据部分
const buffer = new ArrayBuffer(bufferSize);
const dataView = new DataView(buffer);
let bufferSize = os == 'Android' ? 505 :133; // 5 + packetData.length * 2; // 头部5字节 + 数据部分
let buffer = new ArrayBuffer(bufferSize);
let dataView = new DataView(buffer);
// 填充头部
dataView.setUint8(0, 0x55); // 帧头
dataView.setUint8(0, os == 'Android' ? 0x55 : 0x56); // 帧头
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, 0xF4);
} else {
dataView.setUint8(3, 0x00);
dataView.setUint8(4, 0x64);
}
dataView.setUint8(2, currentPacket); // 包序号
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); // 大端字节序
}
if (currentPacket > 51) { //第52包补FF
for (var i = 105; i < bufferSize; i++) {
dataView.setUint8(i, 0xFF);
}
}
//发送数据包
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId,
10)
.then(() => {
10).then(() => {
updateLoading(these, {
text: "正在发送:" + currentPacket + "/" +
totalPackets
})
currentPacket++;
updateLoading(these, {
text: "正在发送:" + currentPacket + "/" +
totalPackets
})
currentPacket++;
setTimeout(sendNextPacket,os=='Android'? these.inteval:these.inteval/2);
}).catch(err => {
console.log("发送数据包失败了" + JSON.stringify(err));
if (err.code == '10007') {
setTimeout(sendNextPacket, these.inteval);
}).catch(err => {
console.log("发送数据包失败了" + JSON.stringify(err));
if (err.code == '10007') {
setTimeout(sendNextPacket, these.inteval);
return;
}
these.Status.BottomMenu.show = false;
these.showPop({
message: err.msg,
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
});
hideLoading(these);
these.rgb565Data = null;
reject(err);
return;
}
these.Status.BottomMenu.show = false;
these.showPop({
message: err.msg,
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
});
hideLoading(these);
these.rgb565Data = null;
reject(err);
});
}
if (ReSendNo) {
@ -923,7 +906,7 @@
ImgCutOver: function(data) {
showLoading(these, {
text: "正在发送0/52"
text: "正在发送..."
});
console.log("data=", data);
these.Status.BottomMenu.show = false;
@ -964,6 +947,8 @@
})
return;
}
let os=plus.os.name;
// os='Android';
let f = these.getDevice();
if (!f) {
@ -983,7 +968,7 @@
return new Promise((resolve, reject) => {
if (f) {
// 总数据包数
var totalPackets = 1536; //36;
var totalPackets =os=='Android' ? 1536 : 6000; //36;
let currentPacket = 1;
console.log("发送数据准备中,总共" + totalPackets);
@ -996,27 +981,30 @@
const sendNextVideoPacket = () => {
// console.log("准备发送一段数据");
if (currentPacket > totalPackets) {
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);
});
}, 500);
}, os=='Android'?500:15000);
}
these.Status.BottomMenu.show = false;
hideLoading(these);
these.showPop({
showPop: true,
message: "上传成功",
iconUrl: "/static/images/common/success.png"
});
these.videoHexArray = null;
resolve();
@ -1024,7 +1012,7 @@
}
// 计算当前包的数据
let packetSize = 500;
let packetSize =os=='Android'? 500:128;
// 创建数据包
@ -1040,33 +1028,28 @@
// 构建数据包
////console.log("packetData.length"+packetData.length);
const bufferSize = 504; // 头部5字节 + 数据部分
const bufferSize =packetSize+4; // 头部5字节 + 数据部分
const buffer = new ArrayBuffer(bufferSize);
const dataView = new DataView(buffer);
let sortNo = currentPacket.toString(16).padStart(4, '0');
// 填充头部
dataView.setUint8(0, 0x55); // 帧头
dataView.setUint8(0, os=='Android'?0x55:0x56); // 帧头
dataView.setUint8(1, 0x04); // 帧类型:开机画面
dataView.setUint8(2, '0x' + sortNo.substring(0, 2)); // 包序号
dataView.setUint8(3, '0x' + sortNo.substring(2, 4)); // 包序号
// dataView.setUint8(4, 0x01);
// dataView.setUint8(5, 0xF4);
dataView.setUint16(2, currentPacket,false); // 包序号
for (let i = 0; i < packetData.length; i++) {
dataView.setUint8(4 + i, '0x' + packetData[i]);
dataView.setUint8(4 + i, parseInt(packetData[i],16));
}
let inteval = 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++;
@ -1078,7 +1061,7 @@
if (err.code == '10007') { //遇到这个错误自动重新发送
console.log(err.errMsg + ",发送失败了,正在补偿:" +
currentPacket);
setTimeout(sendNextVideoPacket, inteval);
setTimeout(sendNextVideoPacket, 500);
} else {
these.Status.BottomMenu.show = false;
hideLoading(these);
@ -1192,7 +1175,7 @@
if (res.data) {
these.videoHexArray = res.data;
updateLoading(these, {
text: "正在发送:0/1536"
text: "正在发送..."
});
these.Status.BottomMenu.show = false;
@ -1236,7 +1219,7 @@
}).catch((ex1) => {
//console.log("出现了异常", ex1)
}).finally(() => {
hideLoading(these);
});
}
@ -1592,7 +1575,7 @@
let err = false;
this.formData.textLines.find((txt) => {
if (txt.length === 0 || txt.length > 7) {
if (txt.length === 0 || txt.length > 8) {
console.log("txt=", txt);
err = true;
return true;
@ -1601,7 +1584,7 @@
})
if (err) {
this.showPop({
message: "单位、部门、姓名必须填写且最多7字",
message: "单位、部门、姓名必须填写且最多8字",
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
@ -1656,11 +1639,12 @@
linePixels.push(0x00);
}
linePixels = [0xFA, 0x06, 0x03, i + 1].concat(linePixels);
combinedData.push([0xFA, 0x06, i + 1, 1].concat(linePixels.slice(0, 128)));
combinedData.push([0xFA, 0x06, i + 1, 2].concat(linePixels.slice(128, 256)));
linePixels.push(0xFF)
combinedData.push(linePixels);
}
combinedData.push([0x74, 0x72, 0x61, 0x6E, 0x73, 0x6D, 0x69, 0x74, 0x20, 0x63, 0x6F, 0x6D,
0x70, 0x6C, 0x65, 0x74, 0x65
@ -1712,11 +1696,11 @@
text: '正在发送' + curr + '/' + len
});
curr++;
setTimeout(sendPacket, 150);
setTimeout(sendPacket, 300);
}).catch(err => {
if (err.code == '10007') {
setTimeout(sendPacket, 150);
setTimeout(sendPacket, 300);
} else {
console.log("err:", err);
hideLoading(these);
@ -1750,6 +1734,7 @@
setTimeout(() => {
Promise.allSettled([holdHand(), drawText()]).then(results => {
console.log("results=", results)
if (results[0].status == 'rejected') {
updateLoading(these, {
text: results[0].reason