123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696 |
- <template>
- <view class="contentike">
- <view class="fixed" style="color: #FFFDEF;">
- <cu-custom bgColor="bg-gradual-sisBlack" :isBack="true">
- <block slot="backText"><view style="height: 80rpx;line-height: 80rpx;color: silver;">返回</view></block>
- <block slot="content">
- <view style="color: silver;">{{ address }}</view>
- </block>
- </cu-custom>
- </view>
- <view class="threeTarget" v-show="targetdetail_visable.targetdetail_target">
- <view class="target">
- <view class="target_zi">指标</view>
- <view class="target_dianLiang">{{targetName}}</view>
- </view>
- <view class="target">
- <view style="font-size: 16px;margin-top: -7px;">数值</view>
- <view class="target_count">{{ targetdetail.targetdetail_target }}</view>
- </view>
- <view class="target">
- <view style="font-size: 16px;margin-top: -7px;">单位</view>
- <view class="target_danWei">{{targetUnit}}</view>
- </view>
- </view>
- <view class="qiun-charts">
- <view class="speedPowerDiagram">24小时指标曲线图</view>
- <canvas canvas-id="canvasLineA" id="canvasLineA" class="charts" @touchstart="touchLineA"></canvas>
- </view>
- <view class="qiun-columnCharts">
- <view class="sevenDayColunm">7天指标柱状图</view>
- <canvas canvas-id="canvasColumn" id="canvasColumn" class="charts" @touchstart="touchColumn"></canvas>
- </view>
- </view>
- </template>
- <script>
- import uCharts from '../../components/tools/u-charts/u-charts.js';
- import res from '../../common/data.json';
- var _self;
- var canvaLineA;
- var canvaColumn = null;
- export default {
- data() {
- let data = {
- targetName:"日发电量",
- targetUnit:"万kwh",
- pointKey:"HB_GD_KBF_JS_P4_L19_220_CI0136",
- targetdetail_visable: { targetdetail_target: true, targetdetail_curve: true, targetdetail_histogram: true},
- targetdetail: { targetdetail_target: '', targetdetail_curve: '', targetdetail_histogram: ''},
- socketTask_targetdetail_target:"",
- socketTask_targetdetail_curve:"",
- socketTask_targetdetail_histogram:"",
- cWidth: '',
- cHeight: '',
- pixelRatio: 1,
- serverData: '',
- address: '',
- }
- return data;
- },
- created: function() {
- this.address = this.getWindPowerStationNameToSessionStorage();
- this.windPowerStationId = uni.getStorageSync('windPowerStationId');
- this.targetdetail_target();
- this.targetdetail_curve();
- this.targetdetail_histogram();
- },
- onShow() {
- this.windPowerStationId = uni.getStorageSync('windPowerStationId');
- this.address = this.getWindPowerStationNameToSessionStorage();
- this.hideModals();
- },
- onLoad() {
- _self = this;
- this.cWidth = uni.upx2px(750);
- this.cHeight = uni.upx2px(400);
- this.getColumnServerData();
- this.getLineServerData();
- },
- onReady() {},
- computed:{
- backStageIp:function(){
- return this.$store.state.wholeSituationBackStageIp;
- }, backStagePort:function(){
- return this.$store.state.wholeSituationBackStagePort;
- },windpowerstationNameToId:function(){
- return this.$store.state.windpowerstationNameToId;
- }
- },
- methods: {
- targetInformation(pointKey,callTargetName,callTargetUnit){
- this.address = this.getWindPowerStationNameToSessionStorage();
- this.windPowerStationId = uni.getStorageSync('windPowerStationId');
- this.pointKey = pointKey;
- this.targetName = callTargetName;
- this.targetUnit = callTargetUnit;
- this.targetdetail_target();
- this.targetdetail_curve();
- this.targetdetail_histogram();
- },async targetdetail_target() {
- let ip;
- uni.request({
- url:'http://'+this.backStageIp+':'+this.backStagePort+'/targetdetail/targetdetail_target?pointKey='+this.pointKey,
- success: (res) => {
- ip = res.data;
- }
- });
- let _this = this;
- // 创建一个this.socketTask对象【发送、接收、关闭socket都由这个对象操作】
- this.socketTask_targetdetail_target = uni.connectSocket({
- // 【非常重要】必须确保你的服务器是成功的,如果是手机测试千万别使用ws://127.0.0.1:9099【特别容易犯的错误】
- url: 'ws://'+this.backStageIp+':'+this.backStagePort+'/websocket/pageNumber_8/functionNumber_1',
- success(data) {
- console.log('websocket连接成功');
- }
- });
- // 消息的发送和接收必须在正常连接打开中,才能发送或接收【否则会失败】
- this.socketTask_targetdetail_target.onOpen(res => {
- console.log('WebSocket连接正常打开中...!');
- this.is_open_socket = true;
- // 注:只有连接正常打开中 ,才能正常收到消息
- this.socketTask_targetdetail_target.onMessage(res => {
- //console.log("收到服务器内容:" + res.data);
- _this.targetdetail.targetdetail_target =JSON.parse(res.data)[ip];
- //console.log(_this.targetdetail.targetdetail_target);
- });
- });
- // 这里仅是事件监听【如果socket关闭了会执行】
- this.socketTask_targetdetail_target.onClose(() => {
- uni.request({
- url: 'http://'+this.backStageIp+':'+this.backStagePort+'/targetdetail/close_targetdetail_target?pointKey='+this.pointKey,
- success: (res) => {
- }
- });
- })
- },
- targetdetail_curve() {
- let ip;
- uni.request({
- url: 'http://'+this.backStageIp+':'+this.backStagePort+'/targetdetail/targetdetail_curve?pointKey='+this.pointKey,
- success: (res) => {
- ip = res.data;
- }
- });
- let _this = this;
- // 创建一个this.socketTask对象【发送、接收、关闭socket都由这个对象操作】
- this.socketTask_targetdetail_curve = uni.connectSocket({
- // 【非常重要】必须确保你的服务器是成功的,如果是手机测试千万别使用ws://127.0.0.1:9099【特别容易犯的错误】
- url: 'ws://'+this.backStageIp+':'+this.backStagePort+'/websocket/pageNumber_8/functionNumber_2',
- success(data) {
- console.log('websocket连接成功');
- }
- });
- // 消息的发送和接收必须在正常连接打开中,才能发送或接收【否则会失败】
- this.socketTask_targetdetail_curve.onOpen(res => {
- console.log('WebSocket连接正常打开中...!');
- this.is_open_socket = true;
- // 注:只有连接正常打开中 ,才能正常收到消息
- this.socketTask_targetdetail_curve.onMessage(res => {
- //console.log("收到服务器内容:" + res.data);
- _this.targetdetail.targetdetail_curve = JSON.parse(res.data)[ip];
-
- let LineA = {
- categories: [
- '17:26',
- '18:56',
- '19:56',
- '20:56',
- '21:56',
- '22:56',
- '23:56',
- '00:56',
- '01:56',
- '02:56',
- '03:56',
- '04:56',
- '05:56',
- '06:56',
- '07:56',
- '08:56',
- '09:56',
- '10:56',
- '11:56',
- '12:56',
- '13:56',
- '14:56',
- '15:56',
- '16:56',
- '17:56 '
- ],
- series: [
- {
- name: '功率',
- data: [17, 21, 19, 22, 20.2, 19.1, 22.4, 23.8, 21.5, 22.9, 19.2, 22.4, 18.7, 22.1, 21.4, 22.7, 18.4, 18.4, 21.8, 22.5, 22.9, 19.8, 22.7, 23, 22.8],
- color: '#4A80B1',
- textColor: '#FFFFFF',
- textSize: this.seriesTextSize,
- format: val => {
- return val + 'kwh';
- },
- index: 0,
- legendShape: 'circle'
- }
- ]
- };
-
- LineA.categories=[];
- LineA.series[0].data=[];
- LineA.series[0].name=this.targetName;
- for(var i=0;i<_this.targetdetail.targetdetail_curve.length;i++){
- _this.targetdetail.targetdetail_curve[i].pointTime = new Date(_this.targetdetail.targetdetail_curve[i].pointTime*1000).Format("MM/dd");
- LineA.categories.push(_this.targetdetail.targetdetail_curve[i].pointTime);
- LineA.series[0].data.push(_this.targetdetail.targetdetail_curve[i].pointValueInDouble);
- }
-
-
- this.showLineA('canvasLineA', LineA);
-
-
-
- });
- });
- // 这里仅是事件监听【如果socket关闭了会执行】
- this.socketTask_targetdetail_curve.onClose(() => {
- uni.request({
- url: 'http://'+this.backStageIp+':'+this.backStagePort+'/targetdetail/close_targetdetail_curve?pointKey='+this.pointKey,
- success: (res) => {
- }
- });
- })
- },
- targetdetail_histogram() {
- Date.prototype.Format = function(fmt) {
- var o = {
- "M+": this.getMonth() + 1, //月份
- "d+": this.getDate(), //日
- "h+": this.getHours(), //小时
- "m+": this.getMinutes(), //分
- "s+": this.getSeconds(), //秒
- "q+": Math.floor((this.getMonth() + 3) / 3), //季度
- "S": this.getMilliseconds() //毫秒
- };
- if(/(y+)/.test(fmt))
- fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
- for(var k in o)
- if(new RegExp("(" + k + ")").test(fmt))
- fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
- return fmt;
- };
- let ip;
- uni.request({
- url: 'http://'+this.backStageIp+':'+this.backStagePort+'/targetdetail/targetdetail_histogram?pointKey='+this.pointKey,
- success: (res) => {
- ip = res.data;
- }
- });
- let _this = this;
- // 创建一个this.socketTask对象【发送、接收、关闭socket都由这个对象操作】
- this.socketTask_targetdetail_histogram = uni.connectSocket({
- // 【非常重要】必须确保你的服务器是成功的,如果是手机测试千万别使用ws://127.0.0.1:9099【特别容易犯的错误】
- url: 'ws://'+this.backStageIp+':'+this.backStagePort+'/websocket/pageNumber_8/functionNumber_3',
- success(data) {
- console.log('websocket连接成功');
- }
- });
- // 消息的发送和接收必须在正常连接打开中,才能发送或接收【否则会失败】
- this.socketTask_targetdetail_histogram.onOpen(res => {
- console.log('WebSocket连接正常打开中...!');
- this.is_open_socket = true;
- // 注:只有连接正常打开中 ,才能正常收到消息
- this.socketTask_targetdetail_histogram.onMessage(res => {
- //console.log("收到服务器内容:" + res.data);
- _this.targetdetail.targetdetail_histogram = JSON.parse(res.data)[ip];
- let Column = {
- "categories": ["04/11","04/12", "04/13", "04/14", "04/15", "04/16", "04/17"],
- "series": [{
- "name": "发电量",
- "data": [],
- "color": "#29C35A"
- }]
- };
- Column.categories=[];
- Column.series[0].data=[];
- Column.series[0].name=this.targetName;
- for(var i=0;i<_this.targetdetail.targetdetail_histogram.length;i++){
- _this.targetdetail.targetdetail_histogram[i].pointTime = new Date(_this.targetdetail.targetdetail_histogram[i].pointTime*1000).Format("MM/dd");
- Column.categories.push(_this.targetdetail.targetdetail_histogram[i].pointTime);
- Column.series[0].data.push(_this.targetdetail.targetdetail_histogram[i].pointValueInDouble);
- }
- //这里我后台返回的是数组,所以用等于,如果您后台返回的是单条数据,需要push进去
- _self.showColumn('canvasColumn', Column);
- });
- });
- // 这里仅是事件监听【如果socket关闭了会执行】
- this.socketTask_targetdetail_histogram.onClose(() => {
- uni.request({
- url: 'http://'+this.backStageIp+':'+this.backStagePort+'/targetdetail/close_targetdetail_histogram?pointKey='+this.pointKey,
- success: (res) => {
- }
- });
- });
- },pushWindPowerStationNameToSessionStorage(windpowerstationName) {
- uni.setStorageSync('windpowerstationName', windpowerstationName);
- //sessionStorage.setItem('windpowerstationName', windpowerstationName);
- //alert("v"+ sessionStorage.getItem("windpowerstationName"));
- //this.common.goback('/pages/index/Index');
- },
- getWindPowerStationNameToSessionStorage() {
- uni.getStorageSync('windpowerstationName');
- return uni.getStorageSync('windpowerstationName');
- },
- getLineServerData() {
- // 折线图
- let LineA = {
- categories: [
- '17:26',
- '18:56',
- '19:56',
- '20:56',
- '21:56',
- '22:56',
- '23:56',
- '00:56',
- '01:56',
- '02:56',
- '03:56',
- '04:56',
- '05:56',
- '06:56',
- '07:56',
- '08:56',
- '09:56',
- '10:56',
- '11:56',
- '12:56',
- '13:56',
- '14:56',
- '15:56',
- '16:56',
- '17:56 '
- ],
- series: [
- {
- name: '功率',
- data: [17, 21, 19, 22, 20.2, 19.1, 22.4, 23.8, 21.5, 22.9, 19.2, 22.4, 18.7, 22.1, 21.4, 22.7, 18.4, 18.4, 21.8, 22.5, 22.9, 19.8, 22.7, 23, 22.8],
- color: '#4A80B1',
- textColor: '#FFFFFF',
- textSize: this.seriesTextSize,
- format: val => {
- return val + 'kwh';
- },
- index: 0,
- legendShape: 'circle'
- }
- ]
- };
- this.showLineA('canvasLineA', LineA);
- },
- showLineA(canvasId, chartData) {
- canvaLineA = new uCharts({
- $this: _self,
- canvasId: canvasId,
- type: 'line',
- fontSize: 11,
- legend: {
- show: true,
- position: 'top',
- float: 'right',
- fontColor: 'silver',
- itemGap: '4'
- },
- dataLabel: false,
- dataPointShape: false,
- background: '#FFFFFF',
- pixelRatio: _self.pixelRatio,
- categories: chartData.categories,
- series: chartData.series,
- animation: true,
- xAxis: {
- type: 'grid',
- gridColor: 'silver',
- fontColor: 'silver',
- gridType: 'solid',
- gridColor: '#2E2E2E',
- axisLineColor: '#2E2E2E',
- labelCount: '3'
- // itemCount:"3"
- },
- yAxis: {
- data: [
- {
- type: 'value',
- fontColor: 'silver',
- disabled: false, //y轴轴线
- min: 0,
- max: 40,
- position: 'left',
- axisLineColor: '#2E2E2E',
- title: ' 功率:(kw/h)',
- titleFontColor: 'silver'
- },
- {
- fontColor: 'silver',
- disabled: false, //y轴轴线
- min: 0,
- max: 40,
- position: 'right',
- axisLineColor: '#2E2E2E',
- title: '功率:(kwh)',
- titleFontColor: 'silver'
- }
- ],
- gridColor: '#2E2E2E',
- splitNumber: 4,
- gridType: 'solid',
- dashLength: 8,
- showTitle: 'true',
- format: val => {
- return val.toFixed(0) + '元';
- }
- },
- width: _self.cWidth * _self.pixelRatio,
- height: _self.cHeight * _self.pixelRatio,
- extra: {
- line: {
- type: 'line',
- width: '1'
- }
- }
- });
- },
- touchLineA(e) {
- canvaLineA.showToolTip(e, {
- format: function(item, category) {
- return category + ' ' + item.name + ':' + item.data;
- }
- });
- },
- moveLineA(e) {
- canvaLineA.scroll(e);
- },
- getColumnServerData() {
- let Column = {
- "categories": [],
- "series": [{
- "name": "发电量",
- "data": [],
- "color": "#29C35A"
- }]
- };
- //这里我后台返回的是数组,所以用等于,如果您后台返回的是单条数据,需要push进去
- _self.showColumn('canvasColumn', Column);
- },
- showColumn(canvasId, chartData) {
- canvaColumn = new uCharts({
- $this: _self,
- canvasId: canvasId,
- type: 'column',
- legend: {
- show: true,
- fontSize: 12,
- padding: 5,
- fontColor: 'silver',
- itemGap: '4',
- // margin:0,
- position: 'top',
- float: 'right'
- },
- fontSize: 11,
- background: '#242424',
- pixelRatio: _self.pixelRatio,
- animation: true,
- categories: chartData.categories,
- series: chartData.series,
- xAxis: {
- // disabled:true,
- rotateLabel: true,
- disableGrid: true,
- axisLineColor: '#2D2D2D',
- fontColor: '#ffffff'
- // gridColor:'#2D2D2D',
- },
- yAxis: {
- showTitle: true,
- // disableGrid:true,
- gridType: 'solid',
- dashLength: 8,
- gridColor: '#2D2D2D',
- splitNumber: 5,
- min: 0,
- max: 40,
- data: [
- {
- min: 0,
- max: 40,
- position: 'left',
- axisLine: false,
- fontColor: 'silver',
- // title: '7天功率柱状图',
- title: ' 功率:(kw/h)',
- titleFontColor: 'silver',
- // title: '功率(kw/h)',
- // titleFontColor: '#FFFFFF',
- titleFontSize: 11,
- format: val => {
- return val.toFixed(0) + '';
- }
- }
- ]
- },
- dataLabel: true,
- width: _self.cWidth * _self.pixelRatio,
- height: _self.cHeight * _self.pixelRatio,
- extra: {
- column: {
- type: 'group',
- // width: _self.cWidth * _self.pixelRatio * 0.45 / chartData.categories.length
- width: 12,
- lineStyle: {
- width: 5
- }
- }
- }
- });
- },
- goToIndex() {
- uni.switchTab({
- url: '/pages/index/Index'
- });
- },
- touchColumn(e) {
- canvaColumn.showToolTip(e, {
- format: function(item, category) {
- if (typeof item.data === 'object') {
- return category + ' ' + item.name + ':' + item.data.value;
- } else {
- return category + ' ' + item.name + ':' + item.data;
- }
- }
- });
- }
- }
- };
- </script>
- <style>
- @font-face {
- font-family: '方正兰亭细黑_GBK';
- src: url(../../static/方正兰亭细黑_GBK.TTF);
- }
- page {
- /* background-color: #FFFFFF; */
- font-family: '方正兰亭细黑_GBK';
- background-color: #1f1f1f;
- color: silver;
- font-size: 14px;
- }
- body {
- background: #1f1f1f;
- font-family: '方正兰亭细黑_GBK';
- font-size: 14px;
- color: silver;
- }
- .addressName {
- /* width: 100%; */
- /* background-color: white; */
- /* width: 126px; */
- height: 80rpx;
- line-height: 80rpx;
- margin-left: 40%;
- color: silver;
- font-size: 18px;
- }
- .target_dianLiang {
- margin-top: 15px;
- font-size: 16px;
- font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Helvetica Neue', STHeiti, 'Microsoft Yahei', Tahoma, Simsun, sans-serif;
- }
- .target_count {
- margin-top: 15px;
- font-size: 16px;
- font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Helvetica Neue', STHeiti, 'Microsoft Yahei', Tahoma, Simsun, sans-serif;
- }
- .target_danWei {
- margin-top: 15px;
- font-size: 16px;
- font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Helvetica Neue', STHeiti, 'Microsoft Yahei', Tahoma, Simsun, sans-serif;
- }
- .threeTarget {
- width: 100%;
- height: 120px;
- background-color: #242424;
- display: -webkit-flex;
- display: flex;
- justify-content: space-around;
- float: left;
- }
- .target {
- width: 28%;
- height: 78px;
- background: -webkit-linear-gradient(top, rgba(159, 131, 111, 0.1) 0%, rgba(193, 94, 21, 0.2) 100%);
- border-radius: 5px;
- float: left;
- margin-top: 20px;
- text-align: center;
- color: silver;
- padding-top: 20px;
- font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Helvetica Neue', STHeiti, 'Microsoft Yahei', Tahoma, Simsun, sans-serif;
- }
- .target_zi {
- font-size: 16px;
- text-align: center;
- margin-top: -7px;
- }
- .speedPowerDiagram {
- width: 100px;
- height: 30px;
- user-select: text;
- -webkit-user-select: text;
- -moz-user-select: text;
- -ms-user-select: text;
- color: silver;
- float: left;
- margin-top: 18px;
- margin-left: 9px;
- font-size: 11px;
- }
- .qiun-charts {
- width: 750upx;
- height: 400upx;
- margin-top: 140px;
- background-color: #242424;
- }
- .charts {
- width: 750upx;
- height: 400upx;
- }
- .qiun-columnCharts {
- width: 750upx;
- height: 400upx;
- margin-top: 20px;
- background-color: #242424;
- }
- .sevenDayColunm {
- width: 100px;
- height: 30px;
- user-select: text;
- -webkit-user-select: text;
- -moz-user-select: text;
- -ms-user-select: text;
- color: silver;
- float: left;
- margin-top: 18px;
- margin-left: 10px;
- font-size: 11px;
- }
- </style>
|