作者 刘晓艳

成品

@@ -14,7 +14,8 @@ @@ -14,7 +14,8 @@
14 "pages/logs/logs", 14 "pages/logs/logs",
15 "pages/yujing/yujing", 15 "pages/yujing/yujing",
16 "pages/qiyeyongdian/qyyd/qyyd", 16 "pages/qiyeyongdian/qyyd/qyyd",
17 - "pages/member/member" 17 + "pages/member/member",
  18 + "pages/chengpin/chengpin"
18 ], 19 ],
19 "window": { 20 "window": {
20 "backgroundTextStyle": "light", 21 "backgroundTextStyle": "light",
  1 +// pages/qiyeyongdian/detail/detail.js
  2 +
  3 +import * as echarts from '../../ec-canvas/echarts';
  4 +
  5 +const app = getApp();
  6 +var Chart = null;
  7 +Page({
  8 +
  9 + /**
  10 + * 页面的初始数据
  11 + */
  12 + data: {
  13 + showModal: false,
  14 + monthList: ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"],
  15 + time: '2019.01.01-2019.01.31',
  16 + changeColor: -1,
  17 + ec: {
  18 +
  19 + onInit: function (canvas, width, height) {
  20 +
  21 + chart = echarts.init(canvas, null, {
  22 +
  23 + width: width,
  24 +
  25 + height: height
  26 +
  27 + });
  28 +
  29 + canvas.setChart(chart);
  30 +
  31 + return chart;
  32 +
  33 + },
  34 +
  35 + lazyLoad: true, // 延迟加载
  36 + showt: false
  37 + },
  38 +
  39 + },
  40 + choice(e) {
  41 + let index = e.currentTarget.dataset.id;
  42 + index = index + 1
  43 + if (index == 1 || index == 3 || index == 5 || index == 7 || index == 8 || index == 10 || index == 12) {
  44 + this.setData({
  45 + time: "(" + "2019." + "0" + index + ".01" + "-2019" + index + ".31" + ")"
  46 + })
  47 + } else {
  48 + this.setData({
  49 + time: "(" + "2019." + "0" + index + ".01" + "-2019" + index + ".30" + ")"
  50 + })
  51 + }
  52 + this.setData({
  53 + changeColor: index - 1
  54 + })
  55 + },
  56 + three() {
  57 + this.setData({
  58 + time: '近30天',
  59 + showt: !this.data.showt
  60 + })
  61 + },
  62 + toShowModal(e) {
  63 + this.setData({
  64 + showModal: true
  65 +
  66 + })
  67 + },
  68 +
  69 + hideModal() {
  70 + this.setData({
  71 + showModal: false
  72 + });
  73 + },
  74 + /**
  75 + * 生命周期函数--监听页面加载
  76 + */
  77 + onLoad: function (options) {
  78 +
  79 + this.echartsComponnet = this.selectComponent('#mychart');
  80 +
  81 + //如果是第一次绘制
  82 +
  83 + if (!Chart) {
  84 +
  85 + this.init_echarts(); //初始化图表
  86 +
  87 + } else {
  88 +
  89 + this.setOption(Chart); //更新数据
  90 +
  91 + }
  92 +
  93 + },
  94 + //初始化图表
  95 +
  96 + init_echarts: function () {
  97 +
  98 + this.echartsComponnet.init((canvas, width, height) => {
  99 +
  100 + // 初始化图表
  101 +
  102 + const Chart = echarts.init(canvas, null, {
  103 +
  104 + width: width,
  105 +
  106 + height: height
  107 +
  108 + });
  109 +
  110 + this.setOption(Chart)
  111 +
  112 + // 注意这里一定要返回 chart 实例,否则会影响事件处理等
  113 +
  114 + return Chart;
  115 +
  116 + });
  117 +
  118 + },
  119 +
  120 + setOption: function (Chart) {
  121 +
  122 + Chart.clear(); // 清除
  123 +
  124 + Chart.setOption(this.getOption()); //获取新数据
  125 +
  126 + },
  127 +
  128 + // 图表配置项
  129 +
  130 + getOption() {
  131 +
  132 + var self = this;
  133 +
  134 + var option = {
  135 +
  136 + color: ["#FFF"], //图例图标颜色
  137 + // lineStyle:{//阴影
  138 + // shadowColor: '#6495F8',
  139 + // shadowBlur: 10
  140 + // },
  141 + xAxis: { //横坐标
  142 +
  143 + type: 'category',
  144 +
  145 + name: '日期', //横坐标名称
  146 +
  147 + nameTextStyle: { //在name值存在下,设置name的样式
  148 +
  149 + color: '#333',
  150 +
  151 + fontStyle: 'normal'
  152 +
  153 + },
  154 + axisLabel: {
  155 + interval: 0,
  156 + },
  157 + boundaryGap: false, //1.true 数据点在2个刻度直接 2.fals 数据点在分割线上,即刻度值上
  158 +
  159 + data: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31'],
  160 +
  161 + axisLabel: {
  162 +
  163 + textStyle: {
  164 +
  165 + fontSize: 13,
  166 +
  167 + color: '#5D5D5D'
  168 +
  169 + }
  170 +
  171 + }
  172 +
  173 + },
  174 +
  175 + yAxis: { //纵坐标
  176 +
  177 + type: 'value',
  178 +
  179 + position: 'left',
  180 +
  181 + name: '千瓦时', //纵坐标名称
  182 +
  183 + nameTextStyle: { //在name值存在下,设置name的样式
  184 +
  185 + color: '#333333',
  186 +
  187 + fontStyle: 'normal'
  188 +
  189 + },
  190 +
  191 + splitNumber: 5, //坐标轴的分割段数
  192 +
  193 +
  194 + min: 0,
  195 +
  196 + max: 500,
  197 +
  198 + },
  199 +
  200 + series: [{
  201 +
  202 + type: 'line',
  203 +
  204 + data: [100, 120, 123, 142, 231, 231, 123, 341, 234, 432, 100, 120, 123, 142, 231, 231, 123, 341, 234, 432, 100, 120, 123, 142, 231, 231, 123, 341, 234, 432, 253],
  205 +
  206 + symbol: 'true',
  207 +
  208 + itemStyle: {
  209 +
  210 + normal: {
  211 +
  212 + lineStyle: {
  213 +
  214 + color: '#6495F8'
  215 +
  216 + }
  217 +
  218 + }
  219 +
  220 + },
  221 + // areaStyle: {
  222 + // normal: {
  223 + // color: '#6495F8' //改变区域颜色
  224 + // }
  225 + // },
  226 +
  227 + }],
  228 +
  229 + }
  230 +
  231 + return option;
  232 +
  233 + },
  234 + /**
  235 + * 生命周期函数--监听页面初次渲染完成
  236 + */
  237 + onReady: function () {
  238 +
  239 + },
  240 +
  241 + /**
  242 + * 生命周期函数--监听页面显示
  243 + */
  244 + onShow: function () {
  245 +
  246 + },
  247 +
  248 + /**
  249 + * 生命周期函数--监听页面隐藏
  250 + */
  251 + onHide: function () {
  252 +
  253 + },
  254 +
  255 + /**
  256 + * 生命周期函数--监听页面卸载
  257 + */
  258 + onUnload: function () {
  259 +
  260 + },
  261 +
  262 + /**
  263 + * 页面相关事件处理函数--监听用户下拉动作
  264 + */
  265 + onPullDownRefresh: function () {
  266 +
  267 + },
  268 +
  269 + /**
  270 + * 页面上拉触底事件的处理函数
  271 + */
  272 + onReachBottom: function () {
  273 +
  274 + },
  275 +
  276 + /**
  277 + * 用户点击右上角分享
  278 + */
  279 + onShareAppMessage: function () {
  280 +
  281 + }
  282 +})
  1 +{
  2 + "navigationBarTextStyle": "black",
  3 + "navigationBarTitleText": "成品",
  4 + "usingComponents": {}
  5 +}
  1 +<!--pages/qiyeyongdian/detail/detail.wxml-->
  2 +<!-- 日期选择 -->
  3 +<view class="modal-mask" bindtap="hideModal" wx:if="{{showModal}}"></view>
  4 +<view wx:if="{{showModal}}">
  5 + <view class="modal-content">
  6 + <!-- 年份 -->
  7 + <view class="modal_year">2019年</view>
  8 + <!-- 月份 -->
  9 + <view class="modal_month">
  10 + <view class="month_single {{changeColor == index?'change':''}}" wx:for="{{monthList}}" wx:key="" data-id="{{index}}" catchtap="choice">{{item}}</view>
  11 + </view>
  12 + <view class="date_descript {{showt==true?'tactive':''}}" bindtap="three">近30天</view>
  13 + <view class='btns'>
  14 + <view class="cacle" bindtap="hideModal">取消</view>
  15 + <view class="cacle sure" bindtap="hideModal">确定</view>
  16 + </view>
  17 + </view>
  18 +</view>
  19 +<!-- 月份 -->
  20 +<view class="search_month">
  21 + <view class="rowimg">
  22 + <image src='/img/row.png' class="left"></image>
  23 + </view>
  24 + <view class="date_time" bindtap='toShowModal'>
  25 + <!-- 近30天(2019.03.01-2019.03.30) -->
  26 + 2019.06
  27 + <view class="rowimg">
  28 + <image src='/img/row.png' class="down"></image>
  29 + </view>
  30 + </view>
  31 + <view class="rowimg">
  32 + <image src='/img/row.png'></image>
  33 + </view>
  34 +</view>
  35 +<!-- 折线图 -->
  36 +<view class="charts_line">
  37 + <view class="chart">
  38 + <ec-canvas id="mychart" canvas-id="mychart-line" ec="{{ ec }}"></ec-canvas>
  39 +<!-- <ec-canvas id="mychart-dom-graph" canvas-id="mychart-graph" ec="{{ec}}"></ec-canvas> -->
  40 + </view>
  41 +
  42 + <view class="total_power">
  43 + <view>2019.06</view>
  44 + </view>
  45 +
  46 +</view>
  1 +/* pages/qiyeyongdian/detail/detail.wxss */
  2 +
  3 +.search_month {
  4 + width: 686rpx;
  5 + padding: 0 30rpx;
  6 + height: 70rpx;
  7 + background-color: #f3f5f8;
  8 + display: flex;
  9 + flex-direction: row;
  10 + justify-content: space-between;
  11 + align-items: center;
  12 +}
  13 +
  14 +/* 左箭头 */
  15 +
  16 +.left {
  17 + transform: rotate(180deg);
  18 +}
  19 +
  20 +/* 日期 */
  21 +
  22 +.date_time {
  23 + color: #666;
  24 + font-size: 28rpx;
  25 + display: flex;
  26 + flex-direction: row;
  27 + align-items: center;
  28 +}
  29 +
  30 +.down {
  31 + transform: rotate(90deg);
  32 + margin-left: 10rpx
  33 +}
  34 +
  35 +/* 折线图 */
  36 +
  37 +
  38 +
  39 +.chart {
  40 + width: 750rpx;
  41 + height: 394rpx;
  42 + margin: 0 auto;
  43 + display: flex;
  44 + justify-content: center;
  45 + align-items: center;
  46 +}
  47 +
  48 +ec-canvas {
  49 + width: 100%;
  50 + height: 100%;
  51 +}
  52 +
  53 +.total_power {
  54 + display: flex;
  55 + flex-direction: row;
  56 + justify-content: space-around;
  57 +}
  58 +
  59 +/* 弹出框 */
  60 +
  61 +.modal-mask {
  62 + width: 100%;
  63 + height: 100%;
  64 + position: fixed;
  65 + top: 0;
  66 + left: 0;
  67 + background: #000;
  68 + opacity: 0.5;
  69 + overflow: hidden;
  70 + z-index: 9000;
  71 + color: #fff;
  72 +}
  73 +
  74 +.modal-dialog {
  75 + width: 100%;
  76 + overflow: hidden;
  77 + position: fixed;
  78 + top: 45%;
  79 + left: 0;
  80 + z-index: 9500;
  81 + margin: -180rpx 70rpx;
  82 +}
  83 +
  84 +.modal-content {
  85 + position: fixed;
  86 + top: 0;
  87 + left: 0;
  88 + z-index: 9500;
  89 + width: 100%;
  90 + /* height: 55%; */
  91 + overflow: hidden;
  92 + /* padding: 120rpx 50rpx 50rpx; */
  93 + background: #fff;
  94 + border-radius: 2rpx;
  95 +}
  96 +
  97 +/* 年份 */
  98 +
  99 +.modal_year {
  100 + padding: 38rpx;
  101 + border: 1rpx solid #f5f5f5;
  102 + font-size: 28rpx;
  103 + color: #666;
  104 + text-align: center;
  105 +}
  106 +
  107 +/* 月份 */
  108 +
  109 +.modal_month {
  110 + display: flex;
  111 + flex-wrap: wrap;
  112 + flex-direction: row;
  113 + margin: 40rpx 0 30rpx;
  114 +}
  115 +
  116 +.month_single {
  117 + width: 33.333%;
  118 + height: 120rpx;
  119 + text-align: center;
  120 + border-radius: 6rpx;
  121 + font-size: 32rpx;
  122 + color: #333;
  123 + line-height: 120rpx;
  124 +}
  125 +
  126 +.change {
  127 + background-color: #ff9400;
  128 + color: #fff;
  129 +}
  130 +
  131 +.date_descript {
  132 + width: 296rpx;
  133 + height: 70rpx;
  134 + line-height: 70rpx;
  135 + text-align: center;
  136 + color: #ff9400;
  137 + font-size: 28rpx;
  138 + margin: 0 auto;
  139 + background: rgba(244, 244, 244, 1);
  140 + border-radius: 6rpx;
  141 +}
  142 +.tactive{
  143 + background: #ff9400;
  144 + color:#fff;
  145 +}
  146 +
  147 +.btns {
  148 + margin-top: 50rpx;
  149 + display: flex;
  150 + flex-direction: row;
  151 + align-items: center;
  152 + border-top: 1rpx solid #f5f5f5;
  153 +}
  154 +
  155 +.cacle {
  156 + width: 50%;
  157 + color: #afafaf;
  158 + height: 87rpx;
  159 + line-height: 87rpx;
  160 + text-align: center;
  161 + font-size: 34rpx;
  162 +}
  163 +
  164 +.sure {
  165 + color: #ff9400;
  166 + border-left: 1rpx solid #f5f5f5;
  167 +}
@@ -39,7 +39,7 @@ @@ -39,7 +39,7 @@
39 "list": [] 39 "list": []
40 }, 40 },
41 "miniprogram": { 41 "miniprogram": {
42 - "current": 4, 42 + "current": -1,
43 "list": [ 43 "list": [
44 { 44 {
45 "id": -1, 45 "id": -1,
@@ -49,13 +49,6 @@ @@ -49,13 +49,6 @@
49 "scene": null 49 "scene": null
50 }, 50 },
51 { 51 {
52 - "id": 1,  
53 - "name": "detail",  
54 - "pathName": "pages/qiyeyongdian/detail/detail",  
55 - "query": "",  
56 - "scene": null  
57 - },  
58 - {  
59 "id": -1, 52 "id": -1,
60 "name": "企业用电", 53 "name": "企业用电",
61 "pathName": "pages/qiyeyongdian/detail/detail", 54 "pathName": "pages/qiyeyongdian/detail/detail",
@@ -64,15 +57,16 @@ @@ -64,15 +57,16 @@
64 }, 57 },
65 { 58 {
66 "id": -1, 59 "id": -1,
67 - "name": "企业用电",  
68 - "pathName": "pages/qiyeyongdian/detail/detail", 60 + "name": "人员",
  61 + "pathName": "pages/member/member",
69 "query": "", 62 "query": "",
70 "scene": null 63 "scene": null
71 }, 64 },
72 { 65 {
73 "id": -1, 66 "id": -1,
74 - "name": "人员",  
75 - "pathName": "pages/member/member", 67 + "name": "成品",
  68 + "pathName": "pages/chengpin/chengpin",
  69 + "query": "",
76 "scene": null 70 "scene": null
77 } 71 }
78 ] 72 ]