合并主分支
# Conflicts: # pages/210/deviceControl/index.vue # pages/650/HBY650.vue # pages/common/index/index.vue # unpackage/dist/dev/app-plus/static/tabs/device-HL.png # unpackage/dist/dev/app-plus/static/tabs/device.png # unpackage/dist/dev/app-plus/static/tabs/my-HL.png # unpackage/dist/dev/app-plus/static/tabs/my.png # utils/BleReceive.js # utils/loading.js
This commit is contained in:
@ -1,311 +1,311 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<!-- 设备列表 -->
|
||||
<scroll-view class="device-list" scroll-y>
|
||||
<view class="device-card" v-for="(item, index) in deviceList" :key="index" @click="toggleSelect(index)">
|
||||
<!-- 复选框 -->
|
||||
<view class="checkbox" :class="{ checked: item.checked }">
|
||||
<uni-icons v-if="item.checked" type="checkmarkempty" size="18" color="rgb(0, 0, 0)"></uni-icons>
|
||||
</view>
|
||||
<!-- 设备信息 -->
|
||||
<view class="device-content">
|
||||
<view class="device-header">
|
||||
<view class="deviceIMG">
|
||||
<image :src="item.devicePic" class="IMG" mode="aspectFit"></image>
|
||||
</view>
|
||||
<view class="device-name">
|
||||
<view>设备:{{item.deviceName}}</view>
|
||||
<view class="ID">
|
||||
<view class="ID">ID:{{item.deviceImei}}</view>
|
||||
<view class="onlines" v-if="item.onlineStatus==1">在线</view>
|
||||
<!-- 离线状态 -->
|
||||
<view class="unlines" v-if="item.onlineStatus==0">离线</view>
|
||||
<view>电量:{{item.battery || '0'}}%</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="editInfmation">
|
||||
<button class="login-btn" @click="callMessage">呼叫设备</button>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<!-- 成功提示弹框 -->
|
||||
<CustomPopup :show="showPopupFlag" :title="popupTitle" :message="popupMessage"
|
||||
icon="/static/images/common/bj_1.png" :confirm-text="popupConfirmText" :show-cancel="false"
|
||||
@confirm="onPopupConfirm" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import CustomPopup from '@/components/CustomPopup/CustomPopup.vue'
|
||||
import {
|
||||
deviceInfo,
|
||||
} from '@/api/common/index.js'
|
||||
import {
|
||||
deviceSendMessage
|
||||
} from '@/api/6170/deviceControl.js'
|
||||
export default {
|
||||
components: {
|
||||
CustomPopup
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
deviceList: [],
|
||||
showPopupFlag: false,
|
||||
popupTitle: '',
|
||||
popupMessage: '确定要呼叫所选设备!',
|
||||
popupConfirmText: '确认'
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
toggleSelect(index) {
|
||||
this.deviceList[index].checked = !this.deviceList[index].checked
|
||||
this.$forceUpdate()
|
||||
},
|
||||
// 获取设备列表
|
||||
getData(deviceType) {
|
||||
this.loading = true;
|
||||
let data = {
|
||||
pageNum: 1,
|
||||
pageSize: 20,
|
||||
deviceType: deviceType
|
||||
}
|
||||
deviceInfo(data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
const newDevices = res.rows.map(device => ({
|
||||
...device,
|
||||
showConfirm: false,
|
||||
checked: false
|
||||
}));
|
||||
this.total = res.total;
|
||||
this.deviceList = newDevices
|
||||
}
|
||||
}).finally(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
//确认呼叫设备
|
||||
callMessage() {
|
||||
const selectedDevices = this.deviceList.filter(item => item.checked)
|
||||
if (selectedDevices.length === 0) {
|
||||
uni.showToast({
|
||||
title: '请选择一个设备',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
this.showPopupFlag = true
|
||||
},
|
||||
//弹框确认
|
||||
onPopupConfirm() {
|
||||
const selectedDevices = this.deviceList.filter(item => item.checked)
|
||||
const deviceIds = selectedDevices.map(item => item.id);
|
||||
let data = {
|
||||
deviceIds: deviceIds
|
||||
}
|
||||
deviceSendMessage(data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
this.showPopupFlag = false
|
||||
uni.navigateBack()
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
onLoad(options) {
|
||||
const eventChannel = this.getOpenerEventChannel();
|
||||
// 监听 'deviceSend' 事件,获取传过来的数据
|
||||
eventChannel.on('deviceCall', (data) => {
|
||||
console.log('Received detail data:', data);
|
||||
this.getData(data.data)
|
||||
});
|
||||
// 如果需要向调用页面返回数据,可以触发 'ack' 事件
|
||||
eventChannel.emit('ack', {})
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.container {
|
||||
min-height: 100vh;
|
||||
background-color: rgb(18, 18, 18);
|
||||
box-sizing: border-box;
|
||||
overflow-x: hidden;
|
||||
|
||||
}
|
||||
|
||||
.device-list {
|
||||
flex: 1;
|
||||
padding: 0 20rpx;
|
||||
|
||||
}
|
||||
|
||||
.device-card {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 95%;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.checkbox {
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
border: 2rpx solid rgba(255, 255, 255, 0.5);
|
||||
margin-right: 20rpx;
|
||||
border-radius: 4rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.checkbox.checked {
|
||||
background-color: rgb(187, 230, 0);
|
||||
border-color: rgb(187, 230, 0);
|
||||
}
|
||||
|
||||
.device-content {
|
||||
background-color: rgb(26, 26, 26);
|
||||
border-radius: 16rpx;
|
||||
position: relative;
|
||||
/* display: flex; */
|
||||
align-items: center;
|
||||
padding: 20rpx;
|
||||
width: 95%;
|
||||
}
|
||||
|
||||
.device-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 15rpx;
|
||||
}
|
||||
|
||||
.device-name {
|
||||
font-size: 32rpx;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
margin-left: 12rpx;
|
||||
line-height: 50rpx;
|
||||
width: 83%;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.ID {
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
font-size: 26rpx;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.device-status {
|
||||
width: 122rpx;
|
||||
height: 52rpx;
|
||||
font-size: 26rpx;
|
||||
border-radius: 0px 8px 0px 8px;
|
||||
background-color: rgb(42, 42, 42);
|
||||
position: absolute;
|
||||
top: 0rpx;
|
||||
right: 0rpx;
|
||||
text-align: center;
|
||||
line-height: 52rpx;
|
||||
}
|
||||
|
||||
.online {
|
||||
color: rgb(187, 230, 0);
|
||||
}
|
||||
|
||||
.unline {
|
||||
color: rgba(255, 255, 255, 0.4);
|
||||
}
|
||||
|
||||
.device-info {
|
||||
display: flex;
|
||||
justify-content: space-evenly;
|
||||
font-size: 26rpx;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
padding-top: 10rpx;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.deviceIMG {
|
||||
width: 100rpx;
|
||||
height: 100rpx;
|
||||
border-radius: 16rpx;
|
||||
position: relative;
|
||||
background-color: rgba(42, 42, 42, 0.6);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.IMG {
|
||||
width: 68rpx;
|
||||
height: 50rpx;
|
||||
margin-left: 17%;
|
||||
}
|
||||
|
||||
.onlines {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.onlines::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
width: 15rpx;
|
||||
height: 15rpx;
|
||||
background: rgb(0, 171, 103);
|
||||
border-radius: 50%;
|
||||
top: 20rpx;
|
||||
left: -20rpx
|
||||
}
|
||||
|
||||
.unlines {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.unlines::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
width: 15rpx;
|
||||
height: 15rpx;
|
||||
background: rgba(255, 255, 255, 0.4);
|
||||
border-radius: 50%;
|
||||
top: 20rpx;
|
||||
left: -20rpx
|
||||
}
|
||||
|
||||
.line {
|
||||
width: 2rpx;
|
||||
height: 24rpx;
|
||||
background: linear-gradient(90deg,
|
||||
rgba(0, 0, 0, 0) 0%,
|
||||
rgb(255, 255, 255) 50%,
|
||||
rgba(255, 255, 255, 0) 100%);
|
||||
margin-top: 12rpx;
|
||||
}
|
||||
|
||||
.ql-editor {
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
font-size: 30rpx;
|
||||
}
|
||||
|
||||
.editInfmation {
|
||||
padding: 20rpx;
|
||||
position: fixed;
|
||||
bottom: 50rpx;
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.login-btn {
|
||||
margin-top: 30rpx;
|
||||
background-color: rgb(187, 230, 0);
|
||||
color: rgb(35, 35, 35);
|
||||
border-radius: 50rpx;
|
||||
width: 90%;
|
||||
}
|
||||
<template>
|
||||
<view class="container">
|
||||
<!-- 设备列表 -->
|
||||
<scroll-view class="device-list" scroll-y>
|
||||
<view class="device-card" v-for="(item, index) in deviceList" :key="index" @click="toggleSelect(index)">
|
||||
<!-- 复选框 -->
|
||||
<view class="checkbox" :class="{ checked: item.checked }">
|
||||
<uni-icons v-if="item.checked" type="checkmarkempty" size="18" color="rgb(0, 0, 0)"></uni-icons>
|
||||
</view>
|
||||
<!-- 设备信息 -->
|
||||
<view class="device-content">
|
||||
<view class="device-header">
|
||||
<view class="deviceIMG">
|
||||
<image :src="item.devicePic" class="IMG" mode="aspectFit"></image>
|
||||
</view>
|
||||
<view class="device-name">
|
||||
<view>设备:{{item.deviceName}}</view>
|
||||
<view class="ID">
|
||||
<view class="ID">ID:{{item.deviceImei}}</view>
|
||||
<view class="onlines" v-if="item.onlineStatus==1">在线</view>
|
||||
<!-- 离线状态 -->
|
||||
<view class="unlines" v-if="item.onlineStatus==0">离线</view>
|
||||
<view>电量:{{item.battery || '0'}}%</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="editInfmation">
|
||||
<button class="login-btn" @click="callMessage">呼叫设备</button>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<!-- 成功提示弹框 -->
|
||||
<CustomPopup :show="showPopupFlag" :title="popupTitle" :message="popupMessage"
|
||||
icon="/static/images/common/bj_1.png" :confirm-text="popupConfirmText" :show-cancel="false"
|
||||
@confirm="onPopupConfirm" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import CustomPopup from '@/components/CustomPopup/CustomPopup.vue'
|
||||
import {
|
||||
deviceInfo,
|
||||
} from '@/api/common/index.js'
|
||||
import {
|
||||
deviceSendMessage
|
||||
} from '@/api/6170/deviceControl.js'
|
||||
export default {
|
||||
components: {
|
||||
CustomPopup
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
deviceList: [],
|
||||
showPopupFlag: false,
|
||||
popupTitle: '',
|
||||
popupMessage: '确定要呼叫所选设备!',
|
||||
popupConfirmText: '确认'
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
toggleSelect(index) {
|
||||
this.deviceList[index].checked = !this.deviceList[index].checked
|
||||
this.$forceUpdate()
|
||||
},
|
||||
// 获取设备列表
|
||||
getData(deviceType) {
|
||||
this.loading = true;
|
||||
let data = {
|
||||
pageNum: 1,
|
||||
pageSize: 20,
|
||||
deviceType: deviceType
|
||||
}
|
||||
deviceInfo(data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
const newDevices = res.rows.map(device => ({
|
||||
...device,
|
||||
showConfirm: false,
|
||||
checked: false
|
||||
}));
|
||||
this.total = res.total;
|
||||
this.deviceList = newDevices
|
||||
}
|
||||
}).finally(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
//确认呼叫设备
|
||||
callMessage() {
|
||||
const selectedDevices = this.deviceList.filter(item => item.checked)
|
||||
if (selectedDevices.length === 0) {
|
||||
uni.showToast({
|
||||
title: '请选择一个设备',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
this.showPopupFlag = true
|
||||
},
|
||||
//弹框确认
|
||||
onPopupConfirm() {
|
||||
const selectedDevices = this.deviceList.filter(item => item.checked)
|
||||
const deviceIds = selectedDevices.map(item => item.id);
|
||||
let data = {
|
||||
deviceIds: deviceIds
|
||||
}
|
||||
deviceSendMessage(data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
this.showPopupFlag = false
|
||||
uni.navigateBack()
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
onLoad(options) {
|
||||
const eventChannel = this.getOpenerEventChannel();
|
||||
// 监听 'deviceSend' 事件,获取传过来的数据
|
||||
eventChannel.on('deviceCall', (data) => {
|
||||
console.log('Received detail data:', data);
|
||||
this.getData(data.data)
|
||||
});
|
||||
// 如果需要向调用页面返回数据,可以触发 'ack' 事件
|
||||
eventChannel.emit('ack', {})
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.container {
|
||||
min-height: 100vh;
|
||||
background-color: rgb(18, 18, 18);
|
||||
box-sizing: border-box;
|
||||
overflow-x: hidden;
|
||||
|
||||
}
|
||||
|
||||
.device-list {
|
||||
flex: 1;
|
||||
padding: 0 20rpx;
|
||||
|
||||
}
|
||||
|
||||
.device-card {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 95%;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.checkbox {
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
border: 2rpx solid rgba(255, 255, 255, 0.5);
|
||||
margin-right: 20rpx;
|
||||
border-radius: 4rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.checkbox.checked {
|
||||
background-color: rgb(187, 230, 0);
|
||||
border-color: rgb(187, 230, 0);
|
||||
}
|
||||
|
||||
.device-content {
|
||||
background-color: rgb(26, 26, 26);
|
||||
border-radius: 16rpx;
|
||||
position: relative;
|
||||
/* display: flex; */
|
||||
align-items: center;
|
||||
padding: 20rpx;
|
||||
width: 95%;
|
||||
}
|
||||
|
||||
.device-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 15rpx;
|
||||
}
|
||||
|
||||
.device-name {
|
||||
font-size: 32rpx;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
margin-left: 12rpx;
|
||||
line-height: 50rpx;
|
||||
width: 83%;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.ID {
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
font-size: 26rpx;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.device-status {
|
||||
width: 122rpx;
|
||||
height: 52rpx;
|
||||
font-size: 26rpx;
|
||||
border-radius: 0px 8px 0px 8px;
|
||||
background-color: rgb(42, 42, 42);
|
||||
position: absolute;
|
||||
top: 0rpx;
|
||||
right: 0rpx;
|
||||
text-align: center;
|
||||
line-height: 52rpx;
|
||||
}
|
||||
|
||||
.online {
|
||||
color: rgb(187, 230, 0);
|
||||
}
|
||||
|
||||
.unline {
|
||||
color: rgba(255, 255, 255, 0.4);
|
||||
}
|
||||
|
||||
.device-info {
|
||||
display: flex;
|
||||
justify-content: space-evenly;
|
||||
font-size: 26rpx;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
padding-top: 10rpx;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.deviceIMG {
|
||||
width: 100rpx;
|
||||
height: 100rpx;
|
||||
border-radius: 16rpx;
|
||||
position: relative;
|
||||
background-color: rgba(42, 42, 42, 0.6);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.IMG {
|
||||
width: 68rpx;
|
||||
height: 50rpx;
|
||||
margin-left: 17%;
|
||||
}
|
||||
|
||||
.onlines {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.onlines::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
width: 15rpx;
|
||||
height: 15rpx;
|
||||
background: rgb(0, 171, 103);
|
||||
border-radius: 50%;
|
||||
top: 20rpx;
|
||||
left: -20rpx
|
||||
}
|
||||
|
||||
.unlines {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.unlines::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
width: 15rpx;
|
||||
height: 15rpx;
|
||||
background: rgba(255, 255, 255, 0.4);
|
||||
border-radius: 50%;
|
||||
top: 20rpx;
|
||||
left: -20rpx
|
||||
}
|
||||
|
||||
.line {
|
||||
width: 2rpx;
|
||||
height: 24rpx;
|
||||
background: linear-gradient(90deg,
|
||||
rgba(0, 0, 0, 0) 0%,
|
||||
rgb(255, 255, 255) 50%,
|
||||
rgba(255, 255, 255, 0) 100%);
|
||||
margin-top: 12rpx;
|
||||
}
|
||||
|
||||
.ql-editor {
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
font-size: 30rpx;
|
||||
}
|
||||
|
||||
.editInfmation {
|
||||
padding: 20rpx;
|
||||
position: fixed;
|
||||
bottom: 50rpx;
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.login-btn {
|
||||
margin-top: 30rpx;
|
||||
background-color: rgb(187, 230, 0);
|
||||
color: rgb(35, 35, 35);
|
||||
border-radius: 50rpx;
|
||||
width: 90%;
|
||||
}
|
||||
</style>
|
||||
@ -39,24 +39,15 @@
|
||||
<!-- 设备基本信息 -->
|
||||
<view class="info-card">
|
||||
<view class="info-row">
|
||||
<text class="info-label">设备名称</text>
|
||||
<text class="info-label">设备状态</text>
|
||||
<text class="info-value status-running">运行中</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">蓝牙名称</text>
|
||||
<text class="info-value status-running">FB-Site_02</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">蓝牙状态</text>
|
||||
<text class="info-value status-running">未连接</text>
|
||||
</view>
|
||||
<view class="hr"></view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">联机状态</text>
|
||||
<text class="info-value status-greend">联机</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">定位信</text>
|
||||
<text class="info-label">定位信息</text>
|
||||
<view class="info-value status-running" @click="gpsPosition">
|
||||
<view class="info-value status-running">114.72 30.28</view>
|
||||
<view class="info-value status-running">
|
||||
@ -78,13 +69,69 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 灯光模式选择 -->
|
||||
<!-- <view class="mode-section">
|
||||
<view class="mode-buttons">
|
||||
<view class="mode-v1">
|
||||
<view class="mode-v2" @click="selectMode">
|
||||
<image src="/static/images/210/lj.png" class="setIMG"></image>
|
||||
<view>
|
||||
<view class="battery-v2">联机设备</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="mode-v1">
|
||||
<view class="mode-v2" @click="uploadStartup">
|
||||
<image src="/static/images/common/path7.png" class="setIMG" mode="aspectFit"></image>
|
||||
<view>
|
||||
<view class="battery-v2">开机画面</view>
|
||||
<view class="mode-v3">上传</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="mode-v1">
|
||||
<view class="mode-v2" @click="automaticAlarm">
|
||||
<image src="/static/images/210/zd.png" class="setIMG" mode="aspectFit"></image>
|
||||
<view>
|
||||
<view class="battery-v2">自动报警</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="mode-v1">
|
||||
<view class="mode-v2" @click="anualAlarm">
|
||||
<image src="/static/images/210/zd-HL.png" class="setIMG" mode="aspectFit"></image>
|
||||
<view>
|
||||
<view class="battery-v2">手动报警</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="mode-v1">
|
||||
<view class="mode-v2">
|
||||
<image src="/static/images/210/bj.png" class="setIMG" mode="aspectFit"></image>
|
||||
<view>
|
||||
<view class="battery-v2">报警声音</view>
|
||||
<view class="mode-v3">上传</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="mode-v1">
|
||||
<view class="mode-v2" @click="alarmTime">
|
||||
<image src="/static/images/210/time.png" class="setIMG" mode="aspectFit"></image>
|
||||
<view>
|
||||
<view class="battery-v2">报警时长</view>
|
||||
<view class="mode-v3">{{alarmTimeDisplay }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</view> -->
|
||||
<view class="mode-section">
|
||||
<view class="mode-buttons">
|
||||
<view v-for="(item, index) in modeItems" :key="index" class="mode-v1"
|
||||
:class="{ 'active-mode': selectedIndex === index }">
|
||||
<view class="mode-v2" @click="handleModeClick(index)">
|
||||
<image :src="selectedIndex === index ? item.activeImage : item.image" class="setIMG"
|
||||
mode="aspectFit"></image>
|
||||
<view v-for="(item, index) in modeItems" :key="index" class="mode-v1" :class="{ 'active-mode': selectedIndex === index }">
|
||||
<view class="mode-v2"
|
||||
@click="handleModeClick(index)">
|
||||
<image :src="item.image" class="setIMG" mode="aspectFit"></image>
|
||||
<view>
|
||||
<view class="battery-v2">{{ item.title }}</view>
|
||||
<view class="mode-v3" v-if="item.subTitle">{{ item.subTitle }}</view>
|
||||
@ -193,34 +240,94 @@
|
||||
</view>
|
||||
</view>
|
||||
<!-- ======各个弹框类型======= -->
|
||||
<CustomPopupTXT :show="currentPopup.show" v-bind="currentPopup.config" @confirm="handleConfirm"
|
||||
@cancel="handleCancel" class="custom-popup-txt" />
|
||||
<!-- ===========报警声音========== -->
|
||||
<view class="agreement-mask" v-if="lightModeC">
|
||||
<view class="agreement-popupB" @click.stop>
|
||||
<view class="popup-title">报警声音</view>
|
||||
|
||||
<view class="example_img">
|
||||
<image src="/static/images/210/upload.png" mode="aspectFit" class="uploadIMG"></image>
|
||||
<view>点击选择上传文件</view>
|
||||
</view>
|
||||
<view class="example_img">
|
||||
<image src="/static/images/210/delete.png" mode="aspectFit" class="uploadIMG"></image>
|
||||
<view>删除</view>
|
||||
</view>
|
||||
<!-- 按钮组 -->
|
||||
<view class="popup-buttons">
|
||||
<button class="agree" @click="handleAlarmSound">确定</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<CustomPopup :show="currentPopup.show" v-bind="currentPopup.config" @confirm="handleConfirm"
|
||||
@cancel="handleCancel" />
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import CustomPopupTXT from '@/components/CustomPopup/CustomPopup.vue'
|
||||
// 弹框配置中心
|
||||
const POPUP_CONFIGS = {
|
||||
person: {
|
||||
config: {
|
||||
icon: '/static/images/common/sendSucc.png',
|
||||
message: '信息发送成功',
|
||||
showCancel: false
|
||||
},
|
||||
|
||||
},
|
||||
// 开机log
|
||||
logo: {
|
||||
config: {
|
||||
icon: '/static/images/common/upload.png',
|
||||
message: '上传成功',
|
||||
showCancel: false
|
||||
},
|
||||
|
||||
},
|
||||
bettery: {
|
||||
config: {
|
||||
title: '设备电量低于20%',
|
||||
titleColor: 'rgba(224, 52, 52, 1)',
|
||||
message: '请及时充电',
|
||||
icon: '/static/images/common/path.png',
|
||||
popupBorder: '1rpx solid rgba(224, 52, 52, 0.3)',
|
||||
confirmBtnBg: 'rgba(224, 52, 52, 1)',
|
||||
showCancel: true
|
||||
},
|
||||
onConfirm() {
|
||||
console.log('确认按钮');
|
||||
return true; // 直接关闭
|
||||
}
|
||||
},
|
||||
|
||||
cancel: {
|
||||
config: {
|
||||
titleColor: 'rgba(224, 52, 52, 1)',
|
||||
icon: '/static/images/common/svg.png',
|
||||
popupBorder: '1rpx solid rgba(224, 52, 52, 0.3)',
|
||||
confirmBtnBg: 'rgba(224, 52, 52, 1)',
|
||||
showCancel: true //取消按钮
|
||||
},
|
||||
onConfirm() {
|
||||
console.log('解除报警确认');
|
||||
}
|
||||
},
|
||||
del: {
|
||||
config: {
|
||||
message: '确定开启报警?',
|
||||
icon: '/static/images/210/bj_1.png',
|
||||
popupBorder: '1rpx solid rgba(255, 200, 78, 1)',
|
||||
confirmBtnBg: 'rgba(255, 200, 78, 1)',
|
||||
showCancel: true
|
||||
},
|
||||
onConfirm() {
|
||||
console.log('删除确认');
|
||||
}
|
||||
},
|
||||
// 自动报警
|
||||
autoAlarm: {
|
||||
config: {
|
||||
icon: '/static/images/6170/svg.png',
|
||||
title: '报警信息',
|
||||
message: '002号设备(ID:123456)\n出现报警', // 使用\n换行
|
||||
showCountdown: true,
|
||||
countdownTime: 59,
|
||||
confirmText: '解除报警',
|
||||
popupBorder: '1rpx solid rgba(224, 52, 52, 0.3)',
|
||||
confirmBtnBg: 'rgba(224, 52, 52, 1)',
|
||||
confirmBtnColor: "rgba(255, 255, 255, 0.87)",
|
||||
showCancel: false,
|
||||
},
|
||||
onConfirm() {
|
||||
console.log('自动报警确认');
|
||||
// 这里可以添加自动报警的逻辑
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
import MqttClient from '@/utils/mqtt.js';
|
||||
import {
|
||||
deviceDetail,
|
||||
@ -240,46 +347,36 @@
|
||||
clientid
|
||||
} from '@/utils/request'
|
||||
export default {
|
||||
components: {
|
||||
CustomPopupTXT
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
selectedIndex: -1,
|
||||
lightModeC: false,
|
||||
selectedIndex: -1, // Track currently selected index
|
||||
modeItems: [{
|
||||
image: "/static/images/210/lj.png",
|
||||
activeImage: "/static/images/210/lj-HL.png",
|
||||
title: "联机设备",
|
||||
subTitle: ""
|
||||
},
|
||||
{
|
||||
image: "/static/images/210/bj.png",
|
||||
activeImage: "/static/images/210/bj-HL.png",
|
||||
title: "报警声音",
|
||||
subTitle: "上传"
|
||||
},
|
||||
{
|
||||
image: "/static/images/210/zd.png",
|
||||
activeImage: "/static/images/210/zd-HL.png",
|
||||
title: "自动报警",
|
||||
subTitle: ""
|
||||
},
|
||||
{
|
||||
image: "/static/images/210/zd.png",
|
||||
activeImage: "/static/images/210/zd-HL.png",
|
||||
title: "手动报警",
|
||||
subTitle: ""
|
||||
},
|
||||
{
|
||||
image: "/static/images/common/path7.png",
|
||||
activeImage: "/static/images/210/path-HL.png",
|
||||
title: "开机画面",
|
||||
subTitle: "上传"
|
||||
},
|
||||
{
|
||||
image: "/static/images/210/zd.png",
|
||||
title: "自动报警",
|
||||
subTitle: ""
|
||||
},
|
||||
{
|
||||
image: "/static/images/210/zd-HL.png",
|
||||
title: "手动报警",
|
||||
subTitle: ""
|
||||
},
|
||||
{
|
||||
image: "/static/images/210/bj.png",
|
||||
title: "报警声音",
|
||||
subTitle: "上传"
|
||||
},
|
||||
{
|
||||
image: "/static/images/210/time.png",
|
||||
activeImage: "/static/images/210/time-HL.png",
|
||||
title: "报警时长",
|
||||
subTitle: "30秒"
|
||||
}
|
||||
@ -327,118 +424,6 @@
|
||||
radioSelected: 0, // -1表示未选中任何项
|
||||
deviceType: '',
|
||||
popupType: '', //弹框类型
|
||||
// 弹框配置中心
|
||||
POPUP_CONFIGS: {
|
||||
// 人员信息发送
|
||||
person: {
|
||||
config: {
|
||||
icon: '/static/images/common/sendSucc.png',
|
||||
message: '信息发送成功',
|
||||
showCancel: false
|
||||
},
|
||||
confirm() {
|
||||
return true; // 直接关闭
|
||||
}
|
||||
},
|
||||
// 上传开机log
|
||||
logo: {
|
||||
config: {
|
||||
icon: '/static/images/common/upload.png',
|
||||
message: '上传成功',
|
||||
showCancel: false
|
||||
},
|
||||
confirm() {
|
||||
return true; // 直接关闭
|
||||
}
|
||||
},
|
||||
// 电量低于20%.提示框
|
||||
bettery: {
|
||||
config: {
|
||||
show: true, // 必须显式设置为true
|
||||
showIcon: true, // 显示图标
|
||||
title: '设备电量低于20%',
|
||||
titleColor: 'rgba(224, 52, 52, 1)',
|
||||
message: '请及时充电',
|
||||
icon: '/static/images/common/path.png',
|
||||
popupBorder: '1rpx solid rgba(224, 52, 52, 0.3)',
|
||||
confirmBtnBg: 'rgba(224, 52, 52, 1)',
|
||||
showCancel: true
|
||||
},
|
||||
confirm() {
|
||||
return true; // 直接关闭
|
||||
}
|
||||
},
|
||||
// 解除报警关闭的那个提示
|
||||
cancel: {
|
||||
config: {
|
||||
show: true, // 必须显式设置为true
|
||||
showIcon: true, // 显示图标
|
||||
titleColor: 'rgba(224, 52, 52, 1)',
|
||||
icon: '/static/images/6170/svg.png',
|
||||
popupBorder: '1rpx solid rgba(224, 52, 52, 0.3)',
|
||||
confirmBtnBg: 'rgba(224, 52, 52, 1)',
|
||||
showCancel: true //取消按钮
|
||||
},
|
||||
confirm() {
|
||||
console.log('解除报警确认');
|
||||
}
|
||||
},
|
||||
// 手动报警弹框
|
||||
del: {
|
||||
config: {
|
||||
show: true, // 必须显式设置为true
|
||||
showIcon: true, // 显示图标
|
||||
message: '确定开启报警?',
|
||||
icon: '/static/images/210/bj_1.png',
|
||||
popupBorder: '1rpx solid rgba(255, 200, 78, 1)',
|
||||
confirmBtnBg: 'rgba(255, 200, 78, 1)',
|
||||
showCancel: true
|
||||
},
|
||||
confirm() {
|
||||
return 'alarmCountdown'; //点击确认,再次弹框,解除报警,再次报警的类型
|
||||
}
|
||||
},
|
||||
// 手动报警再次弹框 再次报警,解除报警指令
|
||||
alarmCountdown: {
|
||||
config: {
|
||||
show: true, // 必须显式设置为true
|
||||
showIcon: true, // 显示图标
|
||||
title: '报警倒计时',
|
||||
icon: '/static/images/6170/svg.png',
|
||||
message: '59秒',
|
||||
popupBorder: '1rpx solid rgba(224, 52, 52, 1)',
|
||||
confirmBtnBg: 'rgba(224, 52, 52, 1)',
|
||||
cancelBtnColor: "rgba(224, 52, 52, 1)",
|
||||
confirmBtnColor: "rgba(255, 255, 255, 0.87)",
|
||||
confirmText: '解除报警',
|
||||
cancelText: "再次报警",
|
||||
showCancel: true //取消按钮
|
||||
},
|
||||
confirm() {
|
||||
console.log('解除报警确认');
|
||||
}
|
||||
},
|
||||
// 自动报警
|
||||
autoAlarm: {
|
||||
config: {
|
||||
show: true, // 必须显式设置为true
|
||||
showIcon: true, // 显示图标
|
||||
icon: '/static/images/6170/svg.png',
|
||||
title: '报警信息',
|
||||
message: '002号设备(ID:123456)\n出现报警', // 使用\n换行
|
||||
showCountdown: true,
|
||||
countdownTime: 59,
|
||||
confirmText: '解除报警',
|
||||
popupBorder: '1rpx solid rgba(224, 52, 52, 0.3)',
|
||||
confirmBtnBg: 'rgba(224, 52, 52, 1)',
|
||||
confirmBtnColor: "rgba(255, 255, 255, 0.87)",
|
||||
showCancel: false,
|
||||
},
|
||||
confirm() {
|
||||
console.log('自动报警解除报警的弹框');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@ -451,21 +436,13 @@
|
||||
showPopup(type) {
|
||||
this.currentPopup = {
|
||||
show: true,
|
||||
config: this.POPUP_CONFIGS[type].config,
|
||||
callback: this.POPUP_CONFIGS[type].confirm
|
||||
config: POPUP_CONFIGS[type].config,
|
||||
callback: POPUP_CONFIGS[type].onConfirm
|
||||
}
|
||||
console.log(type, 'typetype');
|
||||
},
|
||||
handleConfirm() {
|
||||
if (this.currentPopup.callback) {
|
||||
const nextPopupType = this.currentPopup.callback(); // 执行回调并获取下一个弹框类型
|
||||
this.currentPopup.show = false; // 关闭当前弹框
|
||||
if (nextPopupType) {
|
||||
this.showPopup(nextPopupType); // 打开下一个弹框
|
||||
}
|
||||
} else {
|
||||
this.currentPopup.show = false; // 默认关闭
|
||||
}
|
||||
this.currentPopup.show = false;
|
||||
console.log('这是点击了确认');
|
||||
},
|
||||
// 统一处理取消
|
||||
handleCancel() {
|
||||
@ -477,8 +454,8 @@
|
||||
case 0:
|
||||
this.selectMode();
|
||||
break;
|
||||
case 1: // 报警声音
|
||||
this.soundAlarm();
|
||||
case 1:
|
||||
this.uploadStartup();
|
||||
break;
|
||||
case 2:
|
||||
this.automaticAlarm();
|
||||
@ -486,9 +463,6 @@
|
||||
case 3:
|
||||
this.manualAlarm();
|
||||
break;
|
||||
case 4:
|
||||
this.uploadStartup();
|
||||
break;
|
||||
case 5:
|
||||
this.alarmTime();
|
||||
break;
|
||||
@ -502,13 +476,6 @@
|
||||
this.radioSelected = index;
|
||||
console.log('选中了单选选项:', this.radioList[index]);
|
||||
},
|
||||
// 报警声音
|
||||
soundAlarm() {
|
||||
this.lightModeC = true
|
||||
},
|
||||
handleAlarmSound() {
|
||||
this.lightModeC = false
|
||||
},
|
||||
// 自动报警
|
||||
automaticAlarm() {
|
||||
this.showPopup('autoAlarm');
|
||||
@ -641,37 +608,33 @@
|
||||
this.lightModeA = false;
|
||||
// console.log("保存的时间:", time);
|
||||
},
|
||||
handleIconClick(s, e) {
|
||||
if (s === 0) {
|
||||
console.log("消息",s);
|
||||
handleIconClick(index) {
|
||||
// 历史记录
|
||||
if (index === 0) {
|
||||
uni.navigateTo({
|
||||
url: '/pages/670/History',
|
||||
success: (res) => {
|
||||
res.eventChannel.emit('detailData', {
|
||||
data: this.device,
|
||||
});
|
||||
}
|
||||
})
|
||||
return;
|
||||
} else if (s === 1) {
|
||||
console.log("分享");
|
||||
uni.navigateTo({
|
||||
url: '/pages/common/share/index',
|
||||
url: '/pages/210/historyRecords/index',
|
||||
events: {
|
||||
ack: function(data) {}
|
||||
},
|
||||
success: (res) => {
|
||||
let json = {
|
||||
persissonType: '210'
|
||||
};
|
||||
Object.assign(json, this.device);
|
||||
res.eventChannel.emit('share', {
|
||||
data: json
|
||||
data: this.itemInfo,
|
||||
});
|
||||
}
|
||||
})
|
||||
} else {
|
||||
uni.navigateTo({
|
||||
url: '/pages/6170/share/index',
|
||||
events: {
|
||||
ack: function(data) {}
|
||||
},
|
||||
success: (res) => {
|
||||
res.eventChannel.emit('share', {
|
||||
data: this.itemInfo,
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
// 分享
|
||||
@ -925,8 +888,7 @@
|
||||
.mode-v1.active-mode .battery-v2 {
|
||||
color: #BBE600 !important;
|
||||
}
|
||||
|
||||
.mode-v1.active-mode .mode-v3 {
|
||||
.mode-v1.active-mode .mode-v3{
|
||||
color: #BBE600 !important;
|
||||
}
|
||||
|
||||
@ -1052,11 +1014,6 @@
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.hr {
|
||||
border-bottom: 2rpx solid rgba(255, 255, 255, 0.04);
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.info-label {
|
||||
font-size: 28rpx;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
@ -1296,10 +1253,10 @@
|
||||
|
||||
.agreement-popupB {
|
||||
width: 100%;
|
||||
/* height: 32%; */
|
||||
height: 32%;
|
||||
background-color: rgb(42, 42, 42);
|
||||
border-radius: 60rpx 60rpx 0rpx 0rpx;
|
||||
padding: 40rpx 0rpx 140rpx 40rpx;
|
||||
padding: 40rpx;
|
||||
box-sizing: border-box;
|
||||
position: absolute;
|
||||
bottom: 0rpx;
|
||||
@ -1314,21 +1271,6 @@
|
||||
border: 1px solid rgba(255, 200, 78, 1);
|
||||
}
|
||||
|
||||
.example_img {
|
||||
display: flex;
|
||||
color: #fff;
|
||||
margin-bottom: 20rpx;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
font-size: 30rpx;
|
||||
}
|
||||
|
||||
.uploadIMG {
|
||||
width: 62rpx;
|
||||
height: 62rpx;
|
||||
margin-right: 15rpx;
|
||||
}
|
||||
|
||||
.popup-Title {
|
||||
color: rgba(255, 200, 78, 1);
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
<view>
|
||||
<view class="device-page">
|
||||
<view class="sendFlex">
|
||||
<view class="Sendmessage" @click="call">呼叫</view>
|
||||
<view class="Sendmessage" @click="location">呼叫</view>
|
||||
<view class="Sendmessage" @click="handleSend">发送信息</view>
|
||||
</view>
|
||||
<scroll-view class="device-list" scroll-y @scrolltolower="onScrollToLower" :lower-threshold="100"
|
||||
@ -79,20 +79,6 @@
|
||||
}
|
||||
})
|
||||
},
|
||||
// 呼叫功能
|
||||
call(){
|
||||
uni.navigateTo({
|
||||
url: '/pages/210/call/index',
|
||||
events: {
|
||||
ack: function(data) {}
|
||||
},
|
||||
success: (res) => {
|
||||
res.eventChannel.emit('deviceCall', {
|
||||
data:this.deviceType
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
onShow() {
|
||||
this.getData()
|
||||
|
||||
1947
pages/BlueTooth/ModeSetting/HBY6155.vue
Normal file
1947
pages/BlueTooth/ModeSetting/HBY6155.vue
Normal file
File diff suppressed because it is too large
Load Diff
1925
pages/BlueTooth/ModeSetting/HBY6155V1.vue
Normal file
1925
pages/BlueTooth/ModeSetting/HBY6155V1.vue
Normal file
File diff suppressed because it is too large
Load Diff
1892
pages/BlueTooth/ModeSetting/HBY650.vue
Normal file
1892
pages/BlueTooth/ModeSetting/HBY650.vue
Normal file
File diff suppressed because it is too large
Load Diff
1899
pages/BlueTooth/ModeSetting/HBY650_1.vue
Normal file
1899
pages/BlueTooth/ModeSetting/HBY650_1.vue
Normal file
File diff suppressed because it is too large
Load Diff
2837
pages/BlueTooth/ModeSetting/HBY670V1.vue
Normal file
2837
pages/BlueTooth/ModeSetting/HBY670V1.vue
Normal file
File diff suppressed because it is too large
Load Diff
1499
pages/BlueTooth/ModeSetting/ModeSetting.vue
Normal file
1499
pages/BlueTooth/ModeSetting/ModeSetting.vue
Normal file
File diff suppressed because it is too large
Load Diff
472
pages/BlueTooth/ModeSetting/VideoSend.vue
Normal file
472
pages/BlueTooth/ModeSetting/VideoSend.vue
Normal file
@ -0,0 +1,472 @@
|
||||
<template>
|
||||
<view class="content">
|
||||
<canvas canvas-id="flashCanvas"
|
||||
style="width: 160px; height: 80px; z-index: 9999;position: fixed; top:-9999px;left:-9999px;"></canvas>
|
||||
|
||||
<f-video ref="compARef" :src="videoPath" :direction="-90" :autoplay="true" @shotVideoClick="shotVideoClick"
|
||||
:videoWidth="videoWidth" :videoHeight="videoHeight"></f-video>
|
||||
|
||||
|
||||
<view>
|
||||
<text>发送间隔</text>
|
||||
<input type="text" v-model="inteval" />
|
||||
</view>
|
||||
<view>
|
||||
<button @click="checkVideo">选择视频</button>
|
||||
<!-- <button @click="CutImg">发送</button> -->
|
||||
<button @click="uploadVideo">发送</button>
|
||||
</view>
|
||||
|
||||
|
||||
<view class="sending-progress" v-if="isSending">
|
||||
<view class="progress-bar">
|
||||
<view class="progress-fill" :style="{ width: progress + '%' }"></view>
|
||||
</view>
|
||||
<text>正在发送: {{ progress }}% ({{ currentPacket }}/{{ totalPackets }})</text>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Common from '@/utils/Common';
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
videoPath: '',
|
||||
inteval: 0,
|
||||
progress: 0,
|
||||
currentPacket: 0,
|
||||
totalPackets: 100,
|
||||
|
||||
connectedDeviceId: '',
|
||||
serviceId: '0xFFE1',
|
||||
writeCharacteristicId: '0xFFE1',
|
||||
notifyCharacteristicId: '0xFFE2',
|
||||
isSending: "",
|
||||
textProgress: "",
|
||||
|
||||
imgs: [],
|
||||
videoWidth: 320,
|
||||
videoHeight: 160,
|
||||
videoDuration: 2,
|
||||
|
||||
hexArray: []
|
||||
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
const eventChannel = this.getOpenerEventChannel();
|
||||
|
||||
eventChannel.on('receiveDevice', (data) => {
|
||||
this.connectedDeviceId = data.connectedDeviceId;
|
||||
this.serviceId = data.serviceId;
|
||||
this.writeCharacteristicId = data.writeCharacteristicId;
|
||||
this.notifyCharacteristicId = data.notifyCharacteristicId;
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
checkVideo: function() {
|
||||
uni.chooseVideo({
|
||||
sourceType: ['album', 'camera'],
|
||||
compressed: false,
|
||||
maxDuration: 2,
|
||||
camera: 'back',
|
||||
success: (res) => {
|
||||
this.videoPath = res.tempFilePath;
|
||||
|
||||
this.imgs = [];
|
||||
this.hexArray = [];
|
||||
this.$refs.compARef.base64 = [];
|
||||
this.videoWidth = res.width;
|
||||
this.videoHeight = res.height;
|
||||
this.videoDuration = res.duration;
|
||||
console.log("视频宽:" + res.width + ",视频高:" + res.height + ",视频时长:" + res.duration);
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
uploadVideo: function() {
|
||||
|
||||
if (this.hexArray.length > 0) {
|
||||
console.log("开始处理,无需上传");
|
||||
this.shotVideoClick(this.hexArray, 'rgb565');
|
||||
return;
|
||||
|
||||
}
|
||||
if(!this.videoPath){
|
||||
uni.showToast({
|
||||
title: "请选择视频",
|
||||
icon: 'fail'
|
||||
})
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("正在上传视频");
|
||||
uni.showLoading({
|
||||
title: "上传中"
|
||||
});
|
||||
|
||||
let p2=new Promise((resolve,reject)=>{
|
||||
let start = new Date();
|
||||
console.log("Common.baseURL="+Common.baseURL);
|
||||
uni.uploadFile({
|
||||
url:Common.baseURL+'video/upload',
|
||||
filePath: this.videoPath,
|
||||
name: 'file',
|
||||
header: {
|
||||
"Method": "POST",
|
||||
"Content-Type": "multipart/form-data"
|
||||
},
|
||||
timeout: 600000,
|
||||
fail: (ex) => {
|
||||
//console.log("上传视频失败" + JSON.stringify(ex));
|
||||
uni.showToast({
|
||||
title: "视频文件上传失败了,请检查网络连接",
|
||||
icon: 'fail'
|
||||
})
|
||||
uni.hideLoading();
|
||||
reject(ex);
|
||||
},
|
||||
success: (res) => {
|
||||
let end = new Date();
|
||||
var diff = (end.getTime() - start.getTime()) / 1000;
|
||||
let s = diff % 60;
|
||||
let m = (diff - s) / 60;
|
||||
console.log("上传完成,耗时:" + m + "分" + s + "秒");
|
||||
uni.hideLoading();
|
||||
resolve(res);
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
let p1=this.HoldYouHand();
|
||||
|
||||
Promise.all([p2,p1]).then((arr)=>{
|
||||
|
||||
if(arr[1]===true){
|
||||
let res=arr[0];
|
||||
res = JSON.parse(res.data);
|
||||
|
||||
if (res.data) {
|
||||
this.hexArray = res.data;
|
||||
uni.showLoading({
|
||||
title: "正在发送"
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
this.shotVideoClick(res.data, 'rgb565');
|
||||
}, 0)
|
||||
|
||||
} else {
|
||||
console.log("res")
|
||||
uni.showModal({
|
||||
content: "服务器未返回RGB565数据",
|
||||
title: '错误'
|
||||
})
|
||||
}
|
||||
}else{
|
||||
uni.showModal({
|
||||
content:"与设备握手失败了",
|
||||
title:"错误"
|
||||
})
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
shotVideoClick: function(array, type) {
|
||||
//console.log("处理视频完成", array);
|
||||
//console.log("type=" + type)
|
||||
//console.log("array=", array);
|
||||
this.imgs = array;
|
||||
|
||||
|
||||
|
||||
var sendImagePackets = (imageData) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
this.isSending = true;
|
||||
this.progress = 0;
|
||||
this.currentPacket = 0;
|
||||
|
||||
// 总数据包数
|
||||
const totalPackets = 1536;
|
||||
this.totalPackets = totalPackets;
|
||||
let currentPacket = 1;
|
||||
|
||||
// 发送单个数据包
|
||||
const sendNextPacket = () => {
|
||||
////console.log("currentPacket="+currentPacket+",imageData.length="+imageData.length);
|
||||
if (currentPacket > totalPackets) {
|
||||
this.isSending = false;
|
||||
resolve();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// 计算当前包的数据
|
||||
let packetSize = 250;
|
||||
if (type == 'rgb565') {
|
||||
packetSize = 500;
|
||||
}
|
||||
|
||||
// 创建数据包
|
||||
const startIndex = (currentPacket - 1) * packetSize;
|
||||
const endIndex = Math.min(startIndex + packetSize, imageData.length);
|
||||
if (startIndex > endIndex) {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
////console.log("111111");
|
||||
const packetData = imageData.slice(startIndex, endIndex);
|
||||
|
||||
// 构建数据包
|
||||
////console.log("packetData.length"+packetData.length);
|
||||
const bufferSize = 506; // 头部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(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);
|
||||
|
||||
|
||||
if (type == 'rgb565') {
|
||||
for (let i = 0; i < packetData.length; i++) {
|
||||
dataView.setUint8(6 + i, '0x' + packetData[i]);
|
||||
}
|
||||
} else {
|
||||
for (let i = 0; i < packetData.length; i++) {
|
||||
dataView.setUint16(6 + i * 2, packetData[i], false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let inteval = parseInt(this.inteval ? this.inteval : 0);
|
||||
this.sendData(buffer).then(() => {
|
||||
// 更新进度
|
||||
this.currentPacket = currentPacket;
|
||||
this.progress = Math.round((currentPacket / totalPackets) *
|
||||
100);
|
||||
//console.log(`发送数据包完成 ${currentPacket}/${totalPackets}`);
|
||||
|
||||
// 发送下一个包(添加延迟避免蓝牙缓冲区溢出)
|
||||
currentPacket++;
|
||||
|
||||
|
||||
setTimeout(sendNextPacket, inteval);
|
||||
}).catch(err => {
|
||||
|
||||
// console.log(err.errMsg + ",发送失败了,正在补偿:" + currentPacket);
|
||||
setTimeout(sendNextPacket, inteval);
|
||||
// uni.showToast({
|
||||
// title:"发送失败"+JSON.stringify(err)
|
||||
// })
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
sendNextPacket();
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
if (type == 'rgb565') {
|
||||
let start = new Date();
|
||||
console.log("开始发送");
|
||||
sendImagePackets(array).then(() => {
|
||||
console.log("发送完成");
|
||||
let end = new Date();
|
||||
var diff = (end.getTime() - start.getTime()) / 1000;
|
||||
let s = diff % 60;
|
||||
let m = (diff-s) / 60;
|
||||
console.log("发送完成,耗时:" + m + "分" + s + "秒");
|
||||
uni.showToast({
|
||||
title: "发送完成,耗时:" + m + "分" + s + "秒",
|
||||
icon: 'success'
|
||||
})
|
||||
}).catch((ex1) => {
|
||||
//console.log("出现了异常", ex1)
|
||||
}).finally(() => {
|
||||
uni.hideLoading();
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
HoldYouHand() {
|
||||
|
||||
var promise=new Promise((resolve,reject)=>{
|
||||
try{
|
||||
let start=new Date();
|
||||
var str = "video transmit start"; //握手的协议字符串
|
||||
console.log("开始握手:"+str)
|
||||
|
||||
// 1. 创建 ArrayBuffer 和 DataView
|
||||
const buffer = new ArrayBuffer(str.length);
|
||||
const dataView = new DataView(buffer);
|
||||
|
||||
// 2. 将字符串转换为 ASCII 码并写入 DataView
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
dataView.setUint8(i, str.charCodeAt(i));
|
||||
}
|
||||
//console.log("111111");
|
||||
this.sendData(buffer).then(() => {
|
||||
// 开始发送第一个包
|
||||
setTimeout(()=>{
|
||||
|
||||
let end = new Date();
|
||||
var diff = (end.getTime() - start.getTime()) / 1000;
|
||||
let s = diff % 60;
|
||||
let m = (diff - s) / 60;
|
||||
|
||||
console.log("握手成功并完成2200ms等待,耗时"+m+"分"+s+"秒");
|
||||
|
||||
resolve(true);
|
||||
}, 2200);
|
||||
|
||||
}).catch(err => {
|
||||
//console.log("握手没有成功");
|
||||
reject(err);
|
||||
});
|
||||
}catch(ex){
|
||||
reject(ex);
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
return promise;
|
||||
|
||||
},
|
||||
sendData(buffer) {
|
||||
////console.log("deviceId=" + this.connectedDeviceId);
|
||||
////console.log("serviceId=" + this.serviceId);
|
||||
|
||||
return new Promise(async (resolve, reject) => {
|
||||
|
||||
// //console.log("开始发送数据,buffer");
|
||||
|
||||
|
||||
var promise = new Promise((succ, err) => {
|
||||
uni.writeBLECharacteristicValue({
|
||||
deviceId: this.connectedDeviceId,
|
||||
serviceId: this.serviceId,
|
||||
characteristicId: this.writeCharacteristicId,
|
||||
value: buffer,
|
||||
writeType: plus.os.name == 'iOS' ? 'write' : 'writeNoResponse',
|
||||
success: () => {
|
||||
// //console.log("发送数据成功");
|
||||
succ();
|
||||
},
|
||||
fail: (ex) => {
|
||||
//console.log("发送数据失败", ex);
|
||||
err(ex);
|
||||
},
|
||||
complete: function() {
|
||||
// //console.log("123456");
|
||||
}
|
||||
});
|
||||
});
|
||||
if (plus.os.name == 'iOS') {
|
||||
|
||||
function timeout(ms) {
|
||||
return new Promise((_, err) => {
|
||||
setTimeout(() => {
|
||||
err({
|
||||
code: -1,
|
||||
errMsg: '超时了'
|
||||
})
|
||||
}, ms);
|
||||
});
|
||||
}
|
||||
|
||||
let inteval = parseInt(this.inteval ? this.inteval : 0);
|
||||
|
||||
Promise.race([promise, timeout(inteval)]).then(resolve).catch((ex) => {
|
||||
//console.log("ex=", ex);
|
||||
if (ex.code == -1) {
|
||||
resolve();
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
|
||||
}).finally(() => {
|
||||
//console.log("完成了")
|
||||
});
|
||||
} else {
|
||||
promise.then(resolve).catch(reject);
|
||||
}
|
||||
});
|
||||
},
|
||||
CutImg: function() {
|
||||
if (this.imgs.length == 30) {
|
||||
this.shotVideoClick(this.imgs, 'img');
|
||||
return;
|
||||
}
|
||||
//console.log("开始处理视频")
|
||||
uni.showLoading({
|
||||
title: '开始处理'
|
||||
});
|
||||
this.$refs.compARef.shotVideoClick(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.sending-progress {
|
||||
margin-top: 30rpx;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.progress-bar {
|
||||
height: 12rpx;
|
||||
background-color: #e0e0e0;
|
||||
border-radius: 6rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.progress-fill {
|
||||
height: 100%;
|
||||
background-color: #409eff;
|
||||
transition: width 0.3s;
|
||||
}
|
||||
|
||||
input {
|
||||
border: 2rpx solid #000000;
|
||||
}
|
||||
|
||||
button {
|
||||
height: 100rpx;
|
||||
line-height: 100rpx;
|
||||
font-size: 28rpx;
|
||||
float: left;
|
||||
}
|
||||
|
||||
.content {
|
||||
width: 100vw;
|
||||
height: 300px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
</style>
|
||||
517
pages/BlueTooth/ModeSetting/VideoSend_1.vue
Normal file
517
pages/BlueTooth/ModeSetting/VideoSend_1.vue
Normal file
@ -0,0 +1,517 @@
|
||||
<template>
|
||||
<view class="content">
|
||||
<canvas canvas-id="flashCanvas"
|
||||
style="width: 160px; height: 80px; z-index: 9999;position: fixed; top:-9999px;left:-9999px;"></canvas>
|
||||
|
||||
<f-video ref="compARef" :src="videoPath" :direction="-90" :autoplay="true" @shotVideoClick="shotVideoClick"
|
||||
:videoWidth="videoWidth" :videoHeight="videoHeight"></f-video>
|
||||
|
||||
<view>
|
||||
<text>并发包数量</text>
|
||||
<input type="text" v-model="packgeCnt" />
|
||||
</view>
|
||||
<view>
|
||||
<text>发送间隔</text>
|
||||
<input type="text" v-model="inteval" />
|
||||
</view>
|
||||
<view>
|
||||
<button @click="checkVideo">选择视频</button>
|
||||
<!-- <button @click="CutImg">发送</button> -->
|
||||
<button @click="uploadVideo">发送</button>
|
||||
</view>
|
||||
|
||||
|
||||
<view class="sending-progress" v-if="isSending">
|
||||
<view class="progress-bar">
|
||||
<view class="progress-fill" :style="{ width: progress + '%' }"></view>
|
||||
</view>
|
||||
<text>正在发送: {{ progress }}% ({{ currentPacket }}/{{ totalPackets }})</text>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
videoPath: '',
|
||||
packgeCnt: 20,
|
||||
inteval: 0,
|
||||
progress: 0,
|
||||
currentPacket: 0,
|
||||
totalPackets: 100,
|
||||
|
||||
connectedDeviceId: '',
|
||||
serviceId: '0xFFE1',
|
||||
writeCharacteristicId: '0xFFE1',
|
||||
notifyCharacteristicId: '0xFFE2',
|
||||
isSending: "",
|
||||
textProgress: "",
|
||||
|
||||
imgs: [],
|
||||
videoWidth: 320,
|
||||
videoHeight: 160,
|
||||
videoDuration: 2,
|
||||
|
||||
hexArray: []
|
||||
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
const eventChannel = this.getOpenerEventChannel();
|
||||
|
||||
eventChannel.on('receiveDevice', (data) => {
|
||||
this.connectedDeviceId = data.connectedDeviceId;
|
||||
this.serviceId = data.serviceId;
|
||||
this.writeCharacteristicId = data.writeCharacteristicId;
|
||||
this.notifyCharacteristicId = data.notifyCharacteristicId;
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
checkVideo: function() {
|
||||
uni.chooseVideo({
|
||||
sourceType: ['album', 'camera'],
|
||||
compressed: false,
|
||||
maxDuration: 2,
|
||||
camera: 'back',
|
||||
success: (res) => {
|
||||
this.videoPath = res.tempFilePath;
|
||||
|
||||
this.imgs = [];
|
||||
this.hexArray = [];
|
||||
this.$refs.compARef.base64 = [];
|
||||
this.videoWidth = res.width;
|
||||
this.videoHeight = res.height;
|
||||
this.videoDuration = res.duration;
|
||||
console.log("视频宽:" + res.width + ",视频高:" + res.height + ",视频时长:" + res.duration);
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
uploadVideo: function() {
|
||||
|
||||
if (this.hexArray.length > 0) {
|
||||
console.log("开始处理,无需上传");
|
||||
this.shotVideoClick(this.hexArray, 'rgb565');
|
||||
return;
|
||||
|
||||
}
|
||||
if(!this.videoPath){
|
||||
uni.showToast({
|
||||
title: "请选择视频",
|
||||
icon: 'fail'
|
||||
})
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("正在上传视频");
|
||||
uni.showLoading({
|
||||
title: "上传中"
|
||||
});
|
||||
|
||||
let p2=new Promise((resolve,reject)=>{
|
||||
console.log("Common.baseURL="+Common.baseURL);
|
||||
let start = new Date();
|
||||
uni.uploadFile({
|
||||
url: Common.baseURL+'video/upload',
|
||||
// url: 'http://192.168.110.169:5000/video/upload',
|
||||
filePath: this.videoPath,
|
||||
name: 'file',
|
||||
header: {
|
||||
"Method": "POST",
|
||||
"Content-Type": "multipart/form-data"
|
||||
},
|
||||
timeout: 600000,
|
||||
fail: (ex) => {
|
||||
//console.log("上传视频失败" + JSON.stringify(ex));
|
||||
uni.showToast({
|
||||
title: "视频文件上传失败了,请检查网络连接",
|
||||
icon: 'fail'
|
||||
})
|
||||
uni.hideLoading();
|
||||
reject(ex);
|
||||
},
|
||||
success: (res) => {
|
||||
let end = new Date();
|
||||
var diff = (end.getTime() - start.getTime()) / 1000;
|
||||
let s = diff % 60;
|
||||
let m = (diff - s) / 60;
|
||||
console.log("上传完成,耗时:" + m + "分" + s + "秒");
|
||||
uni.hideLoading();
|
||||
resolve(res);
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
let p1=this.HoldYouHand();
|
||||
|
||||
Promise.all([p2,p1]).then((arr)=>{
|
||||
if(arr[1]===true){
|
||||
let res=arr[0];
|
||||
res = JSON.parse(res.data);
|
||||
|
||||
if (res.data) {
|
||||
this.hexArray = res.data;
|
||||
uni.showLoading({
|
||||
title: "正在发送"
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
this.shotVideoClick(res.data, 'rgb565');
|
||||
}, 0)
|
||||
|
||||
} else {
|
||||
console.log("res")
|
||||
uni.showModal({
|
||||
content: "服务器未返回RGB565数据",
|
||||
title: '错误'
|
||||
})
|
||||
}
|
||||
}else{
|
||||
uni.showModal({
|
||||
content:"与设备握手失败了",
|
||||
title:"错误"
|
||||
})
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
pause(e) {
|
||||
////console.log('pause--------------------------', e);
|
||||
},
|
||||
shotVideoClick: function(array, type) {
|
||||
//console.log("处理视频完成", array);
|
||||
//console.log("type=" + type)
|
||||
//console.log("array=", array);
|
||||
this.imgs = array;
|
||||
|
||||
|
||||
|
||||
var sendImagePackets = (imageData) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
this.isSending = true;
|
||||
this.progress = 0;
|
||||
this.currentPacket = 0;
|
||||
|
||||
// 总数据包数
|
||||
const totalPackets = 1536;
|
||||
this.totalPackets = totalPackets;
|
||||
let currentPacket = 1;
|
||||
let promises = [];
|
||||
// 发送单个数据包
|
||||
const sendNextPacket = () => {
|
||||
////console.log("currentPacket="+currentPacket+",imageData.length="+imageData.length);
|
||||
if (currentPacket > totalPackets) {
|
||||
this.isSending = false;
|
||||
resolve();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// 计算当前包的数据
|
||||
let packetSize = 250;
|
||||
if (type == 'rgb565') {
|
||||
packetSize = 500;
|
||||
}
|
||||
|
||||
// 创建数据包
|
||||
const startIndex = (currentPacket - 1) * packetSize;
|
||||
const endIndex = Math.min(startIndex + packetSize, imageData.length);
|
||||
if (startIndex > endIndex) {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
////console.log("111111");
|
||||
const packetData = imageData.slice(startIndex, endIndex);
|
||||
|
||||
// 构建数据包
|
||||
////console.log("packetData.length"+packetData.length);
|
||||
const bufferSize = 506; // 头部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(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);
|
||||
|
||||
|
||||
if (type == 'rgb565') {
|
||||
for (let i = 0; i < packetData.length; i++) {
|
||||
dataView.setUint8(6 + i, '0x' + packetData[i]);
|
||||
}
|
||||
} else {
|
||||
for (let i = 0; i < packetData.length; i++) {
|
||||
dataView.setUint16(6 + i * 2, packetData[i], false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let inteval = parseInt(this.inteval ? this.inteval : 0);
|
||||
let promise = this.sendData(buffer);
|
||||
promises.push(promise);
|
||||
let packgeCnt = parseInt(this.packgeCnt || 20);
|
||||
if (currentPacket % packgeCnt == 0 || (currentPacket >= totalPackets &&
|
||||
promises.length > 0)) {
|
||||
Promise.all(promises).then(() => {
|
||||
if (currentPacket >= totalPackets) {
|
||||
this.isSending = false;
|
||||
resolve();
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
this.currentPacket = currentPacket;
|
||||
this.progress = Math.round((currentPacket / totalPackets) *
|
||||
100);
|
||||
currentPacket++;
|
||||
setTimeout(sendNextPacket, inteval);
|
||||
})
|
||||
} else {
|
||||
currentPacket++;
|
||||
sendNextPacket();
|
||||
}
|
||||
// .then(() => {
|
||||
// // 更新进度
|
||||
// this.currentPacket = currentPacket;
|
||||
// this.progress = Math.round((currentPacket / totalPackets) *
|
||||
// 100);
|
||||
|
||||
// currentPacket++;
|
||||
|
||||
|
||||
// setTimeout(sendNextPacket, inteval);
|
||||
// }).catch(err => {
|
||||
|
||||
// console.log(err.errMsg+",发送失败了,正在补偿:" + currentPacket);
|
||||
// setTimeout(sendNextPacket, inteval);
|
||||
|
||||
// });
|
||||
};
|
||||
|
||||
//
|
||||
|
||||
|
||||
sendNextPacket();
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
if (type == 'rgb565') {
|
||||
let start = new Date();
|
||||
console.log("开始发送");
|
||||
sendImagePackets(array).then(() => {
|
||||
|
||||
let end = new Date();
|
||||
|
||||
var diff = (end.getTime() - start.getTime()) / 1000;
|
||||
let s = diff % 60;
|
||||
let m = (diff - s) / 60;
|
||||
console.log("发送完成,耗时:" + m + "分" + s + "秒");
|
||||
uni.showToast({
|
||||
title: "发送完成,耗时:" + m + "分" + s + "秒",
|
||||
icon: 'success',
|
||||
|
||||
})
|
||||
}).catch((ex1) => {
|
||||
//console.log("出现了异常", ex1)
|
||||
}).finally(() => {
|
||||
uni.hideLoading();
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
HoldYouHand() {
|
||||
|
||||
var promise=new Promise((resolve,reject)=>{
|
||||
try{
|
||||
let start=new Date();
|
||||
var str = "video transmit start"; //握手的协议字符串
|
||||
console.log("开始握手:"+str)
|
||||
|
||||
// 1. 创建 ArrayBuffer 和 DataView
|
||||
const buffer = new ArrayBuffer(str.length);
|
||||
const dataView = new DataView(buffer);
|
||||
|
||||
// 2. 将字符串转换为 ASCII 码并写入 DataView
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
dataView.setUint8(i, str.charCodeAt(i));
|
||||
}
|
||||
//console.log("111111");
|
||||
this.sendData(buffer).then(() => {
|
||||
// 开始发送第一个包
|
||||
setTimeout(()=>{
|
||||
|
||||
let end = new Date();
|
||||
var diff = (end.getTime() - start.getTime()) / 1000;
|
||||
let s = diff % 60;
|
||||
let m = (diff - s) / 60;
|
||||
|
||||
console.log("握手成功并完成2200ms等待,耗时"+m+"分"+s+"秒");
|
||||
|
||||
resolve(true);
|
||||
}, 2200);
|
||||
|
||||
}).catch(err => {
|
||||
//console.log("握手没有成功");
|
||||
reject(err);
|
||||
});
|
||||
}catch(ex){
|
||||
reject(ex);
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
return promise;
|
||||
|
||||
},
|
||||
sendData(buffer) {
|
||||
let sendBuffer = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
var promise = new Promise((succ, err) => {
|
||||
uni.writeBLECharacteristicValue({
|
||||
deviceId: this.connectedDeviceId,
|
||||
serviceId: this.serviceId,
|
||||
characteristicId: this.writeCharacteristicId,
|
||||
value: buffer,
|
||||
writeType: plus.os.name == 'iOS' ? 'write' : 'writeNoResponse',
|
||||
success: () => {
|
||||
// console.log("发送数据成功");
|
||||
succ();
|
||||
},
|
||||
fail: (ex) => {
|
||||
if (ex.code == '10007') {
|
||||
// console.log("失败重试");
|
||||
setTimeout(() => {
|
||||
sendBuffer().then(succ).catch(err);
|
||||
}, this.inteval || 0)
|
||||
// succ()
|
||||
|
||||
} else
|
||||
|
||||
{
|
||||
// console.log("发送数据失败",ex);
|
||||
err(ex);
|
||||
}
|
||||
},
|
||||
complete: function() {
|
||||
//console.log("123456");
|
||||
}
|
||||
});
|
||||
});
|
||||
if (plus.os.name == 'iOS') {
|
||||
|
||||
function timeout(ms) {
|
||||
return new Promise((_, err) => {
|
||||
setTimeout(() => {
|
||||
err({
|
||||
code: -1,
|
||||
errMsg: '超时了'
|
||||
})
|
||||
}, ms);
|
||||
});
|
||||
}
|
||||
|
||||
Promise.race([promise, timeout(this.inteval ? this.inteval : 0)]).then(() => {
|
||||
// console.log("成功了");
|
||||
resolve();
|
||||
})
|
||||
.catch((ex) => {
|
||||
|
||||
if (ex.code == -1) {
|
||||
// console.log("超时了")
|
||||
resolve();
|
||||
} else {
|
||||
reject(ex);
|
||||
// console.log("异常了", ex);
|
||||
//sendBuffer().then(resolve).catch(reject);
|
||||
}
|
||||
|
||||
});
|
||||
} else {
|
||||
|
||||
promise.then(() => {
|
||||
//console.log("then........")
|
||||
resolve();
|
||||
}).catch(() => {
|
||||
//console.log("catch.........")
|
||||
reject()
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
return sendBuffer();
|
||||
},
|
||||
CutImg: function() {
|
||||
if (this.imgs.length == 30) {
|
||||
this.shotVideoClick(this.imgs, 'img');
|
||||
return;
|
||||
}
|
||||
//console.log("开始处理视频")
|
||||
uni.showLoading({
|
||||
title: '开始处理'
|
||||
});
|
||||
this.$refs.compARef.shotVideoClick(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.sending-progress {
|
||||
margin-top: 30rpx;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.progress-bar {
|
||||
height: 12rpx;
|
||||
background-color: #e0e0e0;
|
||||
border-radius: 6rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.progress-fill {
|
||||
height: 100%;
|
||||
background-color: #409eff;
|
||||
transition: width 0.3s;
|
||||
}
|
||||
|
||||
input {
|
||||
border: 2rpx solid #000000;
|
||||
}
|
||||
|
||||
button {
|
||||
height: 100rpx;
|
||||
line-height: 100rpx;
|
||||
font-size: 28rpx;
|
||||
float: left;
|
||||
}
|
||||
|
||||
.content {
|
||||
width: 100vw;
|
||||
height: 300px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
</style>
|
||||
537
pages/BlueTooth/ModeSetting/VideoSend_670.vue
Normal file
537
pages/BlueTooth/ModeSetting/VideoSend_670.vue
Normal file
@ -0,0 +1,537 @@
|
||||
<template>
|
||||
<view class="content">
|
||||
<canvas canvas-id="flashCanvas"
|
||||
style="width: 160px; height: 80px; z-index: 9999;position: fixed; top:-9999px;left:-9999px;"></canvas>
|
||||
|
||||
<view>
|
||||
<view>
|
||||
选择的视频:{{videoPath}}</view>
|
||||
</view>
|
||||
<view>
|
||||
重发包序号:{{reSendNumber}}
|
||||
</view>
|
||||
<view>
|
||||
<text>发送间隔</text>
|
||||
<input type="text" v-model="inteval" />
|
||||
</view>
|
||||
<view>
|
||||
<button @click="checkVideo">选择视频</button>
|
||||
|
||||
<button @click="uploadVideo">发送</button>
|
||||
</view>
|
||||
|
||||
|
||||
<view class="sending-progress" v-if="isSending">
|
||||
<view class="progress-bar">
|
||||
<view class="progress-fill" :style="{ width: progress + '%' }"></view>
|
||||
</view>
|
||||
<text>正在发送: {{ progress }}% ({{ currentPacket }}/{{ totalPackets }})</text>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Common from '../../../utils/Common';
|
||||
var mqttClient=null;
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
videoPath: '',
|
||||
inteval: 0,
|
||||
progress: 0,
|
||||
currentPacket: 0,
|
||||
totalPackets: 100,
|
||||
|
||||
connectedDeviceId: '',
|
||||
serviceId: '0xFFE1',
|
||||
writeCharacteristicId: '0xFFE1',
|
||||
notifyCharacteristicId: '0xFFE2',
|
||||
isSending: "",
|
||||
textProgress: "",
|
||||
netMode:"ble",
|
||||
IMEI:"",
|
||||
|
||||
|
||||
imgs: [],
|
||||
videoWidth: 320,
|
||||
videoHeight: 160,
|
||||
videoDuration: 2,
|
||||
|
||||
hexArray: [],
|
||||
reSendNumber:""
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
const eventChannel = this.getOpenerEventChannel();
|
||||
|
||||
eventChannel.on('receiveDevice', (data) => {
|
||||
this.connectedDeviceId = data.connectedDeviceId;
|
||||
this.serviceId = data.serviceId;
|
||||
this.writeCharacteristicId = data.writeCharacteristicId;
|
||||
this.notifyCharacteristicId = data.notifyCharacteristicId;
|
||||
this.netMode=data.netMode;
|
||||
mqttClient=data.mqttClient;
|
||||
this.IMEI=data.IMEI;
|
||||
});
|
||||
|
||||
eventChannel.on('ReSendVideo',(data)=>{
|
||||
//重新发送某一包
|
||||
this.reSendNumber=data.videoNo;
|
||||
setTimeout(()=>{
|
||||
this.shotVideoClick(this.hexArray,'rgb565',data.videoNo);
|
||||
},0);
|
||||
|
||||
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
checkVideo: function() {
|
||||
uni.chooseVideo({
|
||||
sourceType: ['album', 'camera'],
|
||||
compressed: false,
|
||||
maxDuration: 2,
|
||||
camera: 'back',
|
||||
success: (res) => {
|
||||
this.videoPath = res.tempFilePath;
|
||||
|
||||
this.imgs = [];
|
||||
this.hexArray = [];
|
||||
|
||||
this.videoWidth = res.width;
|
||||
this.videoHeight = res.height;
|
||||
this.videoDuration = res.duration;
|
||||
console.log("视频宽:" + res.width + ",视频高:" + res.height + ",视频时长:" + res.duration);
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
uploadVideo: function() {
|
||||
|
||||
if (this.hexArray.length > 0) {
|
||||
console.log("开始处理,无需上传");
|
||||
this.shotVideoClick(this.hexArray, 'rgb565');
|
||||
return;
|
||||
|
||||
}
|
||||
if(!this.videoPath){
|
||||
uni.showToast({
|
||||
title: "请选择视频",
|
||||
icon: 'fail'
|
||||
})
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("正在上传视频");
|
||||
uni.showLoading({
|
||||
title: "上传中"
|
||||
});
|
||||
|
||||
let p2=new Promise((resolve,reject)=>{
|
||||
let start = new Date();
|
||||
console.log("Common.baseURL="+Common.baseURL);
|
||||
uni.uploadFile({
|
||||
url:Common.baseURL+'video/upload',
|
||||
filePath: this.videoPath,
|
||||
name: 'file',
|
||||
header: {
|
||||
"Method": "POST",
|
||||
"Content-Type": "multipart/form-data"
|
||||
},
|
||||
timeout: 600000,
|
||||
fail: (ex) => {
|
||||
//console.log("上传视频失败" + JSON.stringify(ex));
|
||||
uni.showToast({
|
||||
title: "视频文件上传失败了,请检查网络连接",
|
||||
icon: 'fail'
|
||||
})
|
||||
uni.hideLoading();
|
||||
reject(ex);
|
||||
},
|
||||
success: (res) => {
|
||||
let end = new Date();
|
||||
var diff = (end.getTime() - start.getTime()) / 1000;
|
||||
let s = diff % 60;
|
||||
let m = (diff - s) / 60;
|
||||
console.log("上传完成,耗时:" + m + "分" + s + "秒");
|
||||
uni.hideLoading();
|
||||
resolve(res);
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
let p1=this.HoldYouHand();
|
||||
|
||||
Promise.all([p2,p1]).then((arr)=>{
|
||||
|
||||
if(arr[1]===true){
|
||||
let res=arr[0];
|
||||
res = JSON.parse(res.data);
|
||||
|
||||
if (res.data) {
|
||||
this.hexArray = res.data;
|
||||
uni.showLoading({
|
||||
title: "正在发送"
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
this.shotVideoClick(res.data, 'rgb565');
|
||||
}, 0)
|
||||
|
||||
} else {
|
||||
console.log("res")
|
||||
uni.showModal({
|
||||
content: "服务器未返回RGB565数据",
|
||||
title: '错误'
|
||||
})
|
||||
}
|
||||
}else{
|
||||
uni.showModal({
|
||||
content:"与设备握手失败了",
|
||||
title:"错误"
|
||||
})
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
shotVideoClick: function(array, type,ReSendNo) {
|
||||
//console.log("处理视频完成", array);
|
||||
//console.log("type=" + type)
|
||||
//console.log("array=", array);
|
||||
this.imgs = array;
|
||||
|
||||
|
||||
|
||||
var sendImagePackets = (imageData) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
this.isSending = true;
|
||||
this.progress = 0;
|
||||
this.currentPacket = 0;
|
||||
|
||||
// 总数据包数
|
||||
var totalPackets = 1536;
|
||||
this.totalPackets = totalPackets;
|
||||
let currentPacket = 1;
|
||||
if(ReSendNo){
|
||||
this.progress = ReSendNo-1;
|
||||
this.currentPacket = ReSendNo-1;
|
||||
currentPacket=ReSendNo;
|
||||
totalPackets=ReSendNo;
|
||||
this.totalPackets=ReSendNo;
|
||||
}
|
||||
// 发送单个数据包
|
||||
const sendNextPacket = () => {
|
||||
////console.log("currentPacket="+currentPacket+",imageData.length="+imageData.length);
|
||||
if (currentPacket > totalPackets) {
|
||||
this.isSending = false;
|
||||
if(!ReSendNo){
|
||||
this.bleSendComplete();
|
||||
}else{
|
||||
// this.reSendNumber="";
|
||||
}
|
||||
|
||||
resolve();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// 计算当前包的数据
|
||||
let packetSize = 250;
|
||||
if (type == 'rgb565') {
|
||||
packetSize = 500;
|
||||
}
|
||||
|
||||
// 创建数据包
|
||||
const startIndex = (currentPacket - 1) * packetSize;
|
||||
const endIndex = Math.min(startIndex + packetSize, imageData.length);
|
||||
if (startIndex > endIndex) {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
////console.log("111111");
|
||||
const packetData = imageData.slice(startIndex, endIndex);
|
||||
|
||||
// 构建数据包
|
||||
////console.log("packetData.length"+packetData.length);
|
||||
const bufferSize = 506; // 头部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(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);
|
||||
|
||||
|
||||
if (type == 'rgb565') {
|
||||
for (let i = 0; i < packetData.length; i++) {
|
||||
dataView.setUint8(6 + i, '0x' + packetData[i]);
|
||||
}
|
||||
} else {
|
||||
for (let i = 0; i < packetData.length; i++) {
|
||||
dataView.setUint16(6 + i * 2, packetData[i], false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let inteval = parseInt(this.inteval ? this.inteval : 0);
|
||||
this.sendData(buffer).then(() => {
|
||||
// 更新进度
|
||||
this.currentPacket = currentPacket;
|
||||
this.progress = Math.round((currentPacket / totalPackets) *
|
||||
100);
|
||||
console.log(`发送数据包完成 ${currentPacket}/${totalPackets}`);
|
||||
|
||||
// 发送下一个包(添加延迟避免蓝牙缓冲区溢出)
|
||||
currentPacket++;
|
||||
|
||||
|
||||
setTimeout(sendNextPacket, inteval);
|
||||
}).catch(err => {
|
||||
|
||||
console.log(err.errMsg + ",发送失败了,正在补偿:" + currentPacket);
|
||||
setTimeout(sendNextPacket, inteval);
|
||||
// uni.showToast({
|
||||
// title:"发送失败"+JSON.stringify(err)
|
||||
// })
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
sendNextPacket();
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
if (type == 'rgb565') {
|
||||
let start = new Date();
|
||||
console.log("开始发送");
|
||||
sendImagePackets(array).then(() => {
|
||||
console.log("发送完成");
|
||||
let end = new Date();
|
||||
var diff = (end.getTime() - start.getTime()) / 1000;
|
||||
let s = diff % 60;
|
||||
let m = (diff-s) / 60;
|
||||
console.log("发送完成,耗时:" + m + "分" + s + "秒");
|
||||
uni.showModal({
|
||||
content: "发送完成,耗时:" + m + "分" + s + "秒",
|
||||
title: 'success'
|
||||
});
|
||||
|
||||
}).catch((ex1) => {
|
||||
console.log("出现了异常", ex1)
|
||||
}).finally(() => {
|
||||
uni.hideLoading();
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
HoldYouHand() {
|
||||
|
||||
var promise=new Promise((resolve,reject)=>{
|
||||
try{
|
||||
let start=new Date();
|
||||
var str = "video transmit start"; //握手的协议字符串
|
||||
console.log("开始握手:"+str)
|
||||
|
||||
// 1. 创建 ArrayBuffer 和 DataView
|
||||
const buffer = new ArrayBuffer(str.length);
|
||||
const dataView = new DataView(buffer);
|
||||
|
||||
// 2. 将字符串转换为 ASCII 码并写入 DataView
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
dataView.setUint8(i, str.charCodeAt(i));
|
||||
}
|
||||
//console.log("111111");
|
||||
this.sendData(buffer).then(() => {
|
||||
// 开始发送第一个包
|
||||
setTimeout(()=>{
|
||||
|
||||
let end = new Date();
|
||||
var diff = (end.getTime() - start.getTime()) / 1000;
|
||||
let s = diff % 60;
|
||||
let m = (diff - s) / 60;
|
||||
|
||||
console.log("握手成功并完成2200ms等待,耗时"+m+"分"+s+"秒");
|
||||
|
||||
resolve(true);
|
||||
}, 2200);
|
||||
|
||||
}).catch(err => {
|
||||
//console.log("握手没有成功");
|
||||
reject(err);
|
||||
});
|
||||
}catch(ex){
|
||||
reject(ex);
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
return promise;
|
||||
|
||||
},
|
||||
bleSendComplete() {
|
||||
var str = "transmit complete"; //握手的协议字符串
|
||||
let buffer = new ArrayBuffer(str.length);
|
||||
let dataView = new DataView(buffer);
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
dataView.setUint8(i, str.charCodeAt(i));
|
||||
}
|
||||
setTimeout(()=>{
|
||||
this.sendData(buffer).then(() => {
|
||||
console.log("完成指令发送成功");
|
||||
}).catch(err => {
|
||||
console.log("完成指令发送失败");
|
||||
});
|
||||
},1500)
|
||||
|
||||
},
|
||||
sendData(buffer) {
|
||||
if(this.netMode=='ble'){
|
||||
return this.sendBle(buffer);
|
||||
|
||||
}
|
||||
|
||||
return this.sendMQ(buffer);
|
||||
},
|
||||
sendBle(buffer){
|
||||
return new Promise(async (resolve, reject) => {
|
||||
|
||||
// //console.log("开始发送数据,buffer");
|
||||
|
||||
|
||||
var promise = new Promise((succ, err) => {
|
||||
uni.writeBLECharacteristicValue({
|
||||
deviceId: this.connectedDeviceId,
|
||||
serviceId: this.serviceId,
|
||||
characteristicId: this.writeCharacteristicId,
|
||||
value: buffer,
|
||||
writeType: plus.os.name == 'iOS' ? 'write' : 'writeNoResponse',
|
||||
success: () => {
|
||||
// //console.log("发送数据成功");
|
||||
succ();
|
||||
},
|
||||
fail: (ex) => {
|
||||
//console.log("发送数据失败", ex);
|
||||
err(ex);
|
||||
},
|
||||
complete: function() {
|
||||
// //console.log("123456");
|
||||
}
|
||||
});
|
||||
});
|
||||
if (plus.os.name == 'iOS') {
|
||||
|
||||
function timeout(ms) {
|
||||
return new Promise((_, err) => {
|
||||
setTimeout(() => {
|
||||
err({
|
||||
code: -1,
|
||||
errMsg: '超时了'
|
||||
})
|
||||
}, ms);
|
||||
});
|
||||
}
|
||||
|
||||
let inteval = parseInt(this.inteval ? this.inteval : 0);
|
||||
|
||||
Promise.race([promise, timeout(inteval)]).then(resolve).catch((ex) => {
|
||||
//console.log("ex=", ex);
|
||||
if (ex.code == -1) {
|
||||
resolve();
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
|
||||
}).finally(() => {
|
||||
//console.log("完成了")
|
||||
});
|
||||
} else {
|
||||
promise.then(resolve).catch(reject);
|
||||
}
|
||||
});
|
||||
},
|
||||
sendMQ(message) {
|
||||
|
||||
const topic = `B/${this.IMEI}`;
|
||||
return new Promise((resolve, reject) => {
|
||||
if(!mqttClient){
|
||||
reject("MQTT未连接");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
let flag=mqttClient.publish(topic, message, {
|
||||
qos: 1
|
||||
});
|
||||
if(flag){
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
reject("MQTT未连接,无法发布消息");
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.sending-progress {
|
||||
margin-top: 30rpx;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.progress-bar {
|
||||
height: 12rpx;
|
||||
background-color: #e0e0e0;
|
||||
border-radius: 6rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.progress-fill {
|
||||
height: 100%;
|
||||
background-color: #409eff;
|
||||
transition: width 0.3s;
|
||||
}
|
||||
|
||||
input {
|
||||
border: 2rpx solid #000000;
|
||||
}
|
||||
|
||||
button {
|
||||
height: 100rpx;
|
||||
line-height: 100rpx;
|
||||
font-size: 28rpx;
|
||||
float: left;
|
||||
}
|
||||
|
||||
.content {
|
||||
width: 100vw;
|
||||
height: 300px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
</style>
|
||||
115
pages/BlueTooth/ModeSetting/index.vue
Normal file
115
pages/BlueTooth/ModeSetting/index.vue
Normal file
@ -0,0 +1,115 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<view class="grid">
|
||||
<view class="cell" @click="goToDetail(item.name)" v-for="item,index in options">{{item.url}}</view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
options: [{
|
||||
name: '/pages/BlueTooth/ModeSetting/ModeSetting',
|
||||
url: '7307'
|
||||
},
|
||||
{
|
||||
name: '/pages/BlueTooth/ModeSetting/HBY650',
|
||||
url: 'HBY650'
|
||||
},
|
||||
{
|
||||
name: '/pages/BlueTooth/ModeSetting/HBY650_1',
|
||||
url: 'HBY650_V1'
|
||||
},
|
||||
|
||||
{
|
||||
name: '/pages/BlueTooth/ModeSetting/HBY6155',
|
||||
url: '6155'
|
||||
},
|
||||
{
|
||||
name: '/pages/BlueTooth/ModeSetting/HBY6155V1',
|
||||
url: '6155_V1'
|
||||
},
|
||||
{
|
||||
name: "/pages/BlueTooth/ModeSetting/HBY670V1",
|
||||
url: 'HBY670'
|
||||
},
|
||||
|
||||
{
|
||||
name: '/pages/MapTest/MapTest',
|
||||
url: '地图测试'
|
||||
},
|
||||
{
|
||||
name: '',
|
||||
url: '更多'
|
||||
}
|
||||
|
||||
]
|
||||
|
||||
}
|
||||
},
|
||||
onShow: () => {
|
||||
|
||||
},
|
||||
methods: {
|
||||
goToDetail: function(url) {
|
||||
console.log("url=" + url)
|
||||
let qd = () => {
|
||||
uni.showToast({
|
||||
title: '敬请期待',
|
||||
duration: 2000,
|
||||
icon: "none"
|
||||
});
|
||||
|
||||
};
|
||||
if (url) {
|
||||
uni.navigateTo({
|
||||
url: url,
|
||||
success: () => {
|
||||
|
||||
},
|
||||
fail: () => {
|
||||
qd();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
qd();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.container {
|
||||
padding: 15px;
|
||||
background-color: #f5f5f5;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.grid {
|
||||
display: flex;
|
||||
align-content: space-around;
|
||||
align-items: stretch;
|
||||
justify-items: center;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.cell {
|
||||
padding: 0rpx 20rpx;
|
||||
border: 2rpx solid rgba(0, 0, 0, 0.3);
|
||||
border-radius: 15rpx;
|
||||
font-size: 28rpx;
|
||||
height: 70rpx;
|
||||
line-height: 70rpx;
|
||||
margin-left: 30rpx;
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
</style>
|
||||
273
pages/BlueTooth/ModeSetting/update.vue
Normal file
273
pages/BlueTooth/ModeSetting/update.vue
Normal file
@ -0,0 +1,273 @@
|
||||
<template>
|
||||
<view class="update-container">
|
||||
<!-- 进度条 -->
|
||||
<view v-if="showProgress" class="progress-container">
|
||||
<view class="progress-title">正在更新 {{ progress }}%</view>
|
||||
<view class="progress-bar">
|
||||
<view class="progress" :style="{ width: progress + '%' }"></view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 更新提示弹窗 -->
|
||||
<view v-if="showUpdateDialog" class="dialog-mask">
|
||||
<view class="dialog">
|
||||
<view class="dialog-title">发现新版本 v{{ newVersion }}</view>
|
||||
<view class="dialog-content">{{ updateInfo.desc || '有新的功能和优化,建议立即更新' }}</view>
|
||||
<view class="dialog-buttons">
|
||||
<button v-if="!updateInfo.force" class="cancel-btn" @click="showUpdateDialog = false">稍后更新</button>
|
||||
<button class="confirm-btn" @click="startUpdate">立即更新</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
// 当前版本
|
||||
currentVersion: '',
|
||||
// 最新版本
|
||||
newVersion: '',
|
||||
// 更新信息
|
||||
updateInfo: {},
|
||||
// 是否显示更新弹窗
|
||||
showUpdateDialog: false,
|
||||
// 是否显示进度条
|
||||
showProgress: false,
|
||||
// 更新进度
|
||||
progress: 0
|
||||
};
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
// 初始化时检查版本
|
||||
this.checkVersion();
|
||||
},
|
||||
|
||||
methods: {
|
||||
/**
|
||||
* 检查当前版本
|
||||
*/
|
||||
async checkVersion() {
|
||||
try {
|
||||
// 获取当前应用版本
|
||||
const versionInfo = plus.runtime.version;
|
||||
this.currentVersion = versionInfo;
|
||||
console.log('当前版本:', this.currentVersion);
|
||||
|
||||
// 调用后端接口检查最新版本
|
||||
// 这里替换为你的后端接口地址
|
||||
const res = await this.$http.get('/api/checkVersion', {
|
||||
platform: uni.getSystemInfoSync().platform,
|
||||
version: this.currentVersion
|
||||
});
|
||||
|
||||
if (res.code === 0 && res.data.hasUpdate) {
|
||||
this.newVersion = res.data.version;
|
||||
this.updateInfo = res.data;
|
||||
// 显示更新提示
|
||||
this.showUpdateDialog = true;
|
||||
} else {
|
||||
console.log('当前已是最新版本');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('版本检查失败:', error);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 开始更新
|
||||
*/
|
||||
startUpdate() {
|
||||
if (!this.updateInfo.downloadUrl) {
|
||||
uni.showToast({
|
||||
title: '更新地址不存在',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
this.showUpdateDialog = false;
|
||||
this.showProgress = true;
|
||||
this.downloadWgt(this.updateInfo.downloadUrl);
|
||||
},
|
||||
|
||||
/**
|
||||
* 下载wgt包
|
||||
*/
|
||||
downloadWgt(url) {
|
||||
const downloadTask = uni.downloadFile({
|
||||
url: url,
|
||||
success: (downloadResult) => {
|
||||
if (downloadResult.statusCode === 200) {
|
||||
// 下载成功,安装wgt包
|
||||
this.installWgt(downloadResult.tempFilePath);
|
||||
} else {
|
||||
this.showProgress = false;
|
||||
uni.showToast({
|
||||
title: '下载失败',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
this.showProgress = false;
|
||||
console.error('下载失败:', err);
|
||||
uni.showToast({
|
||||
title: '下载失败,请稍后重试',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// 监听下载进度
|
||||
downloadTask.onProgressUpdate((res) => {
|
||||
this.progress = res.progress;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 安装wgt包
|
||||
*/
|
||||
installWgt(path) {
|
||||
plus.runtime.install(
|
||||
path,
|
||||
{
|
||||
force: false // 是否强制安装
|
||||
},
|
||||
() => {
|
||||
console.log('安装成功');
|
||||
this.showProgress = false;
|
||||
|
||||
// 安装成功后提示重启
|
||||
uni.showModal({
|
||||
title: '更新完成',
|
||||
content: '应用已更新,是否立即重启?',
|
||||
showCancel: !this.updateInfo.force,
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
// 重启应用
|
||||
plus.runtime.restart();
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
(err) => {
|
||||
console.error('安装失败:', err);
|
||||
this.showProgress = false;
|
||||
uni.showToast({
|
||||
title: '更新失败: ' + err.message,
|
||||
icon: 'none',
|
||||
duration: 3000
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.update-container {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
pointer-events: none;
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
/* 进度条样式 */
|
||||
.progress-container {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
background-color: #fff;
|
||||
padding: 10rpx 20rpx;
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
.progress-title {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
margin-bottom: 10rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.progress-bar {
|
||||
height: 8rpx;
|
||||
background-color: #eee;
|
||||
border-radius: 4rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.progress {
|
||||
height: 100%;
|
||||
background-color: #007aff;
|
||||
transition: width 0.3s ease;
|
||||
}
|
||||
|
||||
/* 弹窗样式 */
|
||||
.dialog-mask {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
.dialog {
|
||||
width: 600rpx;
|
||||
background-color: #fff;
|
||||
border-radius: 16rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.dialog-title {
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
padding: 30rpx;
|
||||
text-align: center;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
|
||||
.dialog-content {
|
||||
font-size: 32rpx;
|
||||
color: #666;
|
||||
padding: 40rpx 30rpx;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.dialog-buttons {
|
||||
display: flex;
|
||||
border-top: 1px solid #eee;
|
||||
}
|
||||
|
||||
.cancel-btn, .confirm-btn {
|
||||
flex: 1;
|
||||
height: 100rpx;
|
||||
line-height: 100rpx;
|
||||
font-size: 32rpx;
|
||||
border: none;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.cancel-btn {
|
||||
color: #666;
|
||||
border-right: 1px solid #eee;
|
||||
}
|
||||
|
||||
.confirm-btn {
|
||||
color: #007aff;
|
||||
}
|
||||
</style>
|
||||
@ -9,8 +9,8 @@
|
||||
<scroll-view class="tab-bar" scroll-x="true" scroll-with-animation>
|
||||
<view class="tab-container">
|
||||
<view v-for="(tab, index) in tabs" :key="index"
|
||||
:class="['tab-item', activeTab === index ? 'active' : '']" @click="switchTab(tab, index)">
|
||||
{{ tab.typeName }}
|
||||
:class="['tab-item', activeTab === index ? 'active' : '']" @click="switchTab(tab,index)">
|
||||
{{tab.typeName}}
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
@ -18,70 +18,65 @@
|
||||
<image src="/static/images/common/more.png" mode="aspectFit" class="more"></image>
|
||||
</view>
|
||||
</view>
|
||||
<view class="sendFlex" v-if="activeTab && activeTab.id !== '' && activeTabInfo.communicationMode == 0">
|
||||
<view class="sendFlex"
|
||||
v-if="activeTab && activeTab.id !== ''&& activeTabInfo.communicationMode==0 && activeTabInfo.typeName=='BJQ6170'">
|
||||
<view class="callpolice" @click="callpolice">报警</view>
|
||||
<view class="Sendmessage" @click="location">位置</view>
|
||||
<view class="Sendmessage" @click="handleSend">发送信息</view>
|
||||
</view>
|
||||
<mescroll-uni v-if="deviceList.length > 0" class="device-list" @init="mescrollInit" @down="downCallback"
|
||||
@up="upCallback" :up="upOption" :down="downOption" :fixed="false"
|
||||
:style="{ height: mescrollHeight + 'px' }">
|
||||
<uni-swipe-action ref="swipeAction">
|
||||
<block v-for="(item, index) in deviceList" :key="index" :ref="'swipeItem_' + index">
|
||||
<uni-swipe-action-item :right-options="Options" @click="handleSwipeClick($event, item, index)"
|
||||
class="device-card"
|
||||
:style="{ border: item.communicationMode == 0 && item.onlineStatus == 1 && item.alarmStatus == 1 ? '1px solid rgba(224, 52, 52, 1)' : 'none' }">
|
||||
<view @click.stop="handleFile(item)">
|
||||
<view class="device-header">
|
||||
<view class="deviceIMG">
|
||||
<image :src="item.devicePic" class="IMG" mode="aspectFit"></image>
|
||||
</view>
|
||||
<view class="device-name">
|
||||
<view>设备:{{ item.deviceName }}</view>
|
||||
<view class="ID">
|
||||
<view class="ID" v-if="item.communicationMode == 0">ID:{{
|
||||
item.deviceImei }}
|
||||
<scroll-view class="device-list" scroll-y @scrolltolower="onScrollToLower" :lower-threshold="100"
|
||||
style="height:80vh;">
|
||||
<view v-if="deviceList.length>0">
|
||||
<uni-swipe-action ref="swipeAction">
|
||||
<block v-for="(item, index) in deviceList" :key="index" :ref="'swipeItem_' + index">
|
||||
<uni-swipe-action-item :right-options="Options"
|
||||
@click="handleSwipeClick($event, item, index)" class="device-card"
|
||||
:style="{ border: item.communicationMode==0 && item.onlineStatus==1 && item.alarmStatus==1 ? '1px solid rgba(224, 52, 52, 1)' : 'none' }">
|
||||
<view @click.stop="handleFile(item)">
|
||||
<view class="device-header">
|
||||
<view class="deviceIMG">
|
||||
<image :src="item.devicePic" class="IMG" mode="aspectFit"></image>
|
||||
</view>
|
||||
<view class="device-name">
|
||||
<view>设备:{{item.deviceName}}</view>
|
||||
<view class="ID">
|
||||
<view class="ID" v-if="item.communicationMode==0">ID:{{item.deviceImei}}
|
||||
</view>
|
||||
<view class="ID" v-else>ID:{{item.deviceMac}}</view>
|
||||
<!-- 在线状态 -->
|
||||
<view class="onlines"
|
||||
v-if="item.communicationMode==0 && item.onlineStatus==1">在线</view>
|
||||
<!-- 离线状态 -->
|
||||
<view class="offlines"
|
||||
v-if="item.communicationMode==0 && item.onlineStatus==0">离线</view>
|
||||
<view>电量:{{item.battery || '0'}}%</view>
|
||||
</view>
|
||||
<view class="ID" v-else>ID:{{ item.deviceMac }}</view>
|
||||
<!-- 在线状态 -->
|
||||
<view class="onlines"
|
||||
v-if="item.communicationMode == 0 && item.onlineStatus == 1">在线
|
||||
</view>
|
||||
<!-- 离线状态 -->
|
||||
<view class="offlines"
|
||||
v-if="item.communicationMode == 0 && item.onlineStatus == 0">离线
|
||||
</view>
|
||||
<view class="offlines"
|
||||
v-if="item.communicationMode == 0 && item.onlineStatus == 2">故障
|
||||
</view>
|
||||
<view>电量:{{ item.battery || '0' }}%</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="device-callpolice"
|
||||
v-if="item.communicationMode==0 && item.onlineStatus==1 && item.alarmStatus==1">
|
||||
报警中</view>
|
||||
<view v-if="item.communicationMode==1">
|
||||
<view class="device-status online">已连接</view>
|
||||
<view class="device-status unline">未连接</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="device-callpolice"
|
||||
v-if="item.communicationMode == 0 && item.onlineStatus == 1 && item.alarmStatus == 1">
|
||||
报警中</view>
|
||||
<view v-if="item.communicationMode == 1">
|
||||
<view class="device-status online">已连接</view>
|
||||
<view class="device-status unline">未连接</view>
|
||||
</view>
|
||||
</view>
|
||||
<image src="/static/images/common/cires.png" class="circle" mode="aspectFit"></image>
|
||||
</uni-swipe-action-item>
|
||||
</block>
|
||||
</uni-swipe-action>
|
||||
<!-- 加载状态提示 -->
|
||||
<view class="loading-status">
|
||||
<text v-if="loading">加载中...</text>
|
||||
<text v-if="finished">没有更多数据了</text>
|
||||
<image src="/static/images/common/cires.png" class="circle" mode="aspectFit"></image>
|
||||
</uni-swipe-action-item>
|
||||
</block>
|
||||
</uni-swipe-action>
|
||||
<!-- 加载状态提示 -->
|
||||
<view class="loading-status">
|
||||
<text v-if="loading">加载中...</text>
|
||||
<text v-if="finished">没有更多数据了</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</mescroll-uni>
|
||||
<view v-else class="noDATA">
|
||||
<view> <uni-icons type="image-filled" size="120" color="rgba(255, 255, 255, 0.9)"></uni-icons>
|
||||
<view v-else class="noDATA">
|
||||
<view> <uni-icons type="image-filled" size="120" color="rgba(255, 255, 255, 0.9)"></uni-icons>
|
||||
</view>
|
||||
暂无数据
|
||||
</view>
|
||||
暂无数据
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
<!-- 删除弹框 -->
|
||||
<view class="agreement-mask" v-if="deleteShow" @click="closePopup('delete')" catchtouchmove="true">
|
||||
@ -150,11 +145,11 @@
|
||||
deviceReName
|
||||
} from '@/api/common/index.js'
|
||||
import BleHelper from '@/utils/BleHelper.js';
|
||||
import MescrollUni from 'mescroll-uni/mescroll-uni.vue'
|
||||
var ble = null;
|
||||
var ble=null;
|
||||
export default {
|
||||
components: {
|
||||
MescrollUni
|
||||
onPullDownRefresh() {
|
||||
// 执行下拉刷新时的操作,比如重新获取数据
|
||||
this.onIntall();
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@ -206,79 +201,24 @@
|
||||
action: 'share'
|
||||
}
|
||||
],
|
||||
mescroll: null,
|
||||
downOption: {
|
||||
auto: false
|
||||
},
|
||||
upOption: {
|
||||
auto: false,
|
||||
noMoreSize: 0,
|
||||
offset: 50,
|
||||
isLock: false,
|
||||
empty: {
|
||||
tip: '暂无数据',
|
||||
hideScroll: false
|
||||
}
|
||||
},
|
||||
page: 1, // 当前页码
|
||||
size: 12, // 每页条数
|
||||
size: 10, // 每页条数
|
||||
total: 0, // 总数据量
|
||||
loadedCount: 0,
|
||||
loading: false,
|
||||
finished: false,
|
||||
deviceId: '',
|
||||
deviceName: "", //重命名
|
||||
activeTabInfo: '',
|
||||
mescrollHeight: 0,
|
||||
activeTabInfo: ''
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
mescrollInit(mescroll) {
|
||||
this.mescroll = mescroll;
|
||||
},
|
||||
// 下拉刷新
|
||||
downCallback() {
|
||||
const currentDeviceType = this.activeTabInfo?.id === '' ? undefined : this.activeTabInfo?.id;
|
||||
const tempList = [...this.deviceList];
|
||||
// 重置分页参数
|
||||
this.page = 1;
|
||||
this.finished = false;
|
||||
this.loadedCount = 0;
|
||||
this.total = 0; // 重置总数
|
||||
this.getData(currentDeviceType)
|
||||
.then(() => {
|
||||
this.mescroll.endDownScroll(true);
|
||||
})
|
||||
.catch(() => {
|
||||
this.deviceList = tempList;
|
||||
this.mescroll.endDownScroll(false);
|
||||
});
|
||||
},
|
||||
// 上拉加载
|
||||
upCallback() {
|
||||
if (this.loading) {
|
||||
this.mescroll.endUpScroll(false);
|
||||
return;
|
||||
}
|
||||
const currentDeviceType = this.activeTabInfo?.id === '' ? undefined : this.activeTabInfo?.id;
|
||||
this.getData(currentDeviceType)
|
||||
.then(() => {
|
||||
// 如果本次加载的数据量为0,则说明没有更多数据
|
||||
const hasMore = this.deviceList.length > 0 && this.deviceList.length % this.size === 0;
|
||||
this.mescroll.endUpScroll(hasMore);
|
||||
})
|
||||
.catch(() => {
|
||||
this.page--;
|
||||
this.mescroll.endUpScroll(false);
|
||||
});
|
||||
},
|
||||
// 更多
|
||||
allMore() {
|
||||
this.showshare = !this.showshare;
|
||||
},
|
||||
// 所有分享,所有类型
|
||||
handleshareClick(item) {
|
||||
this.showshare = false;
|
||||
this.showshare = false; // 关闭弹窗
|
||||
switch (item.action) {
|
||||
case 'type':
|
||||
uni.navigateTo({
|
||||
@ -296,16 +236,17 @@
|
||||
closePopup(type) {
|
||||
if (type === 'delete') {
|
||||
this.deleteShow = false;
|
||||
uni.showTabBar();
|
||||
uni.showTabBar(); // 显示TabBar
|
||||
} else if (type === 'rename') {
|
||||
this.RenameModel = false;
|
||||
uni.showTabBar();
|
||||
uni.showTabBar(); // 显示TabBar
|
||||
}
|
||||
},
|
||||
// tab导航切换栏
|
||||
getTab() {
|
||||
deviceTypeList({}).then((res) => {
|
||||
if (res.code == 200) {
|
||||
//console.log("deviceTypeList=" + JSON.stringify(res.data));
|
||||
this.tabs = [{
|
||||
id: '',
|
||||
name: '全部设备',
|
||||
@ -325,66 +266,47 @@
|
||||
switchTab(tab, index) {
|
||||
this.deviceList = [];
|
||||
this.activeTab = index;
|
||||
this.activeTabInfo = tab;
|
||||
// 完全重置分页状态
|
||||
this.page = 1;
|
||||
this.finished = false;
|
||||
this.loadedCount = 0;
|
||||
this.total = 0; // 重置总数
|
||||
this.activeTabInfo = tab
|
||||
this.page = 1; // 重置页码
|
||||
this.finished = false; // 重
|
||||
// 明确传递参数,空字符串改为null或undefined
|
||||
const deviceType = tab.id === '' ? undefined : tab.id;
|
||||
this.$nextTick(() => {
|
||||
this.getSystemInfoSyncH();
|
||||
});
|
||||
this.getData(deviceType);
|
||||
if (this.mescroll) {
|
||||
this.mescroll.resetUpScroll();
|
||||
}
|
||||
},
|
||||
// 获取设备列表
|
||||
getData(deviceType = '') {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (this.loading || this.finished) {
|
||||
reject('正在加载或已无更多数据');
|
||||
return;
|
||||
}
|
||||
this.loading = true;
|
||||
let data = {
|
||||
pageNum: this.page,
|
||||
pageSize: this.size,
|
||||
deviceType: deviceType
|
||||
}
|
||||
deviceInfo(data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
const newDevices = res.rows.map(device => ({
|
||||
...device,
|
||||
showConfirm: false
|
||||
}));
|
||||
if (this.page === 1) {
|
||||
this.total = Number(res.total) || 0;
|
||||
this.deviceList = newDevices;
|
||||
this.loadedCount = newDevices.length;
|
||||
} else {
|
||||
this.deviceList = [...this.deviceList, ...newDevices];
|
||||
this.loadedCount += newDevices.length;
|
||||
}
|
||||
const hasMoreData = this.loadedCount < this.total;
|
||||
if (!hasMoreData) {
|
||||
this.finished = true;
|
||||
}
|
||||
if (hasMoreData) {
|
||||
this.page++;
|
||||
}
|
||||
resolve();
|
||||
if (this.loading || this.finished) return;
|
||||
this.loading = true;
|
||||
let data = {
|
||||
pageNum: this.page,
|
||||
pageSize: this.size,
|
||||
deviceType: deviceType // 使用传入的设备类型
|
||||
}
|
||||
deviceInfo(data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
const newDevices = res.rows.map(device => ({
|
||||
...device,
|
||||
showConfirm: false
|
||||
}));
|
||||
|
||||
// 如果是第一页或切换分类,替换数据
|
||||
this.deviceList = this.page === 1 ? newDevices : [...this.deviceList, ...newDevices];
|
||||
this.total = res.total;
|
||||
// 判断是否加载完成
|
||||
if (res.rows.length < this.size || this.deviceList.length >= this.total) {
|
||||
this.finished = true;
|
||||
} else {
|
||||
reject(res.msg || '获取数据失败');
|
||||
this.page++;
|
||||
}
|
||||
}).catch((err) => {
|
||||
reject(err);
|
||||
}).finally(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
}
|
||||
}).finally(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
// 滚动触底事件处理
|
||||
onScrollToLower() {
|
||||
this.getData();
|
||||
},
|
||||
// 添加扫一扫图标
|
||||
scan() {
|
||||
this.showTooltip = !this.showTooltip;
|
||||
@ -395,59 +317,21 @@
|
||||
},
|
||||
// 添加设备,扫一扫,蓝牙
|
||||
handleMenuClick(item) {
|
||||
this.showTooltip = false;
|
||||
this.showTooltip = false; // 关闭弹窗
|
||||
switch (item.action) {
|
||||
case 'scan':
|
||||
// 扫一扫
|
||||
uni.scanCode({
|
||||
success: (res) => {
|
||||
let cleanedResult = res.result.trim();
|
||||
console.log("scanResult=", cleanedResult);
|
||||
let promise = new Promise((resolve, reject) => {
|
||||
let url = '';
|
||||
try {
|
||||
let json = JSON.parse(cleanedResult);
|
||||
console.log("json=", json);
|
||||
if ('blue' in json) {
|
||||
let mac = json.blue;
|
||||
if (mac) {
|
||||
if (!mac.includes(':')) {
|
||||
mac = mac.replace(/(.{2})/g,'$1:').slice(0,-1)
|
||||
}
|
||||
url =`/pages/common/addBLE/LinkBle?mac=${encodeURIComponent(mac)}`;
|
||||
console.log("蓝牙设备",mac);
|
||||
}
|
||||
|
||||
|
||||
} else if ('imei' in json) {
|
||||
let imei = json.imei;
|
||||
if (iemi) {
|
||||
url =
|
||||
`/pages/common/qrcode/qrcode?deviceId=${encodeURIComponent(imei)}`;
|
||||
console.log("4G设备:",imei)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} catch (error) {
|
||||
console.error("识别二维码失败,",error);
|
||||
} finally {
|
||||
|
||||
if(!url){
|
||||
url =
|
||||
`/pages/common/qrcode/qrcode?deviceId=${encodeURIComponent(cleanedResult)}`
|
||||
console.log("未知设备:",cleanedResult)
|
||||
}
|
||||
|
||||
resolve(url);
|
||||
}
|
||||
});
|
||||
promise.then(res => {
|
||||
uni.navigateTo({
|
||||
url: res
|
||||
});
|
||||
console.log('条码内容:', res);
|
||||
// 清除之前的数据
|
||||
this.previousScanResult = null;
|
||||
// 处理新的扫码结果
|
||||
const cleanedResult = res.result.trim();
|
||||
console.log('扫码结果:', cleanedResult);
|
||||
// 跳转并传递扫描结果
|
||||
uni.navigateTo({
|
||||
url: `/pages/common/qrcode/qrcode?deviceId=${encodeURIComponent(cleanedResult)}`
|
||||
});
|
||||
},
|
||||
fail: (err) => {
|
||||
@ -461,13 +345,17 @@
|
||||
break;
|
||||
case 'bluetooth':
|
||||
uni.navigateTo({
|
||||
url: "/pages/common/addBLE/addEquip?search=all"
|
||||
url: "/pages/common/addBLE/addEquip"
|
||||
})
|
||||
break;
|
||||
}
|
||||
},
|
||||
// 右滑点击事件处理
|
||||
handleSwipeClick(e, item, index) {
|
||||
const {
|
||||
content
|
||||
} = e
|
||||
console.log(item, 'eeeee');
|
||||
switch (e.content.text) {
|
||||
case '删除':
|
||||
this.handleDeleteDevice(item, index)
|
||||
@ -486,6 +374,9 @@
|
||||
// 确认删除
|
||||
handleBtn() {
|
||||
uni.showTabBar()
|
||||
let data = {
|
||||
id: this.deviceId.id
|
||||
}
|
||||
deviceUnbind(this.deviceId.id).then((res) => {
|
||||
if (res.code == 200) {
|
||||
uni.showToast({
|
||||
@ -498,12 +389,10 @@
|
||||
this.getTab()
|
||||
}, 500);
|
||||
this.deleteShow = false
|
||||
if (this.$refs.swipeAction) {
|
||||
this.$refs.swipeAction.closeAll();
|
||||
}
|
||||
console.log("111111", this.deviceId);
|
||||
console.log("ble==null,", ble)
|
||||
ble && ble.DropDevice(null, this.deviceId.id);
|
||||
// 关闭所有滑动项
|
||||
this.$refs.swipeAction.closeAll();
|
||||
|
||||
ble && ble.DropDevice(data.id);
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
@ -521,10 +410,11 @@
|
||||
},
|
||||
handleBtnName() {
|
||||
uni.showTabBar()
|
||||
deviceReName({
|
||||
let data = {
|
||||
id: this.deviceId.id,
|
||||
deviceName: this.deviceName
|
||||
}).then((res) => {
|
||||
}
|
||||
deviceReName(data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
@ -536,9 +426,8 @@
|
||||
}, 500);
|
||||
this.RenameModel = false
|
||||
this.deviceName = ''
|
||||
if (this.$refs.swipeAction) {
|
||||
this.$refs.swipeAction.closeAll();
|
||||
}
|
||||
// 关闭所有滑动项
|
||||
this.$refs.swipeAction.closeAll();
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
@ -548,11 +437,16 @@
|
||||
}
|
||||
})
|
||||
},
|
||||
// 报警
|
||||
// 报警
|
||||
callpolice() {
|
||||
const currentTab = this.tabs[this.activeTab];
|
||||
const deviceType = currentTab.id || '';
|
||||
console.log(`跳转到发送信息页面\n当前设备类型: ${deviceType}\n设备类型名称: ${currentTab.typeName}`);
|
||||
uni.navigateTo({
|
||||
url: '/pages/6170/callPolice/index',
|
||||
events: {
|
||||
ack: function(data) {}
|
||||
},
|
||||
success: (res) => {
|
||||
res.eventChannel.emit('devicePolice', {
|
||||
data: currentTab
|
||||
@ -563,10 +457,16 @@
|
||||
// 发生短信
|
||||
handleSend() {
|
||||
const currentTab = this.tabs[this.activeTab];
|
||||
const deviceType = currentTab.id || '';
|
||||
console.log(`跳转到发送信息页面\n当前设备类型: ${deviceType}\n设备类型名称: ${currentTab.typeName}`);
|
||||
uni.navigateTo({
|
||||
url: '/pages/common/send/index',
|
||||
events: {
|
||||
ack: function(data) {}
|
||||
},
|
||||
success: (res) => {
|
||||
res.eventChannel.emit('deviceSend', {
|
||||
//data: deviceType,
|
||||
data: currentTab
|
||||
});
|
||||
}
|
||||
@ -576,7 +476,11 @@
|
||||
location() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/common/map/index',
|
||||
events: {
|
||||
ack: function(data) {}
|
||||
},
|
||||
success: (res) => {
|
||||
// 页面跳转成功后的回调函数
|
||||
res.eventChannel.emit('Map', {
|
||||
data: this.deviceList,
|
||||
});
|
||||
@ -586,47 +490,50 @@
|
||||
// 列表跳转
|
||||
handleFile(item) {
|
||||
let url = item.detailPageUrl;
|
||||
|
||||
// url="/pages/6331/BJQ6331";
|
||||
|
||||
|
||||
// console.log("url=",url);
|
||||
// if(!url){
|
||||
//url="/pages/670/HBY670"
|
||||
// }
|
||||
uni.navigateTo({
|
||||
url: url,
|
||||
events: {
|
||||
ack: function(data) {}
|
||||
},
|
||||
success: (res) => {
|
||||
// 页面跳转成功后的回调函数
|
||||
res.eventChannel.emit('detailData', {
|
||||
data: item,
|
||||
deviceType: this.tabs[this.activeTab].id || '',
|
||||
apiType: 'listA'
|
||||
apiType: 'listA' //标识,根据这个参数,区分普通详情,分享跳转详情,查不一样的权限信息
|
||||
});
|
||||
},
|
||||
fail(ex) {
|
||||
console.log("ex=", ex);
|
||||
},fail(ex) {
|
||||
console.log("ex=",ex);
|
||||
}
|
||||
})
|
||||
},
|
||||
onIntall() {
|
||||
this.page = 1;
|
||||
this.finished = false;
|
||||
this.loadedCount = 0;
|
||||
this.total = 0;
|
||||
const deviceType = this.activeTabInfo?.id === '' ? undefined : this.activeTabInfo?.id;
|
||||
this.getData(deviceType);
|
||||
this.getData(deviceType); // 重新加载第一页数据
|
||||
setTimeout(() => {
|
||||
// 停止下拉刷新动画
|
||||
uni.stopPullDownRefresh();
|
||||
}, 800);
|
||||
},
|
||||
updateDeviceStatus(data) {
|
||||
this.deviceList = this.deviceList
|
||||
.map(item => {
|
||||
if (!item) return null;
|
||||
if (!item) return null; // 如果 item 是 undefined/null,返回 null
|
||||
if (item.communicationMode == 0) {
|
||||
let messageData;
|
||||
try {
|
||||
messageData = data.message;
|
||||
} catch (e) {
|
||||
return item;
|
||||
return item; // 解析失败则返回原 item
|
||||
}
|
||||
const [deviceId, onlineStatus, battery] = messageData.state || [];
|
||||
console.log('我收到消息了没', item.battery);
|
||||
return {
|
||||
...item,
|
||||
battery: battery ?? item.battery,
|
||||
@ -638,31 +545,24 @@
|
||||
})
|
||||
.filter(Boolean);
|
||||
},
|
||||
// 动态计算屏幕高度
|
||||
getSystemInfoSyncH() {
|
||||
const sysInfo = uni.getSystemInfoSync();
|
||||
const tabBarHeight = 80;
|
||||
const sendBarHeight = 60;
|
||||
const padding = 60;
|
||||
const totalTopHeight = (this.navBarHeight) + (tabBarHeight + sendBarHeight + padding) * (sysInfo
|
||||
.screenWidth / 750);
|
||||
this.mescrollHeight = sysInfo.screenHeight - totalTopHeight;
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.getSystemInfoSyncH()
|
||||
this.getTab()
|
||||
this.onIntall()
|
||||
// 绑定页面做了监听,新增成功,刷新页面
|
||||
uni.$on('refreshDeviceList', () => {
|
||||
this.getTab()
|
||||
this.getTab() // 刷新数据
|
||||
this.onIntall()
|
||||
});
|
||||
// 监听设备状态更新事件
|
||||
uni.$on('deviceStatusUpdate', (data) => {
|
||||
console.log('列表收到消息了么');
|
||||
this.onIntall()
|
||||
});
|
||||
ble = BleHelper.getBleTool();
|
||||
ble=BleHelper.getBleTool();
|
||||
},
|
||||
beforeDestroy() {
|
||||
// 组件销毁前移除监听器
|
||||
uni.$off('refreshDeviceList');
|
||||
},
|
||||
onUnload() {
|
||||
@ -673,7 +573,7 @@
|
||||
</script>
|
||||
|
||||
<style>
|
||||
/* 保持原有样式不变 */
|
||||
/* 页面整体样式 */
|
||||
.device-page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@ -686,6 +586,7 @@
|
||||
width: 100%;
|
||||
color: rgb(255, 255, 255);
|
||||
white-space: nowrap;
|
||||
/* 禁止换行 */
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
|
||||
@ -696,12 +597,17 @@
|
||||
cursor: pointer;
|
||||
margin-bottom: 40rpx;
|
||||
padding-right: 80rpx;
|
||||
/* 预留更多按钮空间 */
|
||||
}
|
||||
|
||||
.tab-item {
|
||||
font-size: 28rpx;
|
||||
/* min-width: 120rpx; */
|
||||
padding: 0 30rpx;
|
||||
/* 左右内边距 */
|
||||
text-align: center;
|
||||
/* 文字居中 */
|
||||
/* 设置最小宽度 */
|
||||
}
|
||||
|
||||
.active {
|
||||
@ -721,12 +627,16 @@
|
||||
|
||||
.tab-bar-wrap {
|
||||
display: flex;
|
||||
/* 横向排列 */
|
||||
align-items: baseline;
|
||||
/* 垂直居中 */
|
||||
position: relative;
|
||||
/* 可选(若需要绝对定位 fallback) */
|
||||
}
|
||||
|
||||
.tab-more {
|
||||
margin-left: 10rpx;
|
||||
/* 与Tab的间距 */
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: linear-gradient(-88.60deg, rgba(18, 18, 18, 1), rgba(18, 18, 18, 0) 100%);
|
||||
@ -823,6 +733,22 @@
|
||||
color: rgb(187, 230, 0);
|
||||
}
|
||||
|
||||
.device-id {
|
||||
font-size: 26rpx;
|
||||
color: #999;
|
||||
margin-bottom: 20rpx;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.device-info {
|
||||
display: flex;
|
||||
justify-content: space-evenly;
|
||||
font-size: 28rpx;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
position: relative;
|
||||
padding: 0rpx 0rpx 30rpx 30rpx;
|
||||
}
|
||||
|
||||
.deviceIMG {
|
||||
width: 100rpx;
|
||||
height: 100rpx;
|
||||
@ -870,6 +796,16 @@
|
||||
left: -20rpx
|
||||
}
|
||||
|
||||
.line {
|
||||
width: 2rpx;
|
||||
height: 24rpx;
|
||||
background: linear-gradient(90deg,
|
||||
rgba(0, 0, 0, 0) 0%,
|
||||
rgb(255, 255, 255) 50%,
|
||||
rgba(255, 255, 255, 0) 100%);
|
||||
margin-top: 12rpx;
|
||||
}
|
||||
|
||||
.loading-status {
|
||||
text-align: center;
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
@ -908,6 +844,18 @@
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* 弹窗主体 */
|
||||
.agreement-popup {
|
||||
width: 100%;
|
||||
height: 50%;
|
||||
background-color: rgb(42, 42, 42);
|
||||
border-radius: 60rpx 60rpx 0rpx 0rpx;
|
||||
padding: 40rpx;
|
||||
box-sizing: border-box;
|
||||
position: absolute;
|
||||
bottom: 0rpx;
|
||||
}
|
||||
|
||||
.agreement-popupC {
|
||||
width: 60%;
|
||||
background-color: rgb(42, 42, 42);
|
||||
@ -959,6 +907,7 @@
|
||||
|
||||
}
|
||||
|
||||
/* 同意按钮 */
|
||||
.agreeBtn {
|
||||
background: #FFC84E;
|
||||
color: #232323;
|
||||
@ -984,6 +933,7 @@
|
||||
position: fixed;
|
||||
right: 18rpx;
|
||||
top: 140rpx;
|
||||
/* 根据导航栏高度调整 */
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
@ -991,6 +941,7 @@
|
||||
position: fixed;
|
||||
right: 18rpx;
|
||||
top: 230rpx;
|
||||
/* 根据导航栏高度调整 */
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
|
||||
@ -5,13 +5,17 @@
|
||||
<image src="/static/images/common/svg.png" class="svg"></image>
|
||||
<view class="scanT">ID: {{ deviceId }}</view>
|
||||
</view>
|
||||
|
||||
<!-- 连接中状态 -->
|
||||
<view class="connecting-container" v-else>
|
||||
<view class="device-info">
|
||||
<view class="">
|
||||
<image src="/static/images/common/svg.png" class="svg"></image>
|
||||
</view>
|
||||
|
||||
<!-- <view>
|
||||
<image src="/static/images/bip.6.png" class="bip"></image>
|
||||
</view> -->
|
||||
|
||||
<text class="device-name">设备名:{{deviceId}}</text>
|
||||
<text class="device-model1">ID:{{deviceId}}</text>
|
||||
</view>
|
||||
@ -67,7 +71,6 @@
|
||||
})
|
||||
console.log(this.deviceId, res);
|
||||
if (res.code == 200) {
|
||||
|
||||
this.isConnectNo = false
|
||||
this.isSuccess = true
|
||||
uni.hideLoading()
|
||||
|
||||
@ -1,34 +1,23 @@
|
||||
<template>
|
||||
<view class="share">
|
||||
<!-- 下拉刷新区域 -->
|
||||
<mescroll-uni ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :up="upOption" :down="downOption">
|
||||
<view class="device-title">已分享用户</view>
|
||||
<view class="" v-if="deviceList.length>0">
|
||||
<view class="device-info" v-for="(item, index) in deviceList" :key="index">
|
||||
<view class="device-header" @click.stop="handleFile(item)">
|
||||
<view class="deviceIMG">
|
||||
<image src="@/static/images/common/user.png" mode="aspectFit" class="IMG"></image>
|
||||
</view>
|
||||
<view class="device-name">
|
||||
<view>用户名:{{item.deviceName}}</view>
|
||||
<view class="ID">
|
||||
<view class="ID">{{item.phonenumber}}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="device-delete">
|
||||
<text class="delete" @click.stop="handleDelete(item)">移除</text>
|
||||
<view class="device-title">已分享用户</view>
|
||||
<view class="device-info" v-for="(item, index) in deviceList" :key="index">
|
||||
<view class="device-header" @click.stop="handleFile(item)">
|
||||
<view class="deviceIMG">
|
||||
<image src="@/static/images/common/user.png" mode="aspectFit" class="IMG"></image>
|
||||
</view>
|
||||
<view class="device-name">
|
||||
<view>用户名:{{item.deviceName}}</view>
|
||||
<view class="ID">
|
||||
<view class="ID">{{item.phonenumber}}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view v-else class="noDATA">
|
||||
<view> <uni-icons type="image-filled" size="120" color="rgba(255, 255, 255, 0.9)"></uni-icons>
|
||||
<view class="device-delete">
|
||||
<text class="delete" @click.stop="handleDelete(item)">移除</text>
|
||||
</view>
|
||||
暂无数据
|
||||
</view>
|
||||
</mescroll-uni>
|
||||
|
||||
</view>
|
||||
<!-- 删除弹框 -->
|
||||
<view class="agreement-mask" v-if="deleteShow" @click="closePopup('delete')">
|
||||
<view class="agreement-popup" @click.stop>
|
||||
@ -53,62 +42,16 @@
|
||||
deviceShareList,
|
||||
deviceShareDelete
|
||||
} from '@/api/6170/share.js'
|
||||
import MescrollUni from 'mescroll-uni/mescroll-uni.vue'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
MescrollUni
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
deviceList: [],
|
||||
deleteShow: false,
|
||||
delelteItemInfo: '',
|
||||
itemInfo: '',
|
||||
mescroll: null, // mescroll实例对象
|
||||
downOption: {
|
||||
auto: false // 不自动加载
|
||||
},
|
||||
upOption: {
|
||||
auto: false, // 不自动加载
|
||||
noMoreSize: 5, // 如果列表已无数据,可设置列表的总数量要大于等于5条才显示无更多数据
|
||||
empty: {
|
||||
tip: '暂无相关数据'
|
||||
}
|
||||
},
|
||||
page: 1, // 当前页码
|
||||
size: 10, // 每页条数
|
||||
total: 0 // 总数据量
|
||||
itemInfo: ''
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// mescroll组件初始化的回调,可获取到mescroll对象
|
||||
mescrollInit(mescroll) {
|
||||
this.mescroll = mescroll;
|
||||
},
|
||||
// 下拉刷新的回调
|
||||
downCallback() {
|
||||
// 重置分页参数
|
||||
this.page = 1;
|
||||
this.getData(this.itemInfo.id).then(res => {
|
||||
// 数据请求成功后,隐藏下拉刷新的状态
|
||||
this.mescroll.endSuccess();
|
||||
}).catch(() => {
|
||||
// 请求失败,隐藏下拉刷新的状态
|
||||
this.mescroll.endErr();
|
||||
})
|
||||
},
|
||||
// 上拉加载的回调
|
||||
upCallback() {
|
||||
this.getData(this.itemInfo.id).then(res => {
|
||||
// 根据是否有数据来决定是否显示无更多数据的提示
|
||||
const hasNext = this.deviceList.length < this.total;
|
||||
this.mescroll.endSuccess(this.deviceList.length, hasNext);
|
||||
}).catch(() => {
|
||||
// 请求失败,隐藏上拉加载的状态
|
||||
this.mescroll.endErr();
|
||||
})
|
||||
},
|
||||
// 点击弹框外的区域关闭
|
||||
closePopup(type) {
|
||||
if (type === 'delete') {
|
||||
@ -130,43 +73,25 @@
|
||||
icon: 'none'
|
||||
})
|
||||
this.deleteShow = false
|
||||
// 删除后刷新列表
|
||||
this.page = 1;
|
||||
this.getData(this.itemInfo.id).then(() => {
|
||||
this.mescroll.resetUpScroll();
|
||||
})
|
||||
this.getData()
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
|
||||
})
|
||||
//
|
||||
},
|
||||
getData(val) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let data = {
|
||||
deviceId: val,
|
||||
pageNum: this.page,
|
||||
pageSize: this.size,
|
||||
let data = {
|
||||
deviceId: val
|
||||
}
|
||||
deviceShareList(data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
this.deviceList = res.rows
|
||||
}
|
||||
deviceShareList(data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
this.total = res.total;
|
||||
if (this.page === 1) {
|
||||
// 如果是第一页,直接替换数据
|
||||
this.deviceList = res.rows;
|
||||
} else {
|
||||
// 如果不是第一页,追加数据
|
||||
this.deviceList = this.deviceList.concat(res.rows);
|
||||
}
|
||||
resolve(res);
|
||||
} else {
|
||||
reject(res);
|
||||
}
|
||||
}).catch(err => {
|
||||
reject(err);
|
||||
})
|
||||
})
|
||||
},
|
||||
// 跳转分享详情
|
||||
@ -184,6 +109,7 @@
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
},
|
||||
onLoad() {
|
||||
const eventChannel = this.getOpenerEventChannel();
|
||||
@ -191,14 +117,7 @@
|
||||
eventChannel.on('shareManagement', (data) => {
|
||||
console.log(data, 'data1t111');
|
||||
this.itemInfo = data.data;
|
||||
// 初始化加载数据
|
||||
this.page = 1;
|
||||
this.getData(this.itemInfo.id).then(() => {
|
||||
// 数据加载完成后,如果需要可以手动触发下拉刷新结束
|
||||
if (this.mescroll) {
|
||||
this.mescroll.endSuccess();
|
||||
}
|
||||
})
|
||||
this.getData(this.itemInfo.id)
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -213,7 +132,7 @@
|
||||
|
||||
.device-title {
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
padding: 30rpx;
|
||||
padding: 30rpx 0;
|
||||
}
|
||||
|
||||
.device-info {
|
||||
@ -245,7 +164,7 @@
|
||||
|
||||
.deviceIMG {
|
||||
/* width: 100rpx; */
|
||||
/* height: 100rpx; */
|
||||
/* height: 100rpx; */
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@ -256,12 +175,6 @@
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.noDATA {
|
||||
text-align: center;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
transform: translate(-0%, 100%);
|
||||
}
|
||||
|
||||
.delete {
|
||||
border-radius: 32px;
|
||||
background: rgba(255, 200, 78, 0.06);
|
||||
|
||||
Reference in New Issue
Block a user