dataCenterXXTJ.js 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. // pages/dataCenterXXTJ/dataCenterXXTJ.js
  2. import * as echarts from '../../ec-canvas/echarts';
  3. import {
  4. imgUrl
  5. } from "../api/request"
  6. const baseUrl = "https://www.cqna.gov.cn/data/"
  7. const request = (options) => {
  8. return new Promise((resolve, reject) => {
  9. options.url = baseUrl + options.url
  10. wx.request({
  11. // 配置 "wx.request" 请求参数
  12. ...options,
  13. header: {
  14. 'content-type': 'application/json;charset=UTF-8'
  15. },
  16. success: function (res) {
  17. console.log("network-res=>", res);
  18. // 返回成功信息
  19. resolve(res.data)
  20. },
  21. fail: function (error) {
  22. console.log("network-err=>", error);
  23. // 返回错误信息
  24. reject(error)
  25. }
  26. })
  27. })
  28. }
  29. Page({
  30. /**
  31. * 页面的初始数据
  32. */
  33. data: {
  34. // 图片前缀
  35. imgUrl: imgUrl,
  36. // 图表
  37. streetlinechartec: {
  38. lazyLoad: true,
  39. },
  40. // 本年度公开信箱办理情况
  41. leaveAMessage: {},
  42. // 详细数据
  43. detailList: [],
  44. // 分页参数
  45. page: 1,
  46. // 按钮是否隐藏
  47. moreBtn: false
  48. },
  49. /**
  50. * 生命周期函数--监听页面加载
  51. */
  52. onLoad(options) {
  53. // 加载字体
  54. // wx.loadFontFace({
  55. // family: 'DOUYU',
  56. // // source: 'url("https://hui.yrslm.com:8089/douyu.ttf")',
  57. // source: 'url("https://www.cqna.gov.cn/mnazw/applet/font/douyu.ttf")',
  58. // success: function (e) {
  59. // console.log(e, '动态加载字体成功')
  60. // },
  61. // fail: function (e) {
  62. // console.log(e, '动态加载字体失败')
  63. // },
  64. // })
  65. // 本年度公开信箱办理情况
  66. this.queryLeaveAMessage();
  67. // 本年度公开信箱办理情况图表
  68. this.treeDiagram = this.selectComponent('#treeDiagram');
  69. this.init_treeDiagram();
  70. // 近90天办理类别统计
  71. this.processingCategory = this.selectComponent('#processingCategory');
  72. this.init_processingCategory();
  73. // 近90天公开信箱领域统计
  74. this.publicMailbox = this.selectComponent('#publicMailbox');
  75. this.init_publicMailbox();
  76. // 详细数据获取
  77. this.queryDetailedData(this.data.page);
  78. },
  79. // 本年度公开信箱办理情况
  80. queryLeaveAMessage() {
  81. request({
  82. url: '/mail/queryLeaveAMessage',
  83. method: 'GET'
  84. }).then(res => {
  85. this.setData({
  86. leaveAMessage: res.data
  87. })
  88. })
  89. },
  90. // 本年度公开信箱办理情况图表
  91. init_treeDiagram() {
  92. this.treeDiagram.init((canvas, width, height, dpr) => {
  93. // 初始化图表
  94. const barChart = echarts.init(canvas, null, {
  95. width: width,
  96. height: height,
  97. devicePixelRatio: dpr
  98. });
  99. barChart.setOption(this.getTreeDiagramOption());
  100. request({
  101. url: '/mail/queryToType?type=1',
  102. method: 'GET'
  103. }).then(res => {
  104. if (res.result) {
  105. barChart.setOption({
  106. series: [{
  107. data: res.data.accept
  108. }, {
  109. data: res.data.handle
  110. }]
  111. })
  112. }
  113. })
  114. // 注意这里一定要返回 chart 实例,否则会影响事件处理等
  115. return barChart;
  116. });
  117. },
  118. // 近90天办理类别统计
  119. init_processingCategory() {
  120. this.processingCategory.init((canvas, width, height, dpr) => {
  121. // 初始化图表
  122. const barChart = echarts.init(canvas, null, {
  123. width: width,
  124. height: height,
  125. devicePixelRatio: dpr
  126. });
  127. barChart.setOption(this.getStatisticsOption());
  128. request({
  129. url: '/mail/queryToType?type=3',
  130. method: 'GET'
  131. }).then(res => {
  132. if (res.result) {
  133. barChart.setOption({
  134. series: [{
  135. data: res.data
  136. }],
  137. legend: {
  138. formatter: function (name) {
  139. let data = res.data
  140. let tarValue
  141. for (let i = 0; i < data.length; i++) {
  142. if (data[i].name == name) {
  143. tarValue = data[i].value
  144. }
  145. }
  146. let v = tarValue + ' 件'
  147. return `${name} ${v}`
  148. }
  149. }
  150. })
  151. }
  152. })
  153. // 注意这里一定要返回 chart 实例,否则会影响事件处理等
  154. return barChart;
  155. });
  156. },
  157. // 近90天公开信箱领域统计
  158. init_publicMailbox() {
  159. this.publicMailbox.init((canvas, width, height, dpr) => {
  160. // 初始化图表
  161. const barChart = echarts.init(canvas, null, {
  162. width: width,
  163. height: height,
  164. devicePixelRatio: dpr
  165. });
  166. barChart.setOption(this.getStatisticsOption());
  167. request({
  168. url: '/mail/queryToType?type=2',
  169. method: 'GET'
  170. }).then(res => {
  171. if (res.result) {
  172. barChart.setOption({
  173. series: [{
  174. data: res.data
  175. }],
  176. legend: {
  177. formatter: function (name) {
  178. let data = res.data
  179. let tarValue
  180. for (let i = 0; i < data.length; i++) {
  181. if (data[i].name == name) {
  182. tarValue = data[i].value
  183. }
  184. }
  185. let v = tarValue + ' 件'
  186. return `${name} ${v}`
  187. }
  188. }
  189. })
  190. }
  191. })
  192. // 注意这里一定要返回 chart 实例,否则会影响事件处理等
  193. return barChart;
  194. });
  195. },
  196. // 本年度公开信箱办理情况图表
  197. getTreeDiagramOption() {
  198. //请求数据
  199. let months = [];
  200. let currYear = new Date().getFullYear();
  201. for (let i = 1; i <= 12; i++) {
  202. let month = i;
  203. month = currYear + "年" + month + "月";
  204. months.push(month);
  205. }
  206. var xAxis = {
  207. type: 'category',
  208. data: months,
  209. splitLine: {
  210. show: true,
  211. alignWithLabel: true,
  212. interval: 0
  213. },
  214. axisLabel: {
  215. interval: 0,
  216. textStyle: {
  217. fontSize: 9
  218. }
  219. },
  220. axisTick: {
  221. show: false
  222. },
  223. },
  224. yAxis = {
  225. type: 'value',
  226. name: '单位:件',
  227. splitLine: {
  228. show: false
  229. },
  230. axisLine: {
  231. show: true
  232. },
  233. },
  234. tooltip = {
  235. trigger: 'axis'
  236. },
  237. dataZoom = [{
  238. type: 'inside',
  239. show: true,
  240. start: 0,
  241. end: 40,
  242. }],
  243. legend = {
  244. data: ['受理数', '办结数'],
  245. itemHeight: 10,
  246. itemWidth: 10,
  247. },
  248. grid = {
  249. left: '5%',
  250. bottom: '5%',
  251. containLabel: true
  252. },
  253. series = [{
  254. name: '受理数',
  255. type: 'bar',
  256. data: [],
  257. itemStyle: {
  258. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  259. offset: 1,
  260. color: '#45D1FF'
  261. },
  262. {
  263. offset: 0,
  264. color: '#0B8FFF'
  265. }
  266. ])
  267. }
  268. },
  269. {
  270. name: '办结数',
  271. type: 'bar',
  272. data: [],
  273. itemStyle: {
  274. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  275. offset: 1,
  276. color: '#84D16A'
  277. },
  278. {
  279. offset: 0.5,
  280. color: '#7EDFA2'
  281. },
  282. {
  283. offset: 0,
  284. color: '#13AC9C'
  285. }
  286. ])
  287. }
  288. }
  289. ]
  290. return {
  291. backgroundColor: '#FFFFFF',
  292. xAxis: xAxis,
  293. yAxis: yAxis,
  294. dataZoom: dataZoom,
  295. tooltip: tooltip,
  296. legend: legend,
  297. grid: grid,
  298. series: series,
  299. animationDelay: function (idx) {
  300. return idx * 50;
  301. },
  302. animationEasing: 'elasticOut'
  303. };
  304. },
  305. // 获取本年度公开信息办理图表
  306. getStatisticsOption() {
  307. //请求数据
  308. let legend = {
  309. top: 'middle',
  310. orient: 'vertical',
  311. right: '10%',
  312. itemHeight: 10,
  313. itemWidth: 10,
  314. },
  315. tooltip = {
  316. trigger: 'item'
  317. },
  318. series = [{
  319. type: 'pie',
  320. left: '-40%',
  321. radius: ['40%', '60%'],
  322. label: {
  323. show: false,
  324. position: 'center'
  325. },
  326. data: []
  327. }]
  328. return {
  329. backgroundColor: '#FFFFFF',
  330. legend: legend,
  331. series: series,
  332. tooltip: tooltip,
  333. animationDelay: function (idx) {
  334. return idx * 50;
  335. },
  336. animationEasing: 'elasticOut'
  337. };
  338. },
  339. // 分页获取详细数据
  340. queryDetailedData(page) {
  341. request({
  342. url: '/mail/queryDetailedData?limit=10&page=' + page
  343. }).then(res => {
  344. if (res.msg === 'SUCCESS') {
  345. if (res.count > 0) {
  346. let temp = this.data.detailList;
  347. for (let index = 0; index < res.data.length; index++) {
  348. res.data[index].inquiry = res.data[index].咨询;
  349. res.data[index].suggestion = res.data[index].建议;
  350. res.data[index].complain = res.data[index].投诉;
  351. res.data[index].other = res.data[index].其他;
  352. res.data[index].comment = res.data[index].意见;
  353. let ym = res.data[index].month.split("-");
  354. res.data[index].month = ym[0] + "年" + ym[1] + "月";
  355. temp.push(res.data[index]);
  356. }
  357. this.setData({
  358. detailList: temp
  359. })
  360. }
  361. } else {
  362. wx.showToast({
  363. title: '没有更多了',
  364. icon: 'none',
  365. duration: 2000
  366. });
  367. this.setData({
  368. moreBtn: true
  369. })
  370. }
  371. })
  372. },
  373. queryDetailedDataPage() {
  374. this.setData({
  375. page: this.data.page + 1
  376. })
  377. this.queryDetailedData(this.data.page);
  378. },
  379. /**
  380. * 生命周期函数--监听页面初次渲染完成
  381. */
  382. onReady() {
  383. },
  384. /**
  385. * 生命周期函数--监听页面显示
  386. */
  387. onShow() {
  388. },
  389. /**
  390. * 生命周期函数--监听页面隐藏
  391. */
  392. onHide() {
  393. },
  394. /**
  395. * 生命周期函数--监听页面卸载
  396. */
  397. onUnload() {
  398. },
  399. /**
  400. * 页面相关事件处理函数--监听用户下拉动作
  401. */
  402. onPullDownRefresh() {
  403. },
  404. /**
  405. * 页面上拉触底事件的处理函数
  406. */
  407. onReachBottom() {
  408. },
  409. /**
  410. * 用户点击右上角分享
  411. */
  412. onShareAppMessage() {
  413. return {
  414. title: '公开信箱统计数据'
  415. }
  416. }
  417. })