1
0
forked from dyf/APP

封装发送照片、视频、文字,各设备调用公共模块

This commit is contained in:
liub
2026-04-24 17:28:56 +08:00
parent 5128c29d86
commit 677586e51c
11 changed files with 961 additions and 1417 deletions

View File

@ -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>
@ -95,13 +95,13 @@
<view class="lampMode">
<view class="mode fleft " v-for="item,index in dic.SOS"
:class="{active:formData.sta_SOSType===item.val,marginLeft:index%2==1}"
v-on:click.stop="sosSetting(item,index)">
:class="{active:formData.sta_SOSType===item.val,marginLeft:index%2==1}"
v-on:click.stop="sosSetting(item,index)">
<view class="leftImg">
<image class="img" :class="(formData.sta_SOSType!==item.val || !item.activeImg)?'':'displayNone'"
:src="item.img" mode="aspectFit"></image>
:src="item.img" mode="aspectFit"></image>
<image class="img" :class="(formData.sta_SOSType===item.val && item.activeImg)?'':'displayNone'"
:src="item.activeImg" mode="aspectFit"></image>
:src="item.activeImg" mode="aspectFit"></image>
</view>
<view class="rightTxt">
<text class="bigTxt">{{item['text']}}</text>
@ -109,7 +109,16 @@
</view>
</view>
<view class="mode fleft " :class="{active:Status.sendDisc}" v-on:click.stop="discern()">
<view class="leftImg">
<image class="img" src="/static/images/common/svg.png" mode="aspectFit"></image>
</view>
<view class="rightTxt">
<text class="bigTxt">识别设备</text>
<text class="smallTxt" v-show="Status.sendDisc">蓝光闪烁中</text>
</view>
</view>
<view class="clear"></view>
</view>
@ -128,8 +137,8 @@
<view class="lampMode">
<view class="colorContent">
<view v-for="item,index in formData.groups" class="item"
:class="{active:item.id==formData.sta_GroupType,marginNoLeft:index%3===0}"
@click.stop="groupSetting(item,index)">
:class="{active:item.id==formData.sta_GroupType,marginNoLeft:index%3===0}"
@click.stop="groupSetting(item,index)">
<view class="polygon" :style="{backgroundColor:item.hex}">
@ -153,7 +162,7 @@
<view class="modeSetting">
<view class="arrow" @click.stop="ArrowModeSet('right_off')"
:class="formData.sta_ArrowMode=='right_off'?'active':''">
:class="formData.sta_ArrowMode=='right_off'?'active':''">
<view class="outCircle">
<view class="item">
<image class="img nomal" src="/static/images/4877/arrow.png" mode="aspectFit"></image>
@ -164,13 +173,13 @@
<view class="text">朝左</view>
</view>
<view class="arrow" @click.stop="ArrowModeSet('right_on')"
:class="formData.sta_ArrowMode=='right_on'?'active':''">
:class="formData.sta_ArrowMode=='right_on'?'active':''">
<view class="outCircle">
<view class="item">
<image class="img nomal translate" src="/static/images/4877/arrow.png" mode="aspectFit">
</image>
<image class="img activity translate" src="/static/images/4877/arrowActive.png"
mode="aspectFit"></image>
mode="aspectFit"></image>
</view>
</view>
<view class="text">朝右</view>
@ -185,7 +194,7 @@
<view class="modeSetting">
<view class="arrow" @click.stop="ArrowSet('red_front')"
:class="formData.sta_ArrowType=='red_front'?'redactive':''">
:class="formData.sta_ArrowType=='red_front'?'redactive':''">
<view class="outCircle">
<view class="item">
<view class="text">红色</view>
@ -194,7 +203,7 @@
</view>
<view class="arrow" @click.stop="ArrowSet('green_back')"
:class="formData.sta_ArrowType=='green_back'?'greenactive':''">
:class="formData.sta_ArrowType=='green_back'?'greenactive':''">
<view class="outCircle">
<view class="item">
<view class="text">绿色</view>
@ -217,7 +226,7 @@
<view class="modeSetting">
<view class="arrow" @click.stop="ArrowSet('red_all')"
:class="formData.sta_ArrowType=='red_all'?'active':''">
:class="formData.sta_ArrowType=='red_all'?'active':''">
<view class="outCircle">
<view class="item">
<image class="img nomal" src="/static/images/4877/arrowLR.png" mode="aspectFit"></image>
@ -228,13 +237,13 @@
<view class="text">红色双向</view>
</view>
<view class="arrow" @click.stop="ArrowSet('green_all')"
:class="formData.sta_ArrowType=='green_all'?'active':''">
:class="formData.sta_ArrowType=='green_all'?'active':''">
<view class="outCircle">
<view class="item">
<image class="img nomal translate" src="/static/images/4877/arrowLR.png" mode="aspectFit">
</image>
<image class="img activity translate" src="/static/images/4877/arrowLRActive.png"
mode="aspectFit"></image>
mode="aspectFit"></image>
</view>
</view>
<view class="text">绿色双向</view>
@ -247,16 +256,16 @@
<!-- 弹窗通知 -->
<MessagePopup :visible="Status.Pop.showPop" :type="Status.Pop.popType" :bgColor="Status.Pop.bgColor"
:borderColor="Status.Pop.borderColor" :textColor="Status.Pop.textColor"
:buttonBgColor="Status.Pop.buttonBgColor" :buttonTextColor="Status.Pop.buttonTextColor"
: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" :showSlot="Status.Pop.showSlot">
:borderColor="Status.Pop.borderColor" :textColor="Status.Pop.textColor"
:buttonBgColor="Status.Pop.buttonBgColor" :buttonTextColor="Status.Pop.buttonTextColor"
: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" :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" />
placeholder-class="popup-prompt-input-placeHolder" v-model="formData.sta_Channel" />
</view>
</MessagePopup>
@ -285,15 +294,15 @@
} from '@/api/4877/BJQ4877.js';
import MqTool from '@/utils/MqHelper.js'
import {
MsgSuccess,
MsgError,
MsgClose,
MsgWarning,
showPop,
MsgInfo,
import {
MsgSuccess,
MsgError,
MsgClose,
MsgWarning,
showPop,
MsgInfo,
MsgClear
} from '@/utils/MsgPops.js'
} from '@/utils/MsgPops.js'
const pagePath = "/pages/4877/BJQ4877";
var ble = null;
@ -306,6 +315,7 @@
data() {
return {
Status: {
sendDisc: '',
apiType: '',
navbar: {
icons: [{
@ -398,6 +408,7 @@
groups: [
]
},
dic: {
SOS: [{
@ -563,15 +574,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;
});
}
},
computed: {
getbleStatu() {
@ -707,7 +718,7 @@
buttonBgColor: "#E03434",
okCallback: null,
buttonText: "确定"
},these)
}, these)
return;
}
@ -738,7 +749,7 @@
cancelCallback: () => {
this.Status.ShowEditChannel = false;
}
},these);
}, these);
},
onChannelChanging() {
let regex = /^(0|([1-9]\d?)|1[01]\d|12[0-5])$/;
@ -788,7 +799,7 @@
buttonBgColor: "#E03434",
okCallback: null,
buttonText: "确定"
},these)
}, these)
return;
}
@ -851,7 +862,7 @@
buttonBgColor: "#E03434",
okCallback: null,
buttonText: "确定"
},these)
}, these)
return;
}
uni.navigateTo({
@ -934,7 +945,7 @@
buttonBgColor: "#E03434",
okCallback: null,
buttonText: "确定"
},these)
}, these)
return;
}
@ -982,7 +993,45 @@
this.formData.warnTime = 0;
}
},
discern() {
//识别设备,连续发送20次识别指令
let f = this.getDevice();
if (!f) {
this.showBleUnConnect();
return;
}
var json = {
ins_disc: 1
}
let index = 0;
let total = 20;
console.error("发送识别指令:", json);
this.Status.sendDisc = true;
let sendNextPacket = () => {
if(index>total){
this.Status.sendDisc = false;
return;
}
ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30).then(res => {
index++;
setTimeout(sendNextPacket,300);
}).catch(err => {
if (err.code == '10007') {
setTimeout(sendNextPacket, 800);
return;
}
if(index==0){
MsgError(err.msg,'',these);
}
this.Status.sendDisc = false;
});
}
sendNextPacket();
},
sosSetting(item, index) {
if (!this.permissions.includes('42') && this.Status.apiType !== 'listA') {
@ -993,7 +1042,7 @@
buttonBgColor: "#E03434",
okCallback: null,
buttonText: "确定"
},these)
}, these)
return;
}
let f = this.getDevice();
@ -1035,7 +1084,7 @@
buttonText: (this.formData.sta_SOSType === 'sos' ? '关闭' : '开启'),
showCancel: true,
buttonCancelText: '取消'
},these);
}, these);
}
if (item.val === 'sos') {
confirmTask();
@ -1085,9 +1134,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(() => {
@ -1181,7 +1230,7 @@
if (receive.deviceId !== this.formData.deviceId) {
return;
}
console.log("收到设备的数据", receive)
let data = recei.ReceiveData(receive, device, pagePath, recArr);
console.log("处理后的数据:", data);
@ -1225,8 +1274,8 @@
},
getDevice: function() {
// console.log("LinkedList=", ble.data.LinkedList);
// console.log("formData=", these.formData);
console.log("LinkedList=", ble.data.LinkedList);
console.log("formData=", these.device);
let f = ble.data.LinkedList.find((v) => {
return v.macAddress == these.device.deviceMac;
});
@ -1255,7 +1304,7 @@
borderColor: "#e034344d",
buttonBgColor: "#E03434",
buttonText: '去连接',
buttonTextColor: '#FFFFFFde',
buttonTextColor: '#FFFFFFde',
okCallback: function() {
uni.navigateTo({
@ -1277,10 +1326,10 @@
}
})
}
},these);
}, these);
},
@ -1302,62 +1351,61 @@
this.Status.Pop.okCallback();
}
},
showPop: function (option) {
hideLoading(this);
let def = {
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: null,
showSlot: false,
buttonCancelText: '',
showCancel: false,
}
let keys = Object.keys(def);
for (let i = 0; i < keys.length; i++) {
let key = keys[i];
if (key in option) {
continue;
}
this.Status.Pop[key] = def[key];
}
if (option) {
keys = Object.keys(option);
for (let i = 0; i < keys.length; i++) {
let key = keys[i];
this.Status.Pop[key] = option[key];
}
}
if (!option.borderColor) {
option.borderColor = '#BBE600';
option.buttonBgColor = '#BBE600';
}
these.Status.Pop.showPop = true;
},
showMsg(msg, isSucc) {
if (isSucc) {
MsgSuccess(msg,'',this);
showPop: function(option) {
hideLoading(this);
let def = {
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: null,
showSlot: false,
buttonCancelText: '',
showCancel: false,
}
else{
MsgError(msg,'',this);
let keys = Object.keys(def);
for (let i = 0; i < keys.length; i++) {
let key = keys[i];
if (key in option) {
continue;
}
this.Status.Pop[key] = def[key];
}
if (option) {
keys = Object.keys(option);
for (let i = 0; i < keys.length; i++) {
let key = keys[i];
this.Status.Pop[key] = option[key];
}
}
if (!option.borderColor) {
option.borderColor = '#BBE600';
option.buttonBgColor = '#BBE600';
}
these.Status.Pop.showPop = true;
},
showMsg(msg, isSucc) {
if (isSucc) {
MsgSuccess(msg, '', this);
} else {
MsgError(msg, '', this);
}
}
}
@ -1569,7 +1617,7 @@
border-color: #aed600 !important;
}
.lampMode .mode.active .bigTxt {
.lampMode .mode.active .bigTxt,.lampMode .mode.active .smallTxt {
color: #aed600 !important;
}
@ -1724,7 +1772,7 @@
text-align: left;
}
.slider-container {