Detail.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. <template>
  2. <view class="contentike">
  3. <view class="fixed" style="color: #FFFDEF;">
  4. <cu-custom bgColor="background-color: #1f1f1f;" :isBack="true">
  5. <block slot="backText">
  6. <view style="height: 80rpx;line-height: 80rpx; color: #FFFDEF;" @tap="goToIndex()">返回</view>
  7. <view class="addressName">{{address}}</view>
  8. </block>
  9. </cu-custom>
  10. </view>
  11. <view class="threeTarget">
  12. <view class="target">
  13. <view class="target_zi">指标</view>
  14. <view class="target_dianLiang">日发电量</view>
  15. </view>
  16. <view class="target">
  17. <view style="font-size: 16px;margin-top: -7px;">数值</view>
  18. <view class="target_count">40</view>
  19. </view>
  20. <view class="target">
  21. <view style="font-size: 16px;margin-top: -7px;">单位</view>
  22. <view class="target_danWei">kw/h</view>
  23. </view>
  24. </view>
  25. <view class="qiun-charts">
  26. <view class="speedPowerDiagram">24小时指标曲线图</view>
  27. <canvas canvas-id="canvasLineA" id="canvasLineA" class="charts" @touchstart="touchLineA"></canvas>
  28. </view>
  29. <view class="qiun-columnCharts">
  30. <view class="sevenDayColunm">7天指标柱状图</view>
  31. <canvas canvas-id="canvasColumn" id="canvasColumn" class="charts" @touchstart="touchColumn"></canvas>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. import uCharts from '../../components/tools/u-charts/u-charts.js';
  37. import res from '../../common/data.json';
  38. var _self;
  39. var canvaLineA;
  40. var canvaColumn = null;
  41. export default {
  42. data() {
  43. let data = {
  44. cWidth: '',
  45. cHeight: '',
  46. pixelRatio: 1,
  47. serverData: '',
  48. address:'',
  49. }
  50. return data;
  51. },
  52. created: function() {
  53. this.address = this.getWindPowerStationNameToSessionStorage();
  54. this.windPowerStationId = uni.getStorageSync('windPowerStationId');
  55. },
  56. onShow() {
  57. this.windPowerStationId = uni.getStorageSync('windPowerStationId');
  58. this.address = this.getWindPowerStationNameToSessionStorage();
  59. // this.hideModals();
  60. },
  61. onLoad() {
  62. _self = this;
  63. this.cWidth = uni.upx2px(750);
  64. this.cHeight = uni.upx2px(400);
  65. this.getColumnServerData();
  66. this.getLineServerData();
  67. },
  68. onReady() {
  69. },
  70. methods: {
  71. pushWindPowerStationNameToSessionStorage(windpowerstationName) {
  72. uni.setStorageSync('windpowerstationName', windpowerstationName);
  73. //sessionStorage.setItem('windpowerstationName', windpowerstationName);
  74. //alert("v"+ sessionStorage.getItem("windpowerstationName"));
  75. //this.common.goback('/pages/index/Index');
  76. },
  77. getWindPowerStationNameToSessionStorage() {
  78. uni.getStorageSync('windpowerstationName');
  79. return uni.getStorageSync('windpowerstationName');
  80. },
  81. getLineServerData() {
  82. // 折线图
  83. let LineA = {
  84. categories: [' 17:26', '18:56', '19:56', '20:56', '21:56', '22:56', '23:56',
  85. '00:56', '01:56', '02:56', '03:56', '04:56', '05:56', '06:56', '07:56', '08:56',
  86. '09:56',
  87. '10:56', '11:56', '12:56', '13:56', '14:56', '15:56', '16:56', '17:56 '
  88. ],
  89. series: [{
  90. name: '功率',
  91. 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,
  92. 21.8, 22.5, 22.9, 19.8, 22.7,
  93. 23, 22.8
  94. ],
  95. color: '#4A80B1',
  96. textColor: '#FFFFFF',
  97. textSize: this.seriesTextSize,
  98. format: (val) => {
  99. return val + "kwh"
  100. },
  101. index: 0,
  102. legendShape: "circle",
  103. }, ]
  104. };
  105. this.showLineA("canvasLineA", LineA);
  106. },
  107. showLineA(canvasId, chartData) {
  108. canvaLineA = new uCharts({
  109. $this: _self,
  110. canvasId: canvasId,
  111. type: 'line',
  112. fontSize: 11,
  113. legend: {
  114. show: true,
  115. position: "top",
  116. float: "right",
  117. fontColor: "silver",
  118. itemGap: "4",
  119. },
  120. dataLabel: false,
  121. dataPointShape: false,
  122. background: '#FFFFFF',
  123. pixelRatio: _self.pixelRatio,
  124. categories: chartData.categories,
  125. series: chartData.series,
  126. animation: true,
  127. xAxis: {
  128. type: 'grid',
  129. gridColor: 'silver',
  130. fontColor: 'silver',
  131. gridType: 'solid',
  132. gridColor: '#2E2E2E',
  133. axisLineColor: "#2E2E2E",
  134. labelCount: "3",
  135. // itemCount:"3"
  136. },
  137. yAxis: {
  138. data: [{
  139. type: "value",
  140. fontColor: 'silver',
  141. disabled: false, //y轴轴线
  142. min: 0,
  143. max: 40,
  144. position: "left",
  145. axisLineColor: "#2E2E2E",
  146. title: " 功率:(kw/h)",
  147. titleFontColor: "silver"
  148. },
  149. {
  150. fontColor: "silver",
  151. disabled: false, //y轴轴线
  152. min: 0,
  153. max: 40,
  154. position: "right",
  155. axisLineColor: "#2E2E2E",
  156. title: "功率:(kwh)",
  157. titleFontColor: "silver"
  158. }
  159. ],
  160. gridColor: "#2E2E2E",
  161. splitNumber: 4,
  162. gridType: 'solid',
  163. dashLength: 8,
  164. showTitle: "true",
  165. format: (val) => {
  166. return val.toFixed(0) + '元'
  167. },
  168. },
  169. width: _self.cWidth * _self.pixelRatio,
  170. height: _self.cHeight * _self.pixelRatio,
  171. extra: {
  172. line: {
  173. type: 'line',
  174. width: '1',
  175. }
  176. }
  177. });
  178. },
  179. touchLineA(e) {
  180. canvaLineA.showToolTip(e, {
  181. format: function(item, category) {
  182. return category + ' ' + item.name + ':' + item.data
  183. }
  184. });
  185. },
  186. moveLineA(e) {
  187. canvaLineA.scroll(e);
  188. },
  189. getColumnServerData() {
  190. res.data.data = res.data;
  191. let Column = {
  192. categories: [],
  193. series: []
  194. };
  195. //这里我后台返回的是数组,所以用等于,如果您后台返回的是单条数据,需要push进去
  196. Column.categories = res.data.data.ColumnB.categories;
  197. Column.series = res.data.data.ColumnB.series;
  198. _self.textarea = JSON.stringify(res.data.data.ColumnB);
  199. _self.showColumn("canvasColumn", Column);
  200. },
  201. showColumn(canvasId, chartData) {
  202. canvaColumn = new uCharts({
  203. $this: _self,
  204. canvasId: canvasId,
  205. type: 'column',
  206. legend: {
  207. show: true,
  208. fontSize: 12,
  209. padding: 5,
  210. fontColor: "silver",
  211. itemGap: "4",
  212. // margin:0,
  213. position: "top",
  214. float: "right"
  215. },
  216. fontSize: 11,
  217. background: '#242424',
  218. pixelRatio: _self.pixelRatio,
  219. animation: true,
  220. categories: chartData.categories,
  221. series: chartData.series,
  222. xAxis: {
  223. // disabled:true,
  224. rotateLabel: true,
  225. disableGrid: true,
  226. axisLineColor: '#2D2D2D',
  227. fontColor: "#ffffff",
  228. // gridColor:'#2D2D2D',
  229. },
  230. yAxis: {
  231. showTitle: true,
  232. // disableGrid:true,
  233. gridType: 'solid',
  234. dashLength: 8,
  235. gridColor: '#2D2D2D',
  236. splitNumber: 5,
  237. min: 0,
  238. max: 40,
  239. data: [{
  240. min: 0,
  241. max: 40,
  242. position: 'left',
  243. axisLine: false,
  244. fontColor: "silver",
  245. // title: '7天功率柱状图',
  246. title: " 功率:(kw/h)",
  247. titleFontColor: "silver",
  248. // title: '功率(kw/h)',
  249. // titleFontColor: '#FFFFFF',
  250. titleFontSize: 11,
  251. format: (val) => {
  252. return val.toFixed(0) + ''
  253. },
  254. }]
  255. },
  256. dataLabel: true,
  257. width: _self.cWidth * _self.pixelRatio,
  258. height: _self.cHeight * _self.pixelRatio,
  259. extra: {
  260. column: {
  261. type: 'group',
  262. // width: _self.cWidth * _self.pixelRatio * 0.45 / chartData.categories.length
  263. width: 12,
  264. lineStyle: {
  265. width: 5,
  266. }
  267. }
  268. }
  269. });
  270. },
  271. goToIndex(){
  272. uni.switchTab({
  273. url: '/pages/index/Index'
  274. });
  275. },
  276. touchColumn(e) {
  277. canvaColumn.showToolTip(e, {
  278. format: function(item, category) {
  279. if (typeof item.data === 'object') {
  280. return category + ' ' + item.name + ':' + item.data.value
  281. } else {
  282. return category + ' ' + item.name + ':' + item.data
  283. }
  284. }
  285. });
  286. },
  287. }
  288. }
  289. </script>
  290. <style>
  291. page {
  292. /* background-color: #FFFFFF; */
  293. font-family:'方正兰亭细黑_GBK';
  294. }
  295. body {
  296. background: #1F1F1F;
  297. font-family:'方正兰亭细黑_GBK';
  298. font-size: 14px;
  299. color: silver;
  300. }
  301. @font-face {
  302. font-family:'方正兰亭细黑_GBK';
  303. src: url(../../static/方正兰亭细黑_GBK.TTF);
  304. }
  305. .addressName {
  306. /* width: 100%; */
  307. /* background-color: white; */
  308. height: 80rpx;
  309. line-height: 80rpx;
  310. margin-left: 100px;
  311. color: #FFFDEF;
  312. }
  313. .target_dianLiang {
  314. margin-top: 15px;
  315. font-size: 16px;
  316. font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", STHeiti, "Microsoft Yahei", Tahoma, Simsun, sans-serif;
  317. }
  318. .target_count {
  319. margin-top: 15px;
  320. font-size: 16px;
  321. font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", STHeiti, "Microsoft Yahei", Tahoma, Simsun, sans-serif;
  322. }
  323. .target_danWei {
  324. margin-top: 15px;
  325. font-size: 16px;
  326. font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", STHeiti, "Microsoft Yahei", Tahoma, Simsun, sans-serif;
  327. }
  328. .threeTarget {
  329. width: 100%;
  330. height: 120px;
  331. background-color: #242424;
  332. display: -webkit-flex;
  333. display: flex;
  334. justify-content: space-around;
  335. float: left;
  336. }
  337. .target {
  338. width: 28%;
  339. height: 78px;
  340. background: -webkit-linear-gradient(top, rgba(159, 131, 111, 0.1)0%, rgba(193, 94, 21, 0.2)100%);
  341. border-radius: 5px;
  342. float: left;
  343. margin-top: 20px;
  344. text-align: center;
  345. color: silver;
  346. padding-top: 20px;
  347. font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", STHeiti, "Microsoft Yahei", Tahoma, Simsun, sans-serif;
  348. }
  349. .target_zi {
  350. font-size: 16px;
  351. text-align: center;
  352. margin-top: -7px;
  353. }
  354. .speedPowerDiagram {
  355. width: 100px;
  356. height: 30px;
  357. user-select: text;
  358. -webkit-user-select: text;
  359. -moz-user-select: text;
  360. -ms-user-select: text;
  361. color: silver;
  362. float: left;
  363. margin-top: 18px;
  364. margin-left: 9px;
  365. font-size: 11px;
  366. }
  367. .qiun-charts {
  368. width: 750upx;
  369. height: 400upx;
  370. margin-top: 140px;
  371. background-color: #242424;
  372. }
  373. .charts {
  374. width: 750upx;
  375. height: 400upx;
  376. }
  377. .qiun-columnCharts {
  378. width: 750upx;
  379. height: 400upx;
  380. margin-top: 20px;
  381. background-color: #242424;
  382. }
  383. .sevenDayColunm {
  384. width: 100px;
  385. height: 30px;
  386. user-select: text;
  387. -webkit-user-select: text;
  388. -moz-user-select: text;
  389. -ms-user-select: text;
  390. color: silver;
  391. float: left;
  392. margin-top: 18px;
  393. margin-left: 10px;
  394. font-size: 11px;
  395. }
  396. </style>