Browse Source

消息设置数据对接

13127578837 11 months ago
parent
commit
9fd1b2fd80

+ 31 - 0
src/api/mine/info.js

@@ -42,6 +42,37 @@ export function getMceList(param) {
     data: param,
   });
 }
+/**
+ * @消息设置详情查询
+ */
+export function getMceSettingInfo(params) {
+  return request({
+      url: '/service-iot/mceSetting/mceSettingInfo',
+      method: 'get',
+      data: params,
+  })
+}
+/**
+ * @消息设置详情查询
+ */
+export function updateMceReceiveStatus(params) {
+  return request({
+      url: '/service-iot/mceReceive',
+      method: 'put',
+      data: params,
+  })
+}
+/**
+ * @消息设置新增/修改接口
+ */
+//
+export function addMceSetting(data) {
+  return request({
+      url: '/service-iot/mceSetting/addMceSetting',
+      method: 'post',
+      data
+  })
+}
 
 /**
  * @字典类型接口

+ 43 - 15
src/pages/common/appMessage/index.vue

@@ -1,31 +1,31 @@
 <template>
-  <scroll-view class="scroll-height" :scroll-y="true" :scroll-into-view="scrollIntoView" :data-theme="'theme-' + proxy.$settingStore.themeColor.name" style="padding-bottom: 44px">
+  <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>
         <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-cell2 list-cell-arrow2">
+          <view class="content-area-center radius bg-white list-cell list-cell-arrow">
             <view class="">
               <image class="content-area-center-image-bg" :src="all.img" />
               <view class="content-area-center-title font16">{{ all.infoTitle }}</view>
               <view class="content-area-center-time font14 ">{{ all.createTime.substring(5,10) }} {{ all.createTime.substring(11,16) }}</view>
             </view>
             <view class="content-area-center-cont font14">{{ all.infoContent }}</view>
+            <view class="content-area-center-status font12" :style="{color: all.readFlag == 0 ? 'rgb(20, 158, 255)' : '#ccc' }">{{ all.readFlag == 0 ? '未读' : '已读' }}</view>
           </view>
         </view>
       </view>
     </view>
   </scroll-view>
+  <oa-tabbar :tabbarValue="1"></oa-tabbar>
 </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 { useStores, commonStores,stystemStores } from "@/store/modules/index";
-import { getMceList } from "@/api/mine/info.js";
-const useStore = useStores();
-const stystemStore = stystemStores();
+import { getMceList,updateMceReceiveStatus } from "@/api/mine/info.js";
+import { storage_msgType } from "@/utils/storage"; 
 const { proxy } = getCurrentInstance();
 const infoType = ref()//消息类型
 const loading =ref(false)
@@ -37,7 +37,7 @@ const data = reactive({
   noticeList: [],
 });
 
-const { scrollIntoView, scrollIntoViewBool, tabsCurrent, allInfoList, noticeList } = toRefs(data);
+const { scrollIntoView, tabsCurrent, noticeList } = toRefs(data);
 
 /**
  * @初始化
@@ -54,10 +54,24 @@ function tabsClick(e) {
 }
 
 /**
- * @跳转
+ * @跳转相应类型系统
  */
 function goContentDetails(e) {
-    proxy.$tab.navigateTo(`/pages/common/textview/index?id=${e.id}`);
+  console.log(e)
+  if(e.infoType == 4){
+    proxy.$tab.navigateTo(`/pages/business/fireIot/alarmManage/alarmDetails/index?id=${e.id}`).then(() => {
+      if(!e.readFlag){
+        updateMceReceiveStatus({id:e.id})
+      }
+    })
+  }else{
+    proxy.$tab.navigateTo(`/pages/common/textview/index?id=${e.id}`).then(() => {
+      if(!e.readFlag){
+        updateMceReceiveStatus({id:e.id})
+      }
+    })
+  }
+
 }
 
 /**
@@ -67,12 +81,12 @@ function goContentDetails(e) {
 function infoListApi() {
   proxy.$modal.loading("加载中");
   getMceList({
-    current: 1,
-    size: 10,
+    // current: 1,
+    // size: 10,
     infoType: infoType.value
   }).then((requset) => {
     let data = requset.data.records
-    let infoTypeList = stystemStore.infoList.static.infoTypeStatic
+    let infoTypeList = storage_msgType.get("msgType")?.infoTypeStatic
     if (requset.status === "SUCCESS") {
       for (let i = 0; i < data.length; i++) {
         for (let j = 0; j < infoTypeList.length; j++) {
@@ -109,6 +123,7 @@ onLoad((options) => {
 onReady(() => {});
 
 onShow(() => {
+  init();
   //调用系统主题颜色
   proxy.$settingStore.systemThemeColor([1]);
 });
@@ -131,7 +146,8 @@ onNavigationBarButtonTap((e) => {
 
   .content-area {
     &-center {
-      margin: 0 10px 20px 10px;
+      margin: 14px 10px -2px;
+      width:calc(100% - 20px);
       padding: 15px;
       overflow: hidden;
       position: relative;
@@ -149,12 +165,12 @@ onNavigationBarButtonTap((e) => {
         white-space: nowrap;      /* 确保文本在一行内显示 */
         overflow: hidden;         /* 隐藏超出容器的内容 */
         text-overflow: ellipsis;  /* 使用省略号表示被截断的文本 */
-        width: 60%;             /* 定义容器宽度 */
+        width: 40%;             /* 定义容器宽度 */
       }
       &-time {
         color: #909399;
         float:right;
-        margin-right:4px;
+        margin-right:14px;
         margin-top:12px
       }
       &-cont {
@@ -165,7 +181,19 @@ onNavigationBarButtonTap((e) => {
         text-overflow: ellipsis;  /* 使用省略号表示被截断的文本 */
         width: 100%;             /* 定义容器宽度 */
       }
+      &-status {
+        margin-top:16px;
+        text-align: right;
+        width: 100%;
+      }
     }
   }
 }
+.list-cell::after{
+  position: absolute;
+}
+.list-cell-arrow::before{
+  top:66rpx;
+  position: absolute;
+}
 </style>

+ 1 - 0
src/pages/common/textview/index.vue

@@ -4,6 +4,7 @@
       <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>
 

+ 45 - 39
src/pages/info.vue

@@ -1,9 +1,18 @@
 <template>
   <u-navbar :autoBack="false" :placeholder="true" :safeAreaInsetTop="true" :bgColor="proxy.$settingStore.themeColor.color">
-    <template #left>
+    <template #left >
       <view class="u-navbar__content__left__item">
-        <view class="u-navbar__content__left__item__title" style="color: #fff">消息({{ stystemStore.infoList.static.total || 0 }})</view>
+        <view class="u-navbar__content__left__item__title" style="color: #fff">
+          消息
+        </view>
+      </view>
+      <view class="u-navbar__content__left__item topBadge">
+        <u-badge numberType="overflow" max="99" :value="infoList.total || 0"></u-badge>
+      </view>
+      <view class="u-navbar__content__left__item" @click="clearMsg" v-if="infoList.total >0">
+        <image class="image-bg-top" src="/static/images/common/clear.png" />
       </view>
+      
     </template>
     <template #right>
       <!-- <view class="u-navbar__content__right__item">
@@ -18,8 +27,8 @@
     </template>
   </u-navbar>
 
-  <scroll-view class="info-container bg-white" scroll-y :style="`height: calc(100vh - (50px + ${proxy.$settingStore.barHightTop} + ${proxy.$settingStore.tabBarHeight}))`">
-    <view class="content-area" v-for="item in stystemStore.infoList.static.infoTypeStatic" :key="item" @tap="goAppMessage(`/pages/common/appMessage/index?type=${item.type}`)">
+  <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-avatar">
         <image class="image-bg" :src="item.img" />
         <view class="uni_top_right font12" style="margin: auto 0">
@@ -42,47 +51,23 @@
 
 <script setup>
 /*----------------------------------依赖引入-----------------------------------*/
-import { onLoad, onShow, onHide, onLaunch } from "@dcloudio/uni-app";
-import { ref, onMounted, inject, shallowRef, reactive, getCurrentInstance, toRefs } from "vue";
+import { onLoad, onShow } from "@dcloudio/uni-app";
+import {  reactive, getCurrentInstance, toRefs } from "vue";
 /*----------------------------------接口引入-----------------------------------*/
-import { getMceReceiveStatic, getDictList } from "@/api/mine/info.js";
+import { getMceReceiveStatic, getDictList, updateMceReceiveStatus } from "@/api/mine/info.js";
 /*----------------------------------组件引入-----------------------------------*/
 /*----------------------------------store引入-----------------------------------*/
-import { stystemStores } from "@/store/modules/index";
 /*----------------------------------公共方法引入-----------------------------------*/
+import { storage_msgType } from "@/utils/storage"; 
 /*----------------------------------公共变量-----------------------------------*/
 const { proxy } = getCurrentInstance();
-const stystemStore = stystemStores();
 /*----------------------------------变量声明-----------------------------------*/
 
 const data = reactive({
-  infoList: [
-    {
-      id: 1,
-      label: "应用消息",
-      img: "/static/images/common/appMessage.png",
-      time: "5月15日",
-      cont: "您收到一条最新消息,请及时查看",
-      badge: 1,
-      path: "/pages/common/appMessage/index",
-    },
-    // {
-    //   id: 2,
-    //   label: "消防知识库",
-    //   time: "5月15日",
-    //   cont: "您收到一条最新消息,请及时查看",
-    //   badge: 0,
-    // },
-    {
-      id: 3,
-      label: "告警通知",
-      img: "/static/images/common/alarmMessage.png",
-      time: "5月15日",
-      cont: "您收到一条最新消息,请及时查看",
-      badge: 0,
-      path: "/pages/common/alarmMessage/index",
-    },
-  ],
+  infoList: {
+    infoTypeStatic:[],
+    total:0
+  }
 });
 
 const { infoList } = toRefs(data);
@@ -116,11 +101,21 @@ function init() {
           }
         }
       }
-      stystemStore.infoList.static = receiveStatic;
+      infoList.value = receiveStatic
+      storage_msgType.set("msgType",receiveStatic)
     });
   });
 }
-
+/**
+ * 清除消息
+ */
+function clearMsg(){
+  if(infoList.value.total >0){
+    updateMceReceiveStatus({id:0}).then(() => {
+      init()
+    })
+  }
+}
 function goAppMessage(path) {
   proxy.$tab.navigateTo(path);
 }
@@ -135,12 +130,20 @@ onShow(() => {
   init();
 });
 
-onLoad((options) => {
+onLoad(() => {
   uni.hideTabBar(); //隐藏自带tabbar
 });
 </script>
 
 <style lang="scss" scoped>
+.topBadge{
+  margin-top:-14px;
+  margin-left:0px;
+}
+.image-bg-top{
+  width:15px;
+  height:19px;
+}
 .info-container {
   padding:0 12px;
   .content-area {
@@ -184,4 +187,7 @@ onLoad((options) => {
     }
   }
 }
+.list-cell-arrow::before{
+  right:10rpx
+}
 </style>

+ 2 - 2
src/pages/login.vue

@@ -142,8 +142,8 @@ function init() {
   }
 
   if (window.location.host) {
-    // linkUrl.value = window.location.host;
-    linkUrl.value = "172.16.120.165:13200";
+    linkUrl.value = window.location.host;
+    // linkUrl.value = "172.16.120.165:13200";
     // linkUrl.value = "localhost:81";
 
     useStore.GetMobileTenantConfig({ url: linkUrl.value });

+ 72 - 0
src/pages/mine/msg/index copy.vue

@@ -0,0 +1,72 @@
+<template>
+  <view class="msg-container">
+    <view class="oa-header-section">
+      <view class="menu-list mt0 mlr0">
+        <view class="list-cell">
+          <view class="menu-item">
+            <view class="title" style="width: 100%">通知公告</view>
+            <u-switch v-model="state.switchList.noticeBulletin" size="20"></u-switch>
+          </view>
+        </view>
+        <view class="list-cell">
+          <view class="menu-item">
+            <view class="title" style="width: 100%">设备告警</view>
+            <u-switch v-model="state.switchList.deviceAlarm" size="20"></u-switch>
+          </view>
+        </view>
+        <view class="list-cell">
+          <view class="menu-item">
+            <view class="title" style="width: 100%">巡检系统</view>
+            <u-switch v-model="state.switchList.inspectionSystem" size="20"></u-switch>
+          </view>
+        </view>
+        <view class="list-cell">
+          <view class="menu-item">
+            <view class="title" style="width: 100%">会议系统</view>
+            <u-switch v-model="state.switchList.meetingNotice" size="20"></u-switch>
+          </view>
+        </view>
+      </view>
+    </view>
+  </view>
+</template>
+
+<script setup>
+import config from "@/config";
+import { onReady, onLoad, onShow, onNavigationBarButtonTap } from "@dcloudio/uni-app";
+import { ref, reactive, computed, getCurrentInstance, toRefs, inject } from "vue";
+import { useStores, commonStores } from "@/store/modules/index";
+import { msgApi } from "@/api/mine";
+
+const useStore = useStores();
+const { proxy } = getCurrentInstance();
+
+const state = reactive({
+  switchList: {},
+});
+
+/**
+ * @初始化
+ */
+function init() {
+  msgApi()
+    .Select()
+    .then((res) => {
+      state.switchList = res.data.appMode;
+    });
+}
+
+onLoad(() => {
+  init();
+});
+
+onShow(() => {
+  //调用系统主题颜色
+  proxy.$settingStore.systemThemeColor([1]);
+});
+</script>
+
+<style lang="scss" scoped>
+.msg-container {
+}
+</style>

+ 44 - 38
src/pages/mine/msg/index.vue

@@ -1,59 +1,62 @@
 <template>
   <view class="msg-container">
+    <view class="tip">提醒设置:关闭后,仍会接收此消息,但不进行消息接收提示</view>
     <view class="oa-header-section">
       <view class="menu-list mt0 mlr0">
-        <view class="list-cell">
+        <view class="list-cell" v-for="(item,index) in modeList" :key="index">
           <view class="menu-item">
-            <view class="title" style="width: 100%">通知公告</view>
-            <u-switch v-model="state.switchList.noticeBulletin" size="20"></u-switch>
-          </view>
-        </view>
-        <view class="list-cell">
-          <view class="menu-item">
-            <view class="title" style="width: 100%">设备告警</view>
-            <u-switch v-model="state.switchList.deviceAlarm" size="20"></u-switch>
-          </view>
-        </view>
-        <view class="list-cell">
-          <view class="menu-item">
-            <view class="title" style="width: 100%">巡检系统</view>
-            <u-switch v-model="state.switchList.inspectionSystem" size="20"></u-switch>
-          </view>
-        </view>
-        <view class="list-cell">
-          <view class="menu-item">
-            <view class="title" style="width: 100%">会议系统</view>
-            <u-switch v-model="state.switchList.meetingNotice" size="20"></u-switch>
+            <view class="title" style="width: 100%">{{ proxy.$common.mapping("dictLabel", "dictValue", index, dictList) }}</view>
+            <u-switch v-model="modeList[index]" size="20" @change="changeMode(modeList)"></u-switch>
           </view>
         </view>
       </view>
     </view>
   </view>
 </template>
-
 <script setup>
-import config from "@/config";
-import { onReady, onLoad, onShow, onNavigationBarButtonTap } from "@dcloudio/uni-app";
-import { ref, reactive, computed, getCurrentInstance, toRefs, inject } from "vue";
-import { useStores, commonStores } from "@/store/modules/index";
-import { msgApi } from "@/api/mine";
-
-const useStore = useStores();
+import { onLoad, onShow } from "@dcloudio/uni-app";
+import { reactive, getCurrentInstance, toRefs, inject } from "vue";
+import { getMceSettingInfo, getDictList, addMceSetting } from "@/api/mine/info.js";
 const { proxy } = getCurrentInstance();
-
 const state = reactive({
-  switchList: {},
+  id: "",
+  modeType: "",
+  modeList:[],
+  dictList:[]
 });
-
+const { id, modeList, modeType, dictList } = toRefs(state);
 /**
  * @初始化
  */
 function init() {
-  msgApi()
-    .Select()
-    .then((res) => {
-      state.switchList = res.data.appMode;
+  getMceSettingInfo().then((res) => {
+    getDictList({
+      dictType: "sys_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
     });
+  });
+}
+/**
+ * @通知状态变更
+ */
+ function changeMode() {
+  addMceSetting({
+      id:id.value,
+      [modeType.value]:JSON.stringify(modeList.value)
+    }).then((response) => {
+      proxy.$modal.msg("修改成功");
+      init()
+    })
 }
 
 onLoad(() => {
@@ -65,8 +68,11 @@ onShow(() => {
   proxy.$settingStore.systemThemeColor([1]);
 });
 </script>
-
 <style lang="scss" scoped>
-.msg-container {
+.tip{
+  background: #F9F9F9;
+  color:#7D7E7E;
+  padding:10px 18px;
+  font-size: 13px;
 }
 </style>

BIN
src/static/images/common/clear.png


+ 0 - 27
src/static/scss/global.scss

@@ -55,33 +55,6 @@
   margin-top: -6px;
   right: 30rpx;
 }
-.list-cell2::after {
-  content: '';
-  position: absolute;
-  border-bottom: 1px solid #eaeef1;
-  -webkit-transform: scaleY(0.5) translateZ(0);
-  transform: scaleY(0.5) translateZ(0);
-  transform-origin: 0 100%;
-  bottom: 0;
-  right: 0;
-  left: 0;
-  pointer-events: none;
-}
-
-.list-cell-arrow2::before {
-  content: ' ';
-  height: 10px;
-  width: 10px;
-  border-width: 2px 2px 0 0;
-  border-color: #c0c0c0;
-  border-style: solid;
-  -webkit-transform: matrix(0.5, 0.5, -0.5, 0.5, 0, 0);
-  transform: matrix(0.5, 0.5, -0.5, 0.5, 0, 0);
-  position: absolute;
-  top: 32.5%;
-  margin-top: -6px;
-  right: 10rpx;
-}
 
 .menu-list {
   margin: 0.625rem 0.625rem;

+ 6 - 1
src/store/modules/stystem.js

@@ -18,7 +18,12 @@ const stystemStores = defineStore(`${storage.get("userId")}_storage-stystem`, {
 
             userId: storage.get("userId"),//用户ID
         },
-        infoList: {},
+        infoList: {
+            static:{
+                infoTypeStatic:[],
+                total:undefined
+            }
+        },
     }),
     // unistorage: true,
     actions: {

+ 19 - 2
src/utils/storage.js

@@ -39,5 +39,22 @@ const storage_stystem = {
     uni.removeStorageSync(useStores().userId + "_storage_common")
   }
 }
-
-export { storage, storage_stystem }
+const storage_msgType = {
+  set: function (key, value) {
+    let tmp = uni.getStorageSync(useStores().userId + "_storage_msgType")
+    tmp = tmp ? tmp : {}
+    tmp[key] = value
+    uni.setStorageSync(useStores().userId + "_storage_msgType", tmp)
+  },
+  get: function (key) {
+    return uni.getStorageSync(useStores().userId + "_storage_msgType")[key] || ""
+  },
+  remove: function (key) {
+    delete uni.getStorageSync(useStores().userId + "_storage_msgType")[key]
+    uni.setStorageSync(useStores().userId + "_storage_msgType", uni.getStorageSync(useStores().userId + "_storage_msgType"))
+  },
+  clean: function () {
+    uni.removeStorageSync(useStores().userId + "_storage_msgType")
+  }
+}
+export { storage, storage_stystem,storage_msgType }