|
@@ -98,13 +98,13 @@
|
|
<scroll-view style="height: calc(100% - 4px);width:100vw;background:#0d2e59;" scroll-y="true">
|
|
<scroll-view style="height: calc(100% - 4px);width:100vw;background:#0d2e59;" scroll-y="true">
|
|
<view class="unit">
|
|
<view class="unit">
|
|
<view class="unit-title">切换企业</view>
|
|
<view class="unit-title">切换企业</view>
|
|
- <view :class="item.id == useStore.tenantId ? 'active' : ''" class="list" v-for="(item, index) in tenantIdList" :key="index">
|
|
|
|
- <image class="list-image" src="@/static/images/index/unit-active.png" v-if="item.id == useStore.tenantId" @click="changeTenantId(item.id)"></image>
|
|
|
|
- <image class="list-image" src="@/static/images/index/unit.png" v-if="item.id != useStore.tenantId" @click="changeTenantId(item.id)"></image>
|
|
|
|
- <text class="list-name" @click="changeTenantId(item.id)">{{ item.tenantName }}</text>
|
|
|
|
- <image class="list-right" src="@/static/images/index/right.png" v-if="item.id == useStore.tenantId"></image>
|
|
|
|
- <text class="list-state" @click="defaultEnterprise(item)" :style="{ color: item.isDefault ? '#8D8F93' : '#2A98FF' }">{{ item.isDefault ? '默认企业' : '设为默认' }}</text>
|
|
|
|
- </view>
|
|
|
|
|
|
+ <view :class="item.id == tenantIdChange ? 'active' : ''" class="list" v-for="(item, index) in tenantIdList" :key="index">
|
|
|
|
+ <image class="list-image" src="@/static/images/index/unit-active.png" v-if="item.id == tenantIdChange" @click="changeTenantId(item.id)"></image>
|
|
|
|
+ <image class="list-image" src="@/static/images/index/unit.png" v-if="item.id != tenantIdChange" @click="changeTenantId(item.id)"></image>
|
|
|
|
+ <text class="list-name" @click="changeTenantId(item.id)">{{ item.tenantName }}</text>
|
|
|
|
+ <image class="list-right" src="@/static/images/index/right.png" v-if="item.id == tenantIdChange"></image>
|
|
|
|
+ <text class="list-state" @click="defaultEnterprise(item)" :style="{ color: item.isDefault ? '#8D8F93' : '#2A98FF' }">{{ item.isDefault ? '默认企业' : '设为默认' }}</text>
|
|
|
|
+ </view>
|
|
</view>
|
|
</view>
|
|
</scroll-view>
|
|
</scroll-view>
|
|
</uni-drawer>
|
|
</uni-drawer>
|
|
@@ -114,7 +114,7 @@
|
|
<script setup>
|
|
<script setup>
|
|
/*----------------------------------依赖引入-----------------------------------*/
|
|
/*----------------------------------依赖引入-----------------------------------*/
|
|
import { onReady, onLoad, onShow, onNavigationBarButtonTap, onPullDownRefresh, onReachBottom } from "@dcloudio/uni-app";
|
|
import { onReady, onLoad, onShow, onNavigationBarButtonTap, onPullDownRefresh, onReachBottom } from "@dcloudio/uni-app";
|
|
-import { ref, onMounted, inject, shallowRef, reactive, getCurrentInstance, toRefs, nextTick } from "vue";
|
|
|
|
|
|
+import { ref, onMounted, inject, shallowRef, reactive, getCurrentInstance, toRefs, nextTick, watch } from "vue";
|
|
/*----------------------------------接口引入-----------------------------------*/
|
|
/*----------------------------------接口引入-----------------------------------*/
|
|
import { scan_push, getHomePageData, getFunctionalModuleStatistics, getAppRouters, qrCodeSend, getMobileBanner } from "@/api/index";
|
|
import { scan_push, getHomePageData, getFunctionalModuleStatistics, getAppRouters, qrCodeSend, getMobileBanner } from "@/api/index";
|
|
/*----------------------------------组件引入-----------------------------------*/
|
|
/*----------------------------------组件引入-----------------------------------*/
|
|
@@ -135,7 +135,7 @@ const commonStore = commonStores();
|
|
const accountState = ref(false); // 有效账号状态(用于企业切换)
|
|
const accountState = ref(false); // 有效账号状态(用于企业切换)
|
|
const showLeft = ref(false); // 左侧菜单
|
|
const showLeft = ref(false); // 左侧菜单
|
|
const showLeftState = ref(false); // 左侧菜单显示状态
|
|
const showLeftState = ref(false); // 左侧菜单显示状态
|
|
-const tenantIdChange = ref(""); // 切换租户ID
|
|
|
|
|
|
+const tenantIdChange = ref(useStore.selectTenantId); // 切换租户ID
|
|
const tenantIdList = ref([]); // 租户ID列表
|
|
const tenantIdList = ref([]); // 租户ID列表
|
|
const state = reactive({
|
|
const state = reactive({
|
|
dialogFlag: false,
|
|
dialogFlag: false,
|
|
@@ -188,40 +188,42 @@ function getTenantList(id) {
|
|
* @企业切换
|
|
* @企业切换
|
|
*/
|
|
*/
|
|
function changeTenantId(id) {
|
|
function changeTenantId(id) {
|
|
- storage.set("tenantId", id);
|
|
|
|
- var info = JSON.parse(
|
|
|
|
- JSON.stringify({
|
|
|
|
- userName: storage.get("account")?.userName,
|
|
|
|
- passWord: storage.get("account")?.passWord,
|
|
|
|
- tenantId: id,
|
|
|
|
- })
|
|
|
|
- );
|
|
|
|
- useStore.LogOut().then(() => {
|
|
|
|
- proxy.$modal.loading("加载中...");
|
|
|
|
- useStore
|
|
|
|
- .Login({
|
|
|
|
- username: decrypt(info.userName),
|
|
|
|
- password: decrypt(info.passWord),
|
|
|
|
- tenantId: id,
|
|
|
|
- method: "switch",
|
|
|
|
- cids: proxy.$settingStore.pushClientId || undefined,
|
|
|
|
- type: proxy.$common.isWechatMp() ? "wx" : "app",
|
|
|
|
- openId: proxy.$common.isWechatMp() ? localStorage.getItem("wxOpenId") : undefined,
|
|
|
|
- })
|
|
|
|
- .then(() => {
|
|
|
|
- // /** 获取用户信息 */
|
|
|
|
- useStore.SET_STORAGE_OBJECT_KEYS({ tenantId: id });
|
|
|
|
- useStore.GetInfo().then((res) => {
|
|
|
|
- proxy.$settingStore.initThemeColor(storageSystem.get("themeColor")); //初始化默认主题
|
|
|
|
- state.recentlyUsed = []
|
|
|
|
- init();
|
|
|
|
- setTimeout(() => {
|
|
|
|
- showLeftStateClick();
|
|
|
|
- proxy.$modal.closeLoading();
|
|
|
|
- },1000)
|
|
|
|
|
|
+ if(tenantIdChange.value!= id){
|
|
|
|
+ tenantIdChange.value = id;
|
|
|
|
+ var info = JSON.parse(
|
|
|
|
+ JSON.stringify({
|
|
|
|
+ userName: storage.get("account")?.userName,
|
|
|
|
+ passWord: storage.get("account")?.passWord,
|
|
|
|
+ tenantId: id,
|
|
|
|
+ })
|
|
|
|
+ );
|
|
|
|
+ useStore.LogOut().then(() => {
|
|
|
|
+ proxy.$modal.loading("加载中...");
|
|
|
|
+ useStore
|
|
|
|
+ .Login({
|
|
|
|
+ username: decrypt(info.userName),
|
|
|
|
+ password: decrypt(info.passWord),
|
|
|
|
+ tenantId: id,
|
|
|
|
+ method: "switch",
|
|
|
|
+ cids: proxy.$settingStore.pushClientId || undefined,
|
|
|
|
+ type: proxy.$common.isWechatMp() ? "wx" : "app",
|
|
|
|
+ openId: proxy.$common.isWechatMp() ? localStorage.getItem("wxOpenId") : undefined,
|
|
|
|
+ })
|
|
|
|
+ .then(() => {
|
|
|
|
+ // /** 获取用户信息 */
|
|
|
|
+ useStore.SET_STORAGE_OBJECT_KEYS({ tenantId: id });
|
|
|
|
+ useStore.GetInfo().then((res) => {
|
|
|
|
+ proxy.$settingStore.initThemeColor(storageSystem.get("themeColor")); //初始化默认主题
|
|
|
|
+ state.recentlyUsed = []
|
|
|
|
+ init();
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ showLeftStateClick();
|
|
|
|
+ proxy.$modal.closeLoading();
|
|
|
|
+ },1000)
|
|
|
|
+ });
|
|
});
|
|
});
|
|
- });
|
|
|
|
- });
|
|
|
|
|
|
+ });
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -229,19 +231,20 @@ function changeTenantId(id) {
|
|
* @param {Object} val 企业对象
|
|
* @param {Object} val 企业对象
|
|
*/
|
|
*/
|
|
function defaultEnterprise(val){
|
|
function defaultEnterprise(val){
|
|
- putTenantByUser({
|
|
|
|
- userId:useStore?.userId,
|
|
|
|
- tenantId:val.id
|
|
|
|
- }).then(() => {
|
|
|
|
- changeTenantId(val.id)
|
|
|
|
- })
|
|
|
|
|
|
+ if(!val.isDefault){
|
|
|
|
+ putTenantByUser({
|
|
|
|
+ userId:useStore?.userId,
|
|
|
|
+ tenantId:val.id
|
|
|
|
+ }).then(() => {
|
|
|
|
+ changeTenantId(val.id)
|
|
|
|
+ })
|
|
|
|
+ }
|
|
}
|
|
}
|
|
/**
|
|
/**
|
|
* @初始化
|
|
* @初始化
|
|
*/
|
|
*/
|
|
async function init(options) {
|
|
async function init(options) {
|
|
if (useStore?.userId) {
|
|
if (useStore?.userId) {
|
|
- tenantIdChange.value = useStore.tenantId; //切换租户ID
|
|
|
|
getTenantList(useStore.userId); //调用获取企业列表方法
|
|
getTenantList(useStore.userId); //调用获取企业列表方法
|
|
}
|
|
}
|
|
//#ifdef H5
|
|
//#ifdef H5
|
|
@@ -485,7 +488,6 @@ onShow(() => {
|
|
});
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
</script>
|
|
-
|
|
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|
|
.home-container {
|
|
.home-container {
|
|
.transition {
|
|
.transition {
|