新增录入 添加等功能

This commit is contained in:
3321822538@qq.com 2024-11-06 16:55:34 +08:00
parent 99888f22c5
commit 27b1b860ab
3 changed files with 1424 additions and 240 deletions

View File

@ -25,8 +25,12 @@
切换设备 <image src="https://api.ccttiot.com/smartmeter/img/static/uwHOBxvbJjkhx1uDiQHI" mode="">
</image>
</view>
<view class="selectshezhi" @click="btnsz">
<image src="https://api.ccttiot.com/smartmeter/img/static/uvCJ8ro0MpfGZd53vypJ" mode=""></image>
<view class="selectshezhi" style="display: flex;">
<view class="selectnames" @click="btnluru" v-if="userobj.userType == 00">
录入设备
</view>
<image @click="btnsz" src="https://api.ccttiot.com/smartmeter/img/static/uvCJ8ro0MpfGZd53vypJ" mode=""></image>
</view>
</view>
<view class="selectbox">
@ -312,7 +316,8 @@
user:{},
lastChar:'',
timer:'',
bjflag:false
bjflag:false,
userobj:{}
}
},
//
@ -342,6 +347,15 @@
},
methods: {
//
btnluru(){
this.datalist = ''
this.mac = ''
this.ver_data = {}
uni.navigateTo({
url:'/pages/myorder/index'
})
},
//
btnshowjs() {
this.showjs = true
@ -1649,6 +1663,23 @@
margin-left: 14rpx;
}
}
.selectnames {
font-size: 28rpx;
color: #3D3D3D;
border: 1px solid;
padding:0 20rpx;
box-sizing: border-box;
border-radius: 20rpx;
background-color: #48893B;
color: #fff;
height: 60rpx;
line-height: 60rpx;
image {
width: 32rpx;
height: 26rpx;
margin-left: 14rpx;
}
}
.selectshezhi {
image {

View File

@ -1,115 +1,526 @@
<template>
<view class="page">
<u-navbar title="我的订单" :border-bottom="false" :background="bgc" title-color='#000' title-size='36' height='38'></u-navbar>
<view class="listorder">
<view class="pages">
<u-navbar title="设备录入" :border-bottom="false" :background="bgc" title-size='38' title-color='#000'
back-icon-color="#000" height='50'></u-navbar>
<view class="title">
<view>SDFGA5452168437113123 &nbsp;&nbsp; <u-icon name="file-text" size="38"></u-icon> </view> <view @click="btnnav"><u-icon name="arrow-right"></u-icon></view>
<text>设备录入列表</text>
<!-- <text style="font-size: 28rpx;width: 160rpx;height: 60rpx;border-radius: 20rpx;background-color: #7FAD76;text-align: center;color: #fff;line-height: 60rpx;margin-top: 20rpx;" @click="btnkzt">控制台</text> -->
</view>
<view class="bh">
<text>柜机编号</text> <text>SDGJRAEG15684721339658</text>
<view class="dblist" v-for="(item, index) in devicesLists" :key="index">
<view class="cen" :id="item.deviceId" @click="createBLEConnections(item)">
<view class="name">
<view class="">
状态<text v-if="item.flags == true" style="color: #e10328;">已录入</text> <text v-else
style="color:seagreen;">未录入</text>
</view>
<view class="bh">
<text>电池编号</text> <text>DFASF5413786946</text>
<!-- <view class="" style="display: flex;width: 100%;">
SN码:{{item.sn == undefined ? '--' : item.sn}}
</view> -->
</view>
<view class="bh">
<text>手机号码</text> <text>12345678978</text>
<view class="mac">
MAC{{item.name.substring(5)}}
</view>
<view class="bh">
<text>订单状态</text> <text>使用中</text>
<view class="" style="color: #7FAD76;margin-top: 10rpx;margin-bottom: 10rpx;text-align: left;">
蓝牙强度:{{item.RSSI}}
</view>
<view class="bh">
<text>订单金额</text> <text>-</text>
</view>
<view class="bh">
<text>租借时间</text> <text>2024-04-08 15:05:21</text>
</view>
<view class="bh">
<text>租借时长</text> <text>-</text>
<view class="rt" :id="item.deviceId" @click="createBLEConnections(item)">
<text style="margin-bottom: 10rpx;">选择</text>
</view>
</view>
<view class="anniu" v-if="seachflag" @click="Search">
<button>重新扫描</button>
</view>
<view class="mask" v-if="titleflag">
<view class="titles">
温馨提示
</view>
<text>未扫描到附近未绑定设备:</text>
<text>1.确保待连接设备在附近且蓝牙处于打开状态</text>
<text>2.确保设备未与其他设备进行蓝牙连接</text>
<text>3.确保设备未被添加过</text>
<button @click="btnyc">好的</button>
</view>
<view v-if="mengcflag" class="mengc"
style="width: 100%;height: 100vh;background-color: #000;opacity: .5;position: fixed;top: 0;left: 0;"></view>
<!-- 选择蓝牙型号 -->
<u-select v-model="shows" :list="arr" @confirm="confirm"></u-select>
</view>
</template>
<script>
const app = getApp();
var xBlufi = require("@/components/blufi/xBlufi.js");
export default {
data() {
return {
mengcflag: false,
titleflag: false, //
bgc: {
backgroundColor: "#F7FAFE",
},
devicesList: [
// {name:'110000',
// mac:'11111'}
],
devicesLists: [],
searching: false,
texts: '正在扫描设备...',
btnflag: true,
tishiflag: false,
option: '',
bluthlist: [], //
status: 'loading',
statusflag: false,
Bluetoothmac: '',
gps: {},
mac: '',
status: false,
storeId: '',
lurulist: [],
arr: [],
shows: false,
arrname: '',
valuexh: '',
deviceId: '',
arrs: '',
sn: '输入SN',
snname: '',
qrResult:'',
name:'',
ver_data:null,
seachflag:true
}
},
onLoad(option) {
// console.log(option);
// this.storeId = option.sn
},
onUnload: function() {
console.log("unload ");
xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent);
wx.closeBLEConnection({
deviceId: this.deviceId,
})
},
//
onShareAppMessage: function() {
return {
title: '绿小能',
path: '/pages/index/index'
title: '创想物联',
path: '/pages/shouye/index'
}
},
//
onShareTimeline: function() {
return {
title: '绿小能',
title: '创想物联',
query: '',
path: '/pages/index/index'
path: '/pages/shouye/index'
}
},
onLoad() {
mounted() {
// this.videoContext = uni.createVideoContext('myVideo', this)
},
methods: {
btnnav(){
btnkzt(){
uni.navigateTo({
url:'/pages/myorder/returned/index'
url:'/page_user/wifijoint/index'
})
},
// sn
scanQRCode(item) {
this.snname = item.name
uni.scanCode({
onlyFromCamera: true,
scanType: ['qrCode'],
success: res => {
function getQueryParam(url, paramName) {
let regex = new RegExp(`[?&]${paramName}=([^&]*)`)
let results = regex.exec(url);
return results ? decodeURIComponent(results[1].replace(/\+/g, ' ')) : null
}
let sceneValue = res.result
let decodedValue = decodeURIComponent(sceneValue)
let id = getQueryParam(decodedValue, 's')
this.storeId = id
this.devicesLists.forEach(item => {
if (item.name == this.snname) {
item.sn = id
}
})
},
fail: err => {
console.error('扫描失败:', err)
uni.showToast({
title: '扫描失败',
icon: 'none'
})
}
})
},
btnshows(item, index) {
this.arrname = item.name
this.shows = true
},
//
confirm(e) {
this.devicesLists.forEach(item => {
if (item.name == this.arrname) {
item.xuanz = e[0].label
this.valuexh = e[0].value
}
})
},
btnyc() {
this.titleflag = false
},
funListenDeviceMsgEvent: function(options) {
switch (options.type) {
case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_MY_DATA:
let loadPercent = options.data;
let loadText = '文件读取中'
break;
case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA:
this.ver_data = this.parseCustomData(options.data)
console.log("1收到设备发来的自定义数据结果", this.ver_data)
break;
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS:
if (options.result) {
this.devicesList = options.data
this.devicesList.forEach(device => {
const mac = device.name.substring(5)
if (device.name == this.qrResult) {
this.deviceId = device.deviceId
this.name = device.name
this.mac = device.name.slice(5, 17)
}
})
}
break;
case xBlufi.XBLUFI_TYPE.TYPE_CONNECTED:
// console.log("" + JSON.stringify(options))
if (options.result) {
setTimeout(()=>{
this.bluetoothflag = false
},3000)
{
console.log("连接回调options.data.deviceId" + options.data.deviceId,
"连接回调options.data.name" + options.data.name)
}
} else {
this.shibaiflag = true
this.bluetoothflag = false
}
break;
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_START:
if (!options.result) {
this.mengcflag = false
uni.hideLoading()
console.log("蓝牙未开启", options)
uni.showToast({
title: '蓝牙未开启,请打开手机蓝牙',
icon: 'none',
duration: 3000
})
} else {
this.searching = true
}
break;
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_STOP:
if (options.result) {
let uniqueDevicesList = Array.from(new Set(this.devicesList));
this.devicesLists = uniqueDevicesList.map(device => {
const deviceId = device.name.substring(5)
const newDevice = {
...device,
xuanz: "请选择",
}; // xuanz
return newDevice
})
let devicesarr = options.data
this.devicesList.forEach(device => {
if (device.name.substring(0, 4) == "CCYK") {
this.devicesList.push(device)
let uniqueDevicesList = Array.from(new Set(this.devicesList))
this.devicesLists = uniqueDevicesList.filter(device => {
const deviceId = device.name.substring(5)
return deviceId
})
}
})
// console.log('ok')
this.mengcflag = false
if (this.devicesLists.length == 0) {
this.titleflag = true
} else {
let arr = []
// console.log(this.devicesLists,'101010');
this.devicesLists.forEach(item => {
arr.push(item.name.slice(5))
})
this.arrs = arr.join(',')
this.$u.get(`/app/getExistMac/${this.arrs}`).then(res => {
if (res.code == 200 && Array.isArray(res.data)) {
const existingDevices = new Map(res.data.map(item => [item.mac, true]))// 使MapMAC
this.devicesLists = this.devicesLists.map(device => {
const trimmedName = device.name.slice(5) // nameMAC
const mac = trimmedName // trimmedNameMAC
device.found = existingDevices.has(mac) // found
if (device.found) {
const sn = res.data.find(val => val.mac === mac)?.sn // res.datasn
if (sn) {
device.sn = sn // sn
}
device.flags = true // flagstrueMAC
} else {
device.flags = false //
}
return device // mapreturn
})
this.devicesLists.sort((a, b) => {
if (a.found && !b.found) return 1 // baa
if (!a.found && b.found) return -1 // ab
return 0;
});
}
})
setTimeout(()=>{
uni.hideLoading()
},2000)
}
} else {
//
this.mengcflag = false
setTimeout(()=>{
uni.hideLoading()
},2000)
console.log('蓝牙停止搜索失败')
}
this.searching = false
break
}
},
//
createBLEConnections(e) {
let Bluetoothmac = e.name.substring(5)
this.devicesLists = []
uni.navigateTo({
url:'/pages/myorder/returned/index?mac='+Bluetoothmac
})
},
//
Search() {
// if (this.status) {
this.seachflag = false
this.mengcflag = true
uni.showLoading({
title: '请稍后...'
})
xBlufi.initXBlufi(1);
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent);
xBlufi.notifyStartDiscoverBle({
'isStart': true
})
//
this.bluthlist = []
this.devicesList = []
this.devicesLists = []
this.arrs = []
//
// this.startBluetoothDevicesDiscovery()
this.statusflag = true
this.texts = '正在扫描蓝牙设备...'
setTimeout(() => {
this.statusflag = false
uni.hideLoading()
// if (this.searching) {
xBlufi.notifyStartDiscoverBle({
'isStart': false
});
this.seachflag = true
}, 2000)
// }
},
//
btnhd() {
this.tishiflag = false
}
}
}
</script>
<style lang="scss">
page {
// background-color: ;
background: linear-gradient(180deg, #25CE88 0%, rgba(255, 255, 255, 0) 100%);
border-radius: 0rpx 0rpx 0rpx 0rpx;
}
.page {
width: 750rpx;
padding-left: 34rpx;
padding-right: 34rpx;
background-color: #F7FAFE !important;
padding-bottom: 300rpx;
box-sizing: border-box;
}
.containers {
width: 100%;
height: 100vh;
position: fixed;
top: 0;
left: 0;
.listorder{
margin-top: 32rpx;
width: 100%;
height: 100%;
background-color: #fff;
border-radius: 30rpx;
padding: 32rpx;
padding-top: 130rpx;
box-sizing: border-box;
.title{
left: 0;
z-index: 999 !important;
}
.pages {
padding: 0 32rpx;
box-sizing: border-box;
}
.sm {
color: #77808D;
border-radius: 0rpx 0rpx 0rpx 0rpx;
display: inline-block;
}
.title {
margin-bottom: 84rpx;
margin-top: 50rpx;
display: flex;
justify-content: space-between;
image {
display: inline-block;
width: 48rpx;
height: 48rpx;
vertical-align: bottom;
margin-right: 10rpx;
}
text:nth-child(1) {
font-weight: 400;
font-size: 66rpx;
color: #262B37;
line-height: 88rpx;
text-align: left;
font-style: normal;
text-transform: none;
display: block;
margin-bottom: 48rpx;
}
}
.dblist {
display: flex;
justify-content: space-between;
width: 100%;
margin-top: 34rpx;
background: #FFFFFF;
box-shadow: 0rpx 10rpx 64rpx 0rpx rgba(0, 0, 0, 0.08);
padding: 20rpx 20rpx 24rpx 18rpx;
box-sizing: border-box;
text-align: center;
border-radius: 10rpx;
.lt {
padding-left: 10rpx;
box-sizing: border-box;
margin-right: 18rpx;
image {
width: 120rpx;
height: 200rpx;
}
}
.cen {
width: 365rpx;
padding-left: 10rpx;
box-sizing: border-box;
.name {
font-family: AlibabaPuHuiTi, AlibabaPuHuiTi;
font-weight: 400;
font-size: 32rpx;
color: #666666;
border-bottom: 1px solid #ccc;
padding-bottom: 20rpx;
margin-bottom: 28rpx;
color: #262B37;
line-height: 40rpx;
text-align: left;
font-style: normal;
text-transform: none;
margin-top: 10rpx;
}
.bh{
display: flex;
justify-content: space-between;
margin-top: 18rpx;
font-size: 24rpx;
color: #808080;
.mac {
font-family: AlibabaPuHuiTi, AlibabaPuHuiTi;
font-weight: 400;
font-size: 26rpx;
color: #262B37;
line-height: 32rpx;
text-align: left;
font-style: normal;
text-transform: none;
margin-top: 16rpx;
}
}
.rt {
margin-top: 32rpx;
box-sizing: border-box;
text {
display: block;
width: 108rpx;
height: 60rpx;
background: rgba(255, 255, 255, 0);
border: 2rpx solid #7FAD76;
filter: blur(0px);
border-radius: 20rpx;
text-align: center;
line-height: 60rpx;
color: #7FAD76;
}
}
}
.anniu {
padding: 0 90rpx;
width: 100%;
box-sizing: border-box;
position: fixed;
left: 0;
bottom: 112rpx;
button {
background: #7FAD76;
border-radius: 52rpx 52rpx 52rpx 52rpx;
color: #fff;
}
}
.mask {
width: 622rpx;
height: 710rpx;
background: #FFFFFF;
filter: blur(0px);
border-radius: 20rpx;
position: fixed;
top: 475rpx;
left: 50%;
transform: translateX(-50%);
padding-top: 38rpx;
padding-left: 60rpx;
padding-right: 60rpx;
box-sizing: border-box;
.titles {
font-size: 48rpx;
color: #262B37;
line-height: 70rpx;
text-align: center;
margin-bottom: 24rpx;
}
text {
display: block;
font-size: 32rpx;
color: #262B37;
line-height: 56rpx;
text-align: left;
}
button {
margin-top: 46rpx;
width: 266rpx;
height: 96rpx;
background: #7FAD76;
border-radius: 52rpx 52rpx 52rpx 52rpx;
color: #fff;
text-align: center;
line-height: 96rpx;
}
}
</style>

File diff suppressed because it is too large Load Diff