smartmeter-app/pages/index/index.vue

823 lines
18 KiB
Vue
Raw Normal View History

2023-11-27 09:57:03 +08:00
<template>
2024-01-27 16:37:52 +08:00
<view class="page">
2024-03-13 10:54:22 +08:00
<u-navbar :is-back="false" :title="tittxt" :border-bottom="false" :background="bgc" title-color='#2E4975'
title-size='36' height='36' id="navbar">
2024-01-27 16:37:52 +08:00
</u-navbar>
2024-03-13 10:54:22 +08:00
<view class="zhuhu" v-if="userType=='00'&&deviceInfo" >
2024-01-27 16:37:52 +08:00
<view class="card1">
<view class="top">
<view class="left">
设备
</view>
<view class="right">
<image class="img1" src="@/static/off.png" mode="" style="margin-right: 30rpx;"></image>
2024-03-13 10:54:22 +08:00
<image class="img1" src="@/static/share.png" mode="" @click="toewm()"></image>
2024-01-27 16:37:52 +08:00
</view>
</view>
<view class="mid">
<view class="mid_left">
<image src="../../static/db.png" mode=""></image>
</view>
<view class="mid_right">
<view class="mid_top">
2024-03-13 10:54:22 +08:00
{{ deviceInfo.deviceName }}
2024-01-27 16:37:52 +08:00
</view>
<view class="mid_bot">
2024-03-13 10:54:22 +08:00
<view class="txt" v-if="deviceInfo">电表号{{ deviceInfo.deviceId }}</view>
<div class="tip" v-if="deviceInfo.onlineStatus==1">在线</div>
<div class="tip" v-if="deviceInfo.onlineStatus==0">离线</div>
2024-01-27 16:37:52 +08:00
</view>
</view>
</view>
<view class="bot">
<view class="bot_left">
<view class="echarts">
2024-03-13 10:54:22 +08:00
2024-01-27 16:37:52 +08:00
<!-- <mpvue-echarts id="main" ref="pieChart" :echarts="echarts" @onInit="initChart" /> -->
<l-echart ref="chart" @finished="initChart"></l-echart>
</view>
</view>
<view class="bot_right">
<view class="cont">
<view class="tit">
150KWH
</view>
<view class="txt">
总电量
</view>
</view>
<view class="cont" style="margin-left: 60rpx;">
<view class="tit">
0.5/
</view>
<view class="txt">
电价
</view>
</view>
</view>
</view>
</view>
<view class="card2">
<view class="tit">实时</view>
<view class="cont_box">
<view class="cont">
2024-03-13 10:54:22 +08:00
<view class="top">{{deviceInfo.realTimePower}}KW</view>
2024-01-27 16:37:52 +08:00
<view class="bot">实时功率</view>
</view>
<view class="cont" style="width: 70rpx;">
2024-03-13 10:54:22 +08:00
<view class="top">{{deviceInfo.electricity}}A</view>
2024-01-27 16:37:52 +08:00
<view class="bot">电流</view>
</view>
<view class="cont">
2024-03-13 10:54:22 +08:00
<view class="top">{{deviceInfo.voltage}}V</view>
2024-01-27 16:37:52 +08:00
<view class="bot">电压</view>
</view>
2024-03-13 10:54:22 +08:00
2024-01-27 16:37:52 +08:00
</view>
</view>
<view class="card3">
<view class="tit">其他</view>
<view class="cont_box">
<view class="cont">
<view class="top">
<image src="@/static/sz.png" mode=""></image>
</view>
<view class="bot">其他设置</view>
</view>
<view class="cont" style="width: 58rpx;">
<view class="top">
<image src="@/static/yc.png" mode="" style="width: 58rpx;height: 60rpx;"></image>
</view>
<view class="bot">异常</view>
</view>
2024-03-13 10:54:22 +08:00
<view class="cont" @click="toydfx()">
2024-01-27 16:37:52 +08:00
<view class="top">
<image src="@/static/fx.png" mode=""></image>
</view>
<view class="bot">用电分析</view>
</view>
2024-03-13 10:54:22 +08:00
2024-01-27 16:37:52 +08:00
</view>
</view>
<view class="button">电费充值</view>
<view class="zhanwei" style="width: 100%;height: 300rpx;">
2024-03-13 10:54:22 +08:00
2024-01-27 16:37:52 +08:00
</view>
</view>
2024-03-13 10:54:22 +08:00
<view class="fd" v-if="userType=='01'" >
<view class="fd_top">
<view class="fd_tit" v-for="(item,index) in titlist" :key="index" :class="index==curtitidx?'act1':''" @click="changeidx(index)">
{{item}}
</view>
<view class="fd_set">
+
</view>
</view>
<view class="warp_box" >
<swiper class="swiper" style="height: 150vh;" :current='curtitidx' @change="swiperchange">
<swiper-item >
<view class="swiper-item " >
<view class="card_box" @click="todetail(item.deviceId)" v-for="(item,index) in deviceList" :key="index">
<view class="card" >
<view class="card_left">
<view class="card_left_tit">
{{item.deviceName}}电表
</view>
<view class="card_left_sta">
<image src="@/static/ele.png" mode=""></image>
<view class="sta_txt">
剩余电量{{item.surplusElectriQuantity}}
</view>
</view>
<view class="card_left_no">
电表号{{item.deviceId}}
</view>
</view>
<view class="card_right">
<image src="@/static/db.png" mode=""></image>
</view>
</view>
</view>
</view>
</swiper-item>
<swiper-item>
<view class="swiper-item ">B</view>
</swiper-item>
<swiper-item>
<view class="swiper-item ">C</view>
</swiper-item>
</swiper>
</view>
2024-01-27 16:37:52 +08:00
</view>
2024-03-13 10:54:22 +08:00
<view class="noDevice">
<view class="img_box">
<image src="@/static/device.png" mode=""></image>
<view class="tps">
暂无设备
</view>
</view>
<view class="addbutn" v-if="userType=='00'">
扫码添加
</view>
<view class="addbutn" v-if="userType=='01'" >
添加方式
</view>
<view class="tip">需要添加设备后方可使用</view>
</view>
2024-01-23 19:15:52 +08:00
<tab-bar :indexs='0'></tab-bar>
2023-11-27 09:57:03 +08:00
</view>
</template>
<script>
2024-01-27 16:37:52 +08:00
import * as echarts from 'echarts'
import LEchart from '@/uni_modules/lime-echart/components/l-echart/l-echart.vue';
2023-11-27 09:57:03 +08:00
export default {
data() {
return {
2024-01-27 16:37:52 +08:00
bgc: {
backgroundColor: "#F7FAFE",
2024-03-13 10:54:22 +08:00
2024-01-27 16:37:52 +08:00
},
2024-03-13 10:54:22 +08:00
deviceInfo:{},
loadings:false,
info:'',
tittxt:"首页",
titlist: [
"全部",
"电表",
"水表",
],
curtitidx:0,
background: ['color1', 'color2', 'color3'],
indicatorDots: true,
autoplay: true,
interval: 2000,
duration: 500,
deviceList:[],
userType:''
}
},
onLoad() {
if(uni.getStorageSync('userType')){
this.userType=uni.getStorageSync('userType')
if(this.userType=='01'){
this.getDeviceList()
}else if(this.userType=='00'){
this.getdevice()
}
}else{
this.getuserinfo()
2023-11-27 09:57:03 +08:00
}
2024-03-13 10:54:22 +08:00
2023-11-27 09:57:03 +08:00
},
methods: {
2024-01-27 16:37:52 +08:00
async initChart() {
2024-03-13 10:54:22 +08:00
let value = 100;
let value2 = this.deviceInfo.surplusElectriQuantity
const option = {
// backgroundColor:"#061740",
title: {
show: false,
text: `历史请求满意度`, // 图表标题
x: 'center',
y: '20',
textStyle: {
color: '#333', //'#fff',
fontSize: 20,
},
},
series: [{
type: 'pie', // 饼图类型
radius: ['98%', '70%'], // 饼图半径,第一个值是内半径,第二个值是外半径
silent: true,
clockwise: true,
startAngle: 90, // 起始角度
z: 0,
zlevel: 0,
data: [{
value: value,
name: '占比', // 数据项名称
itemStyle: {
normal: {
color: '#8883F0', // 数据项颜色
},
},
label: {
normal: {
position: 'center',
formatter: ` {a|${value2}}\n\n{b|剩余电量}`, // 标签内容格式
rich: {
a: {
fontSize: 15,
fontWeight: '700',
color: '#333',
},
b: {
fontSize: 11,
color: '#888',
},
},
},
},
},
{
value: 100 - value,
name: '',
label: {
normal: {
show: false,
},
},
itemStyle: {
normal: {
color: '#173164',
},
},
},
],
},
{
type: 'gauge', // 仪表盘类型
radius: '130%', // 仪表盘半径,占图表容器的百分比
center: ['50%', '50%'], // 仪表盘中心位置
startAngle: 359,
endAngle: 359.9,
splitNumber: 2, // 刻度分割段数
hoverAnimation: true,
axisTick: {
show: true, // 是否显示刻度线
length: 10, // 刻度线长度
lineStyle: {
color: 'auto',
width: 1,
},
},
splitLine: {
length: 0, // 刻度线分隔线长度
lineStyle: {
width: 1,
color: '#061740',
},
},
axisLabel: {
show: false, // 是否显示刻度标签
},
pointer: {
show: false, // 是否显示指针
},
axisLine: {
lineStyle: {
opacity: 0,
},
},
detail: {
show: false, // 是否显示仪表盘详情
},
data: [{
value: 0,
name: '',
}, ],
},
],
};
2024-01-27 16:37:52 +08:00
// console.log( this.$refs.chartRef,'1111');
const chart = await this.$refs.chart.init(echarts);
console.log(option);
chart.setOption(option)
// chart.resize({
// width: uni.upx2px(210), // Convert 210rpx to pixels
// height: uni.upx2px(190.14) // Convert 190.14rpx to pixels
// });
return chart
},
2024-03-13 10:54:22 +08:00
// 获取设备详情
getDevice(){
this.$u.get("app/device/1").then((res) => {
// this.$forceUpdate()
if (res.code == 200) {
this.deviceInfo=res.data
this.loadings=true
}
});
},
getuserinfo(){
this.$u.get("/app/user/userInfo").then((res) => {
// this.$forceUpdate()
if (res.code == 200) {
uni.setStorageSync('userType',res.data.userType)
this.userType=res.data.userType
if(this.userType=='01'){
this.getDeviceList()
}else if(this.userType=='00'){
this.getdevice()
}
}
});
},
getDeviceList(){
this.$u.get("/app/device/list").then((res) => {
// this.$forceUpdate()
if (res.code == 200) {
this.deviceList=res.rows
}
});
},
swiperchange(e){
this.curtitidx=e.detail.current
console.log(e,'aaaa');
},
getdevice(){
this.$u.get("/app/device/tenant").then((res) => {
this.deviceInfo=res.data
this.initChart()
});
},
changeidx(index){
this.curtitidx=index
},
toewm(){
uni.navigateTo({
url:"/pages/shebei/ewm"
})
},
toydfx(){
uni.navigateTo({
url:"/pages/shebei/eletj"
})
},
todetail(id){
uni.navigateTo({
url:"/pages/shebei/sbdetail?id="+id
})
}
2023-11-27 09:57:03 +08:00
}
}
</script>
2024-01-27 16:37:52 +08:00
<style lang="scss">
2024-03-13 10:54:22 +08:00
page {
background-color: #F7FAFE;
}
.page {
.noDevice{
margin-top: 432rpx;
display: flex;
align-items: center;
justify-content: center;
flex-wrap: wrap;
.img_box{
width: 100%;
2024-01-27 16:37:52 +08:00
display: flex;
2024-03-13 10:54:22 +08:00
flex-wrap: wrap;
justify-content: center;
image{
width: 252rpx;
height: 252rpx;
2024-01-27 16:37:52 +08:00
}
2024-03-13 10:54:22 +08:00
.tps{
margin-top: 4rpx;
width: 100%;
text-align: center;
font-weight: 700;
font-size: 32rpx;
color: #BDBCBC;
2024-01-27 16:37:52 +08:00
}
}
2024-03-13 10:54:22 +08:00
.addbutn{
margin-top: 32rpx;
2024-01-27 16:37:52 +08:00
display: flex;
2024-03-13 10:54:22 +08:00
align-items: center;
justify-content: center;
width: 266rpx;
height: 96rpx;
background: #8883F0;
border-radius: 16rpx;
font-weight: 500;
font-size: 36rpx;
color: #FFFFFF;
}
.tip{
margin-top: 30rpx;
width: 100%;
text-align: center;
font-weight: 400;
font-size: 40rpx;
color: #BDBCBC;
}
}
.zhuhu {
margin-top: 20rpx;
padding: 0 40rpx;
.card1 {
padding: 34rpx 0 0 40rpx;
width: 670rpx;
height: 583rpx;
background: #FFFFFF;
box-shadow: 0rpx 14rpx 35rpx 0rpx rgba(53, 140, 255, 0.1);
border-radius: 28rpx 28rpx 28rpx 28rpx;
.top {
2024-01-27 16:37:52 +08:00
display: flex;
2024-03-13 10:54:22 +08:00
flex-wrap: nowrap;
justify-content: space-between;
align-items: center;
.left {
font-size: 35rpx;
2024-01-27 16:37:52 +08:00
font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
font-weight: 400;
2024-03-13 10:54:22 +08:00
color: #8883F0;
2024-01-27 16:37:52 +08:00
}
2024-03-13 10:54:22 +08:00
.right {
margin-right: 56rpx;
.img1 {
width: 76rpx;
height: 76rpx;
}
}
}
.mid {
margin-top: 54rpx;
display: flex;
flex-wrap: nowrap;
align-content: flex-start;
.mid_left {
image {
width: 37rpx;
height: 98rpx;
}
}
.mid_right {
margin-left: 40rpx;
2024-01-27 16:37:52 +08:00
display: flex;
2024-03-13 10:54:22 +08:00
flex-wrap: wrap;
.mid_top {
width: 100%;
font-size: 42rpx;
2024-01-27 16:37:52 +08:00
font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
font-weight: 400;
2024-03-13 10:54:22 +08:00
color: #262B37;
2024-01-27 16:37:52 +08:00
}
2024-03-13 10:54:22 +08:00
.mid_bot {
2024-01-27 16:37:52 +08:00
display: flex;
2024-03-13 10:54:22 +08:00
flex-wrap: nowrap;
2024-01-27 16:37:52 +08:00
align-items: center;
2024-03-13 10:54:22 +08:00
.txt {
font-size: 24rpx;
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;
width: 38rpx;
height: 23rpx;
background: rgba(204, 204, 204, 0);
opacity: 1;
border: 2rpx solid #8883F0;
border-radius: 40rpx;
font-size: 14rpx;
font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
font-weight: 400;
color: #8883F0;
}
2024-01-27 16:37:52 +08:00
}
}
}
2024-03-13 10:54:22 +08:00
.bot {
margin-top: 83rpx;
display: flex;
flex-wrap: nowrap;
align-items: center;
.bot_left {
2024-01-27 16:37:52 +08:00
width: 210rpx;
height: 190.14rpx;
2024-03-13 10:54:22 +08:00
.echarts {
width: 210rpx;
height: 190.14rpx;
}
2024-01-27 16:37:52 +08:00
}
2024-03-13 10:54:22 +08:00
.bot_right {
// margin-top: 50rpx;
display: flex;
flex-wrap: nowrap;
.cont {
.tit {
font-size: 28rpx;
font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
font-weight: 600;
color: #262B37;
line-height: 49rpx;
}
.txt {
font-size: 24rpx;
font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
font-weight: 400;
color: #262B37;
}
}
}
}
}
.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;
2024-01-27 16:37:52 +08:00
}
2024-03-13 10:54:22 +08:00
.cont_box {
margin-top: 32rpx;
2024-01-27 16:37:52 +08:00
display: flex;
flex-wrap: nowrap;
2024-03-13 10:54:22 +08:00
justify-content: space-around;
.cont {
width: 110rpx;
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: center;
.top {
font-size: 32rpx;
2024-01-27 16:37:52 +08:00
font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
2024-03-13 10:54:22 +08:00
font-weight: 400;
2024-01-27 16:37:52 +08:00
color: #262B37;
}
2024-03-13 10:54:22 +08:00
.bot {
margin-top: 20rpx;
2024-01-27 16:37:52 +08:00
font-size: 24rpx;
font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
font-weight: 400;
color: #262B37;
}
}
}
}
2024-03-13 10:54:22 +08:00
.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;
.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;
2024-01-27 16:37:52 +08:00
display: flex;
2024-03-13 10:54:22 +08:00
flex-wrap: nowrap;
justify-content: space-around;
.cont {
width: 112rpx;
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: center;
.top {
image {
width: 56rpx;
height: 56rpx;
}
}
.bot {
margin-top: 28rpx;
font-size: 28rpx;
font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
font-weight: 400;
color: #808080;
}
2024-01-27 16:37:52 +08:00
}
}
}
2024-03-13 10:54:22 +08:00
.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;
2024-01-27 16:37:52 +08:00
font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
font-weight: 400;
2024-03-13 10:54:22 +08:00
color: #FFFFFF;
2024-01-27 16:37:52 +08:00
}
2024-03-13 10:54:22 +08:00
}
.fd{
margin-top: 20rpx;
padding: 0 40rpx;
padding-bottom: 200rpx;
height: 100%;
.fd_top{
2024-01-27 16:37:52 +08:00
display: flex;
flex-wrap: nowrap;
2024-03-13 10:54:22 +08:00
// justify-content: space-between;
align-items: center;
.fd_tit{
// width: 40%;
margin-right: 20rpx;
font-size: 36rpx;
font-weight: 400;
color: #95989D;
}
.act1{
color: #000000;
}
.fd_set{
margin-left: auto;
}
}
.swiper{
.swiper-item{
height: 100%;
.card_box{
margin-top: 34rpx;
display: flex;
flex-wrap: wrap;
.card{
display: flex;
// align-items: center;
margin-top: 20rpx;
width: 658rpx;
height: 282rpx;
background: #fff;
box-shadow: 0rpx 16rpx 40rpx 0rpx rgba(255,255,255,0);
border-radius: 24rpx 24rpx 24rpx 24rpx;
.card_left{
width: 310rpx;
margin-top: 46rpx;
margin-left: 50rpx;
.card_left_tit{
font-size: 44rpx;
font-family: AlibabaPuHuiTi, AlibabaPuHuiTi;
font-weight: 500;
color: #8883F0;
}
.card_left_sta{
margin-top: 15rpx;
display: flex;
flex-wrap: nowrap;
align-items: center;
image{
width: 23.32rpx;
height: 36.47rpx;
}
.sta_txt{
margin-left: 15rpx;
color: #262B37;
font-size: 24rpx;
font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
font-weight: 400;
}
}
.card_left_no{
margin-top: 15rpx;
font-size: 24rpx;
font-family: AlibabaPuHuiTi, AlibabaPuHuiTi;
font-weight: 400;
color: #95989D;
}
}
.card_right{
margin-top: 60rpx;
margin-left: auto;
margin-right: 94rpx;
image{
width: 63.04rpx;
height:167.48rpx ;
}
}
2024-01-27 16:37:52 +08:00
}
}
}
}
}
}
2024-03-13 10:54:22 +08:00
</style>