// pages/statistics/index.js const api = require('../../api/index.js'); Page({ /** * 页面的初始数据 */ data: { // 状态栏高度 statusBarHeight: wx.getStorageSync('statusBarHeight'), // 导航栏高度 navBarHeight: wx.getStorageSync('navBarHeight'), // 导航栏和状态栏高度 navStatusBarHeight: wx.getStorageSync('navStatusBarHeight'), // 胶囊 menu:wx.getStorageSync('menu'), sunec: { lazyLoad: true } }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { this.sunline = this.selectComponent('#sunlinechart') this.onworkorder() // this.getsunlinechart() }, onlevel(){ console.log(1111111); wx.navigateBack({ data:1 }) }, onworkorder(){ let data = { workorderType:'' } api.request(`/workoder/statistics`, 'POST',data) .then((res) => { console.log(res); this.setData({ workorder:res.data }) }) .catch((err) => { console.error('请求失败:', err); // 在这里处理请求失败的情况 }); }, // 日用电价走势 getsunlinechart() { this.sunline.init((canvas, width, height, dpr) => { const chart = echarts.init(canvas, null, { width: width, height: height, devicePixelRatio: dpr }); canvas.setChart(chart); var option = { xAxis: { type: 'category', data: [1,2,3,4,5,6,7,8,9,10] }, yAxis: { type: 'value', axisLine: { show: true, lineStyle: { color: '#999', width: 1 } }, axisTick: { show: false }, splitLine: { show: true, lineStyle: { type: 'dotted', color: '#ccc', width: 1, opacity: 0.6 } } }, grid: { top: '10%', left: '0%', right: '4%', bottom: '3%', containLabel: true }, series: [ { data: [10,20,30,40,50,60,70,70,70,70,70], showSymbol: false, type: 'line', step: 'start', color: '#B2D5CB', } ] }; chart.setOption(option); return chart; }); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, onstatistics(){ wx.switchTab({ url: '/pages/tool/index', }) }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })