Commit a2130fca authored by huangjie's avatar huangjie

切换租户

parent 7daeddb5
......@@ -85,8 +85,8 @@ export default {
methods: {
getTetant(){
this.tenantId = getTenantid()
// getTenants(localStorage.getItem('userphone')).then(res=>{
getTenants('15823584612').then(res=>{
getTenants(localStorage.getItem('userphone')).then(res=>{
// getTenants('15823584612').then(res=>{
if(res.code == 200){
this.tenanlist = res.data
}
......@@ -104,13 +104,15 @@ export default {
}).catch(() => {});
},
getorther(id){
setTenantid(id)
changeTenants(id).then(res=>{
if(res.code == 200){
setToken(res.data.accessToken)
})
setTenantid(id)
location.reload();
this.$router.push({ path: this.redirect || "/" }).catch(()=>{});
}
})
}
}
}
</script>
......
import { login, logout, getInfo } from '@/api/login'
import { getToken, setToken, removeToken } from '@/utils/auth'
import { getToken, setToken, removeToken ,setTenantid} from '@/utils/auth'
const user = {
state: {
......@@ -47,6 +47,7 @@ const user = {
login(username, password, code, uuid).then(res => {
setToken(res.data.token)
commit('SET_TOKEN', res.data.token)
setTenantid(res.data.tenantId)
resolve()
}).catch(error => {
reject(error)
......
......@@ -71,7 +71,7 @@
</template>
<script>
import { getCodeImg,getTenants } from "@/api/login";
import { getCodeImg,getTenants,changeTenants } from "@/api/login";
import Cookies from "js-cookie";
import { encrypt, decrypt } from '@/utils/jsencrypt'
import { setTenantid} from '@/utils/auth'
......@@ -155,7 +155,9 @@ export default {
}
this.$store.dispatch("Login", this.loginForm).then(() => {
localStorage.setItem('userphone',this.loginForm.username)
this.goin()
this.$router.push({ path: this.redirect || "/" }).catch(()=>{});
// this.goin()
}).catch(() => {
this.loading = false;
if (this.captchaEnabled) {
......@@ -174,14 +176,21 @@ export default {
this.islog = true
}else{
setTenantid(this.tenanlist[0].tenantId)
this.$router.push({ path: this.redirect || "/" }).catch(()=>{});
this.changeTenants(this.tenanlist[0].tenantId)
}
}
})
},
tochose(){
setTenantid(this.tenantId)
this.changeTenants(this.tenantId)
},
changeTenants(tenantId){
changeTenants(tenantId).then(res=>{
if(res.code == 200){
this.$router.push({ path: this.redirect || "/" }).catch(()=>{});
}
})
},
}
};
......
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