// index.js import { login } from "../api/request"; import { imgUrl, request } from "../api/request" import { yjzjList } from "../api/index-api" import { send } from "../api/index-api2" import * as echarts from '../../ec-canvas/echarts'; // 获取应用实例 const app = getApp() Page({ data: { imgUrl: imgUrl, // 屏幕高度 navHeight: '', searchInput: '', // 南岸咨询 naTab: 0, naItem: '', // 政民tab communicateTab: 0, // 政民item communicateItem: 0, // 服务列表 serviceItems1: [{ img: imgUrl + 'service-1.png', name: '生活缴费' }, { img: imgUrl + 'service-2.png', name: '社保服务' }, { img: imgUrl + 'service-3.png', name: '公积金' }, { img: imgUrl + 'service-4.png', name: '电子证照' }, { img: imgUrl + 'service-5.png', name: '民政低保' } ], serviceItems2: [{ img: imgUrl + 'service-6.png', name: '税务服务' }, { img: imgUrl + 'service-7.png', name: '交通出行' }, { img: imgUrl + 'service-8.png', name: '核酸采样点' }, { img: imgUrl + 'service-9.png', name: '住房置业' }, // { // img: imgUrl + 'service-10.png', // name: '更多功能' // } ], // 百姓聚焦 peopleService: [{ top: true, name: '12345热线' }, { top: false, name: '个人社保查询' }, { top: false, name: '南岸文旅消费劵' }, { top: false, name: '长喜汇弹子石老街' }, { top: false, name: '南山一棵松' }, { top: false, name: '一次性创业补助' } ], // 南岸咨询二级title naItemTabList: [{ id: 1, name: '政策.咨询' }, { id: 2, name: '党建.服务' }, { id: 3, name: '抗疫.复工' }, { id: 4, name: '功能.服务' } ], // 南岸咨询内容 naContentList: [], // 本年办件数 officeNumber: [], // 评价总量 evalutionNum: 0, // 满意度 evalutionRate: '', // 图表 streetlinechartec: { lazyLoad: true, }, // 图表图片 canvasImg: '', videoInfo: [{ url: 'video1.png', title: '南岸百企风采' }, { url: 'video2.png', title: '“不夜南滨”集乐无' }, { url: 'video3.png', title: '2022爱尚重庆' }, { url: 'video1.png', title: '南岸百企风采' } ], // 意见征集list yjzjDataList: [], // 在线调查 investigatePage: 1, investigateList: [], // 地图服务 mapServiceData: [{ id: 1, name: '政务公开' }, { id: 2, name: '政务服务' }, { id: 3, name: '党群服务' }, { id: 4, name: '核酸检测' }, { id: 5, name: '教育资源' }, { id: 6, name: '医疗卫生' }, { id: 7, name: '户籍管理' }, { id: 8, name: '交通服务' }, ], // 媒体矩阵导航 mediaCurrentTab: 0, // 媒体矩阵导航列表 provList: [{ "name": "南岸发布" }, { "name": "微信公众号" }, { "name": "今日头条" } ], // 媒体矩阵内容选项 mediaSelectList: [{ id: '1', name: "重庆市南岸区人民政府", img: imgUrl + 'index-media-icon1.png' }, { id: '2', name: "南岸文旅", img: imgUrl + 'index-media-icon2.png' }, { id: '3', name: "南岸发布", img: imgUrl + 'index-media-icon3.png' }, { id: '4', name: "南岸国资", img: imgUrl + 'index-media-icon4.png' }, { id: '5', name: "重庆南岸消防", img: imgUrl + 'index-media-icon5.png' }, { id: '6', name: "南岸生态环境", img: imgUrl + 'index-media-icon6.png' }, { id: '7', name: "南岸健康卫士", img: imgUrl + 'index-media-icon7.png' }, { id: '8', name: "南岸公安", img: imgUrl + 'index-media-icon8.png' }, { id: '9', name: "遇见南坪", img: imgUrl + 'index-media-icon9.png' }, { id: '10', name: "书香南岸", img: imgUrl + 'index-media-icon10.png' }, { id: '11', name: "南岸卫生健康监督", img: imgUrl + 'index-media-icon11.png' }, { id: '12', name: "南岸司法", img: imgUrl + 'index-media-icon12.png' }, { id: '13', name: "广阳岛绿色发展公司", img: imgUrl + 'index-media-icon13.png' }, { id: '14', name: "南岸人力社保", img: imgUrl + 'index-media-icon14.png' }, { id: '15', name: "广阳湾智创生态城", img: imgUrl + 'index-media-icon15.png' }, { id: '16', name: "南岸智慧城管", img: imgUrl + 'index-media-icon16.png' }, { id: '17', name: "重庆市南岸区天文街道", img: imgUrl + 'index-media-icon17.png' }, { id: '18', name: "南岸健康", img: imgUrl + 'index-media-icon18.png' }, { id: '19', name: "重庆市南岸区南坪街道", img: imgUrl + 'index-media-icon19.png' } ], // 媒体矩阵南岸发布 mediaReleaseList: [], // 媒体矩阵今日头条 mediaHeadlineList: [] }, onReady() {}, onShow() { if (typeof this.getTabBar === 'function' && this.getTabBar()) { this.getTabBar().setData({ selected: 0 }) } this.setData({ naItem: 0 }), this.setData({ naItemTab: 1 }) }, // 点击服务 clickService1(e) { const index = e.currentTarget.dataset.item switch (index) { case 0: { wx.navigateToMiniProgram({ appId: 'wxd2ade0f25a874ee2', success(res) { // 打开成功 } }) }; break; case 1: { wx.navigateToMiniProgram({ appId: 'wxfc86707bae655315', success(res) { // 打开成功 } }) }; break; case 2: { wx.navigateToMiniProgram({ appId: 'wx0bff7955e6e8b2bb', success(res) { // 打开成功 } }) }; break; case 3: { wx.navigateToMiniProgram({ appId: 'wxfc86707bae655315', success(res) { // 打开成功 } }) }; break; case 4: { wx.navigateToMiniProgram({ appId: 'wxfc86707bae655315', success(res) { // 打开成功 } }) }; break; } }, // 点击服务 clickService2(e) { const index = e.currentTarget.dataset.item switch (index) { case 0: { wx.navigateToMiniProgram({ appId: 'wxfc86707bae655315', success(res) { // 打开成功 } }) }; break; case 1: { wx.navigateToMiniProgram({ appId: 'wxbb58374cdce267a6', success(res) { // 打开成功 } }) }; break; case 2: { wx.navigateTo({ url: '/pages/web/web?url=' + "https://www.cqna.gov.cn/maps/sy_mobile.html&se=核酸检测", }) }; break; case 3: { wx.navigateTo({ url: '/pages/web/web?url=' + "http://221.7.85.104:9999/zfjyjgfwpt/main/mobilepage/guidepage.html", }) }; break; } }, toDataCenter() { wx.navigateTo({ url: '/pages/dataCenter/dataCenter', }) }, onHide() { if (typeof this.getTabBar === 'function' && this.getTabBar()) { this.getTabBar().setData({ selected: -1 }) } }, onLoad() { // 加载字体 wx.loadFontFace({ family: 'DOUYU', // source: 'url("https://hui.yrslm.com:8089/douyu.ttf")', source: 'url("http://116.63.49.144:8081/applet/font/douyu.ttf")', success: function (e) { console.log(e, '动态加载字体成功') }, fail: function (e) { console.log(e, '动态加载字体失败') }, }) // 获取媒体矩阵南岸发布数据 this.getMediaReleaseList(); // 获取媒体矩阵今日头条数据 this.getMediaHeadlineList(); // 获取好差评图表 this.barComponent3 = this.selectComponent('#streetlinechart3'); this.init_bar3(); // 获取本年办件数 this.getOfficeNumberByAreaInfo(); // 意见征集数据 this.yjzjData() // 初始化在线调查page this.setData({ investigatePage: 1, investigateList: [], navHeight: app.globalData.navHeight + app.globalData.menuHeight / 2 }) this.initNadt() // wx.login({ // success(res) { // if (res.code) { // //发起网络请求 // login(res.code).then(res => { // console.log(res) // wx.setStorageSync("token", res.data.data) // }) // } else { // console.log('登录失败!' + res.errMsg) // } // } // }) }, // canvas转图片 canvasToTempImage() { wx.canvasToTempFilePath({ canvas: this.barComponent3.canvasNode, success: (res) => { this.setData({ canvasImg: res.tempFilePath }); } }, this); }, // 加载评价图表 init_bar3() { let that = this; this.barComponent3.init((canvas, width, height, dpr) => { // 初始化图表 const barChart = echarts.init(canvas, null, { width: width, height: height, devicePixelRatio: dpr }); barChart.setOption(this.getScaOption2()); request({ url: '/goodOrbad/getGoodOrBadByYearAndArea?area=1', method: 'GET' }).then(res => { if (res.result === 'ok') { let temp = []; temp.push(res.data.veryDissatisfied); temp.push(res.data.notSatisfied); temp.push(res.data.basicSatisfied); temp.push(res.data.satisfied); temp.push(res.data.great); this.setData({ evalutionNum: res.data.goodOrBad, evalutionRate: (res.data.good / res.data.goodOrBad * 100).toFixed(2) }) barChart.setOption({ series: [{ data: temp }] }) } }) barChart.on("finished", function () { that.canvasToTempImage(); }); // 注意这里一定要返回 chart 实例,否则会影响事件处理等 return barChart; }); }, getScaOption2() { //请求数据 let xAxis = { type: 'value', interval: 500000 }, yAxis = { type: 'category', data: [ '非常不满意', '不满意', '基本满意', '满意', '非常满意' ] }, grid = { left: '20%', top: '10%', bottom: '10%', right: '20%' }, series = [{ data: [], type: 'bar', barWidth: 14, itemStyle: { emphasis: { barBorderRadius: 7 }, normal: { barBorderRadius: 7, color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [{ offset: 0, color: '#3977E6' }, { offset: 1, color: '#37BBF8' } ]), } }, label: { show: true, position: 'right', valueAnimation: true } }] return { backgroundColor: '#FFFFFF', xAxis: xAxis, yAxis: yAxis, grid: grid, series: series, animationDelay: function (idx) { return idx * 50; }, animationEasing: 'elasticOut' }; }, // 获取本年办件数 getOfficeNumberByAreaInfo() { request({ url: '/department/getOfficeNumberByAreaInfo?area=1&timeType=3', method: 'GET' }).then(res => { let temp = []; temp.push(res.data.acceptNumber); temp.push(res.data.serialNumber); temp.push(res.data.applicationNumberNetwork); this.setData({ officeNumber: temp }) }) }, // 搜索框 bindKeyInput: function (e) { this.setData({ searchInput: e.detail.value }) }, naChangeTab: function (e) { this.setData({ naTab: e.detail.current, naItem: e.detail.current, naContentList:[] }) this.setData({ }) if (e.detail.current == 1) { wx.request({ url: 'https://www.cq.gov.cn/ywdt/jrzq/index.json?cqjrcq=cqjrcq&_=1669609973472', success:res=>{ if(res.statusCode ==200){ var s = res.data s= s.substring(7,s.length-1) s = JSON.parse(s) var d = []; var size = s.datas.length<=5?s.datas.length: 5 for (let i = 0; i < size; i++) { d.push({"DOCTITLE":s.datas[i].title,"url":s.datas[i].url}) } this.setData({ naContentList: d }) } } }) } if (e.detail.current == 2) { wx.request({ url: 'https://www.gov.cn/pushinfo/v150203/pushinfo.jsonp?pushInfoJsonpCallBack=pushInfoJsonpCallBack&_=1669609973471', success:res=>{ console.log(res); if(res.statusCode ==200){ var s = res.data s= s.substring(22,s.length-1) s = JSON.parse(s) console.log(s); var d = []; var size = s.length<=5?s.length: 5 for (let i = 0; i < size; i++) { d.push({"DOCTITLE":s[i].description,"url":s[i].link}) } this.setData({ naContentList: d }) } } }) } if (e.detail.current == 0){ let column = ["20430", "59482", "59481"] send(1, 5, column[e.detail.current]).then(res => { if (res.result) { this.setData({ naContentList: res.data.DATA }) } }) } // 重置咨询title-tab this.setData({ naItemTab: 1 }) }, initNadt() { send(1, 5, "20430").then(res => { if (res.result) { this.setData({ naContentList: res.data.DATA }) } }) }, // 南岸咨询子集菜单点击 clickNaTilteTab: function (e) { this.setData({ naItem: e.currentTarget.dataset.item, naContentList:[] }) if (e.currentTarget.dataset.item == 1) { wx.request({ url: 'https://www.cq.gov.cn/ywdt/jrzq/index.json?cqjrcq=cqjrcq&_=1669609973472', success:res=>{ if(res.statusCode ==200){ var s = res.data s= s.substring(7,s.length-1) s = JSON.parse(s) var d = []; var size = s.datas.length<=5?s.datas.length: 5 for (let i = 0; i < size; i++) { d.push({"DOCTITLE":s.datas[i].title,"url":s.datas[i].url}) } this.setData({ naContentList: d }) } } }) } if (e.currentTarget.dataset.item == 2) { wx.request({ url: 'https://www.gov.cn/pushinfo/v150203/pushinfo.jsonp?pushInfoJsonpCallBack=pushInfoJsonpCallBack&_=1669609973471', success:res=>{ console.log(res); if(res.statusCode ==200){ var s = res.data s= s.substring(22,s.length-1) s = JSON.parse(s) console.log(s); var d = []; var size = s.length<=5?s.length: 5 for (let i = 0; i < size; i++) { d.push({"DOCTITLE":s[i].description,"url":s[i].link}) } this.setData({ naContentList: d }) } } }) } if (e.currentTarget.dataset.item == 0){ let column = ["20430", "59482", "59481"] send(1, 5, column[e.currentTarget.dataset.item]).then(res => { if (res.result) { this.setData({ naContentList: res.data.DATA }) } }) } }, // 南岸咨询内容点击 clickNaContent: function (e) { let item = e.currentTarget.dataset.item switch(this.data.naTab){ case 0: wx.navigateTo({ url: '/pages/articlDetail/articlDetail?CHNLID=' + item.CHNLID + '&DOCID=' + item.DOCID, }) break case 1: case 2: wx.navigateTo({ url: '/pages/web/web?url='+item.url, }) break } }, // 南岸咨询更多 naMore: function (e) { let title = ''; switch(this.data.naTab){ case 0: title = '南岸动态' wx.navigateTo({ url: '/pages/aticleList/aticleList?title=' + title + '&id=1', }) break case 1: title = '今日重庆' wx.navigateTo({ url: '/pages/aticleList/aticleList?title=' + title + '&id=2', }) break case 2: title = '国务院信息' wx.navigateTo({ url: '/pages/aticleList/aticleList?title=' + title + '&id=3', }) break } }, // 政民互动 communicateChangeItem: function (e) { this.setData({ communicateItem: e.currentTarget.dataset.item }) }, communicateChangeTab: function (e) { this.setData({ communicateTab: e.detail.current }) if (this.data.communicateTab == 1) { this.getInvestigation(false) } }, // 意见征集接口 yjzjData() { yjzjList().then(res => { var list = [] if (res.statusCode == 200 && res.datas.pageInfo.totalResults > 0) { list = res.datas.data for (var i = 0; i < list.length; i++) { list[i].beginTime = this.formatDateNumber(new Date(list[i].beginTime * 1)) list[i].endTime = this.formatDateNumber(new Date(list[i].endTime * 1)) } this.setData({ 'yjzjDataList': list }) } }) }, // 获取在线调查列表 getInvestigation(flag) { wx.showToast({title: '加载中',icon: 'loading',duration: 1500}) var data = [] wx.request({ url: `https://www.cqna.gov.cn/IGI/open/survey/list?siteId=254&pageIndex=${this.data.investigatePage}&pageSize=10&orderBy=startTime_desc`, method: 'GET', success: res => { data = res.data.datas.data if (data && data.length > 0) { for (var i = 0; i < data.length; i++) { data[i].startTime = this.formatDateNumber(new Date(data[i].startTime * 1)) data[i].endTime = this.formatDateNumber(new Date(data[i].endTime * 1)) } data = this.data.investigateList.concat(data) this.setData({ 'investigateList': data, 'investigatePage': this.data.investigatePage + 1 }) wx.hideToast(); } else { wx.hideToast(); // 下拉刷新会提示加载完成 if (flag) { wx.showToast({title: '已加载全部数据',icon: 'success',duration: 1000}) } } } }) }, // 在线调查触底 investigationScrollBottom(e) { this.getInvestigation(true) }, goToInvestigationDetail(e) { const id = e.target.dataset.id const siteId = e.target.dataset.siteid wx.navigateTo({ url: '/pages/web/web?wxUrl=' + encodeURIComponent(`https://www.cqna.gov.cn/personalCenter/answerSheet/answerSheet.html?siteId=${siteId}&metadataId=${id}`), }) }, goYjzjDetail(e) { var html = e.currentTarget.dataset.item wx.navigateTo({ url: "/pages/yjzjDetail/yjzjDetail?html=" + encodeURIComponent(html) }) }, // 日期格式化 formatDateNumber: function (date) { let myYear = date.getFullYear(); let myMonth = date.getMonth() + 1; let myWeekDay = date.getDate(); return myYear + "-" + myMonth + "-" + myWeekDay }, toList: function () { wx.navigateTo({ url: '/pages/programList/programList', }) }, toLeaveMessage: function () { wx.navigateTo({ url: '/pages/leaveMessage/leaveMessage', }) }, // 媒体矩阵 swichNav: function (e) { var that = this; if (this.data.mediaCurrentTab === e.target.dataset.current) { return false; } else { that.setData({ mediaCurrentTab: e.target.dataset.current, navScrollLeft: e.target.dataset.current >= 2 ? ((e.target.dataset.current - 1) * 215) : 0 }) } }, // 获取媒体矩阵南岸发布数据 getMediaReleaseList() { let date = new Date(); let year = date.getFullYear() let month = date.getMonth() + 1 let day = date.getDate() let time = year + "-" + month + "-" + day; wx.request({ url: 'https://www.cqna.gov.cn/data/article/getNAFBArticleByDate?date=' + time, method: 'GET', success: res => { this.setData({ mediaReleaseList: res.data.data }) } }) }, gotoReleaseDetail(e) { wx.navigateTo({ url: '/pages/web/web?wxUrl=' + encodeURIComponent(e.currentTarget.dataset.url), }) }, // 获取媒体矩阵今日头条数据 getMediaHeadlineList() { wx.request({ url: 'https://www.cqna.gov.cn/data/article/getAllOfficialAccount?official=重庆市南岸区人民政府', method: 'GET', success: res => { this.setData({ mediaHeadlineList: res.data.data.jrtt }) } }) }, gotoHeadlineDetail(e) { wx.navigateTo({ url: '/pages/web/web?wxUrl=' + encodeURIComponent(e.currentTarget.dataset.url), }) }, mediaBindChange: function (e) { var that = this; that.setData({ mediaCurrentTab: e.detail.current, navScrollLeft: e.detail.current >= 2 ? ((e.detail.current - 1) * 215) : 0 }); }, getUserProfile() { wx.setStorageSync('nickname', ""); wx.setStorageSync('avatarUrl', ""); wx.getUserProfile({ desc: '获取用户信息', success: (res) => { wx.setStorageSync('nickname', res.userInfo.nickName); wx.setStorageSync('avatarUrl', res.userInfo.avatarUrl); wx.login({ success(res) { if (res.code) { //发起网络请求 data = { code: res.code } login(data).then(res => { console.log(res) wx.setStorageSync("token", res.data.data) }) } else { console.log('登录失败!' + res.errMsg) } } }) }, fail(res) { console.log("获取用户信息失败", res) } }) }, //印象南岸进入 toYxna() { wx.navigateTo({ url: "/pagesPublic/pages/yxnaJfq/yxnaJfq", }) }, toJfq: function () { wx.navigateTo({ url: '/pagesPublic/pages/yxnaJfq/yxnaJfq', }) }, toJfh: function () { wx.navigateTo({ url: '/pagesPublic/pages/yxnaJfh/yxnaJfh', }) }, toXsj: function () { wx.navigateTo({ url: '/pagesPublic/pages/yxna/yxna', }) }, toQxn: function () { wx.navigateTo({ url: '/pagesPublic/pages/yxnaQxn/yxnaQxn', }) }, gotoSjzx() { wx.navigateTo({ url: '/pages/dataCenter/dataCenter', }) }, gotoZWTJ() { wx.navigateTo({ url: '/pages/dataCenterZWTJ/dataCenterZWTJ', }) }, gotoNewsPaper() { wx.navigateTo({ url: '/pages/newsPaper/newsPaper', }) }, gotoZlwd() { wx.navigateTo({ url: '/pages/web/web?url=' + "https://www.cqna.gov.cn/ghwd/znwd/mobile/index.html", }) }, gotoDTSS(e) { const search = e.currentTarget.dataset.item if (search && search != '') { wx.navigateTo({ url: '/pages/web/web?url=' + "https://www.cqna.gov.cn/maps/sy_mobile.html&se=" + search, }) } else { wx.navigateTo({ url: '/pages/web/web?url=' + "https://www.cqna.gov.cn/maps/sy_mobile.html", }) } }, gotoMTJZ() { wx.navigateTo({ url: '/pages/web/web?url=' + "https://data.cqna.gov.cn/newMedia/officialAccounts.html", }) }, gotoSPTJ() { wx.navigateTo({ url: '/pages/web/web?url=' + "http://www.cqna.com.cn/na_Class/node_24133.html", }) }, gotoNAB() { wx.navigateTo({ url: '/pages/web/web?url=' + "http://www.cqna.com.cn/na_Class/node_24150.html", }) }, })