Commit a2130fca authored by huangjie's avatar huangjie

切换租户

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