74 lines
1.7 KiB
JavaScript
74 lines
1.7 KiB
JavaScript
|
import {
|
||
|
getToken,
|
||
|
setUserInfo,
|
||
|
getUserInfo
|
||
|
} from '../../utils/auth'
|
||
|
import {
|
||
|
findMyProjectList,
|
||
|
findProSubDeptsUserInfo,
|
||
|
} from '../../api/project'
|
||
|
const app = getApp()
|
||
|
Page({
|
||
|
|
||
|
/**
|
||
|
* 页面的初始数据
|
||
|
*/
|
||
|
data: {
|
||
|
proCount:0,
|
||
|
projectInfoList:[],
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面加载
|
||
|
*/
|
||
|
onLoad: function (options) {
|
||
|
if (getToken()) {
|
||
|
this.getMyProjectList();
|
||
|
} else {
|
||
|
console.log("未查询到Token...{}...准备重新登录")
|
||
|
wx.redirectTo({
|
||
|
url: '../../pages/login/login',
|
||
|
})
|
||
|
}
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 查询
|
||
|
* 用户项目信息
|
||
|
* 根据项目配置进入不同页面...
|
||
|
*/
|
||
|
getMyProjectList: function () {
|
||
|
findMyProjectList().then(res=>{
|
||
|
if(res.code==200){
|
||
|
res.rows.forEach(item =>{
|
||
|
item.videoNum = 0;
|
||
|
item.warningCount = 0;
|
||
|
item.monitoringCount = 0;
|
||
|
});
|
||
|
app.globalData.projectInfoList = res.rows;
|
||
|
this.setData({
|
||
|
proCount:res.total,
|
||
|
projectInfoList:res.rows
|
||
|
})
|
||
|
}
|
||
|
});
|
||
|
},
|
||
|
|
||
|
//项目详情
|
||
|
checkProject:function(even){
|
||
|
//赋值到公共参数
|
||
|
app.globalData.useProjectId = even.currentTarget.dataset['id'];
|
||
|
app.globalData.useProjectName = even.currentTarget.dataset['name'];
|
||
|
findProSubDeptsUserInfo(app.globalData.useProjectId).then(detail=>{
|
||
|
if(detail.code==200){
|
||
|
let userInfo = getUserInfo();
|
||
|
userInfo.projectUserInfo = detail.data;
|
||
|
setUserInfo(userInfo);
|
||
|
//单项目直接进入项目页面
|
||
|
wx.redirectTo({
|
||
|
url: '../project_info/index',
|
||
|
})
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
})
|