123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434 |
- // pages/dataCenterXXTJ/dataCenterXXTJ.js
- import * as echarts from '../../ec-canvas/echarts';
- import {
- imgUrl
- } from "../api/request"
- const baseUrl = "https://www.cqna.gov.cn/data/"
- const request = (options) => {
- return new Promise((resolve, reject) => {
- options.url = baseUrl + options.url
- wx.request({
- // 配置 "wx.request" 请求参数
- ...options,
- header: {
- 'content-type': 'application/json;charset=UTF-8'
- },
- success: function (res) {
- // console.log("network-res=>", res);
- // 返回成功信息
- resolve(res.data)
- },
- fail: function (error) {
- // console.log("network-err=>", error);
- // 返回错误信息
- reject(error)
- }
- })
- })
- }
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- // 图片前缀
- imgUrl: imgUrl,
- // 图表
- streetlinechartec: {
- lazyLoad: true,
- },
- // 本年度公开信箱办理情况
- leaveAMessage: {},
- // 详细数据
- detailList: [],
- // 分页参数
- page: 1,
- // 按钮是否隐藏
- moreBtn: false
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- // 加载字体
- // wx.loadFontFace({
- // family: 'DOUYU',
- // // source: 'url("https://hui.yrslm.com:8089/douyu.ttf")',
- // source: 'url("https://www.cqna.gov.cn/mnazw/applet/font/douyu.ttf")',
- // success: function (e) {
- // console.log(e, '动态加载字体成功')
- // },
- // fail: function (e) {
- // console.log(e, '动态加载字体失败')
- // },
- // })
- // 本年度公开信箱办理情况
- this.queryLeaveAMessage();
- // 本年度公开信箱办理情况图表
- this.treeDiagram = this.selectComponent('#treeDiagram');
- this.init_treeDiagram();
- // 近90天办理类别统计
- this.processingCategory = this.selectComponent('#processingCategory');
- this.init_processingCategory();
- // 近90天公开信箱领域统计
- this.publicMailbox = this.selectComponent('#publicMailbox');
- this.init_publicMailbox();
- // 详细数据获取
- this.queryDetailedData(this.data.page);
- },
- // 本年度公开信箱办理情况
- queryLeaveAMessage() {
- request({
- url: '/mail/queryLeaveAMessage',
- method: 'GET'
- }).then(res => {
- this.setData({
- leaveAMessage: res.data
- })
- })
- },
- // 本年度公开信箱办理情况图表
- init_treeDiagram() {
- this.treeDiagram.init((canvas, width, height, dpr) => {
- // 初始化图表
- const barChart = echarts.init(canvas, null, {
- width: width,
- height: height,
- devicePixelRatio: dpr
- });
- barChart.setOption(this.getTreeDiagramOption());
- request({
- url: '/mail/queryToType?type=1',
- method: 'GET'
- }).then(res => {
- if (res.result) {
- barChart.setOption({
- series: [{
- data: res.data.accept
- }, {
- data: res.data.handle
- }]
- })
- }
- })
- // 注意这里一定要返回 chart 实例,否则会影响事件处理等
- return barChart;
- });
- },
- // 近90天办理类别统计
- init_processingCategory() {
- this.processingCategory.init((canvas, width, height, dpr) => {
- // 初始化图表
- const barChart = echarts.init(canvas, null, {
- width: width,
- height: height,
- devicePixelRatio: dpr
- });
- barChart.setOption(this.getStatisticsOption());
- request({
- url: '/mail/queryToType?type=3',
- method: 'GET'
- }).then(res => {
- if (res.result) {
- barChart.setOption({
- series: [{
- data: res.data
- }],
- legend: {
- formatter: function (name) {
- let data = res.data
- let tarValue
- for (let i = 0; i < data.length; i++) {
- if (data[i].name == name) {
- tarValue = data[i].value
- }
- }
- let v = tarValue + ' 件'
- return `${name} ${v}`
- }
- }
- })
- }
- })
- // 注意这里一定要返回 chart 实例,否则会影响事件处理等
- return barChart;
- });
- },
- // 近90天公开信箱领域统计
- init_publicMailbox() {
- this.publicMailbox.init((canvas, width, height, dpr) => {
- // 初始化图表
- const barChart = echarts.init(canvas, null, {
- width: width,
- height: height,
- devicePixelRatio: dpr
- });
- barChart.setOption(this.getStatisticsOption());
- request({
- url: '/mail/queryToType?type=2',
- method: 'GET'
- }).then(res => {
- if (res.result) {
- barChart.setOption({
- series: [{
- data: res.data
- }],
- legend: {
- formatter: function (name) {
- let data = res.data
- let tarValue
- for (let i = 0; i < data.length; i++) {
- if (data[i].name == name) {
- tarValue = data[i].value
- }
- }
- let v = tarValue + ' 件'
- return `${name} ${v}`
- }
- }
- })
- }
- })
- // 注意这里一定要返回 chart 实例,否则会影响事件处理等
- return barChart;
- });
- },
- // 本年度公开信箱办理情况图表
- getTreeDiagramOption() {
- //请求数据
- let months = [];
- let currYear = new Date().getFullYear();
- for (let i = 1; i <= 12; i++) {
- let month = i;
- month = currYear + "年" + month + "月";
- months.push(month);
- }
- var xAxis = {
- type: 'category',
- data: months,
- splitLine: {
- show: true,
- alignWithLabel: true,
- interval: 0
- },
- axisLabel: {
- interval: 0,
- textStyle: {
- fontSize: 9
- }
- },
- axisTick: {
- show: false
- },
- },
- yAxis = {
- type: 'value',
- name: '单位:件',
- splitLine: {
- show: false
- },
- axisLine: {
- show: true
- },
- },
- tooltip = {
- trigger: 'axis'
- },
- dataZoom = [{
- type: 'inside',
- show: true,
- start: 0,
- end: 40,
- }],
- legend = {
- data: ['受理数', '办结数'],
- itemHeight: 10,
- itemWidth: 10,
- },
- grid = {
- left: '5%',
- bottom: '5%',
- containLabel: true
- },
- series = [{
- name: '受理数',
- type: 'bar',
- data: [],
- itemStyle: {
- color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
- offset: 1,
- color: '#45D1FF'
- },
- {
- offset: 0,
- color: '#0B8FFF'
- }
- ])
- }
- },
- {
- name: '办结数',
- type: 'bar',
- data: [],
- itemStyle: {
- color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
- offset: 1,
- color: '#84D16A'
- },
- {
- offset: 0.5,
- color: '#7EDFA2'
- },
- {
- offset: 0,
- color: '#13AC9C'
- }
- ])
- }
- }
- ]
- return {
- backgroundColor: '#FFFFFF',
- xAxis: xAxis,
- yAxis: yAxis,
- dataZoom: dataZoom,
- tooltip: tooltip,
- legend: legend,
- grid: grid,
- series: series,
- animationDelay: function (idx) {
- return idx * 50;
- },
- animationEasing: 'elasticOut'
- };
- },
- // 获取本年度公开信息办理图表
- getStatisticsOption() {
- //请求数据
- let legend = {
- top: 'middle',
- orient: 'vertical',
- right: '10%',
- itemHeight: 10,
- itemWidth: 10,
- },
- tooltip = {
- trigger: 'item'
- },
- series = [{
- type: 'pie',
- left: '-40%',
- radius: ['40%', '60%'],
- label: {
- show: false,
- position: 'center'
- },
- data: []
- }]
- return {
- backgroundColor: '#FFFFFF',
- legend: legend,
- series: series,
- tooltip: tooltip,
- animationDelay: function (idx) {
- return idx * 50;
- },
- animationEasing: 'elasticOut'
- };
- },
- // 分页获取详细数据
- queryDetailedData(page) {
- request({
- url: '/mail/queryDetailedData?limit=10&page=' + page
- }).then(res => {
- if (res.msg === 'SUCCESS') {
- if (res.count > 0) {
- let temp = this.data.detailList;
- for (let index = 0; index < res.data.length; index++) {
- res.data[index].inquiry = res.data[index].咨询;
- res.data[index].suggestion = res.data[index].建议;
- res.data[index].complain = res.data[index].投诉;
- res.data[index].other = res.data[index].其他;
- res.data[index].comment = res.data[index].意见;
- let ym = res.data[index].month.split("-");
- res.data[index].month = ym[0] + "年" + ym[1] + "月";
- temp.push(res.data[index]);
- }
- this.setData({
- detailList: temp
- })
- }
- } else {
- wx.showToast({
- title: '没有更多了',
- icon: 'none',
- duration: 2000
- });
- this.setData({
- moreBtn: true
- })
- }
- })
- },
- queryDetailedDataPage() {
- this.setData({
- page: this.data.page + 1
- })
- this.queryDetailedData(this.data.page);
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- return {
- title: '公开信箱统计数据'
- }
- }
- })
|