|
@@ -9,42 +9,27 @@
|
|
|
</p>
|
|
|
<div class='count-data'>
|
|
|
<div class='outdoor'>
|
|
|
- <div
|
|
|
- class='outdoor-left'
|
|
|
- :style='{"height":maxArr[0]=="--"?0+ "px":((current.tempOutdoor!="--"?current.tempOutdoor:0)/maxArr[0])*160 + "px"}'
|
|
|
- >
|
|
|
- <span>{{current.tempOutdoor=="--"?"--":current.tempOutdoor.toFixed(1)}}℃</span>
|
|
|
+ <div class='outdoor-left' :style='{"height":formatter(current.tempOutdoor,maxArr[0])+ "px"}'>
|
|
|
+ <span>{{formatterNum(current.tempOutdoor,1)}}℃</span>
|
|
|
</div>
|
|
|
- <div
|
|
|
- class='outdoor-right'
|
|
|
- :style='{"height":maxArr[0]=="--"?0+ "px":((similarDay.tempOutdoor!="--"?similarDay.tempOutdoor:0)/maxArr[0])*160 + "px"}'
|
|
|
- >
|
|
|
- <span>{{similarDay.tempOutdoor=="--"?"--":similarDay.tempOutdoor.toFixed(1)}}℃</span>
|
|
|
+ <div class='outdoor-right' :style='{"height":formatter(similarDay.tempOutdoor,maxArr[0])+ "px"}'>
|
|
|
+ <span>{{formatterNum(similarDay.tempOutdoor,1)}}℃</span>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class='indoor'>
|
|
|
- <div
|
|
|
- class='indoor-left'
|
|
|
- :style='{"height":maxArr[1]=="--"?0+ "px": ((current.tempIndoor!="--"?current.tempIndoor:0)/maxArr[1])*160 + "px"}'
|
|
|
- >
|
|
|
- <span>{{current.tempIndoor=="--"?"--":current.tempIndoor.toFixed(1)}}℃</span>
|
|
|
+ <div class='indoor-left' :style='{"height":formatter(current.tempIndoor,maxArr[1])+ "px"}'>
|
|
|
+ <span>{{formatterNum(current.tempIndoor,1)}}℃</span>
|
|
|
</div>
|
|
|
- <div
|
|
|
- class='indoor-right'
|
|
|
- :style='{"height":maxArr[1]=="--"?0+ "px": ((similarDay.tempIndoor!="--"?similarDay.tempIndoor:0)/maxArr[1])*160 + "px"}'
|
|
|
- >
|
|
|
- <span>{{similarDay.tempIndoor=="--"?"--":similarDay.tempIndoor.toFixed(1)}}℃</span>
|
|
|
+ <div class='indoor-right' :style='{"height":formatter(similarDay.tempIndoor,maxArr[1])+ "px"}'>
|
|
|
+ <span>{{formatterNum(similarDay.tempIndoor,1)}}℃</span>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class='coldWar'>
|
|
|
- <div class='coldWar-left' :style='{"height":maxArr[2]=="--"?0+ "px": ((current.energy!="--"?current.energy:0)/maxArr[2])*160 + "px"}'>
|
|
|
- <span>{{current.energy=="--"?"--":current.energy.toFixed(0)}}kWh</span>
|
|
|
+ <div class='coldWar-left' :style='{"height":formatter(current.energy,maxArr[2])+ "px"}'>
|
|
|
+ <span>{{formatterNum(current.energy,0)}}kWh</span>
|
|
|
</div>
|
|
|
- <div
|
|
|
- class='coldWar-right'
|
|
|
- :style='{"height": maxArr[2]=="--"?0+ "px":((similarDay.energy!="--"?similarDay.energy:0)/maxArr[2])*160 + "px"}'
|
|
|
- >
|
|
|
- <span>{{similarDay.energy=="--"?"--":similarDay.energy.toFixed(0)}}kWh</span>
|
|
|
+ <div class='coldWar-right' :style='{"height":formatter(similarDay.energy,maxArr[2])+ "px"}'>
|
|
|
+ <span>{{formatterNum(similarDay.energy,0)}}kWh</span>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -65,15 +50,42 @@ export default {
|
|
|
this.init()
|
|
|
},
|
|
|
methods: {
|
|
|
+ formatter(a, b) {
|
|
|
+ if (a == 0 || b == 0) {
|
|
|
+ return 0
|
|
|
+ }
|
|
|
+ if (a != 'x' && a != '--') {
|
|
|
+ return (a / b) * 160
|
|
|
+ } else {
|
|
|
+ return 0
|
|
|
+ }
|
|
|
+ },
|
|
|
+ formatterNum(a, b) {
|
|
|
+ if (a == 0) {
|
|
|
+ return 0
|
|
|
+ }
|
|
|
+ if (a != 'x' && a != '--') {
|
|
|
+ return a.toFixed(b)
|
|
|
+ } else {
|
|
|
+ return a
|
|
|
+ }
|
|
|
+ },
|
|
|
init() {
|
|
|
if (this.current) {
|
|
|
- if (this.current.tempOutdoor == '-9999' || this.current.tempOutdoor == '-9998') {
|
|
|
+ if (this.current.tempOutdoor == '-9999') {
|
|
|
+ this.current.tempOutdoor = 'x'
|
|
|
+ } else if (this.current.tempOutdoor == '-9998') {
|
|
|
this.current.tempOutdoor = '--'
|
|
|
}
|
|
|
- if (this.current.tempIndoor == '-9999' || this.current.tempIndoor == '-9998') {
|
|
|
+ if (this.current.tempIndoor == '-9999') {
|
|
|
+ this.current.tempIndoor = 'x'
|
|
|
+ } else if (this.current.tempIndoor == '-9998') {
|
|
|
this.current.tempIndoor = '--'
|
|
|
}
|
|
|
- if (this.current.energy == '-9999' || this.current.energy == '-9998') {
|
|
|
+
|
|
|
+ if (this.current.energy == '-9999') {
|
|
|
+ this.current.energy = 'x'
|
|
|
+ } else if (this.current.energy == '-9998') {
|
|
|
this.current.energy = '--'
|
|
|
}
|
|
|
}
|