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.
493 lines
14 KiB
493 lines
14 KiB
import { bannerList, getAllSituation, getSurvey, getToken, getIndexPanel } from '../../api/index'
|
|
import { checkUpdateAvatar, updateAvatar } from '../../api/clerkOnline'
|
|
import { logout } from '../../api/setUp'
|
|
// import * as echarts from '../../components/ec-canvas/echarts.js'
|
|
|
|
// function setOption(chart: any, chartData: AnyArray, color: AnyArray) {
|
|
// const option = {
|
|
// color: color,
|
|
// series: [
|
|
// {
|
|
// type: 'pie',
|
|
// radius: ['70%', '95%'],
|
|
// silent: true,
|
|
// avoidLabelOverlap: false,
|
|
// label: {
|
|
// show: false
|
|
// },
|
|
// labelLine: {
|
|
// show: false,
|
|
// normal: {
|
|
// show: false
|
|
// }
|
|
// },
|
|
// itemStyle: {
|
|
// borderColor: '#fff',
|
|
// borderWidth: '2',
|
|
// },
|
|
// data: chartData
|
|
// }
|
|
// ]
|
|
// }
|
|
// chart.setOption(option)
|
|
// }
|
|
Page({
|
|
data: {
|
|
indexPanel: [],
|
|
banner: [],
|
|
indicatorDots: false,//指示点
|
|
autoplay: false,//true,//自动播放
|
|
circular: false,//衔接滑动
|
|
interval: 2000, //自动播放间隔时长(ms)
|
|
duration: 500,//幻灯片切换时长(ms)
|
|
currentSwiper: 0,
|
|
allheight: 0,
|
|
survey: {
|
|
issueTotal: 0,//议题总数
|
|
unpassedProject: 0,//未转项目
|
|
passedProject: 0,//已转项目
|
|
},//议题总数
|
|
allSituation: {
|
|
userTotal: 0,//用户总数
|
|
companyRepresentTotal: 0,//其中企业代表数
|
|
partyNumber: 0,//党员总数
|
|
userNumber: 0,//居民总数
|
|
},//用户
|
|
chartDataA: [],
|
|
colorA: [],
|
|
chartDataB: [],
|
|
colorB: [],
|
|
ec: {},
|
|
checkUpdateAvatar: false,
|
|
avatar: '',
|
|
userInfo: '',
|
|
propagation: true,
|
|
joinFlag: true
|
|
},
|
|
async onLoad() {
|
|
if (wx.getStorageSync('token')) {
|
|
await this.refreshToken()
|
|
} else {
|
|
wx.redirectTo({
|
|
url: '/pages/login/login'
|
|
})
|
|
}
|
|
await this.checkUpdateAvatar()
|
|
await this.getIndexPanel()
|
|
await this.getBannerList()
|
|
await this.getAllSituation()
|
|
await this.getSurvey()
|
|
this.ecComponentA = this.selectComponent('#mychart-dom-bar-a')
|
|
this.ecComponentB = this.selectComponent('#mychart-dom-bar-b')
|
|
},
|
|
/**
|
|
* 获得首页功能权限
|
|
*/
|
|
async getIndexPanel() {
|
|
let that = this;
|
|
try {
|
|
const res: any = await getIndexPanel()
|
|
var zzjg_ = {
|
|
zzjg_: false
|
|
}
|
|
res.data.push(zzjg_)
|
|
var dqhd_ = {
|
|
dqhd_: false
|
|
}
|
|
res.data.push(dqhd_)
|
|
var zlph_ = {
|
|
zlph_: false
|
|
}
|
|
res.data.push(zlph_)
|
|
var jcsk_ = {
|
|
jcsk_: false
|
|
}
|
|
res.data.push(jcsk_)
|
|
var sjzx_ = {
|
|
sjzx_: false
|
|
}
|
|
res.data.push(sjzx_)
|
|
var gbpj_ = {
|
|
gbpj_: false
|
|
}
|
|
res.data.push(gbpj_)
|
|
var djsk_ = {
|
|
djsk_: false
|
|
}
|
|
res.data.push(djsk_)
|
|
|
|
// 所有等于false的都是后台为配置的权限的
|
|
for (var i = 0; i < res.data.length; i++) {
|
|
if (res.data[i].navCode == '10011') {//组织架构
|
|
for (var i = 0; i < res.data.length; i++) {
|
|
if (res.data[i].zzjg_ == false) {
|
|
res.data[i].zzjg_ = true
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
for (var i = 0; i < res.data.length; i++) {
|
|
if (res.data[i].navCode == '10012') {//党建实况
|
|
for (var i = 0; i < res.data.length; i++) {
|
|
if (res.data[i].djsk_ == false) {
|
|
res.data[i].djsk_ = true
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
for (var i = 0; i < res.data.length; i++) {
|
|
if (res.data[i].navCode == '10013') {//基层实况
|
|
for (var i = 0; i < res.data.length; i++) {
|
|
if (res.data[i].jcsk_ == false) {
|
|
res.data[i].jcsk_ = true
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
for (var i = 0; i < res.data.length; i++) {
|
|
if (res.data[i].navCode == '10014') {//治理排行
|
|
for (var i = 0; i < res.data.length; i++) {
|
|
if (res.data[i].zlph_ == false) {
|
|
res.data[i].zlph_ = true
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
for (var i = 0; i < res.data.length; i++) {
|
|
if (res.data[i].navCode == '10015') {//书记在线
|
|
for (var i = 0; i < res.data.length; i++) {
|
|
if (res.data[i].sjzx_ == false) {
|
|
res.data[i].sjzx_ = true
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
for (var i = 0; i < res.data.length; i++) {
|
|
if (res.data[i].navCode == '10016') {//干部评价
|
|
for (var i = 0; i < res.data.length; i++) {
|
|
if (res.data[i].gbpj_ == false) {
|
|
res.data[i].gbpj_ = true
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
// res.data 重新排序
|
|
var panelList = [];
|
|
for (var i = 0; i < res.data.length; i++) {
|
|
if (res.data[i].navCode == '10011') {//组织架构
|
|
panelList.push(res.data[i])
|
|
} else if (res.data[i].zzjg_ == false) {
|
|
panelList.push(res.data[i])
|
|
}
|
|
};
|
|
for (var i = 0; i < res.data.length; i++) {
|
|
if (res.data[i].navCode == '10012') {//党建实况
|
|
panelList.push(res.data[i])
|
|
} else if (res.data[i].djsk_ == false) {
|
|
panelList.push(res.data[i])
|
|
}
|
|
};
|
|
|
|
for (var i = 0; i < res.data.length; i++) {
|
|
if (res.data[i].navCode == '10013') {//基层实况
|
|
panelList.push(res.data[i])
|
|
} else if (res.data[i].jcsk_ == false) {
|
|
panelList.push(res.data[i])
|
|
}
|
|
};
|
|
|
|
for (var i = 0; i < res.data.length; i++) {
|
|
if (res.data[i].navCode == '10014') {//治理排行
|
|
panelList.push(res.data[i])
|
|
} else if (res.data[i].zlph_ == false) {
|
|
panelList.push(res.data[i])
|
|
}
|
|
};
|
|
|
|
for (var i = 0; i < res.data.length; i++) {
|
|
if (res.data[i].navCode == '10015') {//书记在线
|
|
panelList.push(res.data[i])
|
|
} else if (res.data[i].sjzx_ == false) {
|
|
panelList.push(res.data[i])
|
|
}
|
|
};
|
|
|
|
for (var i = 0; i < res.data.length; i++) {
|
|
if (res.data[i].navCode == '10016') {//干部评价
|
|
panelList.push(res.data[i])
|
|
} else if (res.data[i].gbpj_ == false) {
|
|
panelList.push(res.data[i])
|
|
}
|
|
};
|
|
that.setData({
|
|
indexPanel: panelList,
|
|
})
|
|
} catch (err) {
|
|
console.log(err)
|
|
}
|
|
},
|
|
// 轮播
|
|
getBannerList: function () {
|
|
let that = this
|
|
bannerList().then((res: any) => {
|
|
that.setData({
|
|
banner: res.data
|
|
})
|
|
})
|
|
},
|
|
// banner轮播
|
|
swiperChange: function (e: { detail: { current: any } }) {
|
|
this.setData({
|
|
currentSwiper: e.detail.current
|
|
})
|
|
},
|
|
//数据分析小程序首页-用户接口
|
|
getAllSituation: function () {
|
|
let that = this
|
|
let params = {
|
|
// generateDate: utils.formatTimestamp(new Date()),
|
|
deptId: ''//wx.getStorageSync('childrenID')
|
|
}
|
|
getAllSituation(params).then((res: any) => {
|
|
// (res.data.list.unpassedProject / 10000).toFixed(2)
|
|
that.setData({
|
|
allSituation: res.data
|
|
})
|
|
})
|
|
},
|
|
|
|
//数据分析小程序首页接口-议题接口
|
|
getSurvey: function () {
|
|
let that = this
|
|
let params = {
|
|
deptId: ''//wx.getStorageSync('childrenID')
|
|
}
|
|
// issueTotal: 0,//议题总数
|
|
// unpassedProject: 0,//未转项目
|
|
// passedProject: 0,//已转项目
|
|
getSurvey(params).then((res: any) => {
|
|
that.setData({
|
|
survey: res.data.list,
|
|
})
|
|
|
|
// if (that.data.survey.issueTotal > 9999) {
|
|
// that.setData({
|
|
// survey: {
|
|
// issueTotalA: that.data.survey.issueTotal.toFixed(2)
|
|
// }
|
|
// })
|
|
// };
|
|
|
|
// if (that.data.survey.unpassedProject > 9999) {
|
|
// that.setData({
|
|
// survey: {
|
|
// unpassedProjectA: that.data.survey.unpassedProject.toFixed(2)
|
|
// }
|
|
// })
|
|
// };
|
|
|
|
// if (that.data.survey.passedProject > 9999) {
|
|
// that.setData({
|
|
// survey: {
|
|
// passedProjectA: that.data.survey.passedProject.toFixed(2)
|
|
// }
|
|
// })
|
|
// };
|
|
})
|
|
|
|
},
|
|
// init_a() {
|
|
// // @ts-ignore
|
|
// this.ecComponentA.init((canvas: any, width: any, height: any) => {
|
|
// const chart = echarts.init(canvas, null, {
|
|
// width: width,
|
|
// height: height
|
|
// })
|
|
// setOption(chart, this.data.chartDataA, this.data.colorA)
|
|
// return chart
|
|
// })
|
|
// },
|
|
|
|
// init_b() {
|
|
// this.ecComponentB.init((canvas: any, width: any, height: any) => {
|
|
// const chart = echarts.init(canvas, null, {
|
|
// width: width,
|
|
// height: height
|
|
// })
|
|
// setOption(chart, this.data.chartDataB, this.data.colorB)
|
|
// return chart
|
|
// })
|
|
// },
|
|
|
|
// 判断登录
|
|
refreshToken() {
|
|
let that = this
|
|
wx.login({
|
|
success(res) {
|
|
let wxCode = res.code
|
|
if (wxCode) {
|
|
getToken(wxCode).then(function (res: { data: { registerState: string; token: any; userTagKey: any; deptDataScopeList: any } }) {
|
|
if (res.data.registerState == '0') {
|
|
wx.redirectTo({
|
|
url: '/pages/login/login'
|
|
})
|
|
} else {
|
|
wx.setStorageSync('token', res.data.token)
|
|
wx.setStorageSync('userTagKey', res.data.userTagKey)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
})
|
|
},
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
async onPullDownRefresh() {
|
|
this.setData({
|
|
pageIndex: 1,
|
|
loadVisible: false,
|
|
})
|
|
await this.checkUpdateAvatar()
|
|
await this.getIndexPanel()
|
|
await this.getBannerList()
|
|
await this.getAllSituation()
|
|
await this.getSurvey()
|
|
this.ecComponentA = this.selectComponent('#mychart-dom-bar-a')
|
|
this.ecComponentB = this.selectComponent('#mychart-dom-bar-b')
|
|
wx.stopPullDownRefresh();
|
|
},
|
|
toActDetail(e: AnyObject) {
|
|
wx.navigateTo({ url: `/pages/typicalCases/typicalCases?id=${e.currentTarget.dataset.id}` });
|
|
},
|
|
// 跳转到用户分析模块
|
|
navigateToUserNum() {
|
|
wx.navigateTo({
|
|
url: '/subpages/userNum/pages/userAnalysis/userAnalysis'
|
|
})
|
|
},
|
|
// 跳转到议题总数详情
|
|
navigateToyt() {
|
|
wx.navigateTo({
|
|
url: '/subpages/issue/pages/topicsNumDetail/topicsNumDetail'
|
|
})
|
|
},
|
|
// 跳转到基层实况首页
|
|
navigateToReality() {
|
|
wx.navigateTo({
|
|
url: '/subpages/reality/pages/realityIndex/realityIndex'
|
|
})
|
|
},
|
|
// 跳转到党建实况首页
|
|
navigateToBasicReality() {
|
|
wx.navigateTo({
|
|
url: '/subpages/basicReality/pages/index/index'
|
|
})
|
|
},
|
|
//组织架构
|
|
toOrganizationStree() {
|
|
wx.navigateTo({
|
|
url: '/subpages/organization/pages/organizationStree/organizationStree'
|
|
})
|
|
},
|
|
//治理排行
|
|
navigateTogovernRanking() {
|
|
wx.navigateTo({
|
|
url: '/subpages/governRanking/pages/governRanking/governRanking'
|
|
})
|
|
},
|
|
// 干部评价
|
|
toLeaderComment() {
|
|
wx.navigateTo({ url: '/subpages/leaderModel/pages/leaderIndex/leaderIndex' });
|
|
},
|
|
// 书记在线
|
|
async getInfo(e: any) {
|
|
console.log('3', e)
|
|
if (e.detail.errMsg == 'getUserInfo:ok') {
|
|
// 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
|
|
wx.showLoading({
|
|
title: '加载中.....', //提示的内容,
|
|
mask: true, //显示透明蒙层,防止触摸穿透,
|
|
success: res => { }
|
|
});
|
|
this.setData({
|
|
avatar: e.detail.userInfo.avatarUrl,
|
|
})
|
|
await this.updateAvatar()
|
|
wx.setStorageSync('isBackOpen', false)
|
|
wx.navigateTo({ url: '/subpages/clerkOnline/pages/myGroup/myGroup' });
|
|
wx.hideLoading();
|
|
} else {
|
|
wx.setStorageSync('isBackOpen', false)
|
|
wx.navigateTo({ url: '/subpages/clerkOnline/pages/myGroup/myGroup' });
|
|
wx.hideLoading();
|
|
}
|
|
},
|
|
// 不需要授权的情况下
|
|
goclerkOnline() {
|
|
if (this.data.joinFlag == false) {
|
|
wx.showModal({
|
|
title: '', //提示的标题,
|
|
content: '该用户未加入书记在线功能!', //提示的内容,
|
|
showCancel: false, //是否显示取消按钮,
|
|
confirmText: '确定', //确定按钮的文字,默认为取消,最多 4 个字符,
|
|
confirmColor: '#3CC51F', //确定按钮的文字颜色,
|
|
});
|
|
return
|
|
}
|
|
if (this.data.checkUpdateAvatar) { return }
|
|
wx.setStorageSync('isBackOpen', false)
|
|
wx.navigateTo({ url: '/subpages/clerkOnline/pages/myGroup/myGroup' });
|
|
},
|
|
async checkUpdateAvatar() {
|
|
let res: any = await checkUpdateAvatar()
|
|
this.setData({
|
|
checkUpdateAvatar: res.data.updateFlag,
|
|
joinFlag: res.data.joinFlag
|
|
})
|
|
},
|
|
// 暂未开通模块显示敬请期待
|
|
showInspect() {
|
|
wx.showToast({
|
|
title: '此功能暂未开放',
|
|
icon: 'none',
|
|
duration: 1000
|
|
})
|
|
},
|
|
async updateAvatar() {
|
|
let obj = {
|
|
avatar: this.data.avatar
|
|
}
|
|
let res: any = await updateAvatar(obj)
|
|
},
|
|
//退出登录2020.06.04
|
|
toOutCallBack: function () {
|
|
wx.showModal({
|
|
title:'',
|
|
content:'确定退出当前账号',
|
|
confirmColor: '#29b9a5',
|
|
success (res) {
|
|
if (res.confirm) {
|
|
logout().then(function (res) {
|
|
console.log(wx.getStorageSync('token') + "************" + wx.getStorageSync('userTagKey'))
|
|
wx.setStorageSync('token', '')
|
|
wx.setStorageSync('userTagKey', '')
|
|
wx.setStorageSync('currentGrid', '')
|
|
console.log(wx.getStorageSync('token') + "************" + wx.getStorageSync('userTagKey'))
|
|
wx.reLaunch({
|
|
url: '../../pages/login/login'
|
|
})
|
|
})
|
|
} else if (res.cancel) {
|
|
console.log('取消退出登录')
|
|
}
|
|
}
|
|
})
|
|
}
|
|
})
|
|
|