smartswrtch-app/page_user/sbdetail.vue

1218 lines
31 KiB
Vue
Raw Normal View History

2024-03-13 10:54:22 +08:00
<template>
<view class="page">
2024-05-24 16:48:42 +08:00
<u-navbar :title="tittxt" :border-bottom="false" :background="bgc" back-icon-color="#fff" title-color='#fff'
2024-06-03 16:47:25 +08:00
title-size='36' height='50' id="navbar">
2024-03-13 10:54:22 +08:00
</u-navbar>
2024-05-13 15:32:48 +08:00
<view class="zhuhu">
2024-03-13 10:54:22 +08:00
<view class="card1">
<view class="top">
<view class="left">
设备
</view>
<view class="right">
2024-05-10 17:37:36 +08:00
<!-- <image class="img1" src="https://api.ccttiot.com/smartmeter/img/static/uGvS4RQvbw7OOfhzy6xf" mode="" style="margin-right: 30rpx;" @click="opendevices"></image>
<image class="img1" src="https://api.ccttiot.com/smartmeter/img/static/uNEKwe2WKsJdtQzOdEay" mode="" @click="toewm()"></image> -->
2024-03-13 10:54:22 +08:00
</view>
</view>
<view class="mid">
2024-05-13 15:32:48 +08:00
<view class="mid_left" @click="btnpic">
<image :src="imglist" mode=""></image>
2024-03-13 10:54:22 +08:00
</view>
<view class="mid_right">
<view class="mid_top">
2024-06-04 14:50:30 +08:00
{{ deviceInfo.deviceName == null ? '' : deviceInfo.deviceName }}
2024-06-05 18:07:50 +08:00
<view class="" style="font-size: 26rpx;">
更新时间{{deviceInfo.lastPullTime}}</view>
2024-03-13 10:54:22 +08:00
</view>
<view class="mid_bot">
2024-06-05 18:07:50 +08:00
<view class="txt" v-if="deviceInfo">
S/N码{{ deviceInfo.deviceNo == null ? '' : deviceInfo.deviceNo }}</view>
2024-03-13 10:54:22 +08:00
<div class="tip" v-if="deviceInfo.onlineStatus==1">在线</div>
<div class="tip" v-if="deviceInfo.onlineStatus==0">离线</div>
2024-05-13 15:32:48 +08:00
<div class="tip" v-if="deviceInfo.powerStatus==0">断电</div>
<div class="tip" v-if="deviceInfo.powerStatus==1">正常</div>
2024-03-13 10:54:22 +08:00
</view>
</view>
</view>
<view class="bot">
2024-05-25 18:05:40 +08:00
<!-- <view class="bot_left">
2024-03-13 10:54:22 +08:00
<view class="echarts">
<l-echart ref="chart" @finished="initChart"></l-echart>
2024-05-13 15:32:48 +08:00
<uni-ec-canvas class="uni-ec-canvas" id="uni-ec-canvas" ref="canvas"
canvas-id="uni-ec-canvas" :ec="ec">
2024-05-10 21:35:42 +08:00
</uni-ec-canvas>
2024-03-13 10:54:22 +08:00
</view>
2024-05-25 18:05:40 +08:00
</view> -->
2024-06-05 18:07:50 +08:00
<!-- <view class="bot_right">
2024-05-25 18:05:40 +08:00
<view class="cont" style="text-align: center;">
<view class="tit">
{{deviceInfo.orderAmount == null ? 0 : deviceInfo.orderAmount}}
</view>
<view class="txt">
订单金额
</view>
</view>
2024-05-10 17:37:36 +08:00
<view class="cont" style="text-align: center;">
2024-03-13 10:54:22 +08:00
<view class="tit">
2024-05-24 16:48:42 +08:00
{{deviceInfo.orderCount == null ? 0 : deviceInfo.orderCount}}
2024-03-13 10:54:22 +08:00
</view>
<view class="txt">
2024-05-10 17:37:36 +08:00
订单数
2024-03-13 10:54:22 +08:00
</view>
</view>
2024-05-25 18:05:40 +08:00
<view class="cont" style="text-align: center;">
2024-03-13 10:54:22 +08:00
<view class="tit">
2024-06-05 18:07:50 +08:00
{{timeday}}
sb:{{setMode}}
2024-03-13 10:54:22 +08:00
</view>
<view class="txt">
2024-05-10 17:37:36 +08:00
剩余分钟
2024-03-13 10:54:22 +08:00
</view>
</view>
2024-06-05 18:07:50 +08:00
</view> -->
2024-03-13 10:54:22 +08:00
</view>
</view>
<view class="card2">
<view class="tit">实时</view>
2024-06-05 18:07:50 +08:00
<!-- <view class="cont_box">
2024-03-13 10:54:22 +08:00
<view class="cont">
2024-06-04 14:50:30 +08:00
<view class="top">{{deviceInfo.realTimePower == null ? '' : deviceInfo.realTimePower}}KW</view>
2024-03-13 10:54:22 +08:00
<view class="bot">实时功率</view>
</view>
2024-06-05 18:07:50 +08:00
<view class="cont" >
<view class="top" style="width: 100%">{{deviceInfo.electricity == null ? '' : deviceInfo.electricity}}A</view>
2024-03-13 10:54:22 +08:00
<view class="bot">电流</view>
</view>
2024-06-05 18:07:50 +08:00
<view class="cont" >
<view class="top" style="width:100%">{{deviceInfo.voltage == null ? '' : deviceInfo.voltage}}V</view>
2024-03-13 10:54:22 +08:00
<view class="bot">电压</view>
</view>
2024-06-05 18:07:50 +08:00
</view> -->
<view class="bot_right">
<view class="cont" style="text-align: center;">
<view class="tit">
{{deviceInfo.orderAmount == null ? 0 : deviceInfo.orderAmount}}
</view>
<view class="txt">
订单金额
</view>
</view>
<view class="cont" style="text-align: center;">
<view class="tit">
{{deviceInfo.orderCount == null ? 0 : deviceInfo.orderCount}}
</view>
<view class="txt">
订单数
</view>
</view>
<view class="cont" style="text-align: center;">
<view class="tit">
{{timeday}}
sb:{{setMode}}
</view>
<view class="txt">
剩余分钟
</view>
</view>
2024-03-13 10:54:22 +08:00
</view>
2024-06-05 18:07:50 +08:00
2024-03-13 10:54:22 +08:00
</view>
<view class="card3">
<view class="tit">其他</view>
2024-05-10 17:37:36 +08:00
<view class="cont_box" style="display: block;">
2024-05-13 15:32:48 +08:00
<view class="" style="display: flex;justify-content: space-between;">
<view class="cont" style="width: 120rpx;" @click="topage(0)">
<view class="top">
<image src="https://api.ccttiot.com/smartmeter/img/static/uj4DT6WructS782RY0J7" mode=""
style="width: 58rpx;height: 56rpx;"></image>
</view>
<view class="bot">充值记录</view>
</view>
<view class="cont" style="width: 60rpx;" @click="topage(1)">
<view class="top">
<image src="https://api.ccttiot.com/smartmeter/img/static/uGaAuulryhDmaDwWLuwo" mode=""
style="width: 58rpx;height: 58rpx;"></image>
</view>
<view class="bot">归零</view>
</view>
<view class="cont" style="width: 60rpx;" @click="topage(2)">
<view class="top">
<image src="https://api.ccttiot.com/smartmeter/img/static/u8QfFAKCq8wE32dFA9Go" mode=""
style="width: 58rpx;height: 60rpx;"></image>
</view>
<view class="bot">异常</view>
</view>
<view class="cont" style="width: 120rpx;" @click="toydfx()">
<view class="top">
<image src="https://api.ccttiot.com/smartmeter/img/static/u0N4pFke1isIzNrNT6Wh" mode="">
</image>
</view>
<view class="bot">用电分析</view>
</view>
2024-03-13 10:54:22 +08:00
</view>
2024-05-13 15:32:48 +08:00
<view class="" style="display: flex;margin-top: 20rpx;">
<view class="cont" style="width: 120rpx;" @click="topage(3)">
<view class="top">
2024-06-05 18:07:50 +08:00
<image src="https://api.ccttiot.com/smartmeter/img/static/uijv1lOhn2ds1ZS4gEMT" mode=""
2024-05-13 15:32:48 +08:00
style="width: 58rpx;height: 60rpx;"></image>
</view>
<view class="bot">收费方式</view>
</view>
<view class="cont" style="width: 60rpx;" @click="topage(4)">
<view class="top">
<image src="https://api.ccttiot.com/smartmeter/img/static/ubxoYVnbIK1rk0cfoL3j" mode="">
</image>
</view>
<view class="bot">设置</view>
</view>
2024-06-05 18:07:50 +08:00
<view class="cont" style="width: 60rpx;margin-right: 100rpx;" @click="topage(5)">
2024-05-21 10:49:02 +08:00
<view class="top">
2024-05-21 15:07:11 +08:00
<image src="https://api.ccttiot.com/smartmeter/img/static/uWaQjL7vph474LWTyGfs" mode="">
2024-05-21 10:49:02 +08:00
</image>
</view>
<view class="bot">配网</view>
</view>
2024-06-05 18:07:50 +08:00
<view class="cont" style="width: 60rpx;" @click="topage(6)">
<view class="top">
<image src="https://api.ccttiot.com/smartmeter/img/static/udZvVKZIh6brG3cm3YpN" mode="">
</image>
</view>
<view class="bot">充值</view>
</view>
2024-03-13 10:54:22 +08:00
</view>
</view>
<view class="cont_box" style="padding-left: 30rpx;">
2024-05-13 15:32:48 +08:00
2024-03-13 10:54:22 +08:00
</view>
</view>
</view>
2024-06-05 18:07:50 +08:00
<view class="tanc" v-if="vipflag">
<view class="tit">请输入您需要充值的时长(分钟)</view>
<input type="text" v-model="cztime" />
<view class="xian"></view>
<view class="anniu">
<text @click="btnqx">取消</text> <text style="border-left: 1px solid #D8D8D8;color: #8883F0;"
@click="trueje">确定</text>
</view>
</view>
<view class="mask" v-if="vipflag"></view>
2024-03-13 10:54:22 +08:00
</view>
</template>
<script>
2024-05-10 19:51:14 +08:00
var xBlufi = require("@/page_components/blufi/xBlufi.js")
2024-05-10 21:35:42 +08:00
import uniEcCanvas from '@/components/uni-ec-canvas/uni-ec-canvas.vue'
import * as echarts from '@/components/uni-ec-canvas/echarts'
let chart = null
2024-03-13 10:54:22 +08:00
export default {
2024-05-10 21:35:42 +08:00
components: {
uniEcCanvas
},
2024-03-13 10:54:22 +08:00
data() {
return {
bgc: {
2024-05-21 18:02:34 +08:00
backgroundColor: "#8883f0",
2024-03-13 10:54:22 +08:00
},
2024-05-10 21:35:42 +08:00
ec: {
lazyLoad: true
},
2024-05-13 15:32:48 +08:00
deviceInfo: {},
loadings: false,
info: '',
tittxt: "设备列表",
2024-03-13 10:54:22 +08:00
titlist: [
2024-05-13 15:32:48 +08:00
"全部",
"电表",
"水表",
],
curtitidx: 0,
id: '',
timeday: '',
imglist: '',
token: '',
userImgs: '',
imgflag: true,
2024-05-30 17:24:10 +08:00
mac: "",
name: '',
deviceId: '',
storeId: '',
2024-06-04 17:50:05 +08:00
qrResult: '',
2024-06-05 18:07:50 +08:00
devicesList: [],
setMode:0,
vipflag:false,
cztime:''
2024-03-13 10:54:22 +08:00
}
},
onLoad(option) {
let id = option.id
2024-05-13 15:32:48 +08:00
this.id = id
2024-03-13 10:54:22 +08:00
this.getDevice(id)
2024-06-05 18:07:50 +08:00
xBlufi.initXBlufi(1);
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent);
xBlufi.notifyStartDiscoverBle({
'isStart': true
})
// 停止蓝牙搜索
setTimeout(() => {
xBlufi.notifyStartDiscoverBle({
'isStart': false
});
xBlufi.notifyConnectBle({
isStart: true,
deviceId: this.deviceId,
name: this.name
})
xBlufi.notifyInitBleEsp32({
deviceId: this.deviceId
});
}, 2000)
2024-03-13 10:54:22 +08:00
},
2024-05-13 15:32:48 +08:00
onShow() {
setTimeout(() => {
this.getDevice(this.id)
}, 1000)
this.getQiniuToken()
},
2024-05-24 16:48:42 +08:00
onUnload: function() {
xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent);
xBlufi.notifyStartDiscoverBle({
'isStart': false
});
2024-06-05 18:07:50 +08:00
wx.closeBLEConnection({
deviceId: this.objlist.deviceId,
})
2024-05-24 16:48:42 +08:00
},
onHide() {
xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent);
xBlufi.notifyStartDiscoverBle({
'isStart': false
});
2024-06-05 18:07:50 +08:00
wx.closeBLEConnection({
deviceId: this.objlist.deviceId,
})
2024-05-24 16:48:42 +08:00
},
onBeforeUnmount() {
xBlufi.listenDeviceMsgEvent(false, this.funListenDeviceMsgEvent);
xBlufi.notifyStartDiscoverBle({
'isStart': false
});
2024-06-05 18:07:50 +08:00
wx.closeBLEConnection({
deviceId: this.objlist.deviceId,
})
2024-05-24 16:48:42 +08:00
},
2024-03-13 10:54:22 +08:00
methods: {
2024-05-13 15:32:48 +08:00
getQiniuToken() {
this.$u.get("/common/qiniu/uploadInfo").then((res) => {
2024-03-13 10:54:22 +08:00
if (res.code == 200) {
2024-05-13 15:32:48 +08:00
this.token = res.token
}
});
},
btnpic() {
let _this = this
let math = 'static/' + _this.$u.guid(20)
uni.chooseImage({
count: 1,
type: 'all',
success(res) {
const tempFilePaths = res.tempFiles
wx.uploadFile({
url: 'https://up-z2.qiniup.com',
name: 'file',
filePath: tempFilePaths[0].path,
formData: {
token: _this.token, //后端返回的token
key: 'smartmeter/img/' + math
},
success: function(res) {
let str = JSON.parse(res.data)
_this.userImgs = 'https://api.ccttiot.com/' + str.key
_this.imglist = _this.userImgs
let data = {
deviceId: _this.id,
customPicture: _this.imglist
}
_this.putdevice(data)
2024-05-24 16:48:42 +08:00
2024-05-13 15:32:48 +08:00
}
});
2024-05-10 17:37:36 +08:00
}
2024-05-13 15:32:48 +08:00
})
},
putdevice(data) {
this.$u.put('/app/device', data).then((res) => {
if (res.code == 200) {
uni.showToast({
title: '修改成功',
2024-05-24 16:48:42 +08:00
icon: 'success',
duration: 2000
})
2024-05-30 17:24:10 +08:00
} else if (res.code == 500) {
2024-05-24 16:48:42 +08:00
uni.showToast({
title: '设备不在线',
2024-05-13 15:32:48 +08:00
icon: 'none',
duration: 2000
})
}
})
},
// 获取设备详情
getDevice(id) {
this.$u.get("/app/device/" + id).then((res) => {
// this.$forceUpdate()
if (res.code == 200) {
this.deviceInfo = res.data
2024-05-24 16:48:42 +08:00
this.storeId = res.data.storeId
this.qrResult = 'CTKG-' + res.data.mac
2024-05-13 15:32:48 +08:00
if (res.data.customPicture != '自定义图片路径') {
this.imglist = res.data.customPicture
} else {
this.imglist = res.data.picture
}
let expireTimeStr = this.deviceInfo.expireTime
let expireTimeParts = expireTimeStr.split(" ");
let expireDateParts = expireTimeParts[0].split("-");
let expireTimePartsTime = expireTimeParts[1].split(":");
2024-06-06 13:32:16 +08:00
let expireDate = new Date(expireDateParts[0], expireDateParts[1] - 1, expireDateParts[2],expireTimePartsTime[0], expireTimePartsTime[1], expireTimePartsTime[2])
2024-05-13 15:32:48 +08:00
let now = new Date();
let differenceInMs = expireDate - now;
if (differenceInMs <= 0) {
2024-06-05 18:07:50 +08:00
this.timeday = null
2024-05-13 15:32:48 +08:00
} else {
this.timeday = Math.abs(Math.floor(differenceInMs / (1000 * 60)));
}
this.loadings = true
2024-03-13 10:54:22 +08:00
}
});
2024-05-13 15:32:48 +08:00
2024-05-10 17:37:36 +08:00
},
2024-05-13 15:32:48 +08:00
opendevice() {
let stause = 0
if (this.deviceInfo.powerStatus == 1) {
stause = 0
} else {
stause = 1
2024-05-10 17:37:36 +08:00
}
2024-05-13 15:32:48 +08:00
console.log(stause, 'stausestause');
this.$u.put(`/app/device/${this.deviceInfo.deviceId}/changePower?status=` + stause).then((res) => {
// this.$forceUpdate()
2024-05-10 17:37:36 +08:00
if (res.code == 200) {
2024-05-13 15:32:48 +08:00
// this.groupList=res.rows
setTimeout(() => {
this.getDevice(this.id)
}, 2000)
// this.loadings=true
// this.initChart()
} else {
2024-05-10 17:37:36 +08:00
uni.showToast({
2024-05-13 15:32:48 +08:00
title: res.msg,
icon: 'none'
2024-05-10 17:37:36 +08:00
});
}
});
},
2024-05-13 15:32:48 +08:00
opendevices() {
2024-03-13 10:54:22 +08:00
},
2024-05-13 15:32:48 +08:00
swiperchange(e) {
this.curtitidx = e.detail.current
console.log(e, 'aaaa');
2024-03-13 10:54:22 +08:00
},
2024-05-13 15:32:48 +08:00
changeidx(index) {
this.curtitidx = index
2024-03-13 10:54:22 +08:00
},
2024-05-13 15:32:48 +08:00
toydfx() {
2024-03-13 10:54:22 +08:00
uni.navigateTo({
2024-05-13 15:32:48 +08:00
url: "/page_components/eletj?id=" + this.id
2024-03-13 10:54:22 +08:00
})
},
2024-05-13 15:32:48 +08:00
2024-03-25 19:46:07 +08:00
// 其他部分 点击进行跳转
2024-05-13 15:32:48 +08:00
topage(num) {
if (num == 0) {
2024-03-25 19:46:07 +08:00
uni.navigateTo({ //抄表
2024-05-13 15:32:48 +08:00
url: '/page_user/cbRecord?id=' + this.id
2024-03-25 19:46:07 +08:00
})
2024-05-13 15:32:48 +08:00
} else if (num == 1) {
2024-05-10 17:37:36 +08:00
//归零
2024-05-13 15:32:48 +08:00
this.$u.put(`/app/device/${this.id}/reset`).then((res) => {
if (res.code == 200) {
console.log(res.data);
uni.showToast({
title: res.data,
icon: 'none',
duration: 2000
2024-06-05 18:07:50 +08:00
})
2024-05-13 15:32:48 +08:00
this.getDevice(this.id)
} else if (res.msg == '设备剩余时间不足,无需归零') {
uni.showToast({
title: '设备剩余时间不足,无需归零',
icon: 'none',
duration: 2000
2024-06-05 18:07:50 +08:00
})
}else if(res.code == 500){
uni.showToast({
title: res.msg,
icon: 'none',
duration: 2000
})
2024-06-06 13:32:16 +08:00
// uni.showLoading({
// title: '充值中...'
// })
// let vm = this; // 将外部的 this 绑定到 vm 上
// uni.getNetworkType({
// success(res) {
// if (res.networkType !== 'none') {
// uni.getConnectedBluetoothDevices({
// success(res) {
// console.log('已连接的蓝牙设备信息:', res);
// xBlufi.notifySendCustomData({
// customData: "time@" + 0
// });
// },
// fail(err) {
// console.error('获取已连接蓝牙设备信息失败:', err);
// }
// })
// // vm.$u.get(`/app/bill/recharge/${vm.billNo}/bluetoothSuccess`).then(res => {
// // if(res.code == 200){
// // setTimeout(()=>{
// // uni.hideLoading()
// // uni.navigateBack()
// // },1000)
// // }
// // })
// } else {
// console.log('手机未连接网络');
// }
// }
// })
2024-05-13 15:32:48 +08:00
}
})
} else if (num == 2) { //异常
2024-03-25 19:46:07 +08:00
uni.navigateTo({
2024-05-13 15:32:48 +08:00
url: '/page_fenbao/statulist/fault/yichang/index'
2024-03-25 19:46:07 +08:00
})
2024-05-13 15:32:48 +08:00
} else if (num == 3) {
2024-03-25 19:46:07 +08:00
uni.navigateTo({
2024-05-13 15:32:48 +08:00
url: "/page_fenbao/statulist/taocanlist/index?id=" + this.id
})
} else if (num == 4) { //设置
uni.navigateTo({
url: '/page_user/setting?id=' + this.id
2024-03-25 19:46:07 +08:00
})
2024-05-24 16:48:42 +08:00
} else if (num == 5) {
2024-06-05 18:07:50 +08:00
if(this.deviceId == ''){
xBlufi.initXBlufi(1);
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent);
2024-05-24 16:48:42 +08:00
xBlufi.notifyStartDiscoverBle({
2024-06-05 18:07:50 +08:00
'isStart': true
})
// 停止蓝牙搜索
setTimeout(() => {
xBlufi.notifyStartDiscoverBle({
'isStart': false
});
2024-06-04 17:50:05 +08:00
xBlufi.notifyConnectBle({
isStart: true,
deviceId: this.deviceId,
name: this.name
})
2024-06-05 18:07:50 +08:00
xBlufi.notifyInitBleEsp32({
deviceId: this.deviceId
})
let name = ''
let index = this.name.indexOf('-');
if (index !== -1) {
name = this.name.slice(index + 1);
}
let data = {
storeId: this.storeId,
mac: this.mac
}
this.$u.put('/app/device/bind', data).then((res) => {
if (res.code == 200) {
uni.showToast({
title: '绑定成功',
icon: 'none',
duration: 2000
})
uni.hideLoading();
uni.removeStorageSync('mac');
let systemInfo = uni.getSystemInfoSync();
if (systemInfo.platform == 'android') {
// 当前设备是 Android
uni.navigateTo({
url: '/page_components/wifilist/index?deviceId=' +this.deviceId + '&name=' +this.name
})
} else if (systemInfo.platform == 'ios') {
// 当前设备是 iOS
uni.navigateTo({
url: '/page_fenbao/device/wifivideo?deviceId=' +this.deviceId + '&name=' +this.name
})
}
} else if (res.msg == '设备编号和mac不能同时为空') {
uni.showToast({
title: '设备不在线,未找到设备',
icon: 'none',
duration: 2000
});
} else {
uni.showToast({
title: '连接失败',
icon: 'none',
duration: 2000
});
// uni.navigateBack()
}
})
}, 1000)
}else{
let name = ''
let index = this.name.indexOf('-');
if (index !== -1) {
name = this.name.slice(index + 1);
}
let data = {
storeId: this.storeId,
mac: this.mac
}
this.$u.put('/app/device/bind', data).then((res) => {
if (res.code == 200) {
uni.showToast({
title: '绑定成功',
icon: 'none',
duration: 2000
})
uni.hideLoading();
uni.removeStorageSync('mac');
let systemInfo = uni.getSystemInfoSync();
if (systemInfo.platform == 'android') {
// 当前设备是 Android
uni.navigateTo({
url: '/page_components/wifilist/index?deviceId=' +this.deviceId + '&name=' +this.name
})
} else if (systemInfo.platform == 'ios') {
// 当前设备是 iOS
uni.navigateTo({
url: '/page_fenbao/device/wifivideo?deviceId=' +this.deviceId + '&name=' +this.name
})
}
} else if (res.msg == '设备编号和mac不能同时为空') {
uni.showToast({
title: '设备不在线,未找到设备',
icon: 'none',
duration: 2000
})
} else {
uni.showToast({
title: '连接失败',
icon: 'none',
duration: 2000
});
// uni.navigateBack()
}
})
}
}else if(num == 6){
this.vipflag = true
2024-03-25 19:46:07 +08:00
}
2024-05-24 16:48:42 +08:00
},
2024-06-05 18:07:50 +08:00
trueje(){
let id = this.deviceInfo.deviceId
this.vipflag = false
this.$u.put('/app/device/addTime/' + id + '?amount=' + this.cztime).then(res => {
if(res.code == 200){
uni.showToast({
title: '充值成功',
icon: 'success',
duration: 2000
})
this.getDevice(this.id)
this.cztime = ''
}else if(res.code == 500){
uni.showToast({
title: res.msg,
icon: 'success',
duration: 2000
2024-06-06 13:32:16 +08:00
})
// let vm = this; // 将外部的 this 绑定到 vm 上
// uni.getNetworkType({
// success(res) {
// if (res.networkType !== 'none') {
// uni.getConnectedBluetoothDevices({
// success(res) {
// console.log('已连接的蓝牙设备信息:', res);
// xBlufi.notifySendCustomData({
// customData: "time@" + vm.setMode + vm.cztime
// });
// },
// fail(err) {
// console.error('获取已连接蓝牙设备信息失败:', err);
// }
// })
// // vm.$u.get(`/app/bill/recharge/${vm.billNo}/bluetoothSuccess`).then(res => {
// // if(res.code == 200){
// // setTimeout(()=>{
// // uni.hideLoading()
// // uni.navigateBack()
// // },1000)
// // }
// // })
// } else {
// console.log('手机未连接网络');
// }
// }
// })
2024-06-05 18:07:50 +08:00
}
})
},
btnqx(){
this.vipflag = false
this.cztime = ''
},
2024-05-24 16:48:42 +08:00
2024-05-30 17:24:10 +08:00
funListenDeviceMsgEvent: function(options) {
switch (options.type) {
2024-06-05 18:07:50 +08:00
case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_MY_DATA:
let loadPercent = options.data;
let loadText = '文件读取中'
// console.log("文件读取中", options.data);
break;
case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA:
let ver_data = this.parseCustomData(options.data)
this.setMode = Math.floor(ver_data.setMode / 60)
console.log("1收到设备发来的自定义数据结果", ver_data,this.setMode);
break;
2024-05-30 17:24:10 +08:00
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS:
if (options.result) {
let devicesarr = options.data
// console.log(devicesarr,'devicesarrdevicesarr');
devicesarr.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)
2024-06-05 18:07:50 +08:00
// console.log(this.mac, 'macmacmac');
// this.devicesList = uniqueDevicesList;
2024-05-30 17:24:10 +08:00
}
2024-06-04 17:50:05 +08:00
})
2024-05-30 17:24:10 +08:00
}
break;
case xBlufi.XBLUFI_TYPE.TYPE_CONNECTED:
2024-06-05 18:07:50 +08:00
// console.log("连接回调:" + JSON.stringify(options));
2024-05-30 17:24:10 +08:00
if (options.result) {
uni.hideLoading();
// uni.showToast({
// title: '连接成功',
// icon: 'none'
// });
{
console.log("连接回调options.data.deviceId" + options.data.deviceId,
"连接回调options.data.name" + options.data.name);
}
2024-06-05 18:07:50 +08:00
} else {
2024-06-04 17:50:05 +08:00
uni.hideLoading()
uni.showToast({
title: '设备离线或不在范围内',
icon: 'none',
duration: 2000
})
2024-05-30 17:24:10 +08:00
}
break;
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_START:
if (!options.result) {
console.log("蓝牙未开启", options);
uni.showToast({
title: '蓝牙未开启',
icon: 'none',
duration: 3000
});
} else {
// this.searching = true
//蓝牙搜索开始
// _this.setData({
// searching: true
// });
}
break;
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_STOP:
if (options.result) {
let uniqueDevicesList = Array.from(new Set(this.devicesList));
// 将去重后的数组重新赋值给 this.devicesList
this.devicesList = uniqueDevicesList;
let list = []
filteredDevices.forEach(device => {
// 从设备名称中提取 MAC 地址(假设 MAC 地址是设备名称的后6个字符
let macFromName = device.name.substring(device.name.length - 12);
this.$u.get(`/app/device/${macFromName}/isBind`).then((res) => {
if (res.data == false) {
list.push(device)
} else {
}
})
});
setTimeout(() => {
this.devicesList = list
}, 200)
console.log('蓝牙停止搜索ok');
} else {
//蓝牙停止搜索失败
console.log('蓝牙停止搜索失败');
}
this.searching = false
// _this.setData({
// searching: false
// });
break;
2024-06-05 18:07:50 +08:00
2024-05-30 17:24:10 +08:00
}
},
2024-06-05 18:07:50 +08:00
parseCustomData(data) {
// 将字符串按照 "@" 分割成数组
const dataArray = data.split('@');
// 根据约定,解析各个字段的值
const voltage = parseFloat(dataArray[0].substring(1)); // 去除前缀 "V",并将字符串转换为浮点数
const switchState = dataArray[1].substring(1); // 去除前缀 "S"
const current = parseFloat(dataArray[2].substring(1)); // 去除前缀 "A",并将字符串转换为浮点数
const power = parseFloat(dataArray[4].substring(1)); // 去除前缀 "P",并将字符串转换为浮点数
const remainingPower = parseFloat(dataArray[5].substring(1)); // 去除前缀 "M",并将字符串转换为浮点数
const setMode = dataArray[6].substring(1); // 去除前缀 "T"
// 返回解析后的数据对象
return {
voltage,
switchState,
current,
power,
remainingPower,
setMode
};
},
2024-05-13 15:32:48 +08:00
2024-03-13 10:54:22 +08:00
}
}
</script>
<style lang="scss">
2024-06-05 18:07:50 +08:00
/deep/ .u-title {
2024-06-03 16:47:25 +08:00
padding-bottom: 22rpx;
}
2024-06-05 18:07:50 +08:00
/deep/ .u-icon__icon {
2024-06-03 16:47:25 +08:00
padding-bottom: 22rpx;
}
2024-06-05 18:07:50 +08:00
2024-03-13 10:54:22 +08:00
page {
2024-05-13 15:32:48 +08:00
background-color: #F7FAFE;
2024-03-13 10:54:22 +08:00
}
2024-06-05 18:07:50 +08:00
.mask {
width: 750rpx;
height: 100vh;
background: #000000;
border-radius: 0rpx 0rpx 0rpx 0rpx;
opacity: 0.2;
z-index: 1;
position: fixed;
top: 0;
left: 0;
}
.tanc {
width: 610rpx;
height: 282rpx;
background: #FFFFFF;
border-radius: 30rpx 30rpx 30rpx 30rpx;
position: fixed;
top: 628rpx;
left: 50%;
transform: translateX(-50%);
z-index: 2;
.tit {
width: 100%;
text-align: center;
margin-top: 28rpx;
font-weight: 500;
font-size: 32rpx;
color: #3D3D3D;
}
input {
width: 504rpx;
height: 62rpx;
background: #EEEEEE;
border-radius: 6rpx 6rpx 6rpx 6rpx;
margin: auto;
margin-top: 22rpx;
padding-left: 20rpx;
}
.xian {
width: 610rpx;
height: 2rpx;
background: #D8D8D8;
border-radius: 0rpx 0rpx 0rpx 0rpx;
margin-top: 26rpx;
}
.anniu {
display: flex;
justify-content: space-between;
height: 98rpx;
text {
padding: 24rpx;
text-align: center;
box-sizing: border-box;
font-weight: 500;
font-size: 36rpx;
color: #3D3D3D;
display: inline-block;
width: 100%;
height: 100rpx;
}
}
}
2024-03-13 10:54:22 +08:00
.page {
.zhuhu {
2024-06-05 18:07:50 +08:00
margin-top: 60rpx;
2024-03-13 10:54:22 +08:00
padding: 0 40rpx;
.card1 {
padding: 34rpx 0 0 40rpx;
width: 670rpx;
2024-06-05 18:07:50 +08:00
height: 320rpx;
2024-03-13 10:54:22 +08:00
background: #FFFFFF;
box-shadow: 0rpx 14rpx 35rpx 0rpx rgba(53, 140, 255, 0.1);
border-radius: 28rpx 28rpx 28rpx 28rpx;
.top {
display: flex;
flex-wrap: nowrap;
justify-content: space-between;
align-items: center;
.left {
font-size: 35rpx;
font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
font-weight: 400;
color: #8883F0;
}
.right {
margin-right: 56rpx;
.img1 {
width: 76rpx;
height: 76rpx;
}
}
}
.mid {
2024-05-10 17:37:36 +08:00
margin-top: 20rpx;
2024-03-13 10:54:22 +08:00
display: flex;
flex-wrap: nowrap;
align-content: flex-start;
.mid_left {
image {
2024-06-05 18:07:50 +08:00
width: 160rpx;
2024-05-10 17:37:36 +08:00
height: 160rpx;
2024-05-24 16:48:42 +08:00
border-radius: 20rpx;
2024-03-13 10:54:22 +08:00
}
}
.mid_right {
margin-left: 40rpx;
display: flex;
flex-wrap: wrap;
.mid_top {
width: 100%;
font-size: 42rpx;
font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
font-weight: 400;
color: #262B37;
}
.mid_bot {
display: flex;
flex-wrap: nowrap;
align-items: center;
.txt {
2024-06-05 18:07:50 +08:00
font-size: 26rpx;
2024-03-13 10:54:22 +08:00
font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
font-weight: 400;
color: #95989D;
}
.tip {
display: flex;
align-items: center;
justify-content: center;
margin-left: 19rpx;
2024-05-25 18:05:40 +08:00
// width: 38rpx;
// height: 23rpx;
padding: 5rpx 10rpx;
box-sizing: border-box;
2024-03-13 10:54:22 +08:00
background: rgba(204, 204, 204, 0);
opacity: 1;
border: 2rpx solid #8883F0;
border-radius: 40rpx;
2024-06-05 18:07:50 +08:00
font-size: 26rpx;
2024-03-13 10:54:22 +08:00
font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
font-weight: 400;
color: #8883F0;
}
}
}
}
.bot {
2024-05-10 17:37:36 +08:00
margin-top: 53rpx;
2024-03-13 10:54:22 +08:00
display: flex;
flex-wrap: nowrap;
align-items: center;
.bot_left {
width: 210rpx;
2024-05-11 13:33:17 +08:00
height: 180rpx;
2024-05-13 15:32:48 +08:00
margin-right: 34rpx;
2024-03-13 10:54:22 +08:00
.echarts {
2024-05-11 13:33:17 +08:00
// width: 210rpx;
height: 200rpx;
2024-05-13 15:32:48 +08:00
2024-05-10 21:35:42 +08:00
.uni-ec-canvas {
width: 100%;
2024-05-11 13:33:17 +08:00
height: 100rpx !important;
2024-05-10 21:35:42 +08:00
display: block;
// margin-top: 30rpx;
}
2024-03-13 10:54:22 +08:00
}
}
.bot_right {
// margin-top: 50rpx;
display: flex;
2024-05-25 18:05:40 +08:00
// flex-wrap: nowrap;
2024-05-30 17:24:10 +08:00
width: 100%;
2024-05-25 18:05:40 +08:00
justify-content: space-between;
padding-left: 80rpx;
padding-right: 120rpx;
box-sizing: border-box;
2024-05-30 17:24:10 +08:00
2024-03-13 10:54:22 +08:00
.cont {
.tit {
font-size: 28rpx;
font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
font-weight: 600;
color: #262B37;
line-height: 49rpx;
}
.txt {
2024-06-05 18:07:50 +08:00
font-size: 26rpx;
2024-03-13 10:54:22 +08:00
font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
font-weight: 400;
color: #262B37;
}
}
}
}
}
2024-06-05 18:07:50 +08:00
.bot_right {
// margin-top: 50rpx;
display: flex;
// flex-wrap: nowrap;
width: 100%;
justify-content: space-between;
padding-left: 80rpx;
padding-right: 120rpx;
box-sizing: border-box;
margin-top: 30rpx;
.cont {
.tit {
font-size: 28rpx;
font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
font-weight: 600;
color: #262B37;
line-height: 49rpx;
margin-left: 0;
}
.txt {
font-size: 26rpx;
font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
font-weight: 400;
color: #262B37;
}
}
}
2024-03-13 10:54:22 +08:00
.card2 {
padding-top: 40rpx;
margin-top: 24rpx;
width: 670rpx;
height: 254rpx;
background: #FFFFFF;
box-shadow: 0rpx 16rpx 40rpx 0rpx rgba(53, 140, 255, 0.1);
border-radius: 28rpx;
.tit {
margin-left: 40rpx;
font-size: 35rpx;
font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
font-weight: 400;
color: #8883F0;
}
.cont_box {
margin-top: 32rpx;
display: flex;
flex-wrap: nowrap;
justify-content: space-around;
2024-05-13 15:32:48 +08:00
2024-03-13 10:54:22 +08:00
.cont {
2024-05-10 17:37:36 +08:00
width: 25%;
2024-03-13 10:54:22 +08:00
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: center;
2024-05-13 15:32:48 +08:00
text-align: center;
2024-03-13 10:54:22 +08:00
.top {
2024-03-25 19:46:07 +08:00
width: 110rpx;
2024-03-13 10:54:22 +08:00
font-size: 32rpx;
font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
font-weight: 400;
color: #262B37;
}
.bot {
margin-top: 20rpx;
2024-06-05 18:07:50 +08:00
font-size: 26rpx;
2024-03-13 10:54:22 +08:00
font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
font-weight: 400;
color: #262B37;
}
}
}
}
.card3 {
padding-top: 40rpx;
margin-top: 24rpx;
width: 670rpx;
// height: 318rpx;
background: #FFFFFF;
box-shadow: 0rpx 16rpx 40rpx 0rpx rgba(53, 140, 255, 0.1);
border-radius: 28rpx;
padding-bottom: 20rpx;
2024-05-13 15:32:48 +08:00
2024-03-13 10:54:22 +08:00
.tit {
margin-left: 40rpx;
font-size: 35rpx;
font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
font-weight: 400;
color: #8883F0;
}
.cont_box {
2024-05-10 17:37:36 +08:00
// padding-left: 30rpx;
// padding-right: 30rpx;
padding: 0 40rpx;
2024-03-13 10:54:22 +08:00
margin-top: 32rpx;
display: flex;
flex-wrap: nowrap;
2024-05-10 17:37:36 +08:00
justify-content: space-around;
2024-05-13 15:32:48 +08:00
.cont:last-child {
2024-03-13 10:54:22 +08:00
margin-right: 0rpx;
}
2024-05-13 15:32:48 +08:00
2024-03-13 10:54:22 +08:00
.cont {
width: 112rpx;
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: center;
margin-right: 80rpx;
2024-05-13 15:32:48 +08:00
2024-03-13 10:54:22 +08:00
.top {
image {
width: 56rpx;
height: 56rpx;
}
}
.bot {
margin-top: 15rpx;
font-size: 28rpx;
font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
font-weight: 400;
color: #808080;
}
}
}
}
.button {
margin-left: 76rpx;
margin-top: 178rpx;
display: flex;
justify-content: center;
align-items: center;
width: 520rpx;
height: 104rpx;
background: #8883F0;
box-shadow: 0rpx 16rpx 40rpx 0rpx rgba(42, 130, 228, 0.1);
border-radius: 52rpx 52rpx 52rpx 52rpx;
font-size: 32rpx;
font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
font-weight: 400;
color: #FFFFFF;
}
}
2024-05-13 15:32:48 +08:00
2024-03-13 10:54:22 +08:00
}
</style>