// pages/dangerousProject/index.js const app = getApp() Page({ /** * 页面的初始数据 */ data: { stateNav:1, timeline:[], dangerNameList:[], show: false, loadShow:false, loginName:'', userName:'', deptId:'', projectName:'', projectId:'', allPoint:0, outPoint:0, comPoint:0, fileList: [], id:'', initData:{} }, //项目切换 返回值 onProjectSelect(e){ this.onClickShow(); let projectId = e.detail.id; let projectName = e.detail.text; app.globalData.projectId = projectId; app.globalData.projectName = projectName; this.setData({ projectId:projectId, projectName:projectName, dangerNameList:[], dangerName:'', timeline:[], allPoint:0, outPoint:0, comPoint:0 }) this.onLoad(); }, onImagesArr(e){ // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式 wx.uploadFile({ //图片上传地址 url: app.globalData.reqUrl+'/weixin/security/fileUpload', filePath: e.detail[0], name: 'file', header: { "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8" }, formData: { user: 'test' }, success:res => { // 上传完成需要更新 fileList let data = JSON.parse(res.data); let fileList = this.data.fileList fileList.push({url: data.url}); this.setData({ fileList:fileList}); this.updateDanger(res.data,e.currentTarget.dataset.id) }, }); }, showPopup() { this.setData({ show: true }); }, onClose() { this.setData({ show: false }); }, onClickShow() { this.setData({ loadShow: true }); }, onClickHide() { this.setData({ loadShow: false }); }, onSelectDangerName(e){ this.getProjectDanger(e.detail.id); }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { var that = this; //加载蒙版 that.onClickShow(); //获取缓存数据 wx.getStorage({ key: 'userinfo', success:function(res){ that.setData({ loginName:res.data.loginName, userName:res.data.userName, deptId:res.data.deptId, projectName: app.globalData.projectName, projectId:app.globalData.projectId, initData:{text:app.globalData.projectName,id:app.globalData.projectId} }) that.getProjectDangerPlan(); } }) }, /** * 危大工程计划 */ getProjectDangerPlan(){ var that = this; wx.request({ url: app.globalData.reqUrl+'/weixin/security/getProjectDangerPlan', method: 'get', data: { deptId:this.data.deptId, projectId:this.data.projectId }, success: resData => { this.onClickHide(); if(resData.data.code == 200){ let array = []; for(let i = 0;i { this.onClickHide(); if(resData.data.code == 200){ let timeline = resData.data.data.dangerList; var flag = false; timeline.map(x => { if(x.fileUrl.length > 0){ x.type = 0; }else{ if(!flag){ x.type = 1 flag = true; }else{ x.type = 2; } } let fileUrl = x.fileUrl; for(let i = 0;i