dataCenterZWTJ.js 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. // pages/dataCenterZWTJ/dataCenterZWTJ.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. weekWork: {},
  42. // 本月办件数量
  43. monthWork: {},
  44. // 本年办件数量
  45. yearWork: {},
  46. // 本月部门办件排序
  47. departmentSort: {},
  48. // 事项排序
  49. matterSort: {},
  50. // 一窗通办
  51. windowList: {},
  52. // 南岸区政务服务事项总数数据
  53. matters: [],
  54. // 南岸区政务服务事项总数数据零的数量
  55. mattersZero: 0,
  56. // 实时办件详细
  57. backEndDoing: [],
  58. // 实时办件详细定时器
  59. detailTimer: ''
  60. },
  61. /**
  62. * 生命周期函数--监听页面加载
  63. */
  64. onLoad(options) {
  65. // 加载字体
  66. // wx.loadFontFace({
  67. // family: 'DOUYU',
  68. // // source: 'url("https://hui.yrslm.com:8089/douyu.ttf")',
  69. // source: 'url("https://www.cqna.gov.cn/mnazw/applet/font/douyu.ttf")',
  70. // success: function (e) {
  71. // console.log(e, '动态加载字体成功')
  72. // },
  73. // fail: function (e) {
  74. // console.log(e, '动态加载字体失败')
  75. // },
  76. // })
  77. // 获取本周办件数量
  78. this.getOfficeNumberByAreaInfo(1);
  79. // 获取本月办件数量
  80. this.getOfficeNumberByAreaInfo(2);
  81. // 获取本年办件数量
  82. this.getOfficeNumberByAreaInfo(3);
  83. // 南岸区政务服务事项总数、一窗通办、部门办件情况
  84. this.queryDepartmentItem();
  85. // 互联网申报情况图表
  86. this.barComponent = this.selectComponent('#annulus');
  87. this.init_bar();
  88. // 好差评图表
  89. this.goodOrBad = this.selectComponent('#goodOrBad');
  90. this.init_goodOrBad();
  91. // 实时办件详细
  92. this.getListMatterRank();
  93. // 开启定时器
  94. this.startTimer();
  95. },
  96. // 根据时间类型获取办件数量
  97. getOfficeNumberByAreaInfo(timeType) {
  98. request({
  99. url: '/department/getOfficeNumberByAreaInfo?area=1&timeType=' + timeType,
  100. method: 'GET'
  101. }).then(res => {
  102. if (res.result === 'ok') {
  103. switch (timeType) {
  104. case 1:
  105. this.setData({
  106. weekWork: res.data
  107. });
  108. break;
  109. case 2:
  110. this.setData({
  111. monthWork: res.data
  112. });
  113. break;
  114. case 3:
  115. this.setData({
  116. yearWork: res.data
  117. });
  118. break;
  119. }
  120. }
  121. })
  122. },
  123. // 南岸区政务服务事项总数、一窗通办、部门办件情况
  124. queryDepartmentItem() {
  125. request({
  126. url: '/department/queryDepartmentItemRankByArea?area=1',
  127. method: 'GET'
  128. }).then(res => {
  129. this.setData({
  130. matters: res.data.conutNumbers,
  131. mattersZero: 7 - res.data.listTotal.conutNumber.toString().length,
  132. departmentSort: res.data.listRank,
  133. matterSort: res.data.listMatterRank,
  134. windowList: res.data.listWeb
  135. })
  136. })
  137. },
  138. // 开启定时器
  139. startTimer() {
  140. let that = this;
  141. this.data.detailTimer = setInterval(function () {
  142. that.getListMatterRank();
  143. }, 8000)
  144. },
  145. /**
  146. * 生命周期函数--监听页面初次渲染完成
  147. */
  148. onReady() {
  149. },
  150. /**
  151. * 生命周期函数--监听页面显示
  152. */
  153. onShow() {
  154. },
  155. /**
  156. * 生命周期函数--监听页面隐藏
  157. */
  158. onHide() {
  159. },
  160. /**
  161. * 生命周期函数--监听页面卸载
  162. */
  163. onUnload() {
  164. // 清除定时器
  165. clearInterval(this.data.detailTimer);
  166. },
  167. /**
  168. * 页面相关事件处理函数--监听用户下拉动作
  169. */
  170. onPullDownRefresh() {
  171. },
  172. /**
  173. * 页面上拉触底事件的处理函数
  174. */
  175. onReachBottom() {
  176. },
  177. /**
  178. * 用户点击右上角分享
  179. */
  180. onShareAppMessage() {
  181. return {
  182. title: '政务服务数据统计分析'
  183. }
  184. },
  185. // 获取互联网申报情况图表
  186. init_bar() {
  187. this.barComponent.init((canvas, width, height, dpr) => {
  188. // 初始化图表
  189. const barChart = echarts.init(canvas, null, {
  190. width: width,
  191. height: height,
  192. devicePixelRatio: dpr
  193. });
  194. barChart.setOption(this.getScaOption());
  195. request({
  196. url: '/department/getOfficeNumberByAreaInfo?area=1&timeType=3',
  197. method: 'GET'
  198. }).then(res => {
  199. if (res.result === 'ok') {
  200. barChart.setOption({
  201. series: [{
  202. data: [{
  203. name: '网上申报',
  204. value: res.data.applicationNumberNetwork
  205. },
  206. {
  207. name: '窗口申报',
  208. value: res.data.applicationNumberWindow
  209. }
  210. ]
  211. }]
  212. });
  213. }
  214. })
  215. // 注意这里一定要返回 chart 实例,否则会影响事件处理等
  216. return barChart;
  217. });
  218. },
  219. // 好差评图表
  220. init_goodOrBad() {
  221. this.goodOrBad.init((canvas, width, height, dpr) => {
  222. // 初始化图表
  223. const barChart = echarts.init(canvas, null, {
  224. width: width,
  225. height: height,
  226. devicePixelRatio: dpr
  227. });
  228. request({
  229. url: '/goodOrbad/getGoodOrBadByYearAndArea?area=1',
  230. method: 'GET'
  231. }).then(res => {
  232. if (res.result === 'ok') {
  233. let temp = [];
  234. temp.push(res.data.veryDissatisfied);
  235. temp.push(res.data.notSatisfied);
  236. temp.push(res.data.basicSatisfied);
  237. temp.push(res.data.satisfied);
  238. temp.push(res.data.great);
  239. // 计算最大值,以及分割值
  240. var maxValue = Math.max(...temp)
  241. maxValue = parseInt(maxValue/10000 + 1) * 10000
  242. var interval = maxValue / 4
  243. barChart.setOption(this.getGoodOrBadOption(maxValue, interval));
  244. this.setData({
  245. evalutionNum: res.data.goodOrBad,
  246. evalutionRate: Math.round(res.data.good / res.data.goodOrBad * 100)
  247. })
  248. barChart.setOption({
  249. series: [{
  250. data: temp
  251. }]
  252. })
  253. }
  254. })
  255. // 注意这里一定要返回 chart 实例,否则会影响事件处理等
  256. return barChart;
  257. });
  258. },
  259. // 获取互联网申报情况图表
  260. getScaOption() {
  261. //请求数据
  262. var series = [{
  263. type: 'pie',
  264. radius: ['45%', '70%'],
  265. avoidLabelOverlap: false,
  266. label: {
  267. show: false,
  268. position: 'center'
  269. },
  270. emphasis: {
  271. label: {
  272. show: false
  273. }
  274. },
  275. labelLine: {
  276. show: false
  277. },
  278. data: []
  279. }];
  280. return {
  281. tooltip: {
  282. trigger: 'item',
  283. position: ['12%', '72%'],
  284. textStyle: {
  285. fontWeight: 'normal',
  286. fontSize: 12,
  287. padding: 1
  288. }
  289. },
  290. legend: "",
  291. series: series
  292. };
  293. },
  294. // 获取好差评图表
  295. getGoodOrBadOption(maxValue, interval) {
  296. //请求数据
  297. var xAxis = {
  298. type: 'value',
  299. splitNumber: 4,
  300. max: maxValue,
  301. interval: interval,
  302. axisLine: {
  303. show: true
  304. },
  305. splitLine: {
  306. interval: 0
  307. }
  308. },
  309. yAxis = {
  310. axisTick: {
  311. show: false
  312. },
  313. type: 'category',
  314. data: [
  315. '非常不满意', '不满意', '基本满意', '满意', '非常满意'
  316. ]
  317. },
  318. grid = {
  319. left: '20%',
  320. top: '5%',
  321. bottom: '20%',
  322. right: '20%'
  323. },
  324. series = [{
  325. data: [123, 200, 15220, 80333, 1073671],
  326. type: 'bar',
  327. barWidth: 15,
  328. itemStyle: {
  329. barBorderRadius: [0, 7, 7, 0],
  330. color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [{
  331. offset: 0,
  332. color: '#006BFD'
  333. },
  334. {
  335. offset: 1,
  336. color: '#00E9F1'
  337. }
  338. ]),
  339. },
  340. label: {
  341. show: true,
  342. position: 'right',
  343. valueAnimation: true
  344. }
  345. }]
  346. return {
  347. backgroundColor: '#FFFFFF',
  348. xAxis: xAxis,
  349. yAxis: yAxis,
  350. grid: grid,
  351. series: series,
  352. animationDelay: function (idx) {
  353. return idx * 50;
  354. },
  355. animationEasing: 'elasticOut'
  356. };
  357. },
  358. // 实时办件详细
  359. getListMatterRank() {
  360. request({
  361. url: '/department/getListMatterRank?area=1',
  362. method: 'GET'
  363. }).then(res => {
  364. if (res.result === 'ok') {
  365. this.setData({
  366. backEndDoing: res.data
  367. })
  368. }
  369. })
  370. },
  371. })