You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
466 lines
14 KiB
466 lines
14 KiB
// index.js
|
|
// 获取应用实例
|
|
const app = getApp()
|
|
import api, {getIntelligentMessage,getToken,getStaffbasicinfo,clearMessage,communityOverview,overView} from "../../utils/api"
|
|
import {getInspRecord} from '../../utils/api'
|
|
import * as echarts from '../../ec-canvas/echarts';
|
|
var chart;
|
|
Page({
|
|
data: {
|
|
topDisplay:false,
|
|
selectList:['全部消息','居民信息采集','房屋信息采集','社区满意度自查'],
|
|
selectValue:0,
|
|
communitySelfInspList:[],
|
|
pageSize:5,
|
|
pageNo:1,
|
|
tableData:[],
|
|
lowerThreshold:'20',
|
|
loadMoreVisible:false,
|
|
loadMoreType: "none",
|
|
nodata:false,
|
|
emptyHouseNum:'',
|
|
catesNonIntResiNum:'',
|
|
readFlag:'0',
|
|
agencyName:'--',
|
|
ec: {
|
|
lazyLoad: true
|
|
},
|
|
resiAndhouseTotal:0,
|
|
tabList: [{
|
|
label: "居民",
|
|
value: 1
|
|
}, {
|
|
label: '房屋',
|
|
value: 2
|
|
}],
|
|
tabValue: 1
|
|
},
|
|
// 事件处理函数
|
|
onLoad: async function () {
|
|
// await this.getToken()
|
|
this.getIntelligentMessage()
|
|
// await this.getIntelligentMessage()
|
|
await this.getStaffbasicinfo()
|
|
this.setData({
|
|
statusHeight: app.globalData.deviceInfo.statusHeight,
|
|
navigationHeight: app.globalData.deviceInfo.navigationHeight,
|
|
share:app.globalData.share,
|
|
})
|
|
this.getInspRecord()
|
|
wx.loadFontFace({
|
|
family: 'PingFangSC-regular',
|
|
source: 'url("https://www.your-server.com/PingFangSC-Medium.ttf")',
|
|
success: function() {
|
|
console.log('Font loaded successfully');
|
|
},
|
|
fail: function(error) {
|
|
console.error('Font loading failed', error);
|
|
},
|
|
complete: function() {
|
|
console.log('Font loading process complete');
|
|
}
|
|
});
|
|
this.communityOverview()
|
|
},
|
|
onShareAppMessage() {
|
|
return{
|
|
title:`${this.data.agencyName}${this.data.communitySelfInspTop.monthName}月份满意度调查`,
|
|
path:'/pages/webView/webView?url=' + encodeURIComponent(this.data.communitySelfInspTop.questionnaireUrl),
|
|
imageUrl:'../../images/work/shareBg.png'
|
|
}
|
|
},
|
|
onShow(){
|
|
|
|
this.getSituation()
|
|
this.getInspRecord()
|
|
},
|
|
onPullDownRefresh() {
|
|
this.setData({
|
|
pageNo:1,
|
|
tableData:[]
|
|
})
|
|
this.getIntelligentMessage()
|
|
this.getStaffbasicinfo()
|
|
this.getInspRecord()
|
|
},
|
|
tabChange({detail}) {
|
|
this.setData({
|
|
tabValue: this.data.tabList[detail].value
|
|
})
|
|
this.communityOverview()
|
|
},
|
|
communityOverview(){
|
|
this.selectComponent('#communityOverview').init((canvas, width, height, dpr) => {
|
|
chart = echarts.init(canvas, null, {
|
|
width: width,
|
|
height: height,
|
|
devicePixelRatio: dpr // 像素比
|
|
});
|
|
canvas.setChart(chart);
|
|
|
|
let params = {
|
|
agencyId: app.globalData.user.agencyId,
|
|
orgId: app.globalData.user.agencyId,
|
|
level: app.globalData.user.level,
|
|
}
|
|
let total = null
|
|
communityOverview(params).then(({data}) => {
|
|
if(this.data.tabValue === 2) {
|
|
data = Object.entries(data).map(([key, value]) => {
|
|
let label = '';
|
|
if (key === 'selfStay') {
|
|
label = '自住房屋';
|
|
}else if (key === 'rentOut') {
|
|
label = '出租房屋';
|
|
}else if (key === 'vacantHouse') {
|
|
label = '闲置房屋';
|
|
}
|
|
if (label) {
|
|
return { label, value };
|
|
}
|
|
return null;
|
|
}).filter(item => item !== null);
|
|
total = Number(data[0].value) + Number(data[1].value)
|
|
} else {
|
|
data = Object.entries(data).map(([key, value]) => {
|
|
let label = '';
|
|
if (key === 'permanentResiCount') {
|
|
label = '常住人口';
|
|
}else if (key === 'floatingResiCount') {
|
|
label = '流动人口';
|
|
}
|
|
if (label) {
|
|
return { label, value };
|
|
}
|
|
return null;
|
|
}).filter(item => item !== null);
|
|
total = Number(data[0].value) + Number(data[1].value)
|
|
}
|
|
this.setData({
|
|
resiAndhouseTotal:total
|
|
})
|
|
console.log(data,'ssss');
|
|
let color = ["#4F94FF", "#A182FB", "#27D1A7", "#FCBF06", "#FF7108"]
|
|
|
|
var option = {
|
|
color,
|
|
tooltip: {
|
|
show: true,
|
|
textStyle: {
|
|
color: '#000',
|
|
fontSize: 14
|
|
},
|
|
formatter(params) {
|
|
if (params.name === '') {
|
|
return '';
|
|
}
|
|
return `${params.name} : ${params.percent}%`;
|
|
},
|
|
},
|
|
series: [
|
|
{
|
|
name: '',
|
|
type: 'pie',
|
|
radius: ['30%', '60%'],
|
|
center: ['50%', '50%'], // 修改为居中
|
|
avoidLabelOverlap: true,
|
|
label: {
|
|
color: '#333333',
|
|
alignTo: 'labelLine',
|
|
formatter: function (params) {
|
|
return `{name|${params.data.label}}\n{num|${params.data.value}}`;
|
|
},
|
|
minMargin: 5,
|
|
edgeDistance: 10,
|
|
lineHeight: 15,
|
|
rich: {
|
|
num: {
|
|
fontSize: 17,
|
|
color: '#333333'
|
|
},
|
|
name: {
|
|
fontSize: 14,
|
|
color: '#666666'
|
|
}
|
|
}
|
|
},
|
|
labelLine: {
|
|
length: 15,
|
|
length2: 0,
|
|
maxSurfaceAngle: 80
|
|
},
|
|
data: data
|
|
}
|
|
]
|
|
};
|
|
chart.setOption(option);
|
|
})
|
|
return chart;
|
|
});
|
|
|
|
},
|
|
getInspRecord(){
|
|
let parm ={
|
|
pageSize:1000,
|
|
pageNo:1
|
|
}
|
|
getInspRecord(parm).then(res=>{
|
|
res.data.list = res.data.list.reverse();
|
|
let curMonth = new Date().getMonth() - 0 + 1
|
|
let communitySelfInspTop = res.data.list.filter(item => item.monthName-0 === curMonth).length?res.data.list.filter(item => item.monthName-0 === curMonth)[0]:{}
|
|
let communitySelfInspList = res.data.list.filter(item => item.monthName-0 !== curMonth).splice(0,2)
|
|
this.setData({
|
|
communitySelfInspTop,communitySelfInspList,curMonth
|
|
})
|
|
// this.setData({
|
|
// communitySelfInspTop:res.data.list.splice(0,1)[0],
|
|
// communitySelfInspList:res.data.list.splice(0,2),
|
|
// })
|
|
app.globalData.questionnaireUrl = this.data.communitySelfInspTop.questionnaireUrl
|
|
}).catch(err=>{
|
|
wx.hideLoading()
|
|
console.log(err);
|
|
})
|
|
|
|
|
|
},
|
|
toDetaill(e){
|
|
wx.navigateTo({
|
|
url: `/subpages/communitySelfInsp/pages/synthesis/synthesis?inspRecordId=${encodeURIComponent(e.currentTarget.dataset.item.id)}&qrCodeImgUrl=${encodeURIComponent(e.currentTarget.dataset.item.qrCodeImgUrl)}&agencyName=${encodeURIComponent(e.currentTarget.dataset.item.agencyName)}&monthName=${encodeURIComponent(e.currentTarget.dataset.item.monthName)}&questionnaireUrl=${encodeURIComponent(e.currentTarget.dataset.item.questionnaireUrl)}&status=${encodeURIComponent(e.currentTarget.dataset.item.status)}`
|
|
})
|
|
},
|
|
|
|
toSynthesis(){
|
|
wx.navigateTo({
|
|
url: `/subpages/communitySelfInsp/pages/synthesis/synthesis?inspRecordId=${encodeURIComponent(this.data.communitySelfInspTop.id)}&qrCodeImgUrl=${encodeURIComponent(this.data.communitySelfInspTop.qrCodeImgUrl)}&agencyName=${encodeURIComponent(this.data.communitySelfInspTop.agencyName)}&monthName=${encodeURIComponent(this.data.communitySelfInspTop.monthName)}&questionnaireUrl=${encodeURIComponent(this.data.communitySelfInspTop.questionnaireUrl)}&status=${encodeURIComponent(this.data.communitySelfInspTop.status)}`,
|
|
})
|
|
},
|
|
toHistoryQuery(){
|
|
wx.navigateTo({
|
|
url: '/subpages/communitySelfInsp/pages/historyQuery/historyQuery',
|
|
})
|
|
},
|
|
onScrollToLower(e){
|
|
if (this.data.loadMoreType === 'more') {
|
|
this.setData({
|
|
loadMoreVisible: true,
|
|
})
|
|
this.data.pageNo += 1
|
|
this.getIntelligentMessage()
|
|
}
|
|
},
|
|
getIntelligentMessage(){
|
|
this.setData({
|
|
loadMoreVisible: true,
|
|
nodata: false,
|
|
loadMoreType: "more",
|
|
tableData:[]
|
|
})
|
|
const parm = {
|
|
limit:this.data.pageSize,
|
|
page:this.data.pageNo,
|
|
readFlag:this.data.readFlag
|
|
}
|
|
getIntelligentMessage(parm).then(res=>{
|
|
res.data.list.forEach(item => {
|
|
if (item.msgType === 'resident_base_info') {
|
|
item.typeName = '居民信息采集'
|
|
} else if (item.msgType === 'community_house') {
|
|
item.typeName = '房屋信息采集'
|
|
} else if (item.msgType === 'resident_categiry') {
|
|
item.typeName='数据更新提醒'
|
|
}else if (item.msgType === 'srap_confirm') {
|
|
item.typeName='服务更新提醒'
|
|
}
|
|
})
|
|
console.log( res.data.list);
|
|
this.setData({
|
|
loadMoreType: res.data.list.length === this.data.pageSize ? 'more' : 'none',
|
|
tableData: this.data.tableData.concat(res.data.list),
|
|
})
|
|
console.log(this.data.tableData)
|
|
if (this.data.tableData.length == 0) {
|
|
this.setData({
|
|
loadMoreVisible: false,
|
|
nodata: true,
|
|
})
|
|
|
|
}
|
|
|
|
}).catch(err=>{
|
|
console.log(err);
|
|
this.setData({
|
|
loadMoreVisible: false,
|
|
nodata: true,
|
|
})
|
|
})
|
|
},
|
|
moreNews(){
|
|
wx.navigateTo({
|
|
url: '../../subpages/morenews/pages/morenews/morenews',
|
|
})
|
|
},
|
|
getToken(){
|
|
const parm = {
|
|
wxCode:'',
|
|
app:'gov',
|
|
client:'wxmp',
|
|
appId:'wx6b8716e63abe1b39'
|
|
}
|
|
wx.showLoading({
|
|
title: '加载中...',
|
|
})
|
|
wx.login({
|
|
success: (res) => {
|
|
parm.wxCode = res.code
|
|
getToken(parm).then(res=>{
|
|
wx.hideLoading()
|
|
if(res.code === 0){
|
|
wx.setStorageSync('token', res.data.token)
|
|
}else{
|
|
wx.reLaunch({
|
|
url: '/pages/login/login',
|
|
})
|
|
}
|
|
}).catch(err=>{
|
|
console.log(err);
|
|
})
|
|
},
|
|
})
|
|
},
|
|
getStaffbasicinfo(){
|
|
getStaffbasicinfo().then(res=>{
|
|
app.globalData.user = res.data;
|
|
this.setData({
|
|
agencyName:res.data.agencyName
|
|
})
|
|
}).catch(err=>{
|
|
console.log(err);
|
|
wx.redirectTo({
|
|
url: '/pages/login/login',
|
|
})
|
|
})
|
|
},
|
|
handleChangeFilter(e){
|
|
this.setData({
|
|
selectValue:e.detail.value,
|
|
tableData:[],
|
|
})
|
|
this.getIntelligentMessage()
|
|
},
|
|
handelClickClear(){
|
|
clearMessage().then(res=>{
|
|
this.setData({
|
|
tableData:[],
|
|
pageNo:1
|
|
})
|
|
this.getIntelligentMessage()
|
|
}).catch(err=>{
|
|
console.log(err);
|
|
})
|
|
},
|
|
toDetail(e){
|
|
this.clearOneMessage(e.currentTarget.dataset.item.id)
|
|
if(e.currentTarget.dataset.item.msgType == 'resident_base_info'){
|
|
wx.navigateTo({
|
|
url: `/subpages/searchResult/pages/resiInfo/resiInfo?resiId=${e.currentTarget.dataset.item.targetId}`,
|
|
})
|
|
}else if(e.currentTarget.dataset.item.msgType == 'community_house'){
|
|
wx.navigateTo({
|
|
url: `/subpages/addhouse/pages/addhouse/addhouse?type=edit&houseId=${e.currentTarget.dataset.item.targetId}`,
|
|
})
|
|
}else if(e.currentTarget.dataset.item.msgType == 'resident_category'){
|
|
wx.navigateTo({
|
|
url: `/subpages/residentCategory/pages/residentCategory/residentCategory?category=${e.currentTarget.dataset.item.category}`,
|
|
})
|
|
}
|
|
this.setData({
|
|
[`tableData[${e.currentTarget.dataset.index}].readFlag`]:'1'
|
|
})
|
|
},
|
|
clearOneMessage(id){
|
|
let parm= {
|
|
msgId:id
|
|
}
|
|
api.clearOneMessage(parm).then(res=>{
|
|
console.log(res);
|
|
}).catch(err=>{
|
|
console.log(err);
|
|
})
|
|
},
|
|
// 人房信息采集
|
|
getSituation(){
|
|
wx.showLoading({
|
|
title: '加载中',
|
|
})
|
|
overView().then(res=>{
|
|
this.setData({
|
|
emptyHouseNum: this.formatNumberWithCommas(res.data.emptyHouseNum),
|
|
catesNonIntResiNum:this.formatNumberWithCommas(res.data.catesNonIntResiNum),
|
|
collectedHouseCount:this.formatNumberWithCommas(res.data.totalHouseNum),
|
|
collectedPopulationCount:this.formatNumberWithCommas(res.data.totalResiNum),
|
|
})
|
|
wx.hideLoading()
|
|
}).catch(err=>{
|
|
wx.hideLoading()
|
|
console.log(err);
|
|
})
|
|
},
|
|
formatNumberWithCommas(number) {
|
|
return number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
},
|
|
|
|
onAddResident(){
|
|
wx.navigateTo({
|
|
url: '../../subpages/addResi/pages/addResi/addResi',
|
|
})
|
|
},
|
|
onAddHouseLL(){
|
|
wx.navigateTo({
|
|
url: '../../subpages/addhouse/pages/addhouse/addhouse',
|
|
})
|
|
},
|
|
noHouse(){
|
|
wx.navigateTo({
|
|
url: '../../subpages/nohouse/pages/nohouse/nohouse',
|
|
})
|
|
},
|
|
onresno(){
|
|
wx.navigateTo({
|
|
url: '../../subpages/resnoinformation/pages/resnoinformation/resnoinformation',
|
|
})
|
|
},
|
|
toDemandCheck(){
|
|
wx.navigateTo({
|
|
url: '../../subpages/demandCheck/pages/dissatisfied/demandCheck/demandCheck',
|
|
})
|
|
},
|
|
recognitionCard(){
|
|
wx.navigateTo({
|
|
url: '../../subpages/OCRCard/pages/index/index',
|
|
})
|
|
},
|
|
door(){
|
|
wx.scanCode({
|
|
success: (res) => {
|
|
console.log(res);
|
|
console.log(res.result);
|
|
const houseIdMatch = res.result.match(/&houseId=([^&]*)/);
|
|
const houseIdValue = houseIdMatch ? houseIdMatch[1] : null;
|
|
wx.navigateTo({
|
|
url: `/subpages/house/pages/housePortrait/housePortrait?resiId=${houseIdValue}`,
|
|
|
|
})
|
|
},
|
|
fail: (err) => {
|
|
console.error(err);
|
|
}
|
|
})
|
|
},
|
|
IDCard(){
|
|
wx.navigateTo({
|
|
url: '../../subpages/OCRCard/pages/index/index',
|
|
})
|
|
}
|
|
|
|
})
|
|
|