ljc 1 ヶ月 前
コミット
ec6790d1c6

+ 16 - 4
components/cwg-system.vue

@@ -23,6 +23,11 @@ const props = defineProps({
   textColor: {
     type: String,
     default: '#97A1C0'
+  },
+  // 事件来源标识,用于区分不同组件的事件监听
+  eventSource: {
+    type: String,
+    default: ''
   }
 })
 
@@ -87,7 +92,11 @@ const applySystemList = (data: any[]) => {
 
 async function getSystemList(type = false) {
   const cached = getCache()
-  console.log(1)
+  console.log('system',type,props.form)
+  // top-window组件中,没有token不去请求接口
+  if (props.eventSource === 'top') {
+    if (!userToken.value) return
+  }
   if (!type){
     if (cached && cached.timestamp && Date.now() - cached.timestamp < CACHE_DURATION) {
       applySystemList(cached.data || [])
@@ -95,7 +104,7 @@ async function getSystemList(type = false) {
     }
   }
 
-  console.log('qingqiule')
+ // console.log('qingqiule')
   try {
     const res: any = await customApi.getSystemList({})
     if (res && res.code === Code.StatusOK) {
@@ -167,7 +176,10 @@ onMounted(() => {
   
   getSystemList()
 
-  uni.$on('updateSystemList', () => {
+  uni.$on('updateSystemList', (source) => {
+    // console.log(source)
+    // 如果指定了事件来源,只处理来自该来源的事件
+    if (props.eventSource && source !== props.eventSource) return
     getSystemList(true)
   })
 })
@@ -192,7 +204,7 @@ onUnmounted(() => {
   display: flex;
   align-items: center;
   cursor: pointer;
-  width: 80px;
+  width: px2rpx(80);
   gap: px2rpx(4);
 }
 

+ 1 - 1
pages/login/components/LoginHeaderGroup.vue

@@ -1,7 +1,7 @@
 <template>
   <view class="login-header-group">
     <view class="header-item">
-      <cwg-system :text-color="textColor" :icon-color="iconColor" />
+      <cwg-system :text-color="textColor" :icon-color="iconColor" event-source="login"/>
     </view>
     <view class="divider" :style="{ backgroundColor: dividerColor }"></view>
     <view class="header-item" style="margin-right: 10rpx">

+ 2 - 1
pages/login/index.vue

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

+ 2 - 2
service/ib.ts

@@ -95,8 +95,8 @@ export const ibApi = {
   tradeAccount: (params = {}) => post('/trade/account', params, 'Host90'),
   /** 代理佣金收入 */
   tradeAgentCommission: (params = {}, isVietnam = false) => {
-    let url = '/trade/agent/commission';
-    if (isVietnam) url += '/vn';
+    let url = '/trade/agent/commission/vn';
+    // if (isVietnam) url += '/vn';
     return post(url, params, 'Host90');
   },
   /** 新增代理 */

+ 1 - 1
windows/top-window.vue

@@ -8,7 +8,7 @@
     </div>
     <div class="right" v-if="visible">
       <cwg-payment />
-      <cwg-system />
+      <cwg-system event-source="top"/>
       <cwg-language />
       <cwg-notice />
       <cwg-right-drawer />