1
0
forked from dyf/APP

完成008A功能开发

This commit is contained in:
liub
2026-05-19 17:38:56 +08:00
parent 6d9df4c945
commit 8f53a45280
63 changed files with 4162 additions and 766 deletions

View File

@ -0,0 +1,447 @@
<template>
<view class="content contentBg">
<SubStep :steps="Status.steps.list" :height="'140rpx'" :curr="Status.steps.curr" @stepClick="stepClick">
</SubStep>
<view class="mainPanel" v-show="Status.steps.curr===0">
<view class="main">
<uni-easyinput maxlength="30" class="txteare" v-model="formData.name" :trim="true" placeholder="输入编组名称"
type="textarea" autoHeight :inputBorder="false" :border="false"></uni-easyinput>
</view>
<button class="btnNext" :disabled="!formData.name" :class="{'active':formData.name}"
@click="gotoStep(1)">下一步</button>
</view>
<view class="mainPanel" v-show="Status.steps.curr===1">
<view class="btnAdd" @click="goCheckDevice('main')">
<image class="img" mode="aspectFit" src="/static/images/common/add.png"></image>
<text>添加预警主机</text>
</view>
<scroll-view scroll-y="true" scroll-with-animation class="checkedList" v-show="formData.main.length>0">
<view class="item " v-for="item,index in formData.main">
<view class="panel imgContent center" @click.stop="imgView(item,index)">
<image class="img" :src="item.devicePic" mode="aspectFit"></image>
</view>
<view class="panel centerCol lbl">
<view class="LargeTxt">{{item.deviceName}}</view>
<view class="smallTxt">ID:{{item.deviceImei?item.deviceImei:item.deviceMac}}</view>
</view>
</view>
</scroll-view>
<button class="btnNext" :class="{'active':formData.main.length>0}" :disabled="formData.main.length==0"
@click="gotoStep(1)">下一步</button>
</view>
<view class="mainPanel" v-show="Status.steps.curr===2">
<view class="btnAdd" @click="goCheckDevice('sub')">
<image class="img" mode="aspectFit" src="/static/images/common/add.png"></image>
<text>添加布防联机</text>
</view>
<scroll-view scroll-y="true" scroll-with-animation class="checkedList" v-show="formData.sub.length>0">
<view class="item center" v-for="item,index in formData.sub">
<view class="panel imgContent center" @click.stop="imgView(item,index)">
<image class="img" :src="item.devicePic" mode="aspectFit"></image>
</view>
<view class="panel centerCol lbl">
<view class="LargeTxt">{{item.deviceName}}</view>
<view class="smallTxt">ID:{{item.deviceImei?item.deviceImei:item.deviceMac}}</view>
</view>
</view>
</scroll-view>
<button class="btnNext" :class="{'active':formData.sub.length>0}" :disabled="formData.sub.length==0"
@click="gotoStep(1)">下一步</button>
</view>
<view class="mainPanel" v-show="Status.steps.curr===3">
<view class="btnAdd" @click="goCheckDevice('notify')">
<image class="img" mode="aspectFit" src="/static/images/common/add.png"></image>
<text>添加接收设备</text>
</view>
<scroll-view scroll-y="true" scroll-with-animation class="checkedList" v-show="formData.notify.length>0">
<view class="item" v-for="item,index in formData.notify">
<view class="panel imgContent center" @click.stop="imgView(item,index)">
<image class="img" :src="item.devicePic" mode="aspectFit"></image>
</view>
<view class="panel centerCol lbl">
<view class="LargeTxt">{{item.deviceName}}</view>
<view class="smallTxt">ID:{{item.deviceImei?item.deviceImei:item.deviceMac}}</view>
</view>
</view>
</scroll-view>
<button class="btnNext" :class="{'active':formData.notify.length>0}" :disabled="formData.notify.length==0"
@click="Send">发送</button>
</view>
<MsgBox ref="msgPop" />
<global-loading ref="loading" />
</view>
</template>
<script>
import request from '@/utils/request.js';
import {
showLoading,
hideLoading,
updateLoading
} from '@/utils/loading.js';
import {
MsgSuccess,
MsgError,
MsgClose,
MsgWarning,
showPop,
MsgInfo
} from '@/utils/MsgPops.js'
import Common from '@/utils/Common.js';
var these = null;
export default {
data() {
return {
Status: {
steps: {
list: [{
text: '设置名称'
},
{
text: '设置主机'
},
{
text: '设置联机'
},
{
text: '发送编组'
}
],
curr: 0
}
},
formData: {
id: '',
name: '',
main: [], //通知设备
sub: [], //预警设备
notify: [] //发送设备
}
}
},
computed: {
},
created() {
},
onUnload() {
},
onBackPress() {
if (this.Status.steps.curr > 0) {
this.gotoStep(-1);
return true;
}
},
onShow() {
},
onHide: function() {
},
onLoad(opt) {
these = this;
let eventChannel = this.getOpenerEventChannel();
eventChannel.on('detailData', (res) => {
let data = res.data;
if (data) {
this.formData.id = data.id;
this.formData.name = data.name;
this.formData.main = [];
this.formData.sub = [];
this.formData.notify = [];
setTimeout(this.initData, 0);
}
});
},
methods: {
imgView(item,index){
if(!item.devicePic){
return;
}
uni.previewImage({
urls: [item.devicePic]
});
},
goCheckDevice(type) {
let json = {
type: type,
formData:this.formData
};
Object.assign(json, this.formData);
uni.navigateTo({
url: '/pages/common/linkDefence/checkDevice',
success(res) {
res.eventChannel.emit("detailData", {
data: json
});
},
events: {
checkOver(res) {
these.$set(these.formData, res.type, res.arr)
}
},
fail(ex) {
console.error("出现异常", ex);
}
});
},
initData() {
if (!this.formData.id) {
return;
}
let url = '';
if (!url) {
MsgWarning('后端未开发此接口,敬请期待', '', this);
return;
}
request({
url: url,
data: {
id: this.formData.id
},
method: 'POST'
}).then(res => {
if (res && res.code == 200) {
console.log("请求数据成功", res);
this.formData.main = res.data.filter(v => {
return v.type == 'notify';
});
this.formData.sub = res.data.filter(v => {
return v.type == 'warn';
});
} else {
MsgError(res.msg, '', this);
}
}).catch(ex => {
console.log("ex=", ex);
MsgError(ex.errMsg, '', this);
});
},
stepClick(item, index) {
console.log("步骤被点击:", item);
},
Send() {
showLoading(these, {
text: '发送中'
});
let task = () => {
hideLoading(these);
MsgSuccess("敬请期待", '', these);
}
setTimeout(task, 800);
},
gotoStep(intval) {
if (this.Status.steps.curr + intval > this.Status.steps.list.length - 1) {
return;
} else if (this.Status.steps.curr + intval < 0) {
return;
}
this.Status.steps.curr += intval;
}
}
}
</script>
<style>
.content {
padding: 30rpx;
box-sizing: border-box;
width: 100%;
}
/* #ifdef APP */
.content {
height: 100vh;
}
/* #endif */
/* #ifdef WEB|H5 */
.content {
height: calc(100vh - 44px);
}
/* #endif */
.mainPanel {
width: 100%;
height: calc(100% - 140rpx);
position: relative;
box-sizing: border-box;
border: 1px solid #FFFFFF00;
}
.mainPanel .btnNext {
width: 90%;
transform: translateX(5%);
position: absolute;
bottom: 0rpx;
border-radius: 45rpx;
background: #1A1A1A;
color: rgba(255, 255, 255, 0.4);
font-family: "PingFang SC";
height: 80rpx;
font-size: 28rpx;
line-height: 80rpx;
letter-spacing: 0px;
text-align: center;
}
.mainPanel .btnNext.active {
background: #BBE600;
color: #232323;
}
/deep/ .uni-easyinput__content,
.uni-easyinput__content {
background-color: #1A1A1A !important;
border-radius: 16rpx;
color: #FFFFFF;
text-indent: 10rpx;
box-sizing: border-box;
font-size: 24rpx;
}
/deep/ .uni-textarea-placeholder,
.uni-textarea-placeholder {
color: rgba(255, 255, 255, 0.5);
font-family: "PingFang SC";
font-style: Regular;
font-size: 24rpx;
font-weight: 400;
letter-spacing: 0.14rpx;
}
.mainPanel .main {
transform: translateY(30rpx);
}
.mainPanel .btnAdd {
width: 100%;
height: 150rpx;
border-radius: 16rpx;
background: rgba(26, 26, 26, 1);
display: flex;
flex-direction: column;
justify-content: space-evenly;
align-items: center;
flex-wrap: nowrap;
color: rgba(255, 255, 255, 0.87);
font-family: "PingFang SC";
font-style: Regular;
font-size: 24rpx;
font-weight: 400;
letter-spacing: 0.14rpx;
margin-top: 30rpx;
}
.mainPanel .btnAdd .img {
width: 50rpx;
height: 50rpx;
}
.mainPanel .checkedList {
width: 100%;
height: calc(100% - 300rpx);
transform: translateY(20rpx);
border-radius: 16rpx;
background-color: #1A1A1A;
box-sizing: border-box;
padding: 30rpx;
}
.mainPanel .checkedList .item {
width: 100%;
height: 100rpx;
overflow: hidden;
margin-bottom: 20rpx;
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-content: center;
justify-content: flex-start;
align-items: center;
}
.mainPanel .checkedList .item .panel{
height: 100%;
}
.mainPanel .checkedList .item .lbl{
width: calc(100% - 120rpx);
height: 100%;
transform: translateX(24rpx);
display: flex;
flex-direction: column;
flex-wrap: wrap;
align-content: flex-start;
align-items: flex-start;
justify-content: space-evenly;
}
.mainPanel .checkedList .item .imgContent {
width: 100rpx;
height: 100rpx;
background-color: #2A2A2A;
border-radius: 16rpx;
}
.mainPanel .checkedList .item .img {
width: 80%;
height: 80%;
}
.checkedList .LargeTxt{
color: rgba(255, 255, 255, 0.87);
font-family: "PingFang SC";
font-style: Regular;
font-size: 32rpx;
font-weight: 400;
}
.checkedList .smallTxt{
color: rgba(255, 255, 255, 0.6);
font-family: "PingFang SC";
font-style: Regular;
font-size: 24rpx;
font-weight: 400;
letter-spacing: 0.14rpx;
}
</style>

View File

@ -0,0 +1,882 @@
<template>
<view class="maincontent contentBg">
<uni-nav-bar :border="false" @clickLeft="prevPage" fixed="true" statusBar="true" background-color="#121212"
color="#FFFFFF" :title="Status.navbar.title">
<template v-slot:left>
<view>
<uni-icons type="left" size="24" color="#FFFFFF"></uni-icons>
</view>
</template>
<block slot="right">
<view class="navbarRight center">
<image @click.stop="handleRightClick(index,item)" v-for="item,index in Status.navbar.icons"
class="img" :src="item.src" mode="aspectFit"></image>
</view>
</block>
</uni-nav-bar>
<view class="tab-bar-wrap" v-show="!Status.Search">
<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}}
</view>
</view>
</scroll-view>
<view class="tab-more" @click="Status.Search=!Status.Search">
<image src="/static/images/common/search.png" mode="aspectFit" class="more"></image>
</view>
</view>
<view class="searchRow" v-show="Status.Search">
<view class="ipt">
<uni-easyinput class="txteare" maxlength="30" v-model="filter.txt" :trim="true" placeholder="搜索设备"
type="text" :inputBorder="false" :border="false"></uni-easyinput>
</view>
<view class="btn" @click.stop="Status.Search=false">取消</view>
<view class="clear"></view>
</view>
<view class="listContent">
<mescroll-uni class="device-list" @init="mescrollInit" @down="downCallback" @up="upCallback" :up="upOption"
:down="downOption" :fixed="false">
<view class="listItem center" v-for="item,index in deviceList">
<view class="opt center">
<view class="checkbox center" @click.stop="checkToggle(item,index)"
:class="{active:checks.find((v,i)=>{return v.id===item.id})}">
<uni-icons class="icon" type="checkmarkempty" size="17" color="#000000"></uni-icons>
</view>
</view>
<view class="main">
<view class="device-header">
<view class="deviceIMG" @click.stop="imgView(item,index)">
<image :src="item.devicePic" class="IMG" mode="aspectFit"></image>
</view>
<view class="device-name">
<view>设备:{{item.deviceName}}</view>
<view class="ID">
ID:{{item.deviceImei?item.deviceImei:item.deviceMac}}
</view>
<view class="ID">
<view class="center ">
<view :class="{'onlines':item.onlineStatus==1,'offlines':item.onlineStatus==0}">
{{item.onlineStatus==1?'在线':'离线'}}
</view>
<view class="splitLine"></view>
<view>电量{{item.battery || '0'}}%</view>
</view>
<view @click.stop="Disc(item,index)" class="disc center"
:class="{active:item.isDisc}">
<image src="/static/images/common/disc.png" class="discImg" mode="aspectFit">
</image>
<text>识别</text>
</view>
</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 || item.communicationMode==2">
<view class="device-status" :class="item.bleStatu?'online':'unline'">
{{item.bleStatu?'已连接':'未连接'}}
</view>
</view>
</view>
</view>
</mescroll-uni>
</view>
<view :class="{active:checks.length>0}" class="btnOK" @click.stop="OkCheck()">确定</view>
<global-loading ref="loading" />
<MsgBox ref="msgPop" />
</view>
</template>
<script>
var timeout = null;
var these = null;
var eventChannel = null;
var ble = null;
var recei = null;
var pagePath = "pages/common/linkDefence/checkDevice";
import request, {
baseURL
} from '@/utils/request.js';
import {
showLoading,
hideLoading,
updateLoading
} from '@/utils/loading.js';
import {
MsgSuccess,
MsgError,
MsgClose,
MsgWarning,
showPop,
MsgInfo,
MsgClear,
MsgPrompt
} from '@/utils/MsgPops.js';
import {
deviceInfo,
deviceTypeList
} from '@/api/common/index.js'
import Common from '@/utils/Common.js';
import bleTool from '@/utils/BleHelper.js';
import BleReceive from '@/utils/BleReceive';
export default {
data() {
return {
filter: {
txt: ''
},
Status: {
navbar: {
icons: [{
src: '/static/images/common/add.png',
type: 'add'
}],
title: '选择设备',
showBack: true,
height: 90,
},
type: null,
Search: false
},
mescroll: null,
downOption: {
auto: false,
autoShowLoading: false,
},
upOption: {
auto: false,
noMoreSize: 0,
offset: 10,
isLock: false,
empty: {
tip: '暂无数据',
hideScroll: false,
icon: '/static/images/common/empty.png'
},
textNoMore: '没有更多数据了'
},
deviceList: [],
checks: [],
tabs: [],
activeTabInfo: '',
activeTab: 0,
formData: {
id: '',
name: '',
main: [], //通知设备
sub: [], //预警设备
notify: [] //发送设备
}
}
},
created() {
this.Status.navbar.height = uni.getSystemInfoSync().statusBarHeight + 44;
},
onLoad() {
this.getTab();
these = this;
this.$watch("filter.txt",(newVal,oldVal)=>{
if(this.mescroll){
this.mescroll.triggerDownScroll();
}
});
eventChannel = this.getOpenerEventChannel();
eventChannel.on('detailData', (res) => {
let data = res.data;
console.log("收到上级页面传参", data);
this.Status.type = data.type;
let keys = Object.keys(data.formData);
for (let i = 0; i < keys.length; i++) {
let key = keys[i];
this.formData[key] = data.formData[key];
}
if (data.type == 'main') {
this.checks = data.main;
this.Status.navbar.title = "选择预警主机";
} else if (data.type == 'sub') {
this.checks = data.sub;
this.Status.navbar.title = "选择布防联机";
} else if (data.type == 'notify') {
this.checks = data.notify;
this.Status.navbar.title = "选择接收设备";
}
setTimeout(() => {
if (this.mescroll) {
this.mescroll.triggerDownScroll();
}
}, 0);
});
ble = bleTool.getBleTool();
recei = BleReceive.getBleReceive();
//蓝牙连接成功的回调
ble.addRecoveryCallback((res) => {
// console.log("蓝牙连接成功的回调");
this.bleRecovery(res);
}, pagePath);
//蓝牙断开连接的回调
ble.addDisposeCallback((res) => {
console.log("蓝牙断开连接的回调");
this.bleBreak(res);
}, pagePath);
//蓝牙适配器恢复可用的回调,一般是重连设备
ble.addStateRecoveryCallback(res => {
// console.log("蓝牙适配器恢复可用的回调");
this.bleStateRecovery();
}, pagePath);
//蓝牙适配器不可用的回调
ble.addStateBreakCallback(res => {
// console.error("蓝牙适配器不可用的回调");
this.bleStateBreak();
}, pagePath);
//接收到消息的回调
ble.addReceiveCallback((receive, device, path, recArr) => {
// console.error("首页收到消息了");
let json = recei.ReceiveData(receive, device, path, recArr);
// console.error("消息内容",json);
this.updateBleStatu();
}, pagePath);
// eventChannel.emit('checkOver', {type:'',arr:[]});//
},
methods: {
imgView(item, index) {
if (!item.devicePic) {
return;
}
uni.previewImage({
urls: [item.devicePic]
});
},
checkToggle(item, index) {
let f = this.checks.find((v, i) => {
if (v.id === item.id) {
this.checks.splice(i, 1);
return true;
}
return false;
});
if (!f) {
this.checks.push({
id: item.id,
deviceName: item.deviceName,
deviceImei: item.deviceImei,
deviceMac: item.deviceMac,
devicePic: item.devicePic
});
}
console.log("checks=", this.checks);
},
bleStateBreak() {
console.error("蓝牙适配器不可用");
this.updateBleStatu();
},
bleStateRecovery() {
if (this.isPageShow) {
console.log("蓝牙适配器恢复可用,重连断开的设备");
ble.linkAllDevices();
}
},
bleBreak(res) {
console.error("蓝牙断开连接", res);
if (res.deviceId) {
this.updateBleStatu(res.deviceId);
}
},
bleRecovery(res) {
// console.log("蓝牙连接成功", res);
if (res.deviceId) {
this.updateBleStatu(res.deviceId);
}
},
updateBleStatu() { //更新列表的蓝牙连接状态,电池 电量
if (ble) {
for (var i = 0; i < this.deviceList.length; i++) {
let f = null;
if (ble.data && ble.data.LinkedList) {
f = ble.data.LinkedList.find(v => {
if (v.macAddress && v.device && v.device.id) {
return v.device.id == this.deviceList[i].id;
}
return false;
});
}
if (f) {
this.$set(this.deviceList[i], 'bleStatu', f.Linked);
if (f.formData) {
let battary = 0;
if ('battary' in f.formData) {
battary = f.formData.battary;
} else if ('sta_PowerPercent' in f.formData) {
battary = f.formData.sta_PowerPercent;
} else if ('sta_battery' in f.formData) {
battary = f.formData.sta_battery;
}
this.$set(this.deviceList[i], 'battery', battary);
}
}
}
return;
}
console.error("ble is null")
},
getTab() {
deviceTypeList({}).then((res) => {
if (res.code == 200) {
//console.log("deviceTypeList=" + JSON.stringify(res.data));
this.tabs = [{
id: '',
name: '全部设备',
typeName: '全部设备'
},
...res.data.map(item => ({
id: item.id,
name: item.typeName,
typeName: item.typeName,
communicationMode: item.communicationMode
}))
];
}
})
},
isChecked(item, index) {
let f = this.checks.find((v, i) => {
return v.id == item.id;
});
if (f) {
return true;
}
return false;
},
OkCheck() {
if (this.checks.length == 0) {
return;
}
eventChannel.emit('checkOver', {
type: this.Status.type,
arr: this.checks
});
uni.navigateBack();
},
onClick(btn, i, item, index) {
if (btn.type == 'rename') {
console.log("执行重命名");
MsgPrompt(this, btn.type, () => {
console.log("确定被点击");
}, false, true);
return;
}
if (btn.type == 'drop') {
console.log("执行删除");
MsgError('删除后不可恢复,您确认删除"' + item + '"吗?', '确定', this, () => {
this.deviceList.splice(index, 1);
}, true);
return;
}
},
change(event) {
console.log('改变事件', event);
},
swipeChange(e, index) {
console.log('当前状态:' + e + ',下标:' + index)
},
gotoDetail(item, index) {
console.log("item=", item);
},
mescrollInit(mescroll) {
this.mescroll = mescroll;
},
// 下拉刷新
downCallback() {
if (this.mescroll) {
this.mescroll.resetUpScroll(false);
this.mescroll.scrollTo(0, 0);
}
this.getData();
},
// 上拉加载
upCallback() {
this.getData();
},
getData() {
var task = () => {
return new Promise((resolve, reject) => {
if (!this.Status.type) {
this.mescroll.endSuccess(0, false);
resolve();
return;
}
let data = {
pageNum: this.mescroll.num,
pageSize: 10,
deviceType: this.activeTabInfo ? this.activeTabInfo.id : '', // 使用传入的设备类型
isAsc: 'desc',
orderByColumn: 'bindingTime',
deviceName:this.filter.txt
}
if (!data.pageNum) {
this.mescroll.endSuccess(0, false);
resolve();
return;
}
let method = deviceInfo;
if (this.Status.type == 'notify') {
method = () => {
let rows=this.formData.main;
rows=rows.concat(this.formData.sub);
rows=rows.filter(v=>{
return v.deviceName.toLowerCase().indexOf(this.filter.txt.toLowerCase())>-1;
})
let json = {
code: 200,
rows: rows
};
return Promise.resolve(json);
}
}
method(data).then((res) => {
if (res.code == 200) {
const newDevices = res.rows.map(device => ({
...device,
showConfirm: false
}));
// 如果是第一页或切换分类,替换数据
if (data.pageNum === 1) {
this.deviceList = newDevices
} else {
//防止后端返回的数据包含已有数据
for (var i = 0; i < newDevices.length; i++) {
let device = newDevices[i];
let f = this.deviceList.find(v => {
return v.id === device.id;
});
if (!f) {
this.deviceList.push(device);
}
}
}
this.updateBleStatu();
// 判断是否加载完成
let hasNext = true;
if (res.rows.length < data.pageSize || this.deviceList.length >= this
.total) {
hasNext = false;
} else {
hasNext = true;
}
this.mescroll.endSuccess(res.rows.length, hasNext);
} else {
this.mescroll.endSuccess(0, false);
}
}).finally(() => {
resolve();
});
});
}
clearTimeout(timeout);
//防止下拉刷新的同时会调用一次上拉加载的问题
timeout = setTimeout(task, 50);
},
prevPage() {
uni.navigateBack({
});
},
handleRightClick(s, e) {
if (s === 0) {
} else if (s === 1) {
}
},
}
}
</script>
<style>
.maincontent {
height: 100vh;
}
.listContent {
height: calc(100% - 270rpx);
transform: translateY(20rpx);
}
.listItem {
width: 100%;
min-height: 140rpx;
box-sizing: border-box;
margin-bottom: 20rpx;
}
.swipBtn {
display: flex;
flex-direction: column;
flex-wrap: wrap;
align-content: center;
justify-content: center;
align-items: center;
}
.uni-swipe .icon,
/deep/ .uni-swipe .icon {
width: 35rpx;
height: 35rpx;
}
.uni-swipe .txt,
/deep/ .uni-swipe .txt {
color: rgba(255, 255, 255, 0.87);
font-family: "PingFang SC";
font-style: Regular;
font-size: 24rpx;
font-weight: 400;
letter-spacing: 0.14rpx;
}
.uni-swipe,
/deep/ .uni-swipe {
margin-bottom: 20rpx;
border-radius: 16rpx;
overflow: hidden;
}
.tab-bar-wrap {
display: flex;
align-items: center;
position: relative;
margin-top: 90rpx;
height: 66rpx;
}
.tab-bar {
width: 100%;
color: rgb(255, 255, 255);
white-space: nowrap;
/* 禁止换行 */
overflow: hidden;
position: relative;
}
.tab-container {
display: flex;
cursor: pointer;
align-items: center;
padding-right: 80rpx;
/* 预留更多按钮空间 */
}
.tab-item {
font-size: 28rpx;
padding: 0 30rpx;
text-align: center;
position: relative;
}
.tab-item.active {
color: #bbe600;
height: 66rpx;
font-weight: bold;
}
.tab-item.active::before {
content: "";
background-color: #bbe600;
position: absolute;
top: 90%;
left: 35%;
width: 30%;
height: 6rpx;
border-radius: 6rpx;
}
.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%);
height: 66rpx;
}
.more {
width: 30rpx;
height: 30rpx;
margin-top: 5rpx;
}
.listItem .opt {
width: 70rpx;
height: 210rpx;
}
.listItem .opt .checkbox {
width: 35rpx;
height: 35rpx;
box-sizing: border-box;
border: 1px solid rgba(255, 255, 255, 0.4);
border-radius: 8rpx;
background-color: #00000000;
}
.listItem .opt .checkbox .icon {
display: none;
}
.listItem .opt .checkbox.active {
background-color: #AED600 !important;
}
.listItem .opt .checkbox.active .icon {
display: block;
}
.listItem .main {
width: calc(100% - 70rpx);
height: 210rpx;
}
.device-header {
display: flex;
align-items: center;
margin-bottom: 15rpx;
padding: 30rpx 0 10rpx 30rpx;
background: rgba(26, 26, 26, 1);
}
.device-name {
font-size: 32rpx;
color: rgba(255, 255, 255, 0.87);
margin-left: 24rpx;
line-height: 50rpx;
width: 75%;
white-space: nowrap;
}
.ID {
color: rgba(255, 255, 255, 0.6);
font-size: 26rpx;
display: flex;
justify-content: space-between;
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;
}
.p10 {
padding-left: 20rpx;
}
.splitLine {
background: linear-gradient(180deg, rgba(0, 0, 0, 0), rgba(255, 255, 255, 1) 44.525%, rgba(255, 254.75, 254.75, 0) 92%);
opacity: 0.2;
width: 4rpx;
height: 25rpx;
margin: 0rpx 20rpx;
}
.disc {
padding: 5rpx 10rpx;
margin-right: -30rpx;
}
.disc.active {
background-color: #2a2a2a !important;
;
}
.discImg {
width: 24rpx;
height: 24rpx;
margin-right: 10rpx;
}
.IMG {
width: 68rpx;
height: 50rpx;
margin-left: 17%;
object-fit: contain;
}
.device-callpolice {
width: 122rpx;
height: 52rpx;
font-size: 24rpx;
border-radius: 0px 8px 0px 8px;
background-color: rgba(224, 52, 52, 1);
position: absolute;
top: 0rpx;
right: -4rpx;
text-align: center;
line-height: 52rpx;
color: #fff;
}
.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);
}
.btnOK.active {
background: rgba(187, 230, 0, 1) !important;
color: rgba(35, 35, 35, 1) !important;
}
.btnOK {
/* 矩形 7 */
width: 80%;
height: 90rpx;
line-height: 90rpx;
border-radius: 90rpx;
text-align: center;
color: rgba(255, 255, 255, 0.4);
background: rgba(26, 26, 26, 1);
font-family: "PingFang SC";
font-style: Bold;
font-size: 28rpx;
font-weight: 400;
box-shadow: 0px 0px 2px 0px rgb(255 255 255 / 30%);
position: fixed;
z-index: 1;
bottom: 50rpx;
left: 10%;
text-align: center;
}
.searchRow {
width: 100%;
height: 70rpx;
margin-top: 90rpx;
}
.searchRow .ipt {
width: calc(100% - 80rpx);
height: 100%;
float: left;
}
.searchRow .btn {
width: 80rpx;
height: 100%;
line-height: 70rpx;
text-align: right;
color: rgba(255, 255, 255, 0.87);
font-family: "PingFang SC";
font-style: Regular;
font-size: 28rpx;
font-weight: 400;
letter-spacing: 0.14rpx;
float: left;
}
/deep/ .uni-easyinput__content,
.uni-easyinput__content {
background-color: #1A1A1A !important;
border-radius: 70rpx;
color: #FFFFFF;
text-indent: 10rpx;
box-sizing: border-box;
font-size: 24rpx;
}
/deep/ .uni-textarea-placeholder,
.uni-textarea-placeholder {
color: rgba(255, 255, 255, 0.5);
font-family: "PingFang SC";
font-style: Regular;
font-size: 24rpx;
font-weight: 400;
letter-spacing: 0.14rpx;
}
</style>

View File

@ -0,0 +1,509 @@
<template>
<view class="maincontent contentBg">
<uni-nav-bar :border="false" @clickLeft="prevPage" fixed="true" statusBar="true" background-color="#121212"
color="#FFFFFF" :title="Status.navbar.title">
<template v-slot:left>
<view>
<uni-icons type="left" size="24" color="#FFFFFF"></uni-icons>
</view>
</template>
<block slot="right">
<view class="navbarRight center">
<image @click.stop="handleRightClick(index,item)" v-for="item,index in Status.navbar.icons"
class="img" :src="item.src" mode="aspectFit"></image>
</view>
</block>
</uni-nav-bar>
<view class="listContent">
<mescroll-uni class="device-list" @init="mescrollInit" @down="downCallback" @up="upCallback" :up="upOption"
:down="downOption" :fixed="false">
<uni-swipe-action>
<uni-swipe-action-item v-for="item,index in deviceList" @click="onClick"
@change="swipeChange($event, 0)" :autoClose="false">
<view class="listItem" @click.stop="gotoDetail(item,index)">
<view class="itemMain">
<view class="title">{{item.name?item.name:'预警设防'+index}}</view>
<view class="splitLine"></view>
<view class="row">
<view class="lbl">布防联机:{{item.total}}</view>
<view class="lbl">接收设备:{{item.notify}}</view>
</view>
<view class="row">
<view class="lbl">布防联机:{{item.sub}}</view>
<view class="lbl">预警主机:{{item.warn}}</view>
</view>
</view>
</view>
<template v-slot:right>
<view class="swipBtn" @click.stop="onClick(btn,i,item,index)"
v-for="btn,i in Status.SwipOptions"
:style="{'backgroundColor':btn.style.backgroundColor,'width':btn.style.width}">
<image :src="btn.style.icon" mode="aspectFit" class="icon"
:style="{'filter':btn.style.filter}"></image>
<text class="txt">{{btn.text}}</text>
</view>
</template>
</uni-swipe-action-item>
</uni-swipe-action>
</mescroll-uni>
</view>
<global-loading ref="loading" />
<MsgBox ref="msgPop" />
<MsgBox ref="rename">
<view class="renamePop center">
<view class="lbl">设备名称</view>
<input class="txt" v-model="cEdit.name" type="text" placeholder="输入名称" maxlength="20"
placeholder-class="txtplace" />
</view>
</MsgBox>
</view>
</template>
<script>
import request, {
baseURL
} from '@/utils/request.js';
import {
showLoading,
hideLoading,
updateLoading
} from '@/utils/loading.js';
import {
MsgSuccess,
MsgError,
MsgClose,
MsgWarning,
showPop,
MsgInfo,
MsgClear,
MsgPrompt
} from '@/utils/MsgPops.js';
import Common from '@/utils/Common.js';
var timeout = null;
var these = null;
export default {
data() {
return {
Status: {
navbar: {
icons: [{
src: '/static/images/common/add.png',
type: 'add'
}],
title: '预警布防',
showBack: true,
height: 90
},
SwipOptions: [{
type: "rename",
text: '重命名',
style: {
backgroundColor: '#E09319',
icon: '/static/images/common/rename.png',
width: '120rpx', // 初始宽度
},
},
{
type: 'drop',
text: '删除',
style: {
backgroundColor: 'rgb(240, 60, 60)',
icon: '/static/images/common/dell.png',
width: '120rpx', // 初始宽度
filter: 'brightness(0) invert(0.87)'
},
},
],
},
mescroll: null,
downOption: {
auto: true,
autoShowLoading: false,
},
upOption: {
auto: false,
noMoreSize: 0,
offset: 10,
isLock: false,
empty: {
tip: '暂无数据',
hideScroll: false,
icon: '/static/images/common/empty.png'
},
textNoMore: '没有更多数据了'
},
deviceList: [],
cEdit: {
id: null,
name: null,
total: null,
notify: null,
sub: null,
warn: null
}
}
},
created() {
this.Status.navbar.height = uni.getSystemInfoSync().statusBarHeight + 44;
},
onLoad() {
these = this;
},
methods: {
ReName() {
if (!this.cEdit.name) {
MsgError('请输入名称', '', these, null, false);
return;
}
let ok = () => {
this.deviceList.find((v, i) => {
if (v.id == this.cEdit.id) {
this.$set(this.deviceList[i], "name", this.cEdit.name)
return true;
}
});
}
let url = '';
if (url) {
request({
url: url,
data: this.cEdit,
method: 'update'
}).then(res => {
if (res && res.code == 200) {
ok();
}
}).catch(ex => {
MsgError(ex.msg, '', these);
});
} else {
ok();
}
},
onClick(btn, i, item, index) {
if (btn.type == 'rename') {
these.cEdit = Object.assign(these.cEdit, item);
console.log("执行重命名");
MsgPrompt(this, btn.type, this.ReName, false, true);
return;
}
if (btn.type == 'drop') {
console.log("执行删除");
MsgError('删除后不可恢复,您确认删除"' + item.name + '"吗?', '确定', this, () => {
this.deviceList.splice(index, 1);
}, true);
return;
}
},
change(event) {
console.log('改变事件', event);
},
swipeChange(e, index) {
console.log('当前状态:' + e + ',下标:' + index)
},
gotoDetail(item, index) {
uni.navigateTo({
url: '/pages/common/linkDefence/addDefence',
success(res) {
res.eventChannel.emit('detailData',{data:item})
}
});
},
mescrollInit(mescroll) {
this.mescroll = mescroll;
},
// 下拉刷新
downCallback() {
if (this.mescroll) {
this.mescroll.resetUpScroll(false);
this.mescroll.scrollTo(0, 0);
}
this.getData();
},
// 上拉加载
upCallback() {
this.getData();
},
getData() {
let task = () => {
let data = {
pageNum: this.mescroll.num,
pageSize: 10,
}
if (!data.pageNum) {
this.mescroll.endSuccess(0, false);
return;
}
let result = (res) => {
// 分页处理
if (data.pageNum === 1) {
this.deviceList = res.rows;
} else {
this.deviceList = this.deviceList.concat(res.rows);
}
let hasNext = true;
if (res.rows.length < data.pageSize || this.deviceList.length >= res.total) {
hasNext = false;
} else {
hasNext = true;
}
this.mescroll.endSuccess(res.rows.length, hasNext);
}
let url = ''; //请求地址
if (url) {
request({
url: url,
data: data,
method: 'GET'
}).then((res) => {
if (res.code == 200) {
result(res);
} else {
this.mescroll.endSuccess(0, false);
}
}).catch(ex => {
MsgError(ex.errMsg, '', this);
this.mescroll.endSuccess(0, false);
});
} else {
if (data.pageNum === 1) {
//开发时做假数据模拟成功
MsgWarning("这是测试数据,非真实场景,真实功能敬请期待", '', this, true, null, false);
}
let res = {
code: 200,
total: 108,
rows: []
};
let currLen = this.deviceList.length;
for (let i = 0; i < data.pageSize; i++) {
if (currLen + i + 1 >= res.total) {
break;
}
let json = {
id: Common.guid(),
name: '预警设防 ' + (i + (data.pageNum - 1) * data.pageSize + 1),
total: (Math.random() * 100).toFixed(0),
notify: (Math.random() * 100).toFixed(0),
sub: (Math.random() * 100).toFixed(0),
warn: (Math.random() * 100).toFixed(0)
};
res.rows.push(json);
}
result(res);
}
}
clearTimeout(timeout);
timeout = setTimeout(task, 50);
},
prevPage() {
uni.navigateBack({
});
},
handleRightClick(s, e) {
if (s === 0) {
uni.navigateTo({
url: '/pages/common/linkDefence/addDefence'
})
} else if (s === 1) {
}
},
}
}
</script>
<style>
.maincontent {
height: 100vh;
}
.listContent {
height: calc(100% - 90rpx);
margin-top: 90rpx;
}
.listItem {
background: rgba(26, 26, 26, 1);
width: 100%;
min-height: 140rpx;
height: auto;
box-sizing: border-box;
padding: 20rpx 30rpx;
}
.listItem .itemMain {
width: 100%;
overflow: hidden;
}
.listItem .title {
color: rgba(255, 255, 255, 0.87);
font-family: "PingFang SC";
font-size: 32rpx;
font-weight: 400;
letter-spacing: 0.14rpx;
text-align: left;
}
.listItem .splitLine {
border-bottom: 1rpx solid rgba(255, 255, 255, 1);
width: 10000px;
height: 0rpx;
margin-top: 15rpx;
margin-bottom: 15rpx;
transform: scale(0.1);
margin-left: -5000px;
}
.listItem .row {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-content: center;
align-items: center;
justify-content: space-between;
margin-bottom: 15rpx;
color: rgba(255, 255, 255, 1);
font-family: "PingFang SC";
font-style: Regular;
font-size: 24rpx;
font-weight: 200;
letter-spacing: 0.07px;
}
/* .listItem .row .lbl{
padding: 0rpx 30rpx 0rpx 0rpx;
text-align: left;
} */
.listItem .row:last-of-type {
margin-bottom: 0rpx;
}
.swipBtn {
display: flex;
flex-direction: column;
flex-wrap: wrap;
align-content: center;
justify-content: center;
align-items: center;
}
.uni-swipe .icon,
/deep/ .uni-swipe .icon {
width: 35rpx;
height: 35rpx;
}
.uni-swipe .txt,
/deep/ .uni-swipe .txt {
color: rgba(255, 255, 255, 0.87);
font-family: "PingFang SC";
font-style: Regular;
font-size: 24rpx;
font-weight: 400;
letter-spacing: 0.14rpx;
}
.uni-swipe,
/deep/ .uni-swipe {
margin-bottom: 20rpx;
border-radius: 16rpx;
overflow: hidden;
}
.renamePop {
width: 100%;
height: 80rpx;
padding: 60rpx 0rpx 30rpx 0rpx;
display: flex;
}
.renamePop .lbl {
color: rgba(255, 255, 255, 0.87);
font-family: "PingFang SC";
font-style: Regular;
font-size: 26rpx;
letter-spacing: 0.14rpx;
width: auto;
padding: 0rpx 10rpx 0rpx 0rpx;
}
.renamePop .txt {
flex: 1;
height: 60rpx;
box-sizing: border-box;
border: 1rpx solid rgba(255, 255, 255, 0.4);
border-radius: 8rpx;
text-align: left;
text-indent: 10rpx;
color: rgba(255, 255, 255, 0.87);
font-family: "PingFang SC";
font-size: 28rpx;
letter-spacing: 0.14rpx;
}
.txtplace {
color: rgba(255, 255, 255, 0.43);
font-family: "PingFang SC";
font-size: 26rpx;
}
</style>