Browse Source

修复消息中心BUG

fanghuisheng 10 months ago
parent
commit
b55dd63bd4

+ 3 - 0
src/App.vue

@@ -7,11 +7,14 @@ import { defineComponent, getCurrentInstance, inject, nextTick, onMounted, watch
 /*----------------------------------store引入-----------------------------------*/
 /*----------------------------------公共方法引入-----------------------------------*/
 import config from "./config";
+import { storageSystem } from "@/utils/storage";
 /*----------------------------------公共变量-----------------------------------*/
 const { proxy } = getCurrentInstance();
 /*----------------------------------变量声明-----------------------------------*/
 
 function initApp() {
+  //初始化默认主题
+  proxy.$settingStore.initThemeColor();
   //初始化获取安全区高度
   proxy.$settingStore.systemHeightTop();
   //隐藏自带tabbar

+ 61 - 55
src/pages/common/appMessage/details.vue

@@ -1,57 +1,63 @@
 <template>
-    <view>
-      <uni-card class="view-title" :title="data?.infoTitle || ''">
-        <view class="uni-body view-content">{{ data?.infoContent || "" }}</view>
-        <text class="uni-body view-time">{{ data?.createTime ? data.createTime.replace("T", " ") : "" }}</text>
-      </uni-card>
-      <oa-tabbar :tabbarValue="1"></oa-tabbar>
-    </view>
-  </template>
-  
-  <script setup>
-  import { onReady, onLoad, onShow, onNavigationBarButtonTap } from "@dcloudio/uni-app";
-  import { ref, onMounted, inject, shallowRef, reactive, getCurrentInstance, toRefs } from "vue";
-  import { getMceList } from "@/api/mine/info.js";
-  const { proxy } = getCurrentInstance();
-  const id = ref(); //消息id
-  const data = ref({});
-  function init() {
-    getMceList({
-      current: 1,
-      size: 10,
-      id: id.value,
-    }).then((requset) => {
-      data.value = requset.data.records[0];
-    });
-  }
-  onLoad((options) => {
-    id.value = options.id;
-    init();
+  <view>
+    <uni-card class="view-title" :title="data?.infoTitle || ''">
+      <view class="uni-body view-content">{{ data?.infoContent || "" }}</view>
+      <text class="uni-body view-time">{{ data?.createTime ? data.createTime.replace("T", " ") : "" }}</text>
+    </uni-card>
+    <oa-tabbar :tabbarValue="1"></oa-tabbar>
+  </view>
+</template>
+
+<script setup>
+/*----------------------------------依赖引入-----------------------------------*/
+import { onReady, onLoad, onShow, onNavigationBarButtonTap } from "@dcloudio/uni-app";
+import { ref, onMounted, inject, shallowRef, reactive, getCurrentInstance, toRefs } from "vue";
+/*----------------------------------接口引入-----------------------------------*/
+import { getMceList } from "@/api/mine/info.js";
+/*----------------------------------组件引入-----------------------------------*/
+/*----------------------------------store引入-----------------------------------*/
+/*----------------------------------公共方法引入-----------------------------------*/
+/*----------------------------------公共变量-----------------------------------*/
+const { proxy } = getCurrentInstance();
+/*----------------------------------变量声明-----------------------------------*/
+const data = ref();
+
+function init(options) {
+  getMceList({
+    current: 1,
+    size: 10,
+    id: options?.contentId,
+  }).then((requset) => {
+    data.value = requset.data.records[0];
   });
-  
-  onShow(() => {
-    //调用系统主题颜色
-    proxy.$settingStore.systemThemeColor([1]);
-  });
-  </script>
-  
-  <style scoped>
-  .view-title {
-    font-weight: bold;
-  }
-  
-  .view-content {
-    font-size: 12px;
-    padding: 12px 0 0;
-    color: #333;
-    line-height: 24px;
-    font-weight: normal;
-    text-indent: 20px;
-  }
-  .view-time {
-    margin: 30px 0 10px;
-    font-size: 12px;
-    float: right;
-  }
-  </style>
-  
+}
+
+onLoad((options) => {
+  init(options);
+});
+
+onShow(() => {
+  //调用系统主题颜色
+  proxy.$settingStore.systemThemeColor([1]);
+});
+</script>
+
+<style scoped>
+.view-title {
+  font-weight: bold;
+}
+
+.view-content {
+  font-size: 12px;
+  padding: 12px 0 0;
+  color: #333;
+  line-height: 24px;
+  font-weight: normal;
+  text-indent: 20px;
+}
+.view-time {
+  margin: 30px 0 10px;
+  font-size: 12px;
+  float: right;
+}
+</style>

+ 23 - 31
src/pages/common/appMessage/index.vue

@@ -2,7 +2,7 @@
   <scroll-view class="scroll-height" :scroll-y="true" :data-theme="'theme-' + proxy.$settingStore.themeColor.name" style="padding-bottom: 64px">
     <view class="appMessage-container">
       <view class="content-area">
-        <u-empty v-if="noticeList.length <= 0 && loading" text="暂无数据" mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png"> </u-empty>
+        <u-empty v-if="noticeList.length <= 0 && state.loading" text="暂无数据" mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png"> </u-empty>
         <view :id="index == noticeList.length - 1 ? 'bottomInfo' : ''" v-for="(all, index) in noticeList" :key="index" v-show="noticeList.length > 0" @click="goContentDetails(all)">
           <view class="content-area-center radius bg-white list-cell list-cell-arrow">
             <view class="">
@@ -21,23 +21,31 @@
 </template>
 
 <script setup>
+/*----------------------------------依赖引入-----------------------------------*/
 import { onLoad, onShow, onReady, onHide, onLaunch, onNavigationBarButtonTap, onPageScroll } from "@dcloudio/uni-app";
 import { ref, reactive, computed, getCurrentInstance, toRefs, inject } from "vue";
+/*----------------------------------接口引入-----------------------------------*/
 import { getMceList, updateMceReceiveStatus } from "@/api/mine/info.js";
+/*----------------------------------组件引入-----------------------------------*/
+/*----------------------------------store引入-----------------------------------*/
+/*----------------------------------公共方法引入-----------------------------------*/
 import { storageSystem } from "@/utils/storage";
+/*----------------------------------公共变量-----------------------------------*/
 const { proxy } = getCurrentInstance();
-const infoType = ref(); //消息类型
-const loading = ref(false);
-const data = reactive({
+const { message_type } = proxy.useDict("message_type");
+/*----------------------------------变量声明-----------------------------------*/
+const state = reactive({
+  loading: false,
+  infoType: undefined, //消息类型
+
   scrollIntoView: "",
   tabsCurrent: 0,
 
   allInfoList: [],
   noticeList: [],
-  pageTitle: undefined,
 });
 
-const { scrollIntoView, tabsCurrent, noticeList, pageTitle } = toRefs(data);
+const { scrollIntoView, tabsCurrent, noticeList } = toRefs(state);
 
 /**
  * @tabs点击事件
@@ -50,15 +58,14 @@ function tabsClick(e) {
  * @跳转相应类型系统
  */
 function goContentDetails(e) {
-  console.log(e);
   if (e.infoType == 4) {
-    proxy.$tab.navigateTo(`/pages/business/fireIot/alarmManage/alarmDetails/index?id=${e.id}`).then(() => {
+    proxy.$tab.navigateTo(`/pages/business/fireIot/alarmManage/alarmDetails/index?contentId=${e.contentId}`).then(() => {
       if (!e.readFlag) {
         updateMceReceiveStatus({ id: e.id });
       }
     });
   } else {
-    proxy.$tab.navigateTo(`/pages/common/appMessage/details?id=${e.id}`).then(() => {
+    proxy.$tab.navigateTo(`/pages/common/appMessage/details?contentId=${e.contentId}`).then(() => {
       if (!e.readFlag) {
         updateMceReceiveStatus({ id: e.id });
       }
@@ -72,30 +79,18 @@ function goContentDetails(e) {
  */
 function infoListApi(options) {
   proxy.$modal.loading("加载中");
-  let infoTypeList = storageSystem.get("infoList")?.infoTypeStatic;
-  for (let i = 0; i < infoTypeList.length; i++) {
-    if (infoType.value == infoTypeList[i].infoType) {
-      pageTitle.value = infoTypeList[i].label;
-      break;
-    }
-  }
+
   uni.setNavigationBarTitle({
-    title: pageTitle.value,
+    title: options?.typeName ? options?.typeName : "消息列表",
   });
+
   getMceList({
-    infoType: infoType.value,
+    infoType: options?.type,
   }).then((requset) => {
     let data = requset.data.records;
     if (requset.status === "SUCCESS") {
-      noticeList.value = data;
-      loading.value = true;
-      setTimeout(() => {
-        scrollIntoView.value = "bottomInfo";
-      }, 0);
-
-      setTimeout(() => {
-        proxy.$modal.closeLoading();
-      }, 100);
+      state.noticeList = data;
+      state.loading = true;
     }
     setTimeout(() => {
       scrollIntoView.value = "bottomInfo";
@@ -106,7 +101,7 @@ function infoListApi(options) {
     }, 100);
 
     if ("id" in options) {
-      noticeList.value.forEach((e) => {
+      state.noticeList.forEach((e) => {
         if (e.id == options.id) {
           goContentDetails(e);
         }
@@ -116,15 +111,12 @@ function infoListApi(options) {
 }
 
 onLoad((options) => {
-  infoType.value = options.type;
-
   infoListApi(options);
 });
 
 onReady(() => {});
 
 onShow(() => {
-  infoListApi({});
   //调用系统主题颜色
   proxy.$settingStore.systemThemeColor([1]);
 });

+ 2 - 2
src/pages/info copy.vue

@@ -54,7 +54,7 @@ import { systemStores } from "@/store/modules/index";
 /*----------------------------------公共变量-----------------------------------*/
 const { proxy } = getCurrentInstance();
 const systemStore = systemStores();
-const { sys_message_type } = proxy.useDict("sys_message_type");
+const { message_type } = proxy.useDict("message_type");
 /*----------------------------------变量声明-----------------------------------*/
 
 const data = reactive({
@@ -92,7 +92,7 @@ const { infoList } = toRefs(data);
 function init() {
   getMceReceiveStatic().then((res) => {
     systemStore.infoList.messageCountData = res.data;
-    systemStore.infoList.messageTypeData = sys_message_type.value;
+    systemStore.infoList.messageTypeData = message_type.value;
     res.data.infoTypeStatic.forEach((e) => {});
   });
 }

+ 5 - 5
src/pages/info.vue

@@ -25,7 +25,7 @@
   </u-navbar>
 
   <scroll-view class="info-container bg-white" scroll-y :style="`height: calc(100vh - (50px + ${proxy.$settingStore.barHightTop} + ${proxy.$settingStore.tabBarHeight}));position: relative;`">
-    <view class="content-area list-cell list-cell-arrow" v-for="item in infoList.infoTypeStatic" :key="item" @tap="goAppMessage(`/pages/common/appMessage/index?type=${item.type}`)">
+    <view class="content-area list-cell list-cell-arrow" v-for="item in infoList.infoTypeStatic" :key="item" @tap="goAppMessage(item)">
       <view class="content-area-avatar">
         <image class="image-bg" :src="item.img" />
         <view class="uni_top_right font12" style="margin: auto 0">
@@ -58,7 +58,7 @@ import { getMceReceiveStatic, updateMceReceiveStatus } from "@/api/mine/info.js"
 import { storageSystem } from "@/utils/storage";
 /*----------------------------------公共变量-----------------------------------*/
 const { proxy } = getCurrentInstance();
-const { sys_message_type } = proxy.useDict("sys_message_type");
+const { message_type } = proxy.useDict("message_type");
 /*----------------------------------变量声明-----------------------------------*/
 const state = reactive({
   infoList: {
@@ -71,7 +71,7 @@ const { infoList } = toRefs(state);
 function init() {
   getMceReceiveStatic().then((res) => {
     let receiveStatic = { infoTypeStatic: res.data.infoTypeStatic, total: res.data.notReadCount };
-    let dictList = sys_message_type.value;
+    let dictList = message_type.value;
     if (receiveStatic.infoTypeStatic.length > 0) {
       for (let i = 0; i < receiveStatic.infoTypeStatic.length; i++) {
         for (let j = 0; j < dictList.length; j++) {
@@ -111,8 +111,8 @@ function clearMsg() {
   });
 }
 
-function goAppMessage(path) {
-  proxy.$tab.navigateTo(path);
+function goAppMessage(item) {
+  proxy.$tab.navigateTo(`/pages/common/appMessage/index?type=${item.type}&typeName=${item.label}`);
 }
 
 function handleIconClick(type) {

+ 15 - 19
src/pages/mine/msg/index.vue

@@ -1,7 +1,7 @@
 <template>
   <view class="msg-container">
-    <view class="tip">提醒设置:关闭后,仍会接收此消息,但不进行消息接收提示</view>
-    <view class="oa-header-section">
+    <view class="oa-header-section">提醒设置:关闭后,仍会接收此消息,但不进行消息接收提示</view>
+    <view class="oa-content-section">
       <view class="menu-list mt0 mlr0">
         <view class="list-cell" v-for="(item, index) in modeList" :key="index">
           <view class="menu-item">
@@ -24,7 +24,7 @@ import { getMceSettingInfo, addMceSetting } from "@/api/mine/info.js";
 /*----------------------------------公共方法引入-----------------------------------*/
 /*----------------------------------公共变量-----------------------------------*/
 const { proxy } = getCurrentInstance();
-const { sys_message_type } = proxy.useDict("sys_message_type");
+const { message_type } = proxy.useDict("message_type");
 /*----------------------------------变量声明-----------------------------------*/
 const state = reactive({
   id: "",
@@ -39,20 +39,16 @@ const { id, modeList, modeType, dictList } = toRefs(state);
  */
 function init() {
   getMceSettingInfo().then((res) => {
-    getDictList({
-      dictType: "message_type",
-    }).then((res1) => {
-      //#ifdef APP-PLUS
-        modeList.value = res.data.appMode
-        modeType.value = "appMode"
-      //#endif
-      //#ifdef H5 || MP-WEIXIN
-        modeList.value = res.data.wcMode
-        modeType.value = "wcMode"
-      //#endif
-      id.value= res.data.id
-      dictList.value = res1.data.rows
-    });
+    //#ifdef APP-PLUS
+    modeList.value = res.data.appMode;
+    modeType.value = "appMode";
+    //#endif
+    //#ifdef H5 || MP-WEIXIN
+    modeList.value = res.data.wcMode;
+    modeType.value = "wcMode";
+    //#endif
+    id.value = res.data.id;
+    dictList.value = message_type.value;
   });
 }
 /**
@@ -78,10 +74,10 @@ onShow(() => {
 });
 </script>
 <style lang="scss" scoped>
-.tip {
+.oa-header-section {
   background: #f9f9f9;
   color: #7d7e7e;
   padding: 10px 18px;
-  font-size: 13px;
+  font-size: $uni-font-size-sm;
 }
 </style>