kaiguan-zfb/page_user/sbdetail.vue
2024-05-21 15:07:11 +08:00

708 lines
17 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="page">
<u-navbar :title="tittxt" :border-bottom="false" :background="bgc" title-color='#2E4975' title-size='36'
height='36' id="navbar">
</u-navbar>
<view class="zhuhu">
<view class="card1">
<view class="top">
<view class="left">
设备
</view>
<view class="right">
<!-- <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> -->
</view>
</view>
<view class="mid">
<view class="mid_left" @click="btnpic">
<image :src="imglist" mode=""></image>
</view>
<view class="mid_right">
<view class="mid_top">
{{ deviceInfo.deviceName }}
</view>
<view class="mid_bot">
<view class="txt" v-if="deviceInfo">S/N码{{ deviceInfo.deviceNo }}</view>
<div class="tip" v-if="deviceInfo.onlineStatus==1">在线</div>
<div class="tip" v-if="deviceInfo.onlineStatus==0">离线</div>
<div class="tip" v-if="deviceInfo.powerStatus==0">断电</div>
<div class="tip" v-if="deviceInfo.powerStatus==1">正常</div>
</view>
</view>
</view>
<view class="bot">
<view class="bot_left">
<view class="echarts">
<!-- <mpvue-echarts id="main" ref="pieChart" :echarts="echarts" @onInit="initChart" /> -->
<l-echart ref="chart" @finished="initChart"></l-echart>
<uni-ec-canvas class="uni-ec-canvas" id="uni-ec-canvas" ref="canvas"
canvas-id="uni-ec-canvas" :ec="ec">
</uni-ec-canvas>
</view>
</view>
<view class="bot_right">
<view class="cont" style="text-align: center;">
<view class="tit">
{{deviceInfo.orderCount}}
</view>
<view class="txt">
订单数
</view>
</view>
<view class="cont" style="margin-left: 100rpx;text-align: center;">
<view class="tit">
{{timeday}}
</view>
<view class="txt">
剩余分钟
</view>
</view>
</view>
</view>
</view>
<view class="card2">
<view class="tit">实时</view>
<view class="cont_box">
<view class="cont">
<view class="top">{{deviceInfo.realTimePower}}KW</view>
<view class="bot">实时功率</view>
</view>
<view class="cont" style="width: 70rpx;">
<view class="top">{{deviceInfo.electricity}}A</view>
<view class="bot">电流</view>
</view>
<view class="cont" style="width: 110rpx;">
<view class="top">{{deviceInfo.voltage}}V</view>
<view class="bot">电压</view>
</view>
</view>
</view>
<view class="card3">
<view class="tit">其他</view>
<view class="cont_box" style="display: block;">
<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>
</view>
<view class="" style="display: flex;margin-top: 20rpx;">
<view class="cont" style="width: 120rpx;" @click="topage(3)">
<view class="top">
<image src="https://api.ccttiot.com/smartmeter/img/static/uW2T5sbuiMPbPaJp9p2U" mode=""
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>
<view class="cont" style="width: 60rpx;" @click="topage(5)">
<view class="top">
<image src="https://api.ccttiot.com/smartmeter/img/static/uWaQjL7vph474LWTyGfs" mode="">
</image>
</view>
<view class="bot">配网</view>
</view>
</view>
</view>
<view class="cont_box" style="padding-left: 30rpx;">
</view>
</view>
</view>
</view>
</template>
<script>
var xBlufi = require("@/page_components/blufi/xBlufi.js")
import uniEcCanvas from '@/components/uni-ec-canvas/uni-ec-canvas.vue'
import * as echarts from '@/components/uni-ec-canvas/echarts'
let chart = null
export default {
components: {
uniEcCanvas
},
data() {
return {
bgc: {
backgroundColor: "#F7FAFE",
},
ec: {
lazyLoad: true
},
deviceInfo: {},
loadings: false,
info: '',
tittxt: "设备列表",
titlist: [
"全部",
"电表",
"水表",
],
curtitidx: 0,
id: '',
timeday: '',
imglist: '',
token: '',
userImgs: '',
imgflag: true,
}
},
onLoad(option) {
setTimeout(() => {
this.$refs.canvas.init(this.initChart)
}, 1000)
let id = option.id
this.id = id
this.getDevice(id)
},
onShow() {
setTimeout(() => {
this.getDevice(this.id)
}, 1000)
this.getQiniuToken()
},
methods: {
async initChart() {
let value = 100;
let value2 = this.deviceInfo.orderAmount
const option = {
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',
},
},
},
},
},
],
},
],
};
// console.log( this.$refs.chartRef,'1111');
const chart = await this.$refs.chart.init(echarts);
// console.log(option,11);
chart.setOption(option)
return chart
},
getQiniuToken() {
this.$u.get("/common/qiniu/uploadInfo").then((res) => {
if (res.code == 200) {
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)
}
});
}
})
},
putdevice(data) {
this.$u.put('/app/device', data).then((res) => {
if (res.code == 200) {
uni.showToast({
title: '修改成功',
icon: 'none',
duration: 2000
})
}
})
},
// 获取设备详情
getDevice(id) {
this.$u.get("/app/device/" + id).then((res) => {
// this.$forceUpdate()
if (res.code == 200) {
this.deviceInfo = res.data
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(":");
let expireDate = new Date(expireDateParts[0], expireDateParts[1] - 1, expireDateParts[2],
expireTimePartsTime[0], expireTimePartsTime[1], expireTimePartsTime[2]
); // 注意月份是从0开始的所以要减1
let now = new Date();
let differenceInMs = expireDate - now;
if (differenceInMs <= 0) {
this.timeday = 0
} else {
this.timeday = Math.abs(Math.floor(differenceInMs / (1000 * 60)));
}
this.loadings = true
this.initChart()
}
});
},
opendevice() {
let stause = 0
if (this.deviceInfo.powerStatus == 1) {
stause = 0
} else {
stause = 1
}
console.log(stause, 'stausestause');
this.$u.put(`/app/device/${this.deviceInfo.deviceId}/changePower?status=` + stause).then((res) => {
// this.$forceUpdate()
if (res.code == 200) {
// this.groupList=res.rows
setTimeout(() => {
this.getDevice(this.id)
}, 2000)
// this.loadings=true
// this.initChart()
} else {
uni.showToast({
title: res.msg,
icon: 'none'
});
}
});
},
opendevices() {
},
swiperchange(e) {
this.curtitidx = e.detail.current
console.log(e, 'aaaa');
},
changeidx(index) {
this.curtitidx = index
},
toydfx() {
uni.navigateTo({
url: "/page_components/eletj?id=" + this.id
})
},
// 其他部分 点击进行跳转
topage(num) {
if (num == 0) {
uni.navigateTo({ //抄表
url: '/page_user/cbRecord?id=' + this.id
})
} else if (num == 1) {
//归零
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
});
this.getDevice(this.id)
} else if (res.msg == '设备剩余时间不足,无需归零') {
uni.showToast({
title: '设备剩余时间不足,无需归零',
icon: 'none',
duration: 2000
});
this.getDevice(this.id)
}
})
} else if (num == 2) { //异常
uni.navigateTo({
url: '/page_fenbao/statulist/fault/yichang/index'
})
} else if (num == 3) {
uni.navigateTo({
url: "/page_fenbao/statulist/taocanlist/index?id=" + this.id
})
} else if (num == 4) { //设置
uni.navigateTo({
url: '/page_user/setting?id=' + this.id
})
}else if(num == 5){
console.log(this.deviceInfo);
uni.navigateTo({
url:'/page_fenbao/device/lianjie?mac=' + this.deviceInfo.mac + '&storeId=' + this.deviceInfo.storeId
})
}
}
}
}
</script>
<style lang="scss">
page {
background-color: #F7FAFE;
}
.page {
.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 {
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 {
margin-top: 20rpx;
display: flex;
flex-wrap: nowrap;
align-content: flex-start;
.mid_left {
image {
width: 170rpx;
height: 160rpx;
}
}
.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 {
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;
}
}
}
}
.bot {
margin-top: 53rpx;
display: flex;
flex-wrap: nowrap;
align-items: center;
.bot_left {
width: 210rpx;
height: 180rpx;
margin-right: 34rpx;
.echarts {
// width: 210rpx;
height: 200rpx;
.uni-ec-canvas {
width: 100%;
height: 100rpx !important;
display: block;
// margin-top: 30rpx;
}
}
}
.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;
}
.cont_box {
margin-top: 32rpx;
display: flex;
flex-wrap: nowrap;
justify-content: space-around;
.cont {
width: 25%;
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: center;
text-align: center;
.top {
width: 110rpx;
font-size: 32rpx;
font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
font-weight: 400;
color: #262B37;
}
.bot {
margin-top: 20rpx;
font-size: 24rpx;
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;
.tit {
margin-left: 40rpx;
font-size: 35rpx;
font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
font-weight: 400;
color: #8883F0;
}
.cont_box {
// padding-left: 30rpx;
// padding-right: 30rpx;
padding: 0 40rpx;
margin-top: 32rpx;
display: flex;
flex-wrap: nowrap;
justify-content: space-around;
.cont:last-child {
margin-right: 0rpx;
}
.cont {
width: 112rpx;
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: center;
margin-right: 80rpx;
.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;
}
}
}
</style>