Forráskód Böngészése

feat: 系统切换

ljc 1 hónapja
szülő
commit
273271315e

+ 2 - 8
components/cwg-page-wrapper.vue

@@ -513,17 +513,11 @@ onShow(() => {
   left: 0;
 }
 
-@media screen and (max-width: 1504px) {
-  .content-wrapper-padding {
-    padding: px2rpx(16) px2rpx(16) 0 px2rpx(16);
-  }
+.content-wrapper-padding {
+  padding: px2rpx(16) px2rpx(16) 0 px2rpx(16);
 }
 
 @media screen and (max-width: 991px) {
-  .content-wrapper-padding {
-    padding: px2rpx(16) px2rpx(16) 0 px2rpx(16);
-  }
-
   .page-wrapper {
     height: 100vh;
   }

+ 2 - 1
components/cwg-right-drawer.vue

@@ -136,7 +136,8 @@ async function handleLogout() {
         await userApi.logout()
     } catch (e) { }
     userStore.clearUserInfo()
-    uni.$emit('updateSystemList')
+  uni.setStorageSync('logoutToSystem',1)
+    // uni.$emit('updateSystemList')
     router.push('/pages/login/index')
     close()
 }

+ 13 - 15
components/cwg-system.vue

@@ -10,7 +10,7 @@
 </template>
 
 <script setup lang="ts">
-import { computed, ref, onMounted,onUnmounted } from 'vue'
+import { computed, ref, onMounted,onUnmounted,nextTick} from 'vue'
 import { useI18n } from 'vue-i18n'
 import Config from '@/config/index'
 import { customApi } from '@/service/custom'
@@ -46,12 +46,12 @@ type SystemItem = {
 const systemList = ref<SystemItem[]>([])
 const currentSystemCode = ref<string | null>(null)
 
-const systemMenuList = computed(() =>
-  systemList.value.map((item) => ({
+const systemMenuList = computed(() =>{
+  return systemList.value.map((item) => ({
     ...item,
     label: getSystemDisplayName(item),
-  })),
-)
+  }))
+})
 
 const currentSystemName = computed(() => {
   if (!currentSystemCode.value || systemList.value.length === 0) {
@@ -59,7 +59,7 @@ const currentSystemName = computed(() => {
   }
   const currentSystem = systemList.value.find((item) => item.sysCode === currentSystemCode.value)
   if (!currentSystem) return '系统切换'
-  
+
   return getSystemDisplayName(currentSystem)
 })
 
@@ -82,6 +82,7 @@ const setCache = (data: any) => {
 }
 
 const applySystemList = (data: any[]) => {
+  // console.log(data,props.eventSource)
   systemList.value = Array.isArray(data) ? data : []
   if (systemList.value.length > 0) {
     const localSystem = systemList.value.find((item) => item && item.localSystem === 1)
@@ -93,21 +94,21 @@ const applySystemList = (data: any[]) => {
 
 async function getSystemList(type = false) {
   const cached = getCache()
-  console.log('system',type,props.form)
+  // console.log('system',type,props.eventSource)
   // top-window组件中,没有token不去请求接口
   if (props.eventSource === 'top') {
     if (!userToken.value) return
   }
-  if (!type){
+  // if (!type){
     if (cached && cached.timestamp && Date.now() - cached.timestamp < CACHE_DURATION) {
       applySystemList(cached.data || [])
       return
     }
-  }
+  // }
 
- // console.log('qingqiule')
   try {
     const res: any = await customApi.getSystemList({})
+    // console.log('res',res)
     if (res && res.code === Code.StatusOK) {
       const data = res.data || []
       applySystemList(data)
@@ -146,7 +147,6 @@ async function confirmSwitchSystem(item: SystemItem) {
   try {
     if (props.eventSource === 'login'){
       const baseUrl = `${item.sysUrl}/#/signin`
-      console.log(baseUrl)
       // #ifdef H5
       window.location.replace(baseUrl)
       // #endif
@@ -160,7 +160,6 @@ async function confirmSwitchSystem(item: SystemItem) {
         const accessToken = res.data
         const token = typeof accessToken === 'string' ? accessToken : String(accessToken || '')
         const baseUrl = `${item.sysUrl}/#/signin?sysLoginToken=${btoa(token)}`
-        console.log(baseUrl)
         // #ifdef H5
         window.location.replace(baseUrl)
         // #endif
@@ -174,7 +173,6 @@ async function confirmSwitchSystem(item: SystemItem) {
     }
 
   } catch (e) {
-    console.log(e)
     uni.showToast({ title: '切换系统失败', icon: 'none' })
   }
 }
@@ -188,13 +186,13 @@ const isInit = ref(false)
 onMounted(() => {
   if (isInit.value) return
   isInit.value = true
-  
+
   getSystemList()
 
   uni.$on('updateSystemList', (source) => {
     // console.log(source)
     // 如果指定了事件来源,只处理来自该来源的事件
-    if (props.eventSource && source !== props.eventSource) return
+    // if (props.eventSource && source !== props.eventSource) return
     getSystemList(true)
   })
 })

+ 1 - 1
pages/ib/index.vue

@@ -27,7 +27,7 @@
               <view class="clearfix pe-2 text-warning"> <img src="/static/images/dollar.png" alt="dollar" class="img-fluid"> </view>
               <view class="clearfix">
                 <view class="mb-1">{{ t('news_add_field.Label.Balance') }}</view>
-                <view class="mb-0 fw-bold">{{ balanceInt }}.{{ balanceDecimal }}<text class="badge bg-danger-subtle text-danger">{{ t('Ib.Index.TotalRevenue') }}: ${{numberFormat(ibData.all || '0')}}</text></view>
+                <view class="mb-0 fw-bold">${{ balanceInt }}.{{ balanceDecimal }}<text class="badge bg-danger-subtle text-danger">{{ t('Ib.Index.TotalRevenue') }}: ${{numberFormat(ibData.all || '0')}}</text></view>
               </view>
             </view>
           </view>

+ 6 - 1
pages/login/index.vue

@@ -677,7 +677,8 @@ async function getCustomLoginInfo() {
   try {
     const res = await userApi.getUserInfo()
     userStore.saveUserInfo(res.data)
-    uni.$emit('updateSystemList', 'login')
+    uni.removeStorageSync('systemListCache')
+    // uni.$emit('updateSystemList', 'login')
     if (res.code === 200) {
       switch (modeStore.value) {
         case 'customer':
@@ -745,6 +746,10 @@ function pickFields(source, fields = ['content', 'enContent']) {
 }
 
 onMounted(() => {
+  if (uni.getStorageSync('logoutToSystem') == 1) {
+    uni.removeStorageSync('logoutToSystem')
+    uni.removeStorageSync('systemListCache')
+  }
   uni.$emit('updateSystemList','login')
   const accountInfo = userStore.accountInfo
   if (accountInfo?.rememberPassword) {

+ 1 - 0
utils/request.js

@@ -102,6 +102,7 @@ const responseInterceptor = (response, options = {}) => {
           uni.reLaunch({
             url: LOGIN_PAGE_PATH,
             success: () => {
+              uni.setStorageSync('logoutToSystem',1)
               ls.set('mode', 'customer');
               isRedirectingToLogin = false;
             },

+ 5 - 1
windows/top-window.vue

@@ -17,7 +17,7 @@
 </template>
 
 <script setup lang="ts">
-import { ref, computed, watch } from 'vue'
+import { ref, computed, watch, onMounted } from 'vue'
 import { storeToRefs } from 'pinia'
 import useUserStore from '@/stores/use-user-store'
 const userStore = useUserStore()
@@ -37,6 +37,10 @@ const props = defineProps({
   },
 })
 
+onMounted(()=>{
+  uni.$emit('updateSystemList','top')
+})
+
 </script>
 
 <style scoped lang="scss">