Compare commits
2 Commits
70651b81f5
...
5e9e32cd81
Author | SHA1 | Date | |
---|---|---|---|
5e9e32cd81 | |||
52c4a0b436 |
525
pages/6170/allShare/index.vue
Normal file
525
pages/6170/allShare/index.vue
Normal file
@ -0,0 +1,525 @@
|
||||
<template>
|
||||
<view>
|
||||
<view class="device-page">
|
||||
<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.name}}
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<scroll-view class="device-list" scroll-y @scrolltolower="onScrollToLower" :lower-threshold="100"
|
||||
style="height:80vh">
|
||||
<view v-if="deviceList.length>0">
|
||||
<view v-for="(group, groupIndex) in groupedDevices" :key="groupIndex">
|
||||
<view class="share-header">
|
||||
<text>{{
|
||||
tabs[activeTab].name === '我的分享'
|
||||
? `分享给“${group.sharedTo}”的设备`
|
||||
: `来自“${group.sharedTo}”分享的设备`
|
||||
}}</text>
|
||||
<text class="edit-btn"
|
||||
@click="toggleEdit(groupIndex)">{{editingGroup === groupIndex ? '完成' : '编辑'}}</text>
|
||||
</view>
|
||||
<block>
|
||||
|
||||
<view class="device-card" v-for="(item, index) in group.devices" :key="index"
|
||||
:ref="'swipeItem_' + index">
|
||||
<view class="checkbox" v-if="editingGroup === groupIndex">
|
||||
<uni-icons @click="handleDelete(item)" type="minus" size="20"
|
||||
color="#FF4D4F"></uni-icons>
|
||||
</view>
|
||||
<view class="device-content" @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">
|
||||
ID:{{item.deviceImei}}</view>
|
||||
<view class="onlines">在线</view>
|
||||
<view>电量:{{item.battery || '80'}}%</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
<!-- 加载状态提示 -->
|
||||
<!-- <view class="loading-status">
|
||||
<text v-if="loading">加载中...</text>
|
||||
<text v-if="finished">没有更多数据了</text>
|
||||
</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>
|
||||
暂无数据
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
<!-- 删除弹框 -->
|
||||
<view class="agreement-mask" v-if="deleteShow" @click="closePopup('delete')">
|
||||
<view class="agreement-popupC" @click.stop>
|
||||
<view class="popup-content">
|
||||
<image src="/static/images/delel.png" class="svg" mode="aspectFit"></image>
|
||||
<uni-icon class="trash"></uni-icon>
|
||||
<view class="popup-Title">
|
||||
{{ tabs[activeTab].name === '我的分享' ? '确定停止分享该设备' : '确定移除他人分享给你的这台设备' }}
|
||||
</view>
|
||||
</view>
|
||||
<!-- 按钮组 -->
|
||||
<view class="popup-buttons">
|
||||
<button class="btn agreeBtn" @click="handleBtn">确定</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
deviceShareList,
|
||||
otherDeviceShareList,
|
||||
deviceShareDelete
|
||||
} from '@/api/6170/share.js'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
deviceList: [],
|
||||
tabs: [{
|
||||
name: '我的分享',
|
||||
},
|
||||
{
|
||||
name: '他人分享',
|
||||
},
|
||||
],
|
||||
activeTab: 0,
|
||||
deleteShow: false,
|
||||
page: 1, // 当前页码
|
||||
size: 10, // 每页条数
|
||||
total: 0, // 总数据量
|
||||
loading: false,
|
||||
finished: false,
|
||||
deviceId: '',
|
||||
editingGroup: null, // 编辑的分组索引
|
||||
currentGroup: null // 当前操作的分组
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
// 根据分享用户分组设备
|
||||
groupedDevices() {
|
||||
const groups = {};
|
||||
this.deviceList.forEach(device => {
|
||||
// 这里假设device.sharedTo是分享目标的手机号
|
||||
const key = device.sharedTo || '未分享';
|
||||
if (!groups[key]) {
|
||||
groups[key] = {
|
||||
sharedTo: key,
|
||||
devices: []
|
||||
};
|
||||
}
|
||||
groups[key].devices.push(device);
|
||||
});
|
||||
return Object.values(groups);
|
||||
},
|
||||
|
||||
},
|
||||
methods: {
|
||||
// 点击弹框外的区域关闭
|
||||
closePopup(type) {
|
||||
if (type === 'delete') {
|
||||
this.deleteShow = false;
|
||||
}
|
||||
},
|
||||
// 跳转到详情页面
|
||||
handleFile(item) {
|
||||
uni.navigateTo({
|
||||
url: "/pages/6170/deviceControl/index",
|
||||
success: (res) => {
|
||||
// 页面跳转成功后的回调函数
|
||||
res.eventChannel.emit('deviceControl', {
|
||||
data: item,
|
||||
apiType: 'listB' // 自定义标识 // 自定义标识,详情哪里根据这个参数不同信息
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
},
|
||||
|
||||
// 编辑
|
||||
toggleEdit(groupIndex) {
|
||||
if (this.editingGroup === groupIndex) {
|
||||
this.editingGroup = null;
|
||||
} else {
|
||||
this.editingGroup = groupIndex;
|
||||
}
|
||||
},
|
||||
// 停止分享
|
||||
handleDelete(item) {
|
||||
console.log(item, 'www');
|
||||
this.deleteShow = true
|
||||
this.delelteItemInfo = item
|
||||
},
|
||||
// 确认停止移除
|
||||
handleBtn() {
|
||||
let allId = this.delelteItemInfo.id
|
||||
deviceShareDelete(allId).then((res) => {
|
||||
if (res.code = 200) {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none'
|
||||
})
|
||||
this.deleteShow = false
|
||||
this.editingGroup = null;
|
||||
this.onIntall()
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
|
||||
})
|
||||
//
|
||||
},
|
||||
// tab切换页
|
||||
switchTab(tab, index) {
|
||||
//console.log(tab, 'tabsss');
|
||||
this.deviceList = [];
|
||||
this.activeTab = index;
|
||||
this.page = 1; // 重置页
|
||||
this.getData(tab);
|
||||
},
|
||||
// 获取设备列表
|
||||
getData(tab) {
|
||||
//console.log(tab.name, 'tab');
|
||||
if (this.loading) return;
|
||||
this.loading = true;
|
||||
let data = {
|
||||
pageNum: this.page,
|
||||
pageSize: this.size,
|
||||
}
|
||||
// 根据当前tab决定调用哪个接口
|
||||
const apiCall = tab.name === '我的分享' ? deviceShareList : otherDeviceShareList;
|
||||
console.log('nihao');
|
||||
apiCall(data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
const newDevices = res.rows.map(device => ({
|
||||
...device,
|
||||
showConfirm: false,
|
||||
sharedTo: device.phonenumber || '未分享'
|
||||
}));
|
||||
// 分页处理
|
||||
if (this.page === 1) {
|
||||
this.deviceList = newDevices;
|
||||
} else {
|
||||
this.deviceList = [...this.deviceList, ...newDevices];
|
||||
}
|
||||
|
||||
this.total = res.total;
|
||||
// 判断是否已加载全部数据
|
||||
if (res.rows.length < this.size || this.deviceList.length >= this.total) {
|
||||
this.finished = true;
|
||||
} else {
|
||||
this.page++;
|
||||
}
|
||||
}
|
||||
}).finally(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
|
||||
|
||||
},
|
||||
// 滚动触底事件处理
|
||||
onScrollToLower() {
|
||||
this.getData();
|
||||
},
|
||||
onIntall() {
|
||||
this.page = 1;
|
||||
const currentTab = this.tabs[this.activeTab];
|
||||
this.getData(currentTab);
|
||||
},
|
||||
},
|
||||
onLoad() {
|
||||
this.onIntall()
|
||||
// 绑定页面做了监听,新增成功,刷新页面
|
||||
uni.$on('refreshDeviceList', () => {
|
||||
this.onIntall()
|
||||
});
|
||||
},
|
||||
beforeDestroy() {
|
||||
// 组件销毁前移除监听器
|
||||
uni.$off('refreshDeviceList');
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
/* 页面整体样式 */
|
||||
.device-page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 100vh;
|
||||
background-color: rgb(18, 18, 18);
|
||||
padding: 30rpx;
|
||||
}
|
||||
|
||||
.tab-bar {
|
||||
width: 100%;
|
||||
color: rgb(255, 255, 255);
|
||||
white-space: nowrap;
|
||||
/* 禁止换行 */
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
|
||||
}
|
||||
|
||||
.tab-container {
|
||||
display: flex;
|
||||
/* justify-content: space-around; */
|
||||
cursor: pointer;
|
||||
margin-bottom: 40rpx;
|
||||
/* min-width: 100%; */
|
||||
/* 最小宽度 */
|
||||
}
|
||||
|
||||
.tab-item {
|
||||
font-size: 28rpx;
|
||||
/* min-width: 120rpx; */
|
||||
padding: 0 30rpx;
|
||||
/* 左右内边距 */
|
||||
text-align: center;
|
||||
/* 文字居中 */
|
||||
/* 设置最小宽度 */
|
||||
}
|
||||
|
||||
.active {
|
||||
color: rgba(187, 230, 0, 1);
|
||||
border-bottom: 6rpx solid rgba(187, 230, 0, 1);
|
||||
height: 60rpx;
|
||||
}
|
||||
|
||||
/* 设备卡片 */
|
||||
.device-card {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.device-content {
|
||||
background-color: rgb(26, 26, 26);
|
||||
border-radius: 16rpx;
|
||||
margin-bottom: 20rpx;
|
||||
position: relative;
|
||||
padding: 20rpx;
|
||||
width: 100%;
|
||||
|
||||
}
|
||||
|
||||
.device-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 15rpx;
|
||||
}
|
||||
|
||||
|
||||
.device-name {
|
||||
font-size: 32rpx;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
margin-left: 24rpx;
|
||||
line-height: 50rpx;
|
||||
width: 78%;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.ID {
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
font-size: 26rpx;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
position: relative;
|
||||
|
||||
}
|
||||
|
||||
.circle {
|
||||
width: 8rpx;
|
||||
height: 40rpx;
|
||||
position: absolute;
|
||||
right: 25rpx;
|
||||
top: 60rpx;
|
||||
}
|
||||
|
||||
.online {
|
||||
color: rgb(187, 230, 0);
|
||||
}
|
||||
|
||||
.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%;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.onlines {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.onlines::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
width: 15rpx;
|
||||
height: 15rpx;
|
||||
background: rgb(0, 171, 103);
|
||||
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;
|
||||
}
|
||||
|
||||
.loading-status {
|
||||
text-align: center;
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
padding: 20rpx;
|
||||
font-size: 22rpx;
|
||||
}
|
||||
|
||||
.noDATA {
|
||||
text-align: center;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
transform: translate(-0%, 100%);
|
||||
}
|
||||
|
||||
.share-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
font-size: 28rpx;
|
||||
margin-bottom: 20rpx;
|
||||
margin-top: 1rpx;
|
||||
}
|
||||
|
||||
.edit-btn {
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
/* 遮罩层 */
|
||||
.agreement-mask {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
.popup-Title {
|
||||
color: rgba(255, 255, 255, 0.86);
|
||||
text-align: center;
|
||||
padding: 30rpx 0rpx;
|
||||
}
|
||||
|
||||
.popup-buttons {
|
||||
display: flex;
|
||||
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: 65%;
|
||||
background: rgba(56, 57, 52, 0.4);
|
||||
border-radius: 40rpx;
|
||||
padding: 30rpx;
|
||||
text-align: center;
|
||||
border: 1px solid rgba(224, 52, 52, 0.3);
|
||||
}
|
||||
|
||||
.popup-flex {
|
||||
display: flex;
|
||||
white-space: nowrap;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
height: 50rpx;
|
||||
padding: 30rpx;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.popup-input {
|
||||
border: 1px solid rgba(255, 255, 255, 0.4);
|
||||
border-radius: 12rpx;
|
||||
margin-left: 15rpx;
|
||||
padding: 10rpx 0rpx;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.svg {
|
||||
width: 58rpx;
|
||||
height: 62rpx;
|
||||
}
|
||||
|
||||
/* 通用按钮样式 */
|
||||
.btn {
|
||||
height: 60rpx;
|
||||
line-height: 60rpx;
|
||||
border-radius: 40rpx;
|
||||
font-size: 24rpx;
|
||||
margin: 10rpx auto;
|
||||
text-align: center;
|
||||
|
||||
}
|
||||
|
||||
/* 同意按钮 */
|
||||
.agreeBtn {
|
||||
background: rgba(224, 52, 52, 1);
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
border: none;
|
||||
width: 170rpx !important;
|
||||
}
|
||||
|
||||
.closeBtn {
|
||||
border: 1px solid rgba(255, 255, 255, 0.2);
|
||||
background-color: rgba(35, 35, 35, 0.87);
|
||||
color: rgba(255, 255, 255, 1);
|
||||
}
|
||||
</style>
|
@ -1,13 +1,18 @@
|
||||
<template>
|
||||
<view>
|
||||
<!-- 添加全局加载遮罩 -->
|
||||
<view v-if="pageLoading" class="page-loading-mask">
|
||||
</view>
|
||||
<!-- 使用自定义导航栏 -->
|
||||
<custom-navbar :title="navTitle" :showBack="true" color="#FFFFFF" rightIcon="/static/images/path.png"
|
||||
@right-click="uploadStartup"></custom-navbar>
|
||||
<view v-show="!pageLoading">
|
||||
<custom-navbar :title="navTitle" :showBack="true" color="#FFFFFF"
|
||||
:rightIcon="isRightIconVisible ? '/static/images/shape.png' : ''"
|
||||
@right-click="shareUp"></custom-navbar>
|
||||
<view class="device-detail-container" :style="{ paddingTop: navBarHeight + 'px' }">
|
||||
<!-- 设备电量信息 -->
|
||||
<view class="battery-section">
|
||||
<view class="battery-sectionLeft">
|
||||
<image src="/static/images/bip.6.png" class="bipImg"></image>
|
||||
<image :src="deviceInfo.devicePic" class="bipImg" mode="aspectFit"></image>
|
||||
</view>
|
||||
<view>
|
||||
<view class="battery-v1">
|
||||
@ -18,7 +23,7 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="battery-v1">
|
||||
<image src="/static/images/nz.png" class="dlIMG"></image>
|
||||
<image src="/static/images/nz.png" class="dlIMG" mode="aspectFit"></image>
|
||||
<view>
|
||||
<view class="battery-v2">1小时</view>
|
||||
<view class="battery-v3">续航时间</view>
|
||||
@ -26,7 +31,6 @@
|
||||
</view>
|
||||
</view>
|
||||
<view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@ -34,7 +38,7 @@
|
||||
<view class="info-card">
|
||||
<view class="info-row">
|
||||
<text class="info-label">IMEI号</text>
|
||||
<text class="info-value">123456</text>
|
||||
<text class="info-value status-running">{{deviceInfo.deviceImei}}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">设备状态</text>
|
||||
@ -42,7 +46,7 @@
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">定位信息</text>
|
||||
<view class="info-value status-running">
|
||||
<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">深圳市龙华区富源晟</view>
|
||||
</view>
|
||||
@ -52,20 +56,20 @@
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">灯光亮度</text>
|
||||
<text class="info-value status-running">%</text>
|
||||
<text class="info-value status-running">{{ sliderValue }}%</text>
|
||||
</view>
|
||||
|
||||
<!-- 灯光亮度控制 -->
|
||||
<view class="control-card">
|
||||
<slider :value="sliderValue" min="0" max="100" activeColor="rgb(187, 230, 0)"
|
||||
backgroundColor="rgb(26, 26, 26)" show-value />
|
||||
|
||||
<slider :value="sliderValue" min="10" max="100" activeColor="rgb(187, 230, 0)"
|
||||
backgroundColor="rgb(26, 26, 26)" :show-value="false" @changing="onSliderChanging"
|
||||
@change="onSliderChanging" />
|
||||
</view>
|
||||
|
||||
<!-- 灯光模式选择 -->
|
||||
<view class="mode-section">
|
||||
<view class="mode-buttons">
|
||||
<view class="mode-v1">
|
||||
<view class="mode-v1" v-if="hasPermission('1')">
|
||||
<view class="mode-v2" @click="selectMode('main')">
|
||||
<image src="/static/images/set.png" class="setIMG"></image>
|
||||
<view>
|
||||
@ -74,18 +78,17 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="mode-v1">
|
||||
<view class="mode-v1" v-if="hasPermission('2')">
|
||||
<view class="mode-v2" @click="lasermode">
|
||||
<image src="/static/images/jg.png" class="setIMG"></image>
|
||||
<image src="/static/images/jg.png" class="setIMG" mode="aspectFit"></image>
|
||||
<view>
|
||||
<view class="battery-v2">激光模式</view>
|
||||
<!--<view class="mode-v3">{{currentSecondaryMode}}</view> -->
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="mode-v1">
|
||||
<view class="mode-v1" v-if="hasPermission('3')">
|
||||
<view class="mode-v2" @click="uploadStartup">
|
||||
<image src="/static/images/path7.png" class="setIMG"></image>
|
||||
<image src="/static/images/path7.png" class="setIMG" mode="aspectFit"></image>
|
||||
<view>
|
||||
<view class="battery-v2">开机画面</view>
|
||||
<view class="mode-v3">上传</view>
|
||||
@ -96,67 +99,67 @@
|
||||
</view>
|
||||
|
||||
<!-- 人员信息登记 -->
|
||||
<view class="form-section">
|
||||
<view class="form-section" v-if="hasPermission('4')">
|
||||
<view class="mode-buttons">
|
||||
<view class="section-title">人员信息登记</view>
|
||||
<!-- <button class="send-btn">发送</button> -->
|
||||
<view class="right-icons">
|
||||
|
||||
<uni-icons @click="toggleForm" :type="isFormExpanded ? 'arrowup' : 'down'" size="20"
|
||||
color="rgba(255, 255, 255, 0.87" class="toggle-icon" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="form-content" v-if="isFormExpanded">
|
||||
<button class="send-btn1">发送</button>
|
||||
<button class="send-btn1" @click="sendPersonnelInfo">发送</button>
|
||||
<view class="form-row">
|
||||
<text class="form-label">单位:</text>
|
||||
<input class="form-input" placeholder="请输入单位" />
|
||||
<input class="form-input" placeholder="请输入单位" v-model="personnelInfo.unitName" />
|
||||
</view>
|
||||
<view class="form-row">
|
||||
<text class="form-label">姓名:</text>
|
||||
<input class="form-input" placeholder="请输入姓名" />
|
||||
<input class="form-input" placeholder="请输入姓名" v-model="personnelInfo.name" />
|
||||
</view>
|
||||
<view class="form-row">
|
||||
<text class="form-label">职位:</text>
|
||||
<input class="form-input" placeholder="请输入职位" />
|
||||
<input class="form-input" placeholder="请输入职位" v-model="personnelInfo.position" />
|
||||
</view>
|
||||
<view class="form-row">
|
||||
<text class="form-label">ID:</text>
|
||||
<input class="form-input" placeholder="请输入ID号" />
|
||||
<input class="form-input" placeholder="请输入ID号" v-model="personnelInfo.code" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 人员信息登记 -->
|
||||
<view class="form-section">
|
||||
<view class="form-section" v-if="hasPermission('5')">
|
||||
<view class="mode-buttons">
|
||||
<view class="section-title">发送信息</view>
|
||||
<button class="send-btn">发送</button>
|
||||
<button class="send-btn" @click="sendTextMessage">发送</button>
|
||||
</view>
|
||||
|
||||
<view class="form-row">
|
||||
<input class="form-input" placeholder="请输入文字" />
|
||||
<input class="form-input" placeholder="请输入文字" v-model="messageToSend" />
|
||||
</view>
|
||||
</view>
|
||||
<!-- 产品信息 -->
|
||||
<view v-if="hasPermission('6')">
|
||||
<view class="section-title">产品信息</view>
|
||||
<view class="mode-buttons">
|
||||
<view class="mode_1" @click="productparams">
|
||||
<image src="/static/images/cp.png" mode="" class="cpIMG"></image>
|
||||
<image src="/static/images/cp.png" mode="" class="cpIMG" mode="aspectFit"></image>
|
||||
<view class="">产品参数</view>
|
||||
</view>
|
||||
<view class="mode_1" @click="operatingInst">
|
||||
<image src="/static/images/sm.png" mode="" class="cpIMG"></image>
|
||||
<image src="/static/images/sm.png" mode="" class="cpIMG" mode="aspectFit"></image>
|
||||
<view class="">操作说明</view>
|
||||
</view>
|
||||
<view class="mode_1" @click="operatingVideo">
|
||||
<image src="/static/images/sp.png" mode="" class="cpIMG"></image>
|
||||
<image src="/static/images/sp.png" mode="" class="cpIMG" mode="aspectFit"></image>
|
||||
<view class="">操作视频</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 弹框 -->
|
||||
<view class="agreement-mask" v-if="lightModeA">
|
||||
<!-- 协议弹窗 -->
|
||||
<view class="agreement-mask" v-if="lightModeA" @click.stop="closePopup">
|
||||
<!-- 灯光模式弹窗 -->
|
||||
<view class="agreement-popup" @click.stop>
|
||||
<!-- 标题 -->
|
||||
<view class="popup-title"> {{ popupTitle }}</view>
|
||||
@ -175,15 +178,23 @@
|
||||
</view>
|
||||
</view>
|
||||
<!-- 上传开机画面弹框 -->
|
||||
<view class="agreement-mask" v-if="lightModeB">
|
||||
<view class="agreement-mask" v-if="lightModeB" @click.stop="closePopup">
|
||||
<!-- 上传画面弹窗 -->
|
||||
<view class="agreement-popup">
|
||||
<view class="agreement-popupB" @click.stop>
|
||||
<!-- 标题 -->
|
||||
<view class="popup-title">上传开机画面</view>
|
||||
<view class="popup-content">
|
||||
<view class="example-body">
|
||||
<uni-file-picker limit="1"></uni-file-picker>
|
||||
<view class="example_title">点击上传图片</view>
|
||||
<!-- <uni-file-picker limit="1" class="custom-file-picker"></uni-file-picker> -->
|
||||
<view class="icoContent" @click="checkImgUpload">
|
||||
<!-- <image mode="aspectFit" class="img" src="/static/images/6155/DeviceDetail/add.png">
|
||||
</image> -->
|
||||
<image v-if="selectedImage" :src="selectedImage" mode="aspectFit" class="img"
|
||||
style="width: 100%; height: 100%;"></image>
|
||||
<image v-else mode="aspectFit" class="img"
|
||||
src="/static/images/6155/DeviceDetail/add.png"></image>
|
||||
</view>
|
||||
<!-- <view class="example_title">点击上传图片</view> -->
|
||||
</view>
|
||||
</view>
|
||||
<!-- 按钮组 -->
|
||||
@ -193,9 +204,9 @@
|
||||
</view>
|
||||
</view>
|
||||
<!--===================== 激光提示框================== -->
|
||||
<view class="agreement-mask" v-if="lightModeC">
|
||||
<view class="agreement-mask" v-if="lightModeC" @click.stop="closePopup">
|
||||
<!-- 上传画面弹窗 -->
|
||||
<view class="agreement-popupC">
|
||||
<view class="agreement-popupC" @click.stop>
|
||||
<!-- 标题 -->
|
||||
<view class="popup-title">确认开启激光模式?</view>
|
||||
<view class="popup-content">
|
||||
@ -209,30 +220,76 @@
|
||||
<!-- 按钮组 -->
|
||||
<view class="popup-buttons">
|
||||
<button class="btn disagree" @click="handleDisagree">取消</button>
|
||||
<button class="btn agreeBtn" @click="handleBtn">确定</button>
|
||||
<button class="btn agreeBtn" @click.stop="handleBtn">确定</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 人员信息成功提示弹框 -->
|
||||
<CustomPopup :show="showPopupFlag" :message="popupMessage" icon="/static/images/sendSucc.png"
|
||||
:confirm-text="popupConfirmText" :show-cancel="false" @confirm="onPopupConfirm" />
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import MqttClient from '@/utils/mqtt.js';
|
||||
import {
|
||||
deviceDetail,
|
||||
registerPersonInfo,
|
||||
deviceSendMessage,
|
||||
deviceShareId
|
||||
} from '@/api/6170/deviceControl.js'
|
||||
import {
|
||||
getDeviceId
|
||||
} from '../../../store/BLETools';
|
||||
import {
|
||||
baseURL,
|
||||
getToken,
|
||||
clientid
|
||||
} from '@/utils/request'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
pageLoading: true,
|
||||
mainMode: 'string',
|
||||
secondaryMode: 'string',
|
||||
navBarHeight: 70 + uni.getSystemInfoSync().statusBarHeight,
|
||||
navTitle: "6170",
|
||||
sliderValue: 50,
|
||||
navTitle: "",
|
||||
sliderValue: 30,
|
||||
lightModeA: false,
|
||||
currentMainMode: '强光模式',
|
||||
currentSecondaryMode: '泛光模式',
|
||||
currentMainMode: '强光',
|
||||
lightModeB: false,
|
||||
lightModeC: false, //激光提示框
|
||||
items: [],
|
||||
isFormExpanded: true, // 默认展开
|
||||
deviceID: ''
|
||||
deviceID: '',
|
||||
itemInfo: {},
|
||||
mqttClient: null,
|
||||
messageToSend: '',
|
||||
personnelInfo: {
|
||||
unitName: '',
|
||||
name: '',
|
||||
position: '',
|
||||
code: '',
|
||||
},
|
||||
deviceInfo: {},
|
||||
modeInstructions: {
|
||||
'关灯': [1, 0, 0, 0, 0],
|
||||
'强光': [1, 1, 0, 0, 0],
|
||||
'弱光': [1, 2, 0, 0, 0],
|
||||
'爆闪': [1, 3, 0, 0, 0],
|
||||
'泛光': [1, 4, 0, 0, 0]
|
||||
},
|
||||
activePermissions: [], // 存储当前设备的权限数组
|
||||
isSharedDevice: false, // 标记是否来自分享
|
||||
isRightIconVisible: false,
|
||||
showPopupFlag: false, //是否显示弹框
|
||||
popupMessage: '!',
|
||||
popupConfirmText: '确认',
|
||||
showUploadPopup: false,
|
||||
selectedImage: null, // 添加这个变量来存储选择的图片
|
||||
file: '',
|
||||
selectedItemIndex: 0
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@ -241,31 +298,46 @@
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 点击弹框外的区域关闭
|
||||
closePopup() {
|
||||
this.lightModeA = false;
|
||||
this.lightModeB = false;
|
||||
this.lightModeC = false;
|
||||
},
|
||||
// *******定位******
|
||||
gpsPosition() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/common/map/index'
|
||||
})
|
||||
},
|
||||
// ***********进度条***********
|
||||
onSliderChanging(e) {
|
||||
this.sliderValue = e.detail.value;
|
||||
},
|
||||
selectMode(type) {
|
||||
this.modeType = type;
|
||||
this.lightModeA = true;
|
||||
if (type === 'main') {
|
||||
this.items = [{
|
||||
text: '强光',
|
||||
selected: this.currentMainMode === '强光模式',
|
||||
image: '/static/images/sett.png'
|
||||
selected: this.currentMainMode === '强光', // 修正匹配条件
|
||||
image: '/static/images/sett.png',
|
||||
},
|
||||
{
|
||||
text: '弱光',
|
||||
selected: this.currentMainMode === '弱光模式',
|
||||
selected: this.currentMainMode === '弱光',
|
||||
image: '/static/images/sett.png'
|
||||
},
|
||||
{
|
||||
text: '爆闪',
|
||||
selected: this.currentMainMode === '爆闪模式',
|
||||
selected: this.currentMainMode === '爆闪',
|
||||
image: '/static/images/bs.png'
|
||||
},
|
||||
{
|
||||
text: '泛光',
|
||||
selected: this.currentMainMode === '泛光模式',
|
||||
selected: this.currentMainMode === '泛光',
|
||||
image: '/static/images/settt.png'
|
||||
},
|
||||
|
||||
];
|
||||
}
|
||||
},
|
||||
@ -276,43 +348,149 @@
|
||||
toggleForm() {
|
||||
this.isFormExpanded = !this.isFormExpanded;
|
||||
},
|
||||
|
||||
onItemClick(index) {
|
||||
const selectedItem = this.items[index];
|
||||
console.log(selectedItem.text, 'selectedItem.text');
|
||||
if (selectedItem.text === '激光') {
|
||||
this.lightModeC = true
|
||||
this.selectedItemIndex = index; // 记录当前选择的索引
|
||||
this.lightModeC = true;
|
||||
} else {
|
||||
this.updateSelectedItem(index);
|
||||
}
|
||||
},
|
||||
updateSelectedItem(index) {
|
||||
// 更新选中状态
|
||||
this.items = this.items.map((item, i) => ({
|
||||
...item,
|
||||
selected: i === index
|
||||
}));
|
||||
if (this.modeType === 'main') {
|
||||
this.currentMainMode = this.items[index].text + '模式';
|
||||
} else {
|
||||
this.currentSecondaryMode = this.items[index].text + '模式';
|
||||
this.currentMainMode = selectedItem.text;
|
||||
this.selectedItemIndex = index;
|
||||
// 强制更新视图(如果需要)
|
||||
this.$forceUpdate();
|
||||
}
|
||||
this.showPopup = false; // 关闭弹窗
|
||||
},
|
||||
// 确认
|
||||
// 灯光模式的确认
|
||||
handleSumbit() {
|
||||
this.lightModeA = false
|
||||
if (this.selectedItemIndex === null) return;
|
||||
const selectedItem = this.items[this.selectedItemIndex];
|
||||
const instruction = this.modeInstructions[selectedItem.text];
|
||||
console.log(selectedItem, 'selectedItemselectedItem');
|
||||
// 修正这里的赋值错误,应该保存索引而不是文本
|
||||
this.selectedItemIndex = this.selectedItemIndex;
|
||||
console.log(this.selectedItemIndex,'this.selectedItemIndexthis.selectedItemIndex');
|
||||
// if (instruction) {
|
||||
// const topic = `B/${this.itemInfo.deviceImei}`;
|
||||
// const message = JSON.stringify(instruction);
|
||||
// // 确保mqttClient已连接
|
||||
// if (this.mqttClient && this.mqttClient.client && this.mqttClient.client.isConnected()) {
|
||||
// this.mqttClient.publish(topic, message);
|
||||
// console.log('已发送指令:', instruction);
|
||||
// } else {
|
||||
// uni.showToast({
|
||||
// title: 'MQTT未连接',
|
||||
// icon: 'none'
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
this.lightModeA = false;
|
||||
},
|
||||
// 上传开机画面
|
||||
uploadStartup() {
|
||||
this.lightModeB = true
|
||||
},
|
||||
// 上传开机画面
|
||||
checkImgUpload() {
|
||||
uni.chooseImage({
|
||||
count: 1,
|
||||
sizeType: ['original', 'compressed'],
|
||||
sourceType: ['album', 'camera'],
|
||||
success: (res) => {
|
||||
// 将选择的图片赋值给selectedImage
|
||||
const file = res.tempFiles[0];
|
||||
const fileSize = file.size || 0;
|
||||
if (fileSize > 2 * 1024 * 1024) {
|
||||
console.log(`文件过大: ${fileSize} 字节`); // 调试日志
|
||||
uni.showToast({
|
||||
title: '图片大小不能超过2MB',
|
||||
icon: 'none',
|
||||
duration: 3000
|
||||
});
|
||||
return;
|
||||
}
|
||||
this.selectedImage = res.tempFilePaths[0];
|
||||
console.log('选择的图片:', res);
|
||||
this.file = res.tempFiles[0].file
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('选择图片失败:', err);
|
||||
uni.showToast({
|
||||
title: '选择图片失败',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
// 上传开机画面确认按键
|
||||
handleupload() {
|
||||
if (!this.selectedImage) {
|
||||
uni.showToast({
|
||||
title: '请上传一张图片',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
uni.uploadFile({
|
||||
url: baseURL + '/app/device/uploadLogo',
|
||||
filePath: this.selectedImage,
|
||||
name: this.file,
|
||||
formData: {
|
||||
deviceId: this.deviceID,
|
||||
},
|
||||
header: {
|
||||
'Authorization': 'Bearer ' + getToken(),
|
||||
'clientid': clientid(),
|
||||
},
|
||||
complete: (res) => {
|
||||
console.log(res, 'resss');
|
||||
try {
|
||||
const responseData = JSON.parse(res.data);
|
||||
if (responseData.code === 200) {
|
||||
uni.showToast({
|
||||
title: responseData.msg,
|
||||
icon: 'success'
|
||||
});
|
||||
this.selectedImage = '';
|
||||
this.file = null;
|
||||
this.lightModeB = false
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: responseData.msg,
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
uni.showToast({
|
||||
title: '上传失败',
|
||||
icon: 'none'
|
||||
});
|
||||
} finally {
|
||||
uni.hideLoading();
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
},
|
||||
// 分享
|
||||
shareUp() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/6170/share/index',
|
||||
events: {
|
||||
ack: function(data) {}
|
||||
},
|
||||
success: (res) => {
|
||||
res.eventChannel.emit('share', {
|
||||
data: this.itemInfo,
|
||||
});
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 操纵说明
|
||||
// 操作说明
|
||||
operatingInst() {
|
||||
uni.navigateTo({
|
||||
url: `/pages/common/operatingInstruct/index?id=${this.deviceID}`
|
||||
@ -331,26 +509,251 @@
|
||||
})
|
||||
|
||||
},
|
||||
// 同意
|
||||
// 激光确认框
|
||||
handleBtn() {
|
||||
this.lightModeC = false
|
||||
this.updateSelectedItem(this.selectedItemIndex); // 使用记录的索引来更新选择项
|
||||
this.lightModeA = false //关闭大弹框
|
||||
},
|
||||
// 不同意
|
||||
//取消
|
||||
handleDisagree() {
|
||||
this.lightModeC = false
|
||||
},
|
||||
// 发送人员信息
|
||||
sendPersonnelInfo() {
|
||||
// if (!this.mqttClient || !this.mqttClient.client.isConnected()) {
|
||||
// uni.showToast({
|
||||
// title: 'MQTT未连接',
|
||||
// icon: 'none'
|
||||
// });
|
||||
// return;
|
||||
// }
|
||||
// const topic = `device/command/${this.deviceID}/personnel`;
|
||||
// const message = JSON.stringify(this.personnelInfo);
|
||||
// this.mqttClient.publish(topic, message);
|
||||
// uni.showToast({
|
||||
// title: '人员信息已发送',
|
||||
// icon: 'success'
|
||||
// });
|
||||
|
||||
if (!this.personnelInfo.unitName) {
|
||||
uni.showToast({
|
||||
title: '单位名称不能为空',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (!this.personnelInfo.name) {
|
||||
uni.showToast({
|
||||
title: '姓名不能为空',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (!this.personnelInfo.position) {
|
||||
uni.showToast({
|
||||
title: '职位不能为空',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (!this.personnelInfo.code) {
|
||||
uni.showToast({
|
||||
title: 'ID不能为空',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
uni.showLoading({
|
||||
title: '发送中...',
|
||||
mask: true
|
||||
})
|
||||
let data = {
|
||||
code: this.personnelInfo.code,
|
||||
name: this.personnelInfo.name,
|
||||
position: this.personnelInfo.position,
|
||||
unitName: this.personnelInfo.unitName,
|
||||
deviceId: this.deviceID
|
||||
}
|
||||
registerPersonInfo(data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
uni.hideLoading()
|
||||
this.showPopupFlag = true
|
||||
this.popupMessage = '人员信息发送成功'
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
})
|
||||
},
|
||||
onPopupConfirm() {
|
||||
this.showPopupFlag = false
|
||||
console.log('用户点击了确定')
|
||||
},
|
||||
// 发送文本消息
|
||||
sendTextMessage() {
|
||||
if (!this.messageToSend) {
|
||||
uni.showToast({
|
||||
title: '请输入要发送的文字',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
uni.showLoading({
|
||||
title: '发送中...',
|
||||
mask: true
|
||||
})
|
||||
let data = {
|
||||
sendMsg: this.messageToSend,
|
||||
deviceIds: [this.deviceID]
|
||||
}
|
||||
deviceSendMessage(data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
uni.hideLoading()
|
||||
this.showPopupFlag = true
|
||||
this.popupMessage = '发送信息成功'
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
})
|
||||
// const topic = `device/command/${this.deviceID}/message`;
|
||||
// this.mqttClient.publish(topic, this.messageToSend);
|
||||
// uni.showToast({
|
||||
// title: '消息已发送',
|
||||
// icon: 'success'
|
||||
// });
|
||||
},
|
||||
// 统一处理返回方法
|
||||
handleDeviceData(res, isFromShared = false) {
|
||||
if (res.code == 200) {
|
||||
// 最后关闭加载状态
|
||||
this.pageLoading = false
|
||||
this.deviceInfo = res.data
|
||||
this.personnelInfo = {
|
||||
unitName: res.data.personnelInfo?.unitName || '',
|
||||
name: res.data.personnelInfo?.name || '',
|
||||
code: res.data.personnelInfo?.code || '',
|
||||
position: res.data.personnelInfo?.position || '',
|
||||
}
|
||||
// 将权限字符串转换为数组 ["1", "2"]
|
||||
if (isFromShared) {
|
||||
this.isSharedDevice = true
|
||||
this.activePermissions = res.data.permission ?
|
||||
res.data.permission.split(',') : []
|
||||
} else {
|
||||
this.isSharedDevice = false
|
||||
this.activePermissions = [] // 非分享设备清空权限
|
||||
}
|
||||
this.messageToSend = res.data.sendMsg || ''
|
||||
// 关闭加载中
|
||||
uni.hideLoading()
|
||||
}
|
||||
},
|
||||
// 检查权限的方法
|
||||
hasPermission(permissionCode) {
|
||||
// 如果还在加载中,直接返回false
|
||||
if (this.pageLoading) return false
|
||||
// 如果不是分享设备,默认有全部权限
|
||||
if (!this.isSharedDevice) return true
|
||||
return this.activePermissions.includes(permissionCode)
|
||||
},
|
||||
// 获取设备详情(普通详情)
|
||||
async fetchDeviceDetail(id) {
|
||||
try {
|
||||
const res = await deviceDetail(id)
|
||||
this.handleDeviceData(res, false)
|
||||
} catch (error) {
|
||||
uni.showToast({
|
||||
title: '获取详情失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
// 获取分享设备详情
|
||||
async fetchSharedDeviceDetail(id) {
|
||||
try {
|
||||
const res = await deviceShareId(id)
|
||||
this.handleDeviceData(res, true)
|
||||
} catch (error) {
|
||||
uni.showToast({
|
||||
title: '获取分享详情失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
console.log(options.id) // 输出: 123
|
||||
this.deviceID = options.id
|
||||
const eventChannel = this.getOpenerEventChannel();
|
||||
// 监听 'detailData' 事件,获取传过来的数据
|
||||
uni.showLoading({
|
||||
title: '加载中...'
|
||||
})
|
||||
eventChannel.on('deviceControl', (data) => {
|
||||
this.itemInfo = data.data;
|
||||
this.deviceID = data.data.id;
|
||||
this.navTitle = data.data.deviceName;
|
||||
this.apiType = data.apiType
|
||||
// 根据 apiType 设置右图标的显示状态
|
||||
this.isRightIconVisible = this.apiType === 'listA';
|
||||
// 初始化并连接MQTT
|
||||
this.mqttClient = new MqttClient();
|
||||
this.mqttClient.connect(() => {
|
||||
console.log('MQTT 连接成功,开始订阅主题');
|
||||
// 订阅来自设备的状态更新
|
||||
const statusTopic = `A/${this.itemInfo.deviceImei}`;
|
||||
this.mqttClient.subscribe(statusTopic, (payload) => {
|
||||
console.log(`收到来自 ${statusTopic} 的消息:`, payload);
|
||||
// uni.showModal({
|
||||
// title: '收到设备消息',
|
||||
// content: payload,
|
||||
// showCancel: false
|
||||
// });
|
||||
});
|
||||
});
|
||||
if (this.apiType === 'listA') {
|
||||
this.fetchDeviceDetail(data.data.id)
|
||||
} else {
|
||||
this.fetchSharedDeviceDetail(data.data.deviceId)
|
||||
}
|
||||
|
||||
});
|
||||
// 如果需要向调用页面返回数据,可以触发 'ack' 事件
|
||||
eventChannel.emit('ack', {})
|
||||
|
||||
},
|
||||
onUnload() {
|
||||
// 页面卸载时断开MQTT连接
|
||||
if (this.mqttClient) {
|
||||
this.mqttClient.disconnect();
|
||||
}
|
||||
},
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
<style scoped>
|
||||
.page-loading-mask {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: #121212;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
/* 优化权限控制区域的显示 */
|
||||
.mode-section,
|
||||
.form-section {
|
||||
transition: opacity 0.3s ease;
|
||||
}
|
||||
|
||||
.device-detail-container {
|
||||
padding: 30rpx;
|
||||
background: #121212;
|
||||
@ -393,6 +796,7 @@
|
||||
width: 204rpx;
|
||||
height: 144rpx;
|
||||
margin-top: 30rpx;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.dlIMG {
|
||||
@ -446,12 +850,6 @@
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.mode-v3 {
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
font-size: 26rpx;
|
||||
@ -557,23 +955,26 @@
|
||||
.example-body {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 70%;
|
||||
top: 65%;
|
||||
width: 100%;
|
||||
transform: translate(-17%, -100%);
|
||||
|
||||
transform: translate(-20%, -100%);
|
||||
}
|
||||
|
||||
.uni-file-picker__container {
|
||||
width: 200rpx !important;
|
||||
border: 1px solid rgb(58, 58, 58);
|
||||
.icoContent {
|
||||
width: 320rpx;
|
||||
height: 160rpx;
|
||||
border-radius: 8rpx;
|
||||
background: rgba(58, 58, 58, 1);
|
||||
text-align: center;
|
||||
line-height: 200rpx;
|
||||
}
|
||||
|
||||
:deep .file-picker__box {
|
||||
width: 40% !important;
|
||||
.img {
|
||||
width: 62rpx;
|
||||
height: 62rpx;
|
||||
}
|
||||
|
||||
.example_title {
|
||||
padding-top: 20rpx;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
}
|
||||
|
||||
@ -605,7 +1006,7 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 20rpx;
|
||||
background: rgb(42, 42, 42);
|
||||
background: rgba(42, 42, 42, 1);
|
||||
border-radius: 16rpx;
|
||||
padding-left: 20rpx;
|
||||
}
|
||||
@ -699,7 +1100,18 @@
|
||||
/* 弹窗主体 */
|
||||
.agreement-popup {
|
||||
width: 100%;
|
||||
height: 50%;
|
||||
height: 40%;
|
||||
background-color: rgb(42, 42, 42);
|
||||
border-radius: 60rpx 60rpx 0rpx 0rpx;
|
||||
padding: 40rpx;
|
||||
box-sizing: border-box;
|
||||
position: absolute;
|
||||
bottom: 0rpx;
|
||||
}
|
||||
|
||||
.agreement-popupB {
|
||||
width: 100%;
|
||||
height: 32%;
|
||||
background-color: rgb(42, 42, 42);
|
||||
border-radius: 60rpx 60rpx 0rpx 0rpx;
|
||||
padding: 40rpx;
|
||||
|
446
pages/6170/shareDevices/index.vue
Normal file
446
pages/6170/shareDevices/index.vue
Normal file
@ -0,0 +1,446 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<!-- 设备信息 -->
|
||||
<view class="device-info">
|
||||
<view class="device-header">
|
||||
<view class="deviceIMG">
|
||||
<image :src="itemInfo.devicePic" mode="aspectFit" class="IMG"></image>
|
||||
</view>
|
||||
<view class="device-name">
|
||||
<view>设备:{{itemInfo.deviceName}}</view>
|
||||
<view class="ID">
|
||||
<view class="ID">ID: {{itemInfo.deviceImei}}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 功能权限 -->
|
||||
<view class="permissions">
|
||||
<view class="permissions-title">功能权限</view>
|
||||
<view :checked="allSelected" class="allSelect" @click="toggleAllSelection()">全选</view>
|
||||
<text class="permissions-title"></text>
|
||||
<view class="permission-item" v-for="(item, index) in permissions" :key="index"
|
||||
@click="toggleSelection(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> {{ item.label }}</view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 被分享人信息 -->
|
||||
<view class="recipient-info">
|
||||
<view class="recipient-title">被分享人信息</view>
|
||||
<input type="number" v-model="phone" placeholder="输入手机号" class="phone-input" :maxlength="11" />
|
||||
<view class="verification-code">
|
||||
<input type="number" v-model="code" placeholder="短信验证码" class="code-input" :maxlength="6" />
|
||||
<view class="get-code-btn" :class="showView?' get_phone_number blue':'get_phone_number grad'"
|
||||
@click="getPhoneCode">{{ isCounting ? `${countdown}s后重新获取` : '获取验证码' }}</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 分享按钮 -->
|
||||
<button class="share-btn" @click="shareUp">分享</button>
|
||||
<!-- 分享弹框 -->
|
||||
<view class="agreement-mask" v-if="shareShow" @click="closePopup('share')">
|
||||
<view class="agreement-popup" @click.stop>
|
||||
<view class="popup-content">
|
||||
<image src="/static/images/success.png" mode="aspectFit" class="svg"></image>
|
||||
<view>
|
||||
<view class="popup-Title">设备分享成功</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 按钮组 -->
|
||||
<view class="popup-buttons">
|
||||
<button class="btn agreeBtn" @click="handleBtn">确定</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
deviceShareId,
|
||||
deviceShareCode,
|
||||
deviceShareAdd
|
||||
} from '@/api/6170/share.js'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
allSelected: false,
|
||||
shareShow: false,
|
||||
showView: false,
|
||||
isCounting: false,
|
||||
countdown: 0,
|
||||
permissions: [{
|
||||
value: "1",
|
||||
label: "灯光模式",
|
||||
checked: false
|
||||
},
|
||||
{
|
||||
value: "2",
|
||||
label: "激光模式",
|
||||
checked: false
|
||||
},
|
||||
{
|
||||
value: "3",
|
||||
label: "开机画面",
|
||||
checked: false
|
||||
},
|
||||
{
|
||||
value: "4",
|
||||
label: "人员信息登记",
|
||||
checked: false
|
||||
},
|
||||
{
|
||||
value: "5",
|
||||
label: "发送信息",
|
||||
checked: false
|
||||
},
|
||||
{
|
||||
value: "6",
|
||||
label: "产品信息",
|
||||
checked: false
|
||||
}
|
||||
],
|
||||
deviceInfo: {},
|
||||
phone: '',
|
||||
code: '',
|
||||
itemInfo: ''
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
closePopup() {
|
||||
this.shareShow = false
|
||||
},
|
||||
toggleAllSelection() {
|
||||
this.allSelected = !this.allSelected;
|
||||
this.permissions.forEach(permission => permission.checked = this.allSelected);
|
||||
},
|
||||
toggleSelection(index) {
|
||||
this.$set(this.permissions[index], 'checked', !this.permissions[index].checked);
|
||||
this.allSelected = this.permissions.every(permission => permission.checked);
|
||||
},
|
||||
|
||||
// 获取验证码
|
||||
async getPhoneCode() {
|
||||
const phoneNumber = this.phone
|
||||
const myreg = /^1[3456789]\d{9}$/;
|
||||
if (!phoneNumber) {
|
||||
uni.showToast({
|
||||
title: '手机号不能为空',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
});
|
||||
return false;
|
||||
} else if (!myreg.test(phoneNumber)) {
|
||||
uni.showToast({
|
||||
title: '请输入正确的手机号',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
});
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
await deviceShareCode({
|
||||
phonenumber: this.phone
|
||||
})
|
||||
// 更新倒计时状态
|
||||
this.isCounting = true;
|
||||
this.showView = true;
|
||||
this.countdown = 60
|
||||
const timer = setInterval(() => {
|
||||
this.countdown--
|
||||
if (this.countdown <= 0) {
|
||||
clearInterval(timer)
|
||||
this.isCounting = false;
|
||||
this.showView = false;
|
||||
}
|
||||
}, 1000)
|
||||
uni.showToast({
|
||||
title: '验证码已发送',
|
||||
icon: 'none'
|
||||
})
|
||||
} catch (error) {}
|
||||
},
|
||||
// 分享按钮提交
|
||||
async shareUp() {
|
||||
if (this.phone == '') {
|
||||
uni.showToast({
|
||||
title: '手机号不能为空',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
return false
|
||||
} else if (this.code == '') {
|
||||
uni.showToast({
|
||||
title: '验证码不能为空',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
return false
|
||||
}else if (!this.permissions.some(permission => permission.checked)) {
|
||||
uni.showToast({
|
||||
title: '请选择至少一个功能权限',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
});
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
uni.showLoading({
|
||||
title: '分享中'
|
||||
})
|
||||
const selectedPermissions = this.permissions.filter(permission => permission.checked).map(
|
||||
permission =>
|
||||
permission.value);
|
||||
const res = await deviceShareAdd({
|
||||
phonenumber: this.phone,
|
||||
smsCode: this.code,
|
||||
deviceId: this.itemInfo.id,
|
||||
permission: selectedPermissions.join(',')
|
||||
})
|
||||
if (res.code == 200) {
|
||||
this.shareShow = true
|
||||
uni.hideLoading()
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
uni.showToast({
|
||||
title: error.msg,
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
handleBtn() {
|
||||
this.shareShow = false
|
||||
uni.navigateTo({
|
||||
url: '/pages/6170/allShare/index'
|
||||
})
|
||||
},
|
||||
},
|
||||
onLoad() {
|
||||
const eventChannel = this.getOpenerEventChannel();
|
||||
// 监听 'shareDevice' 事件,获取传过来的数据
|
||||
eventChannel.on('shareDevice', (data) => {
|
||||
console.log(data, 'data1t111');
|
||||
this.itemInfo = data.data;
|
||||
})
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.container {
|
||||
width: 100%;
|
||||
background: #121212;
|
||||
min-height: 100vh;
|
||||
padding: 30rpx;
|
||||
}
|
||||
|
||||
.device-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 15rpx;
|
||||
}
|
||||
|
||||
.device-name {
|
||||
font-size: 32rpx;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
margin-left: 25rpx;
|
||||
line-height: 50rpx;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.ID {
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
font-size: 26rpx;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.device-info {
|
||||
font-size: 28rpx;
|
||||
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%;
|
||||
}
|
||||
.title {
|
||||
font-size: 18px;
|
||||
color: white;
|
||||
}
|
||||
.device-info {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
border-bottom: 1rpx solid rgba(255, 255, 255, 0.06);
|
||||
}
|
||||
.allSelect {
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
float: right;
|
||||
}
|
||||
.device-icon {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
}
|
||||
.device-id,
|
||||
.device-serial {
|
||||
color: white;
|
||||
}
|
||||
.permissions {
|
||||
width: 100%;
|
||||
margin-top: 20px;
|
||||
padding: 10px;
|
||||
border-bottom: 1rpx solid rgba(255, 255, 255, 0.06);
|
||||
}
|
||||
.permissions-title {
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
font-size: 30rpx;
|
||||
/* padding: 30rpx 0rpx; */
|
||||
}
|
||||
.checkbox {
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
border: 2rpx solid rgba(255, 255, 255, 0.5);
|
||||
margin-right:30rpx;
|
||||
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);
|
||||
}
|
||||
.permission-item {
|
||||
margin-top:35rpx;
|
||||
display: flex;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
line-height: 60rpx;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
.recipient-info {
|
||||
width: 100%;
|
||||
margin-top: 20px;
|
||||
padding: 10px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
.recipient-title {
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
font-size: 30rpx;
|
||||
}
|
||||
.phone-input {
|
||||
width: 100%;
|
||||
margin-top: 20rpx;
|
||||
padding: 40rpx 0;
|
||||
border-bottom: 1rpx solid rgba(255, 255, 255, 0.06);
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
}
|
||||
.verification-code {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
border-bottom: 1rpx solid rgba(255, 255, 255, 0.06);
|
||||
padding: 40rpx 0;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
}
|
||||
.get-code-btn {
|
||||
margin-top: 10px;
|
||||
background-color: transparent;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
font-size: 30rpx;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.share-btn {
|
||||
margin-top: 20px;
|
||||
width: 100%;
|
||||
padding: 5rpx;
|
||||
border-radius: 91rpx;
|
||||
background: rgba(187, 230, 0, 1);
|
||||
}
|
||||
|
||||
/* 遮罩层 */
|
||||
.agreement-mask {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: rgba(0, 0, 0, 0.8);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
.popup-Title {
|
||||
color: rgba(255, 255, 255, 0.86);
|
||||
text-align: center;
|
||||
padding: 30rpx 0rpx;
|
||||
}
|
||||
|
||||
.popup-buttons {
|
||||
display: flex;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* 弹窗主体 */
|
||||
.agreement-popup {
|
||||
width: 60%;
|
||||
background: rgba(56, 57, 52, 0.4);
|
||||
border-radius: 40rpx;
|
||||
padding: 30rpx;
|
||||
text-align: center;
|
||||
border: 1px solid rgba(187, 230, 0, 0.3);
|
||||
}
|
||||
.svg {
|
||||
width: 58rpx;
|
||||
height:58rpx;
|
||||
}
|
||||
/* 通用按钮样式 */
|
||||
.btn {
|
||||
height: 60rpx;
|
||||
line-height: 60rpx;
|
||||
border-radius: 40rpx;
|
||||
font-size: 24rpx;
|
||||
margin: 10rpx auto;
|
||||
text-align: center;
|
||||
|
||||
}
|
||||
|
||||
/* 同意按钮 */
|
||||
.agreeBtn {
|
||||
background: rgba(187, 230, 0, 1);
|
||||
color: #232323;
|
||||
border: none;
|
||||
width: 170rpx !important;
|
||||
}
|
||||
</style>
|
264
pages/6170/shareManagement/index.vue
Normal file
264
pages/6170/shareManagement/index.vue
Normal file
@ -0,0 +1,264 @@
|
||||
<template>
|
||||
<view class="share">
|
||||
<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/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>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 删除弹框 -->
|
||||
<view class="agreement-mask" v-if="deleteShow" @click="closePopup('delete')">
|
||||
<view class="agreement-popup" @click.stop>
|
||||
<view class="popup-content">
|
||||
<image src="/static/images/delel.png" mode="" class="svg"></image>
|
||||
<uni-icon class="trash"></uni-icon>
|
||||
<view>
|
||||
<view class="popup-Title">确定移除该用户!</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 按钮组 -->
|
||||
<view class="popup-buttons">
|
||||
<button class="btn agreeBtn" @click="handleBtn">确定</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
deviceShareList,
|
||||
deviceShareDelete
|
||||
} from '@/api/6170/share.js'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
deviceList: [],
|
||||
deleteShow: false,
|
||||
delelteItemInfo: '',
|
||||
itemInfo: ''
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 点击弹框外的区域关闭
|
||||
closePopup(type) {
|
||||
if (type === 'delete') {
|
||||
this.deleteShow = false;
|
||||
}
|
||||
},
|
||||
// 删除
|
||||
handleDelete(item) {
|
||||
console.log(item, 'www');
|
||||
this.deleteShow = true
|
||||
this.delelteItemInfo = item
|
||||
},
|
||||
handleBtn() {
|
||||
let allId = this.delelteItemInfo.id
|
||||
deviceShareDelete(allId).then((res) => {
|
||||
if (res.code = 200) {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none'
|
||||
})
|
||||
this.deleteShow = false
|
||||
this.getData()
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
|
||||
})
|
||||
//
|
||||
},
|
||||
getData(val) {
|
||||
let data = {
|
||||
deviceid: val
|
||||
}
|
||||
deviceShareList(data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
this.deviceList = res.rows
|
||||
}
|
||||
})
|
||||
},
|
||||
// 跳转分享详情
|
||||
handleFile(item) {
|
||||
uni.navigateTo({
|
||||
url: "/pages/6170/deviceControl/index",
|
||||
success: (res) => {
|
||||
// 页面跳转成功后的回调函数
|
||||
res.eventChannel.emit('deviceControl', {
|
||||
data: item,
|
||||
apiType: 'listB' // 自定义标识 // 自定义标识,详情哪里根据这个参数不同信息
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
},
|
||||
onLoad() {
|
||||
const eventChannel = this.getOpenerEventChannel();
|
||||
// 监听 'shareDevice' 事件,获取传过来的数据
|
||||
eventChannel.on('shareManagement', (data) => {
|
||||
console.log(data, 'data1t111');
|
||||
this.itemInfo = data.data;
|
||||
this.getData(this.itemInfo.id)
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.share {
|
||||
padding: 30rpx;
|
||||
background: #121212;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.device-title {
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
padding: 30rpx 0;
|
||||
}
|
||||
|
||||
.device-info {
|
||||
font-size: 28rpx;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
padding-top: 10rpx;
|
||||
position: relative;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.device-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 15rpx;
|
||||
}
|
||||
|
||||
.device-name {
|
||||
font-size: 32rpx;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
margin-left: 25rpx;
|
||||
line-height: 50rpx;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.ID {
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
.deviceIMG {
|
||||
/* width: 100rpx; */
|
||||
/* height: 100rpx; */
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.device-delete {
|
||||
text-align: end;
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.delete {
|
||||
border-radius: 32px;
|
||||
background: rgba(255, 200, 78, 0.06);
|
||||
display: inline-block;
|
||||
width: 152rpx;
|
||||
height: 60rpx;
|
||||
text-align: center;
|
||||
line-height: 60rpx;
|
||||
color: rgba(224, 52, 52, 1);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.IMG {
|
||||
width: 120rpx;
|
||||
height: 100rpx;
|
||||
margin-left: 17%;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 18px;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.device-info {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
background: rgba(26, 26, 26, 1);
|
||||
border-radius: 16rpx;
|
||||
}
|
||||
|
||||
/* 遮罩层 */
|
||||
.agreement-mask {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
.popup-Title {
|
||||
color: rgba(255, 255, 255, 0.86);
|
||||
text-align: center;
|
||||
padding: 30rpx 0rpx;
|
||||
}
|
||||
|
||||
.popup-buttons {
|
||||
display: flex;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* 弹窗主体 */
|
||||
.agreement-popup {
|
||||
width: 60%;
|
||||
background: rgba(56, 57, 52, 0.4);
|
||||
border-radius: 40rpx;
|
||||
padding: 30rpx;
|
||||
text-align: center;
|
||||
border: 1px solid rgba(224, 52, 52, 0.3);
|
||||
}
|
||||
|
||||
.svg {
|
||||
width: 58rpx;
|
||||
height: 58rpx;
|
||||
}
|
||||
|
||||
/* 通用按钮样式 */
|
||||
.btn {
|
||||
height: 60rpx;
|
||||
line-height: 60rpx;
|
||||
border-radius: 40rpx;
|
||||
font-size: 24rpx;
|
||||
margin: 10rpx auto;
|
||||
text-align: center;
|
||||
|
||||
}
|
||||
|
||||
/* 同意按钮 */
|
||||
.agreeBtn {
|
||||
background: rgba(224, 52, 52, 1);
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
border: none;
|
||||
width: 170rpx !important;
|
||||
}
|
||||
</style>
|
@ -12,16 +12,18 @@
|
||||
{{tab.typeName}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="uniui-more">
|
||||
<image @click="allMore" src="/static/images/more.png" mode="" class="more"></image>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<view class="sendFlex">
|
||||
|
||||
<view class="callpolice">报警</view>
|
||||
<view class="sendFlex" v-if="activeTab && activeTab.id !== ''&& activeTabInfo.communicationMode==0">
|
||||
<!-- <view class="callpolice">报警</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"
|
||||
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"
|
||||
@ -29,7 +31,7 @@
|
||||
<view @click.stop="handleFile(item)">
|
||||
<view class="device-header">
|
||||
<view class="deviceIMG">
|
||||
<image :src="item.devicePic" class="IMG"></image>
|
||||
<image :src="item.devicePic" class="IMG" mode="aspectFit"></image>
|
||||
</view>
|
||||
<view class="device-name">
|
||||
<view>设备:{{item.deviceName}}</view>
|
||||
@ -46,9 +48,8 @@
|
||||
<view class="device-status online">已连接</view>
|
||||
<view class="device-status unline">未连接</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<image src="/static/images/cires.png" class="circle"></image>
|
||||
<image src="/static/images/cires.png" class="circle" mode="aspectFit"></image>
|
||||
</uni-swipe-action-item>
|
||||
</block>
|
||||
</uni-swipe-action>
|
||||
@ -57,11 +58,17 @@
|
||||
<text v-if="loading">加载中...</text>
|
||||
<text v-if="finished">没有更多数据了</text>
|
||||
</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>
|
||||
暂无数据
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
<!-- 删除弹框 -->
|
||||
<view class="agreement-mask" v-if="deleteShow">
|
||||
<view class="agreement-popupC">
|
||||
<view class="agreement-mask" v-if="deleteShow" @click="closePopup('delete')">
|
||||
<view class="agreement-popupC" @click.stop>
|
||||
<view class="popup-content">
|
||||
<image src="/static/images/dell.png" mode="" class="svg"></image>
|
||||
<uni-icon class="trash"></uni-icon>
|
||||
@ -76,13 +83,14 @@
|
||||
</view>
|
||||
</view>
|
||||
<!-- =========重命名============== -->
|
||||
<view class="agreement-mask" v-if="RenameModel">
|
||||
<view class="agreement-popupD">
|
||||
<view class="agreement-mask" v-if="RenameModel" @click="closePopup('rename')">
|
||||
<view class="agreement-popupD" @click.stop>
|
||||
<view class="popup-content">
|
||||
<view>
|
||||
<view class="popup-flex">
|
||||
<text>设备名称</text>
|
||||
<input type="text" v-model="deviceName" placeholder="请输入设备名称" class="popup-input" />
|
||||
<input type="text" v-model="deviceName" placeholder="请输入设备名称" class="popup-input"
|
||||
@click.stop />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -103,6 +111,17 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- ====分享,类型提示框==== -->
|
||||
<view class="tooltip-share" v-if="showshare">
|
||||
<view class="tooltip-arrow"></view>
|
||||
<view class="tooltip-content">
|
||||
<view class="tooltip-item" v-for="(item, index) in shareItems" :key="index"
|
||||
@click="handleshareClick(item)">
|
||||
<image :src="item.icon" class="item-icon" />
|
||||
<text>{{ item.text }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@ -121,6 +140,7 @@
|
||||
tabs: [],
|
||||
activeTab: 0,
|
||||
showTooltip: false,
|
||||
showshare: false,
|
||||
Options: [{
|
||||
text: '重命名',
|
||||
style: {
|
||||
@ -152,21 +172,63 @@
|
||||
action: 'bluetooth'
|
||||
}
|
||||
],
|
||||
shareItems: [{
|
||||
text: '所有类型',
|
||||
icon: '/static/images/type.png',
|
||||
action: 'type'
|
||||
},
|
||||
{
|
||||
text: '所有分享',
|
||||
icon: '/static/images/share.png',
|
||||
action: 'share'
|
||||
}
|
||||
],
|
||||
page: 1, // 当前页码
|
||||
size: 10, // 每页条数
|
||||
total: 0, // 总数据量
|
||||
loading: false,
|
||||
finished: false,
|
||||
deviceId: '',
|
||||
deviceName: "" //重命名
|
||||
deviceName: "", //重命名
|
||||
activeTabInfo: ''
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 更多
|
||||
allMore() {
|
||||
this.showshare = !this.showshare;
|
||||
},
|
||||
// 所有分享,所有类型
|
||||
handleshareClick(item) {
|
||||
this.showshare = false; // 关闭弹窗
|
||||
switch (item.action) {
|
||||
case 'type':
|
||||
uni.navigateTo({
|
||||
url: '/pages/common/allType/index'
|
||||
});
|
||||
break;
|
||||
case 'share':
|
||||
uni.navigateTo({
|
||||
url: "/pages/6170/allShare/index"
|
||||
})
|
||||
break;
|
||||
}
|
||||
},
|
||||
// 点击弹框外的区域关闭
|
||||
closePopup(type) {
|
||||
if (type === 'delete') {
|
||||
this.deleteShow = false;
|
||||
uni.showTabBar(); // 显示TabBar
|
||||
} else if (type === 'rename') {
|
||||
this.RenameModel = false;
|
||||
uni.showTabBar(); // 显示TabBar
|
||||
}
|
||||
},
|
||||
// tab导航切换栏
|
||||
getTab() {
|
||||
deviceTypeList({}).then((res) => {
|
||||
if (res.code == 200) {
|
||||
console.log("deviceTypeList=" + JSON.stringify(res.data));
|
||||
//console.log("deviceTypeList=" + JSON.stringify(res.data));
|
||||
this.tabs = [{
|
||||
id: '',
|
||||
name: '全部设备',
|
||||
@ -186,6 +248,7 @@
|
||||
switchTab(tab, index) {
|
||||
this.deviceList = [];
|
||||
this.activeTab = index;
|
||||
this.activeTabInfo = tab
|
||||
this.page = 1; // 重置页码
|
||||
this.finished = false; // 重
|
||||
// 明确传递参数,空字符串改为null或undefined
|
||||
@ -226,10 +289,11 @@
|
||||
onScrollToLower() {
|
||||
this.getData();
|
||||
},
|
||||
// 添加扫一三图标
|
||||
scan() {
|
||||
this.showTooltip = !this.showTooltip;
|
||||
},
|
||||
|
||||
// 添加设备,扫一扫,蓝牙
|
||||
handleMenuClick(item) {
|
||||
this.showTooltip = false; // 关闭弹窗
|
||||
switch (item.action) {
|
||||
@ -239,15 +303,6 @@
|
||||
});
|
||||
break;
|
||||
case 'bluetooth':
|
||||
// uni.navigateTo({
|
||||
// url: 'pages/common/addBLE/AddDevice',
|
||||
// success:(res)=>{
|
||||
// res.eventChannel.emit('key', { data: 'data from starter page' })
|
||||
// },fail: (ex) => {
|
||||
// console.log("跳转失败了",JSON.stringify(ex));
|
||||
// }
|
||||
// });
|
||||
|
||||
uni.navigateTo({
|
||||
url: "/pages/common/addBLE/addEquip"
|
||||
})
|
||||
@ -256,8 +311,11 @@
|
||||
},
|
||||
// 右滑点击事件处理
|
||||
handleSwipeClick(e, item, index) {
|
||||
const {content} = e
|
||||
console.log(e, 'eeeee');
|
||||
|
||||
const {
|
||||
content
|
||||
} = e
|
||||
console.log(item, 'eeeee');
|
||||
switch (e.content.text) {
|
||||
case '删除':
|
||||
this.handleDeleteDevice(item, index)
|
||||
@ -290,6 +348,8 @@
|
||||
this.onIntall();
|
||||
}, 500);
|
||||
this.deleteShow = false
|
||||
// 关闭所有滑动项
|
||||
this.$refs.swipeAction.closeAll();
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
@ -323,6 +383,8 @@
|
||||
}, 500);
|
||||
this.RenameModel = false
|
||||
this.deviceName = ''
|
||||
// 关闭所有滑动项
|
||||
this.$refs.swipeAction.closeAll();
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
@ -334,8 +396,19 @@
|
||||
},
|
||||
// 发生短信
|
||||
handleSend() {
|
||||
const currentTab = this.tabs[this.activeTab];
|
||||
const deviceType = currentTab.id || 'all';
|
||||
console.log(`跳转到发送信息页面\n当前设备类型: ${deviceType}\n设备类型名称: ${currentTab.typeName}`);
|
||||
uni.navigateTo({
|
||||
url: '/pages/common/send/index'
|
||||
url: '/pages/common/send/index',
|
||||
events: {
|
||||
ack: function(data) {}
|
||||
},
|
||||
success: (res) => {
|
||||
res.eventChannel.emit('deviceSend', {
|
||||
data: deviceType
|
||||
});
|
||||
}
|
||||
})
|
||||
},
|
||||
// 位置
|
||||
@ -345,19 +418,26 @@
|
||||
})
|
||||
},
|
||||
handleFile(item) {
|
||||
console.log('item' + JSON.stringify(item));
|
||||
//console.log('item' + JSON.stringify(item));
|
||||
// communicationMode 0是4G 1是蓝牙
|
||||
if (item.communicationMode == 0) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/6170/deviceControl/index?id=${item.id}`
|
||||
|
||||
url: "/pages/6170/deviceControl/index",
|
||||
events: {
|
||||
ack: function(data) {}
|
||||
},
|
||||
success: (res) => {
|
||||
// 页面跳转成功后的回调函数
|
||||
res.eventChannel.emit('deviceControl', {
|
||||
data: item,
|
||||
apiType: 'listA' // 自定义标识,详情哪里根据这个参数不同信息
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
if (item.typeName == '6155') {
|
||||
uni.navigateTo({
|
||||
url: "/pages/650/HBY650",
|
||||
url: "/pages/6155/deviceDetail",
|
||||
events: {
|
||||
ack: function(data) {
|
||||
|
||||
@ -376,13 +456,22 @@
|
||||
onIntall() {
|
||||
this.page = 1;
|
||||
this.finished = false;
|
||||
this.getData(); // 重新加载第一页数据
|
||||
this.getData(this.deviceType); // 重新加载第一页数据
|
||||
},
|
||||
},
|
||||
onShow() {
|
||||
onLoad() {
|
||||
this.getTab()
|
||||
this.onIntall()
|
||||
}
|
||||
// 绑定页面做了监听,新增成功,刷新页面
|
||||
uni.$on('refreshDeviceList', () => {
|
||||
this.getTab() // 刷新数据
|
||||
this.onIntall()
|
||||
});
|
||||
},
|
||||
beforeDestroy() {
|
||||
// 组件销毁前移除监听器
|
||||
uni.$off('refreshDeviceList');
|
||||
},
|
||||
|
||||
}
|
||||
</script>
|
||||
@ -403,6 +492,7 @@
|
||||
white-space: nowrap;
|
||||
/* 禁止换行 */
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
|
||||
}
|
||||
|
||||
@ -440,6 +530,21 @@
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.uniui-more {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.more {
|
||||
width: 40rpx;
|
||||
height: 8rpx;
|
||||
/* position: absolute; */
|
||||
/* right: 0rpx;
|
||||
z-index: 100; */
|
||||
float: right;
|
||||
top: -95rpx
|
||||
}
|
||||
|
||||
.gprs {
|
||||
width: 28rpx;
|
||||
height: 35rpx;
|
||||
@ -465,118 +570,6 @@
|
||||
position: relative;
|
||||
}
|
||||
|
||||
/* .device-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 15rpx;
|
||||
padding: 30rpx 0 10rpx 30rpx;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.device-name {
|
||||
font-size: 28rpx;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
margin-left: 24rpx;
|
||||
line-height: 50rpx;
|
||||
}
|
||||
|
||||
.ID {
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
||||
|
||||
.circle {
|
||||
width: 8rpx;
|
||||
height: 40rpx;
|
||||
position: absolute;
|
||||
right: 18rpx;
|
||||
top: 65rpx;
|
||||
}
|
||||
|
||||
.online {
|
||||
color: rgb(187, 230, 0);
|
||||
}
|
||||
|
||||
.unline {
|
||||
color: rgba(255, 255, 255, 0.4);
|
||||
}
|
||||
|
||||
.device-id {
|
||||
font-size: 26rpx;
|
||||
color: #999;
|
||||
margin-bottom: 20rpx;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.device-info {
|
||||
display: flex;
|
||||
font-size: 28rpx;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
position: relative;
|
||||
width: 100%;
|
||||
}
|
||||
.device-flex{
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
||||
}
|
||||
|
||||
.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::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
width: 15rpx;
|
||||
height: 15rpx;
|
||||
background: rgb(0, 171, 103);
|
||||
border-radius: 50%;
|
||||
left: 120rpx;
|
||||
top: 15rpx
|
||||
}
|
||||
|
||||
.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);
|
||||
padding: 20rpx;
|
||||
font-size: 22rpx;
|
||||
} */
|
||||
.device-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@ -661,6 +654,7 @@
|
||||
width: 68rpx;
|
||||
height: 50rpx;
|
||||
margin-left: 17%;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.onlines {
|
||||
@ -695,6 +689,12 @@
|
||||
font-size: 22rpx;
|
||||
}
|
||||
|
||||
.noDATA {
|
||||
text-align: center;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
transform: translate(-0%, 100%);
|
||||
}
|
||||
|
||||
/* 遮罩层 */
|
||||
.agreement-mask {
|
||||
position: fixed;
|
||||
@ -756,6 +756,7 @@
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
height: 50rpx;
|
||||
padding: 30rpx;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.popup-input {
|
||||
@ -812,6 +813,14 @@
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
.tooltip-share {
|
||||
position: fixed;
|
||||
right: 18rpx;
|
||||
top: 230rpx;
|
||||
/* 根据导航栏高度调整 */
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
.tooltip-arrow {
|
||||
width: 0;
|
||||
height: 0;
|
||||
|
@ -11,42 +11,61 @@
|
||||
<view class="device-content">
|
||||
<view class="device-header">
|
||||
<view class="deviceIMG">
|
||||
<image src="/static/images/device.png" mode="" class="IMG"></image>
|
||||
<image :src="item.devicePic" class="IMG" mode="aspectFit"></image>
|
||||
</view>
|
||||
<view class="device-name">
|
||||
<view>设备:001-00</view>
|
||||
<view class="ID">ID:{{ item.id }}</view>
|
||||
<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">在线</view> -->
|
||||
<view class="unlines" v-if="item.communicationMode==0">离线</view>
|
||||
<view>电量:90%</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="" v-if="item.communicationMode==1">
|
||||
<view class="device-status online">已连接</view>
|
||||
<view class="device-info">
|
||||
<text class="onlines">在线</text>
|
||||
<text class="line"></text>
|
||||
<text>电量:90℃</text>
|
||||
<view class="device-status unline">未连接</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view style="padding:20rpx;">
|
||||
<view class="editInfmation">
|
||||
<view class="ql-editor">编辑信息</view>
|
||||
<view class="ql-input">
|
||||
<textarea placeholder-style="color:rgba(255, 255, 255, 0.4)" placeholder="请输入内容" class="textarea"/>
|
||||
<textarea placeholder-style="color:rgba(255, 255, 255, 0.4)" placeholder="请输入内容" class="textarea"
|
||||
v-model="messageToSend" />
|
||||
</view>
|
||||
<button class="login-btn">发送</button>
|
||||
<button class="login-btn" @click="sendTextMessage">发送</button>
|
||||
</view>
|
||||
|
||||
</scroll-view>
|
||||
<!-- 成功提示弹框 -->
|
||||
<CustomPopup :show="showPopupFlag" :title="popupTitle" :message="popupMessage" icon="/static/images/sendSucc.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: Array(6).fill().map((_, i) => ({
|
||||
id: `1321615${i}`,
|
||||
checked: false,
|
||||
showConfirm: false
|
||||
})),
|
||||
deviceList: [],
|
||||
messageToSend: '', //发送信息
|
||||
showPopupFlag: false,
|
||||
popupTitle: '',
|
||||
popupMessage: '信息发送成功!',
|
||||
popupConfirmText: '确认'
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@ -54,43 +73,103 @@
|
||||
this.deviceList[index].checked = !this.deviceList[index].checked
|
||||
this.$forceUpdate()
|
||||
},
|
||||
sendMessage() {
|
||||
// 获取设备列表
|
||||
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;
|
||||
});
|
||||
},
|
||||
// 发送文本消息
|
||||
sendTextMessage() {
|
||||
const selectedDevices = this.deviceList.filter(item => item.checked)
|
||||
console.log('选中的设备:', selectedDevices)
|
||||
const deviceIds = selectedDevices.map(item => item.id);
|
||||
if (selectedDevices.length === 0) {
|
||||
uni.showToast({
|
||||
title: `已发送到${selectedDevices.length}台设备`,
|
||||
icon: 'success'
|
||||
title: '请选择一个设备',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (!this.messageToSend) {
|
||||
uni.showToast({
|
||||
title: '请输入要发送的内容',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
let data = {
|
||||
sendMsg: this.messageToSend,
|
||||
deviceIds: deviceIds
|
||||
}
|
||||
deviceSendMessage(data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
this.showPopupFlag = true
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
onPopupConfirm() {
|
||||
this.showPopupFlag = false
|
||||
uni.navigateBack()
|
||||
console.log('用户点击了确定')
|
||||
// 处理确认逻辑
|
||||
},
|
||||
},
|
||||
onLoad(options) {
|
||||
const eventChannel = this.getOpenerEventChannel();
|
||||
// 监听 'deviceSend' 事件,获取传过来的数据
|
||||
eventChannel.on('deviceSend', (data) => {
|
||||
console.log('Received detail data:', data);
|
||||
this.getData(data.data)
|
||||
});
|
||||
// 如果需要向调用页面返回数据,可以触发 'ack' 事件
|
||||
eventChannel.emit('ack', {})
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 100vh;
|
||||
background-color: rgb(18, 18, 18);
|
||||
box-sizing: border-box;
|
||||
overflow-x: hidden;
|
||||
|
||||
}
|
||||
.header {
|
||||
padding: 30rpx;
|
||||
text-align: center;
|
||||
}
|
||||
.title {
|
||||
font-size: 36rpx;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
}
|
||||
|
||||
.device-list {
|
||||
flex: 1;
|
||||
padding: 0 20rpx;
|
||||
|
||||
}
|
||||
|
||||
.device-card {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 94%;
|
||||
width: 95%;
|
||||
}
|
||||
|
||||
.checkbox {
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
@ -101,35 +180,45 @@
|
||||
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;
|
||||
margin-bottom: 20rpx;
|
||||
position: relative;
|
||||
/* display: flex; */
|
||||
align-items: center;
|
||||
padding: 20rpx;
|
||||
width: 93%;
|
||||
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: 24rpx;
|
||||
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;
|
||||
@ -147,12 +236,17 @@
|
||||
color: rgb(187, 230, 0);
|
||||
}
|
||||
|
||||
.unline {
|
||||
color: rgba(255, 255, 255, 0.4);
|
||||
}
|
||||
|
||||
.device-info {
|
||||
display: flex;
|
||||
justify-content: space-evenly;
|
||||
font-size: 28rpx;
|
||||
font-size: 26rpx;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
padding-top: 10rpx;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.deviceIMG {
|
||||
@ -171,6 +265,10 @@
|
||||
margin-left: 17%;
|
||||
}
|
||||
|
||||
.onlines {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.onlines::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
@ -178,8 +276,23 @@
|
||||
height: 15rpx;
|
||||
background: rgb(0, 171, 103);
|
||||
border-radius: 50%;
|
||||
left: 98rpx;
|
||||
bottom: 32rpx
|
||||
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 {
|
||||
@ -206,15 +319,29 @@
|
||||
border-radius: 16rpx;
|
||||
background: rgb(26, 26, 26);
|
||||
}
|
||||
|
||||
.textarea {
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
background: rgba(42, 42, 42, 1);
|
||||
border-radius: 16rpx;
|
||||
padding: 10rpx;
|
||||
height: 150rpx;
|
||||
}
|
||||
|
||||
.editInfmation {
|
||||
padding: 20rpx;
|
||||
border-radius: 40rpx 40rpx 0px 0px;
|
||||
background: rgba(28, 28, 28, 1);
|
||||
position: fixed;
|
||||
bottom: 50rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.login-btn {
|
||||
margin-top: 30rpx;
|
||||
background-color: rgb(187, 230, 0);
|
||||
color: rgb(35, 35, 35);
|
||||
border-radius: 50rpx;
|
||||
width: 90%;
|
||||
margin-left: 10rpx;
|
||||
}
|
||||
</style>
|
Reference in New Issue
Block a user