| 
					
				 | 
			
			
				@@ -481,7 +481,63 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				               response.msg = error.toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           ctx.body = response; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         * 项目管理授权页面 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         * @param {Object} ctx - egg全局页面 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         * @return {void} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        async management(ctx) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          const data = ctx.data; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          // 获取系统维护信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          const maintainData = await ctx.service.maintain.getDataById(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          if (!ctx.app.config.is_debug) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              await ctx.service.maintain.syncMaintainData(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          let account, project; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              if (ctx.session.loginError !== null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                  throw ctx.session.loginError; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              if (!data) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                  throw '参数有误'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              project = await ctx.service.project.getDataByCondition({ code: data.code }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              if (!project) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                throw '未找到该项目'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              account = await ctx.service.projectAccount.getDataByCondition({ project_id: project.id, account: data.account }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              if (!account) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                  throw '您无权限登录系统。'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              if (account.enable !== 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                throw '该账号已被停用,请联系销售人员'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const result = await ctx.service.projectAccount.accountLogin({ project, accountData: account }, 3); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (!result) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                throw '登录出错'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ctx.redirect('/dashboard'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          } catch (error) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              // this.log(error); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              console.log(error); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              ctx.session.loginError = error; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          const errorMessage = ctx.session.loginError; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          // 显示完删除 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          ctx.session.loginError = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          const renderData = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              maintainData, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              maintainConst, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              errorMessage, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              projectData: project, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              accountData: account, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          await ctx.render('login/login_management.ejs', renderData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     return LoginController; 
			 |