lex 1 år sedan
förälder
incheckning
f0c06b86c5

+ 10 - 0
src/api/user.ts

@@ -45,3 +45,13 @@ export const getCategories = (params: any) => {
     data: params
   });
 };
+
+/**
+ * 反馈购买未读条数
+ * @returns suggestMessageUnread
+ */
+export const suggestMessageUnread = (params?: any) => {
+  return request.get('/edu-app/sysSuggestion/suggestMessageUnread', {
+    params
+  });
+};

+ 36 - 3
src/components/layout/layoutTop.tsx

@@ -1,4 +1,4 @@
-import { defineComponent, ref, onMounted, onBeforeMount, nextTick } from 'vue';
+import { defineComponent, ref, onMounted, nextTick, onUnmounted } from 'vue';
 import styles from './index.module.less';
 import { NImage, NBadge, NPopover, NIcon, NModal, NTooltip } from 'naive-ui';
 import styles2 from './modals/suggestion-option.module.less';
@@ -25,6 +25,8 @@ import ImGroup from './imGroup';
 import SuggestionOption from './modals/suggestion-option';
 import dayjs from 'dayjs';
 import ClassModal from '/src/views/home/modals/class-modal';
+import { suggestMessageUnread } from '/src/api/user';
+import { eventGlobal } from '/src/utils';
 export default defineComponent({
   name: 'layoutTop',
   setup() {
@@ -60,11 +62,40 @@ export default defineComponent({
       console.log(suggestionOptionRef.value, 'suggestionOptionRef');
     };
 
+    const suggestionStatus = ref(false);
+    const getSuggestMessageUnread = async () => {
+      try {
+        const { data } = await suggestMessageUnread();
+        const temp = data || [];
+        let system: any = {};
+        temp.forEach((item: any) => {
+          if (item.group === 'SYSTEM') {
+            system = item;
+          }
+        });
+        if (system.number > 0) {
+          suggestionStatus.value = system.number > 0 ? true : false;
+        } else {
+          suggestionStatus.value = false;
+        }
+      } catch {
+        //
+      }
+    };
+
     onMounted(() => {
       window.addEventListener('message', onImMessage);
       showImGroupLoading.value = true;
       showImGroup.value = true;
 
+      getSuggestMessageUnread();
+
+      eventGlobal.on('onSuggestionRead', () => {
+        if (suggestionStatus.value) {
+          getSuggestMessageUnread();
+        }
+      });
+
       nextTick(() => {
         setTimeout(() => {
           showImGroup.value = false;
@@ -87,7 +118,7 @@ export default defineComponent({
       }
     };
 
-    onBeforeMount(() => {
+    onUnmounted(() => {
       window.removeEventListener('message', onImMessage);
     });
 
@@ -139,7 +170,9 @@ export default defineComponent({
               {{
                 trigger: () => (
                   <div class={styles.optons} onClick={showOption}>
-                    <NImage src={opinionIcon} previewDisabled></NImage>
+                    <NBadge dot={suggestionStatus.value} color={'#FF1036'}>
+                      <NImage src={opinionIcon} previewDisabled></NImage>
+                    </NBadge>
                   </div>
                 ),
                 default: '意见反馈'

+ 11 - 0
src/components/layout/modals/api.ts

@@ -38,6 +38,7 @@ export const getSysSuggestionTypeList = (params: object) => {
     data: params
   });
 };
+
 /**
  * @description: 意见反馈列表
  */
@@ -46,3 +47,13 @@ export const getSysSuggestionList = (params: object) => {
     data: params
   });
 };
+
+/**
+ * @description: 意见反馈意见已读
+ */
+export const batchSetRead = (params: object) => {
+  return request.get('/edu-app/sysMessage/batchSetRead', {
+    data: params,
+    params
+  });
+};

+ 12 - 2
src/components/layout/modals/suggestion-list.tsx

@@ -11,11 +11,11 @@ import {
   NImage,
   NButton
 } from 'naive-ui';
-import { getSysSuggestionList } from './api';
+import { batchSetRead, getSysSuggestionList } from './api';
 import CDatePicker from '../../CDatePicker';
 import TheEmpty from '../../TheEmpty';
 import { useDebounceFn, useThrottleFn } from '@vueuse/core';
-import { getTimes } from '/src/utils';
+import { eventGlobal, getTimes } from '/src/utils';
 
 export default defineComponent({
   name: 'suggestion-list',
@@ -85,6 +85,15 @@ export default defineComponent({
       getList();
     }, 500);
 
+    const getBatchSetRead = async () => {
+      try {
+        await batchSetRead({ messageType: 'SYS_SUGGEST_FEEDBACK_TEACHER' });
+
+        eventGlobal.emit('onSuggestionRead');
+      } catch {
+        //
+      }
+    };
     onMounted(() => {
       props.typeList.forEach((item: any) => {
         state.suggestionTypeList.push({
@@ -92,6 +101,7 @@ export default defineComponent({
           value: item.id
         });
       });
+      getBatchSetRead();
       getList();
     });
     return () => (

+ 5 - 1
src/components/layout/modals/suggestion-option.module.less

@@ -417,9 +417,13 @@
 }
 
 
-.suggestionBtn {
+.suggestionBtnDot {
   position: absolute;
   right: 30px;
+}
+
+.suggestionBtn {
+
   border: 1px solid #8BC5FF;
   background: #E4F2FF !important;
   height: 28Px;

+ 35 - 9
src/components/layout/modals/suggestion-option.tsx

@@ -12,7 +12,8 @@ import {
   UploadFileInfo,
   NImage,
   UploadCustomRequestOptions,
-  NModal
+  NModal,
+  NBadge
 } from 'naive-ui';
 import { useUserStore } from '/src/store/modules/users';
 import bgLine from '../images/bg-line.png';
@@ -33,6 +34,7 @@ import {
 import { nextTick } from 'process';
 import { getUploadSign, onFileUpload } from '/src/helpers/oss-file-upload';
 import SuggestionList from './suggestion-list';
+import { suggestMessageUnread } from '/src/api/user';
 
 export default defineComponent({
   name: 'train-update',
@@ -242,7 +244,24 @@ export default defineComponent({
       }
     };
     loadImg(imglist);
+
+    const suggestionStatus = ref(false);
+    const getSuggestMessageUnread = async () => {
+      try {
+        const { data } = await suggestMessageUnread();
+        const temp = data || [];
+        temp.forEach((item: any) => {
+          if (item.group === 'SYSTEM') {
+            suggestionStatus.value = item.number > 0 ? true : false;
+          }
+        });
+      } catch {
+        //
+      }
+    };
+
     onMounted(() => {
+      // getSuggestMessageUnread();
       getTypeList();
       getPhoneInfo();
     });
@@ -266,14 +285,21 @@ export default defineComponent({
             <NImage class={styles.bgLine} src={bgLine} previewDisabled></NImage>
             <h2 class={styles.formTitle}>
               意见反馈
-              <NButton
-                type="primary"
-                round
-                secondary
-                class={styles.suggestionBtn}
-                onClick={() => (showSuggestion.value = true)}>
-                反馈记录
-              </NButton>
+              {/* suggestionStatus */}
+              <NBadge
+                dot={suggestionStatus.value}
+                color={'#FF1036'}
+                offset={[-5, 4]}
+                class={styles.suggestionBtnDot}>
+                <NButton
+                  type="primary"
+                  round
+                  secondary
+                  class={styles.suggestionBtn}
+                  onClick={() => (showSuggestion.value = true)}>
+                  反馈记录
+                </NButton>
+              </NBadge>
             </h2>
 
             <div class={styles.formWrapInfo}>

+ 4 - 4
src/views/notation/index.tsx

@@ -16,7 +16,7 @@ export default defineComponent({
     const userStore = useUserStore();
     const Authorization = userStore.getToken || '';
     const iframeRef = ref();
-    console.log(Authorization);
+    // console.log(Authorization);
     const notationOpenCreate = sessionStorage.getItem('notation-open-create');
     const openCreateUrl = notationOpenCreate == '1' ? '&addShow=1' : '';
     sessionStorage.removeItem('notation-open-create');
@@ -24,9 +24,9 @@ export default defineComponent({
       src: `${
         /(192|localhost)/.test(location.origin)
           ? // ?
-            'https://test.lexiaoya.cn'
-          : // 'http://localhost:3050'
-            location.origin
+            // 'https://test.lexiaoya.cn'
+            'http://localhost:3050'
+          : location.origin
       }/notation/#/create?v=${Date.now()}&Authorization=${Authorization}${openCreateUrl}`
       //   src: `http://localhost:3050/#/create?Authorization=${Authorization}`
     });