소스 검색

新增全局角标功能模块

fanghuisheng 11 달 전
부모
커밋
d677e6e6d7

+ 0 - 1
src/App.vue

@@ -16,7 +16,6 @@ function initApp() {
   //#ifdef APP-PLUS
   plus.screen.lockOrientation("portrait-primary"); //设置不可横屏
   proxy.$settingStore.pushListener(); //开启消息推送监听
-  proxy.$setting.clearBadge(0); // 清除数字
   setInterval(proxy.$settingStore.baseAppInfo(), 1000 * 60 * 5); //动态获取用户设备信息
   //#endif
 }

+ 14 - 23
src/api/mine/info.js

@@ -47,9 +47,9 @@ export function getMceList(param) {
  */
 export function getMceSettingInfo(params) {
   return request({
-      url: '/system/mceSetting/mceSettingInfo',
-      method: 'get',
-      data: params,
+    url: '/system/mceSetting/mceSettingInfo',
+    method: 'get',
+    data: params,
   })
 }
 /**
@@ -57,30 +57,21 @@ export function getMceSettingInfo(params) {
  */
 export function updateMceReceiveStatus(params) {
   return request({
-      url: '/system/mceReceive',
-      method: 'put',
-      data: params,
+    url: '/system/mceReceive',
+    method: 'put',
+    data: params,
   })
 }
+
 /**
- * @消息设置新增/修改接口
+ * @消息设置接口
+ * @新增
+ * @修改
  */
-//
 export function addMceSetting(data) {
   return request({
-      url: '/system/mceSetting/addMceSetting',
-      method: 'post',
-      data
+    url: '/system/mceSetting/addMceSetting',
+    method: 'post',
+    data
   })
-}
-
-/**
- * @字典类型接口
- */
-export function getDictList(param) {
-  return request({
-    url: "/system/dict/data/list",
-    method: "GET",
-    data: param,
-  });
-}
+}

+ 0 - 0
src/api/system/dict/data.js → src/api/system/dict.js


+ 1 - 6
src/components/oa-upload/index.vue

@@ -60,7 +60,6 @@ const props = defineProps({
     default: {
       width: "80px",
       height: "80px",
-      marginBottom: "0px",
     },
   },
   //icon大小
@@ -150,7 +149,7 @@ function uploadViewClose(index) {
   overflow: hidden;
   width: calc(33% - 10px);
   height: 110px;
-  margin: 0 15px 15px 0;
+  margin: 0 10px 10px 0;
   border: 1px solid #d9d9d9;
   border-radius: 6px;
   cursor: pointer;
@@ -188,10 +187,6 @@ function uploadViewClose(index) {
   width: 100%;
 }
 
-.uploadView:nth-child(3n) {
-  margin: 0 !important;
-}
-
 .upload-buttom {
   display: flex;
   font-size: 28px;

+ 15 - 11
src/pages/business/common/fastMail/index.vue

@@ -69,27 +69,31 @@
 </template>
 
 <script setup>
-import config from "@/config";
+/*----------------------------------依赖引入-----------------------------------*/
 import { onLoad, onShow, onReady, onHide, onLaunch, onNavigationBarButtonTap, onPageScroll } from "@dcloudio/uni-app";
 import { ref, reactive, computed, getCurrentInstance, toRefs, inject } from "vue";
-import { useStores, commonStores } from "@/store/modules/index";
-
+/*----------------------------------接口引入-----------------------------------*/
 import { pageQuery } from "@/api/business/fastMail.js";
-
+/*----------------------------------组件引入-----------------------------------*/
+/*----------------------------------store引入-----------------------------------*/
+import { useStores, commonStores } from "@/store/modules/index";
+/*----------------------------------公共方法引入-----------------------------------*/
+/*----------------------------------公共变量-----------------------------------*/
 const { proxy } = getCurrentInstance();
+const useStore = useStores();
 const commonStore = commonStores();
+/*----------------------------------变量声明-----------------------------------*/
+const state = reactive({
+  dataList: [],
+  pageSize: 20,
+  current: 1,
+  total: 0,
 
-const dataList = ref([]);
-const pageSize = ref(20);
-const current = ref(1);
-const total = ref(0);
-
-const data = reactive({
   tabsList: [{ name: "待取件" }, { name: "已取件" }],
   tabsCurrent: 0,
 });
 
-const { tabsList, tabsCurrent } = toRefs(data);
+const { dataList, pageSize, current, total, tabsList, tabsCurrent } = toRefs(state);
 
 /**
  * @页面初始化

+ 4 - 7
src/pages/info copy.vue

@@ -46,7 +46,7 @@
 import { onLoad, onShow, onHide, onLaunch } from "@dcloudio/uni-app";
 import { ref, onMounted, inject, shallowRef, reactive, getCurrentInstance, toRefs } from "vue";
 /*----------------------------------接口引入-----------------------------------*/
-import { getMceReceiveStatic, getDictList } from "@/api/mine/info.js";
+import { getMceReceiveStatic } from "@/api/mine/info.js";
 /*----------------------------------组件引入-----------------------------------*/
 /*----------------------------------store引入-----------------------------------*/
 import { stystemStores } from "@/store/modules/index";
@@ -54,6 +54,7 @@ import { stystemStores } from "@/store/modules/index";
 /*----------------------------------公共变量-----------------------------------*/
 const { proxy } = getCurrentInstance();
 const stystemStore = stystemStores();
+const { sys_message_type } = proxy.useDict("sys_message_type");
 /*----------------------------------变量声明-----------------------------------*/
 
 const data = reactive({
@@ -91,12 +92,8 @@ const { infoList } = toRefs(data);
 function init() {
   getMceReceiveStatic().then((res) => {
     stystemStore.infoList.messageCountData = res.data;
-    getDictList({
-      dictType: "sys_message_type",
-    }).then((res1) => {
-      stystemStore.infoList.messageTypeData = res1.data.rows;
-      res.data.infoTypeStatic.forEach((e) => {});
-    });
+    stystemStore.infoList.messageTypeData = sys_message_type.value;
+    res.data.infoTypeStatic.forEach((e) => {});
   });
 }
 

+ 56 - 59
src/pages/info.vue

@@ -1,18 +1,15 @@
 <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">
-          消息
-        </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">
+      <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">
@@ -27,13 +24,13 @@
     </template>
   </u-navbar>
 
-  <scroll-view class="info-container bg-white " scroll-y :style="`height: calc(100vh - (50px + ${proxy.$settingStore.barHightTop} + ${proxy.$settingStore.tabBarHeight}));position: relative;`">
+  <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">
-            <u-badge numberType="overflow" max="99" :value="item.notReadCount"></u-badge>
-          </view>
+          <u-badge numberType="overflow" max="99" :value="item.notReadCount"></u-badge>
+        </view>
       </view>
       <view class="content-area-child">
         <view class="uni-item mb5 ml10">
@@ -52,68 +49,68 @@
 <script setup>
 /*----------------------------------依赖引入-----------------------------------*/
 import { onLoad, onShow } from "@dcloudio/uni-app";
-import {  reactive, getCurrentInstance, toRefs } from "vue";
+import { reactive, getCurrentInstance, toRefs } from "vue";
 /*----------------------------------接口引入-----------------------------------*/
-import { getMceReceiveStatic, getDictList, updateMceReceiveStatus } from "@/api/mine/info.js";
+import { getMceReceiveStatic, updateMceReceiveStatus } from "@/api/mine/info.js";
 /*----------------------------------组件引入-----------------------------------*/
 /*----------------------------------store引入-----------------------------------*/
 /*----------------------------------公共方法引入-----------------------------------*/
-import { storage_msgType } from "@/utils/storage"; 
+import { storage_msgType } from "@/utils/storage";
 /*----------------------------------公共变量-----------------------------------*/
 const { proxy } = getCurrentInstance();
+const { sys_message_type } = proxy.useDict("sys_message_type");
 /*----------------------------------变量声明-----------------------------------*/
 
 const data = reactive({
   infoList: {
-    infoTypeStatic:[],
-    total:0
-  }
+    infoTypeStatic: [],
+    total: 0,
+  },
 });
 
 const { infoList } = toRefs(data);
 
 function init() {
   getMceReceiveStatic().then((res) => {
-    getDictList({
-      dictType: "sys_message_type",
-    }).then((res1) => {
-      let receiveStatic = { infoTypeStatic:res.data.infoTypeStatic ,total:res.data.notReadCount }
-      let dictList = res1.data.rows
-      if(receiveStatic.infoTypeStatic.length>0){
-        for (let i = 0; i < receiveStatic.infoTypeStatic.length; i++) {
-          for (let j = 0; j < dictList.length; j++) {
-            if(receiveStatic.infoTypeStatic[i].infoType == dictList[j].dictValue){
-              receiveStatic.infoTypeStatic[i].label = dictList[j].dictLabel
-              receiveStatic.infoTypeStatic[i].type = dictList[j].dictValue
-              if(receiveStatic.infoTypeStatic[i].infoType == 1){
-                receiveStatic.infoTypeStatic[i].img = "/static/images/common/noticeMessage.png"
-              }
-              if(receiveStatic.infoTypeStatic[i].infoType == 2){
-                receiveStatic.infoTypeStatic[i].img = "/static/images/common/inspectionMessage.png"
-              }
-              if(receiveStatic.infoTypeStatic[i].infoType == 3){
-                receiveStatic.infoTypeStatic[i].img = "/static/images/common/meetingMessage.png"
-              }
-              if(receiveStatic.infoTypeStatic[i].infoType == 4){
-                receiveStatic.infoTypeStatic[i].img = "/static/images/common/alarmMessage.png"
-              }
+    let receiveStatic = { infoTypeStatic: res.data.infoTypeStatic, total: res.data.notReadCount };
+    let dictList = sys_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++) {
+          if (receiveStatic.infoTypeStatic[i].infoType == dictList[j].value) {
+            receiveStatic.infoTypeStatic[i].label = dictList[j].label;
+            receiveStatic.infoTypeStatic[i].type = dictList[j].value;
+            if (receiveStatic.infoTypeStatic[i].infoType == 1) {
+              receiveStatic.infoTypeStatic[i].img = "/static/images/common/noticeMessage.png";
+            }
+            if (receiveStatic.infoTypeStatic[i].infoType == 2) {
+              receiveStatic.infoTypeStatic[i].img = "/static/images/common/inspectionMessage.png";
+            }
+            if (receiveStatic.infoTypeStatic[i].infoType == 3) {
+              receiveStatic.infoTypeStatic[i].img = "/static/images/common/meetingMessage.png";
+            }
+            if (receiveStatic.infoTypeStatic[i].infoType == 4) {
+              receiveStatic.infoTypeStatic[i].img = "/static/images/common/alarmMessage.png";
             }
           }
         }
       }
-      infoList.value = receiveStatic
-      storage_msgType.set("msgType",receiveStatic)
-    });
+    }
+
+    proxy.$setting.setBadge(res.data.notReadCount); // 设置角标值
+    infoList.value = receiveStatic;
+    storage_msgType.set("msgType", receiveStatic);
   });
 }
 /**
  * 清除消息
  */
-function clearMsg(){
-  if(infoList.value.total >0){
-    updateMceReceiveStatus({id:0}).then(() => {
-      init()
-    })
+function clearMsg() {
+  if (infoList.value.total > 0) {
+    updateMceReceiveStatus({ id: 0 }).then(() => {
+      proxy.$setting.setBadge(0); // 设置角标值
+      init();
+    });
   }
 }
 function goAppMessage(path) {
@@ -122,7 +119,7 @@ function goAppMessage(path) {
 
 function handleIconClick(type) {
   if (type === "设置") {
-    proxy.$tab.navigateTo("/pages/mine/msg/index")
+    proxy.$tab.navigateTo("/pages/mine/msg/index");
   }
 }
 
@@ -136,16 +133,16 @@ onLoad(() => {
 </script>
 
 <style lang="scss" scoped>
-.topBadge{
-  margin-top:-14px;
-  margin-left:0px;
+.topBadge {
+  margin-top: -14px;
+  margin-left: 0px;
 }
-.image-bg-top{
-  width:15px;
-  height:19px;
+.image-bg-top {
+  width: 15px;
+  height: 19px;
 }
 .info-container {
-  padding:0 12px;
+  padding: 0 12px;
   .content-area {
     display: flex;
     padding: 13px 13px 13px 0px;
@@ -157,10 +154,10 @@ onLoad(() => {
         width: 40px;
         height: 40px;
       }
-      .uni_top_right{
+      .uni_top_right {
         position: absolute;
-        right:-10px;
-        top:-4px;
+        right: -10px;
+        top: -4px;
       }
     }
 
@@ -186,7 +183,7 @@ onLoad(() => {
     }
   }
 }
-.list-cell-arrow::before{
-  right:10rpx
+.list-cell-arrow::before {
+  right: 10rpx;
 }
 </style>

+ 35 - 30
src/pages/mine/msg/index.vue

@@ -3,9 +3,9 @@
     <view class="tip">提醒设置:关闭后,仍会接收此消息,但不进行消息接收提示</view>
     <view class="oa-header-section">
       <view class="menu-list mt0 mlr0">
-        <view class="list-cell" v-for="(item,index) in modeList" :key="index">
+        <view class="list-cell" v-for="(item, index) in modeList" :key="index">
           <view class="menu-item">
-            <view class="title" style="width: 100%">{{ proxy.$common.mapping("dictLabel", "dictValue", index, dictList) }}</view>
+            <view class="title" style="width: 100%">{{ proxy.$common.mapping("label", "value", index.toString(), dictList) }}</view>
             <u-switch v-model="modeList[index]" size="20" @change="changeMode(modeList)"></u-switch>
           </view>
         </view>
@@ -14,49 +14,54 @@
   </view>
 </template>
 <script setup>
+/*----------------------------------依赖引入-----------------------------------*/
 import { onLoad, onShow } from "@dcloudio/uni-app";
 import { reactive, getCurrentInstance, toRefs, inject } from "vue";
-import { getMceSettingInfo, getDictList, addMceSetting } from "@/api/mine/info.js";
+/*----------------------------------接口引入-----------------------------------*/
+import { getMceSettingInfo, addMceSetting } from "@/api/mine/info.js";
+/*----------------------------------组件引入-----------------------------------*/
+/*----------------------------------store引入-----------------------------------*/
+/*----------------------------------公共方法引入-----------------------------------*/
+/*----------------------------------公共变量-----------------------------------*/
 const { proxy } = getCurrentInstance();
+const { sys_message_type } = proxy.useDict("sys_message_type");
+/*----------------------------------变量声明-----------------------------------*/
 const state = reactive({
   id: "",
   modeType: "",
-  modeList:[],
-  dictList:[]
+  modeList: [],
+  dictList: [],
 });
 const { id, modeList, modeType, dictList } = toRefs(state);
+
 /**
  * @初始化
  */
 function init() {
   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
-    });
+    //#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 = sys_message_type.value;
   });
 }
 /**
  * @通知状态变更
  */
- function changeMode() {
+function changeMode() {
   addMceSetting({
-      id:id.value,
-      [modeType.value]:JSON.stringify(modeList.value)
-    }).then((response) => {
-      proxy.$modal.msg("修改成功");
-      init()
-    })
+    id: id.value,
+    [modeType.value]: JSON.stringify(modeList.value),
+  }).then((response) => {
+    proxy.$modal.msg("修改成功");
+    init();
+  });
 }
 
 onLoad(() => {
@@ -69,10 +74,10 @@ onShow(() => {
 });
 </script>
 <style lang="scss" scoped>
-.tip{
-  background: #F9F9F9;
-  color:#7D7E7E;
-  padding:10px 18px;
+.tip {
+  background: #f9f9f9;
+  color: #7d7e7e;
+  padding: 10px 18px;
   font-size: 13px;
 }
 </style>

+ 3 - 5
src/plugins/setting.plugins.js

@@ -87,13 +87,11 @@ const clearCache = () => {
 };
 
 export default {
-  // 设置数字
+  // 设置角标
   setBadge(value) {
+    //#ifdef APP-PLUS
     plus.runtime.setBadgeNumber(value);
-  },
-  // 清除数字
-  clearBadge(value) {
-    plus.runtime.setBadgeNumber(value);
+    //#endif
   },
   formatSize,
   clearCache,

+ 8 - 6
src/store/modules/setting.js

@@ -88,12 +88,6 @@ const settingStore = defineStore("storage-setting", {
          * @动态获取用户设备信息
          */
         baseAppInfo() {
-            uni.getNetworkType({
-                success: function (res) {
-                    this.deviceList.networkType = res.networkType;
-                },
-            });
-
             // 获取系统信息
             const systemInfo = uni.getSystemInfoSync();
             this.deviceList.deviceBrand = systemInfo.deviceBrand;
@@ -101,6 +95,14 @@ const settingStore = defineStore("storage-setting", {
             this.deviceList.deviceModel = systemInfo.deviceModel;
             this.deviceList.operateSystem = systemInfo.platform;
 
+            // 获取网络状态
+            uni.getNetworkType({
+                success: function (res) {
+                    this.deviceList.networkType = res.networkType;
+                },
+            });
+
+            // 获取定位信息
             uni.getLocation({
                 type: "gcj02",
                 geocode: true,

+ 3 - 0
src/store/modules/user.js

@@ -9,6 +9,7 @@ import { phoneVerify } from "@/api/common/index.js";
 import config from "@/config";
 import modal from "@/plugins/modal.plugins.js";
 import common from "@/plugins/common.plugins.js";
+import setting from "@/plugins/setting.plugins.js";
 
 const useStores = defineStore("useStores", {
   state: () => ({
@@ -260,6 +261,8 @@ const useStores = defineStore("useStores", {
       return new Promise((resolve, reject) => {
         logout()
           .then(() => {
+            setting.setBadge(0); // 设置角标值
+
             this.SET_TOKEN("");//清空token
             this.SET_ROLES([]);
             this.SET_PERMISSIONS([]);

+ 1 - 1
src/utils/dict.js

@@ -1,4 +1,4 @@
-import { getDicts } from '@/api/system/dict/data'
+import { getDicts } from '@/api/system/dict.js'
 import { ref, toRefs } from "vue";
 /**
  * 获取字典数据