Commit 22a21a63 by 蒋勇

d

parent 325f757a
......@@ -132,7 +132,7 @@ class CtlBase {
pobj.userid = req.session.user ? req.session.user.id : null;
var tocompany = req.session.tocompany;
if (!req.session.app) {
if (!req.session.app || qobj.toKey) {
var appkey = qobj.appKey;
var tokey = qobj.toKey;
if (appkey) {
......
......@@ -202,6 +202,43 @@ class UserCtl extends CtlBase {
return system.getResultFail(-1, "账号或密码有误.");
}
}
async sysManageForApp(pobj, qobj, req){
var user=req.session.user;
var u={userName:user.userName,password:user.password,mobile:user.mobile,owner_id:pobj.id};
var appid = req.session.app.id;
var jumpUrl = req.session.app.authUrl;
if (req.session.toapp) {
jumpUrl = req.session.toapp.authUrl;
u.isNavto=true;
//state为p_app表中appkey
} else{
u.isNavto=false;
}
//登录其它应用,是当前应用的用户要进入其它应用,上下文是当前应用,用户是当前应用的用户
//这种场景是重用目标应用时,比如管理平台重用
//非重用目标应用,需要切换为目标应用的用户
//而要进入其它应用切换身份,需要在设置上下文时,设为目标应用的ID
u.app_id = appid;
var existedUser = await this.service.getUserByUserNamePwd(u);
if (existedUser != null) {
if (appid != settings.platformid) {//非平台应用
await this.cacheManager["OpenCodeCache"].cache(req.session.id, existedUser, 60);
jumpUrl = jumpUrl + "?code=" + req.session.id;
if (req.session.toapp) {
//srcKey是进入到平台管理后,显示来源APP的信息;进入其它应用时,也传递以备后用
jumpUrl = jumpUrl + "&srcKey=" + req.session.app.appkey;
}
}
if (!existedUser.isEnabled) {
return system.getResultFail(system.waitAuditApp, "您的账户处于待审核等待启用状态.");
}else{
return system.getResult({ user: existedUser, jumpUrl: jumpUrl });
}
}else{
return system.getResultFail(-1, "无权进入本系统,请联系服务提供商");
}
}
async login(pobj, qobj, req) {
var appid = req.session.app.id;
var jumpUrl = req.session.app.authUrl;
......
......@@ -194,8 +194,10 @@ module.exports = {
"bizs": {
"docquery": {"title": "查看API文档", "config": null, "path": "/docquery", "comname": "docquery"},
"login": {"title": "登录", "config": null, "path": "/login", "comname": "login"},
"tlogin": {"title": "登录", "config": null, "path": "/tlogin", "comname": "tlogin"},
"register": {"title": "注册", "config": null, "path": "/register", "comname": "register"},
"home": {"title": "前台首页", "config": null, "path": "/", "comname": "home"},
"gtbhome": {"title": "个体宝首页", "config": null, "path": "/gtbhome", "comname": "gtbhome"},
"admin": {"title": "后台首页", "config": null, "path": "/index", "comname": "admin"},
"appconfig": {"title": "应用配置", "config": null, "path": "/appconfig", "comname": "appconfig"},
"approle": {"title": "角色", "config": null, "path": "/approle", "comname": "approle"},
......
......@@ -3,11 +3,20 @@ var system = require("../../base/system");
var metaCtl=system.getObject("web.common.metaCtl");
var userCtl=system.getObject("web.auth.userCtl");
module.exports = function (app) {
app.get("/gtb",async function(req,res){
console.log(req.hostname);
var appinfo=await metaCtl.getAppInfo(req);
res.render("gtb",appinfo);
});
app.get("/auth",async function(req,res){
var code=req.query.code;
var srcKey=req.query.srcKey;
var companyKey=req.query.companyKey;
var gtb=req.query.gtb;
if(!code){
if(gtb){
return res.redirect("/gtb/#/gtbhome");
}
return res.redirect("/");
}else{
await userCtl.authByCode(req);
......
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="keywords" content="PAAS 开放平台">
<meta name="viewport" content="width=device-width, initial-scale=0.8, maximum-scale=0.8, user-scalable=1">
<title id="idtitle">个体宝</title>
<link rel="stylesheet" href="/css/ele/index_2.5.4.css">
<link rel="stylesheet" href="/css/pagecom.css">
<link rel="stylesheet" href="/css/fontawesome/css/font-awesome.min.css">
<link rel="stylesheet" href="/css/fontawesome/css/toolicon-style.css">
<link rel="stylesheet" href="/css/fontface-timely.css">
<script src="/js/vue/vue.min_2.6.10.js"></script>
<script src="/js/vue/vue-router.min.js"></script>
<script src="/js/vue/vuex.min.js"></script>
<script src="/js/ele/index_2.5.4.js"></script>
<script src="/js/vue/axios.min.js"></script>
<script>
//缓存当前域名对应的公司信息,公司、页脚、银行账号---全局变量
var appinfo = JSON.parse(unescape('<%=appinfo%>'));
//缓存当前的基础组件列表
var companyinfo= JSON.parse(unescape('<%=company%>'));
if(companyinfo.status && companyinfo.status==-1){
companyinfo=null;
}
var tocompanyinfo= JSON.parse(unescape('<%=tocompany%>'));
if(tocompanyinfo.status && tocompanyinfo.status==-1){
tocompanyinfo=null;
}
</script>
<style>
body{
margin: 0px;
padding: 0px;
font-size: 14px;
}
.app-main{
width:100%;
height:100%;
background:url("<%='/imgs/bklogin.png'%>") no-repeat;background-size: cover;
box-sizing: border-box;
}
.app-header{
display: flex;
justify-content:space-between;
color: white;
padding: 15px;
box-sizing: border-box;
}
.app-stage{
display: flex;
width: 100%;
padding: 5px;
box-sizing: border-box;
}
.app-stage .rightcontent{
flex-grow:1;
box-sizing: border-box;
}
.app-stage .rightcontent .el-card__body {
height: 100%;
}
.app-stage .rightcontent >.el-card{
border-radius: 0px;
height: 100%;
box-shadow:unset;
box-sizing: border-box;
}
#appName{
font-size: 30px;
font-family:MicrosoftYaHei;
cursor: pointer;
}
.el-button--text{
color: white
}
.activeColor{
color:deepskyblue;
}
</style>
</head>
<body>
<div id="app" v-loading="loading" class="app-main" style="visibility:hidden">
<div id="app-header" class="app-header">
<div id="appName" >
<span @click=appclick> </span>
<span style="font-size:16px;" v-if="currentCompany">
<span style="font-size:20px" class="fa fa-home"></span>
<span v-if="currentUser && currentUser.owner && currentUser.owner.id!=1">{{currentUser.owner.name}}</span>
<!-- <span v-else>{{currentCompany.name}}</span> -->
</span>
</div>
<div id="login">
<gsb-button-group v-if="!currentUser" @select="onselect" ikey="login" :btns="logins"></gsb-button-group>
<span v-if="currentUser">欢迎您,{{currentUser.nickName}}<el-button @click="exitclick" type="text" icon="el-icon-setting">退出</el-button></span>
<!-- <span style="cursor:pointer" @click="settingclick" v-if="(currentUser && currentUser.roles.indexOf('common')>=0) || (currentUser && currentUser.isSuper)"><i class="el-icon-setting"></i>后台管理</span> -->
</div>
</div>
<div id="app-stage" class="app-stage">
<div class="rightcontent">
<transition name="slide-fade">
<router-view>
</router-view>
</transition>
</div>
</div>
</div>
<script src="/js/vue/jquery.min.js"></script>
<script src="/js/common.js"></script>
<script src="/js/gtb.js"></script>
</body>
</html>
\ No newline at end of file
axios.get("/vue/comp/base").then(function(res){
if(res.data){
res.data.forEach(function(comp){
var obj=eval("("+comp+")");
Vue.component(obj.vname,obj);
});
}
console.log("load base component finished...");
function buildPromise(compath){
return Promise.resolve(new Promise(function(resolve,reject){
//异步加载组件
axios.get(compath).then(function(res){
console.log(compath);
// var obj=eval("("+res.data+")");
var obj = eval("(" + unescape(res.data) + ")");
resolve(obj);
}).catch(function(reason){
console.log(reason)
})
}));
}
function componentFactory(comname){
var compath="/vue/comp/"+comname;
var tmpFunc=function(){
return buildPromise(compath);
}
return tmpFunc;
}
window.componentFactory=componentFactory;
const store = new Vuex.Store({
state: {
currentCodePath:"",
currentUser:null,
curSelRow:{},
company:null,
},
});
Vue.mixin({
props:["groupName","modelName"],
computed:Vuex.mapState({
currentUser:state=>{
return state.currentUser;
},
codePath:state=>{
return state.currentCodePath;
},
ctlName:function(){
return this.groupName +"/"+this.modelName+"Ctl";
},
currentCompany:state=>{
return state.company;
},
}),
methods:{
getUrl(md){
return "web/"+this.ctlName+"/"+md;
},
}
});
var routes=[];
var codepaths={};
axios.get("/web/common/metaCtl/getRouteConfig").then(d=>{
Object.keys(d.data.data.bizs).map((k)=>{
//path是路由,静态的路由
var pathTmp=d.data.data.bizs[k].path;
var codepath=d.data.data.bizs[k].codepath;
var tmp={"path":pathTmp,"components":{
"default":componentFactory(d.data.data.bizs[k].comname)
},};
routes.push(tmp);
codepaths[pathTmp]=codepath;//暂存每个叶子节点对应的codepath
});
console.log(routes);
var router=new VueRouter({
routes:routes,
});
router.beforeEach((to, from,next) => {
store.state.currentCodePath = codepaths[to.path];
store.state.company=companyinfo;
next();
});
var app = new Vue({
el:"#app",
router:router,
store:store,
data:function(){
return {
loading:true,
logins:[
],
stageHeight:0,
tocomany:tocompanyinfo,
};
},
created(){
$(window).resize(()=>{
var h=$(window).height();
var m=h-90;
$("#app").css("min-height",h+"px");
$("#app-stage").css("min-height",m+"px");
});
var h=$(window).height();
var m=h-90;
$("#app").css("min-height",h+"px");
$("#app-stage").css("min-height",m+"px");
this.stageHeight=m;
$("#app").css("visibility",'visible');
this.loading=false;
this.$store.state.company=companyinfo;
},
updated(){
},
mounted(){
var self=this;
this.checkLogin(()=>{
if(!this.currentUser){
// this.logins.push({"icon":"el-icon-location-outline","title":"登录","type":"text",key:"login","isOnGrid":true});
// this.logins.push({"icon":"el-icon-edit-outline","title":"注册","type":"text",key:"register","isOnGrid":true});
if(location.href.indexOf("gtb")>=0){
this.$router.replace("/tlogin");
}
}else{
this.logins.push({"icon":"el-icon-arrow-right","title":"退出","type":"text",key:"exit","isOnGrid":true});
this.$router.replace("/gtbhome");
}
});
},
methods:{
showMask(){
},
hideMask(){
},
localdata(key,item){
if(item){
localStorage.setItem(key,JSON.stringify(item));
}else{
var strobj=localStorage.getItem(key);
if(strobj){
return JSON.parse(strobj);
}else{
return null;
}
}
},
appclick(){
location.href="/gtb";
},
settingclick(){
location.href="/admin"
},
async exitclick(){
var d= await this.$root.postReq("/web/auth/userCtl/exit",{});
location.href="/gtb";
},
async checkLogin(cbk){
var d= await this.$root.postReq("/web/auth/userCtl/checkLogin",{});
if(d && d.status==0 && d.data){
this.$store.state.currentUser=d.data;
//检查是否有公司信息
if(!tocompanyinfo && this.currentUser && !this.currentUser.isSuper){
this.$router.push({path:"/companyinfo"});
}
if(cbk){
cbk();
}
}else{
//alert("no login");
if(cbk){
cbk();
}
}
},
onselect(code){
if(code=="login"){
this.$router.push("/login");
}
if(code=="register"){
this.$router.push("/register");
}
},
getReq(path,data){
var self=this;
return axios.get(path,{params:data,"headers":{"codepath":this.currentCodePath}}).then(function(r){
if(r && r.data && r.data.status==-99){
self.$store.state.currentUser=null;
self.hideMask();
self.hideMenu();
self.$router.push("/");
self.$message({
message: '扫码成为合伙人',
type: 'warning'
});
self.showLogin();
return null;
}else{
if(r.data && r.data.bizmsg && r.data.bizmsg!="empty"){
self.$message({
message: r.data.bizmsg,
type: 'warning'
});
}
return r.data?r.data:null;;
}
});
},
postReq(path,data){
return axios.post(path,data,{"headers":{'codepath': this.currentCodePath}}).then(function(r){
if(r && r.data && r.data.status==-99){
self.$store.state.currentUser=null;
self.hideMask();
self.hideMenu();
self.$router.push("/");
self.$message({
message: '扫码成为合伙人',
type: 'warning'
});
self.showLogin();
return null;
}else{
return r.data?r.data:null;
}
});
},
},
});
});
});
......@@ -7,4 +7,9 @@
.gsbform .el-form{
width: 100%;
height: 100%;
padding:10px;margin:5px;position:relative;
}
.frmcollapse{
margin-top:5px;
}
\ No newline at end of file
......@@ -3,8 +3,8 @@ var tmpl=`
<div style="text-align:center"><slot name="title"></slot></div>
<div style="text-align:right"><slot name="topbtnarea"></slot></div>
<transition name = "fade">
<el-form v-if="isshow" class="idform" :disabled="isdisabled" style="padding:10px;margin:5px;position:relative;" ref="refform" label-position="right" label-width="100px" :rules="metaRules" :inline="true" status-icon="true" :model="formModel">
<gsb-collapse :title="group.title" isShow="true" v-for="group in formMetaGroups" style="margin-top:5px">
<el-form v-if="isshow" class="idform" :disabled="isdisabled" ref="refform" label-position="right" label-width="100px" :rules="metaRules" :inline="true" status-icon="true" :model="formModel">
<gsb-collapse class="frmcollapse" :title="group.title" isShow="true" v-for="group in formMetaGroups">
<el-row>
<template v-for="(item,index) in group.ctls">
<el-col :xs="getColSpan(group,0)" :sm="getColSpan(group,1)" :md="getColSpan(group,2)" :lg="getColSpan(group,3)" :xl="getColSpan(group,4)">
......
.gtb-home{
display: flex;
width: 100%;
height: 100%;
margin: auto;
opacity:0.8;
align-items:center;
justify-content: center;
}
.gtb-home .app-child{
width: 234px;
height: 274px;
margin: 15px;
background-color: bisque;
position: relative;
}
.gtb-home .app-child:hover{
border: 1px solid white
}
\ No newline at end of file
<div class="gtb-home">
<div v-for="app in myapps" class="app-child" :style="bgimg(app)">
<span @click="systemsetting(app)" v-if="currentUser && currentUser.roles.indexOf(\'common\')>=0" style="position: absolute;left:5px;top: 10px;font-size:20px;color:red;padding: 5px;cursor: pointer;"><i class="el-icon-setting"></i></span>
<div class="activeColor" @click="goapplogin(app)" style="text-align:right;font-size: 0.8em;cursor: pointer;">
GO
</div>
</div>
</div>
\ No newline at end of file
{
template:'${tmpl}',
data:function(){
return {
apps:null,
bubbles:['x','y','x','y','x','y','x','y','x','y'],
pxheight:"800px",
myapps:[],
carisshow:false,
}
},
mounted:function(){
this.pxheight=(this.$root.stageHeight-60)+"px";
this.myapps=tocompanyinfo?tocompanyinfo.apps:[];
},
created:function(){
},
computed: {
},
methods:{
async systemsetting(app){
var d= await this.$root.postReq("/web/auth/userCtl/sysManageForApp?appKey="+app.appkey+"&toKey="+appinfo.appkey,tocompanyinfo);
window.open(d.data.jumpUrl);
},
bgimg(app){
console.log(app.showimgUrl);
return "background:url('"+app.showimgUrl+"') no-repeat;background-size: cover";
},
async goapplogin(app){
var d= await this.$root.postReq("/web/auth/userCtl/goLoginForApp",app);
if(d && d.status==0 && d.data){
console.log(JSON.stringify(d.data));
window.open(d.data.jumpUrl);
}else{
}
}
},
vname:"gsb_gtbhome"
}
......@@ -56,4 +56,9 @@
bottom: 50px;
right: 50px;
z-index: 99999;
}
.purchaseCar-hide{
z-index: 0;
height: 0px;
}
\ No newline at end of file
......@@ -28,8 +28,8 @@
</el-row>
</el-carousel-item>
</el-carousel>
<div v-if="currentUser && !currentUser.isSuper" class="purchaseCar" style="width:300px;height:600px">
<el-card id="buycar" style="width:320px;height:500px">
<div v-if="currentUser && !currentUser.isSuper" class="purchaseCar">
<el-card id="buycar" style="height:500px">
<span @click="showcar" style="position:absolute;right: 15px;top:15px;font-size:0.5em;cursor: pointer;" class="el-icon-remove-outline"></span>
<el-tooltip v-if="tocompanyinfo" class="item" effect="dark" content="点击切换要进入的公司" placement="top-start">
<span style="font-size:16px;cursor: pointer;" @click="cmpsclick">
......
......@@ -46,9 +46,11 @@
showcar(){
if(this.carisshow){
$("#buycar").fadeOut(1500);
$("#buycar").addClass("purchaseCar-hide");
this.carisshow=false;
}else{
$("#buycar").fadeIn(1500);
$("#buycar").removeClass("purchaseCar-hide");
this.carisshow=true;
}
},
......
.tloginpage{
display: flex;
flex-direction: column;
align-items: center
}
.tlogin{
width:428px;
height:308px;
margin: auto;
}
.tlogin .el-card{
background:rgba(255,255,255,1);
border-radius:12px;
}
.tlogin .el-input__inner{
height: 40px;
width: 308px;
}
.tlogin .el-button{
width: 308px;
}
.tlogin .el-col{
text-align:center
}
<div class="tloginpage">
<div>公司宝logo</div>
<div>个体宝登录系统</div>
<div class="tlogin" >
<gsb-form class="tlogin" ref="loginFrm" @btnclick="loginclick" :metaData="ldms" :refvalidatemethod="validmethod">
</gsb-form>
</div>
</div>
{
template:'${tmpl}',
data:function(){
return {
ldms:[],
}
},
mounted:function(){
this.ldms=[
{
"title":null,
"colnum":1,
ctls:[
{"type":"input","label":"","prop":"userName","placeHolder":"请输入登录账号","style":"margin-top:5px",rules:[ { "required": true, "message": ' ', "trigger": 'blur' },,]},
{"type":"input","label":"","prop":"password","placeHolder":"请输入登录密码","style":"",rules:[ { "required": true, "message": ' ', "trigger": 'blur' },]},
{"type":"btn","label":"登录","prop":"btnLogin","placeHolder":"请输入手机号","style":"","face":"primary"},
]
},
];
},
created:function(){
},
methods:{
validmethod:function (rule,value,callback) {
console.log("code validdate");
var self=this;
var fm=this.currentFrm.getFormModel();
return callback();
},
loginclick:function (fm,prop){
var self=this;
var fm=this.$refs.loginFrm.getFormModel();
this.$refs.loginFrm.overBtnLoading(prop);
this.$refs.loginFrm.validate(function(v){
if(v){
console.log(v);
self.$root.postReq("/web/auth/userCtl/login",{u:fm}).then(function(d){
if(d.status==0){
console.log(d.data);
var tourl="";
if(d.data.jumpUrl.indexOf("?")>=0){
tourl=d.data.jumpUrl+"&"+"gtb=1";
}else{
tourl=d.data.jumpUrl+"?gtb=1";
}
location.href=tourl;
}else{
self.$alert(d.msg, '提示', {
confirmButtonText: '确定',
callback: action => {
}
});
}
});
}
});
},
},
vname:"gsb-tlogin"
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment