info.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <u-navbar :autoBack="false" :placeholder="true" :safeAreaInsetTop="true" :bgColor="proxy.$settingStore.themeColor.color">
  3. <template #left >
  4. <view class="u-navbar__content__left__item">
  5. <view class="u-navbar__content__left__item__title" style="color: #fff">
  6. 消息
  7. </view>
  8. </view>
  9. <view class="u-navbar__content__left__item topBadge">
  10. <u-badge numberType="overflow" max="99" :value="infoList.total || 0"></u-badge>
  11. </view>
  12. <view class="u-navbar__content__left__item" @click="clearMsg" v-if="infoList.total >0">
  13. <image class="image-bg-top" src="/static/images/common/clear.png" />
  14. </view>
  15. </template>
  16. <template #right>
  17. <!-- <view class="u-navbar__content__right__item">
  18. <text class="iconfont oaIcon-qingchu" @click="handleIconClick('清除')"></text>
  19. </view>
  20. <view class="u-navbar__content__right__item">
  21. <text class="iconfont oaIcon-sousuo" @click="handleIconClick('搜索')"></text>
  22. </view> -->
  23. <view class="u-navbar__content__right__item">
  24. <text class="iconfont oaIcon-shezhi" @click="handleIconClick('设置')"></text>
  25. </view>
  26. </template>
  27. </u-navbar>
  28. <scroll-view class="info-container bg-white " scroll-y :style="`height: calc(100vh - (50px + ${proxy.$settingStore.barHightTop} + ${proxy.$settingStore.tabBarHeight}));position: relative;`">
  29. <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}`)">
  30. <view class="content-area-avatar">
  31. <image class="image-bg" :src="item.img" />
  32. <view class="uni_top_right font12" style="margin: auto 0">
  33. <u-badge numberType="overflow" max="99" :value="item.notReadCount"></u-badge>
  34. </view>
  35. </view>
  36. <view class="content-area-child">
  37. <view class="uni-item mb5 ml10">
  38. <view class="uni-item-text font14" style="color: #000000">{{ item.label }}</view>
  39. </view>
  40. <view class="uni-item">
  41. <view class="uni-item-text font12" style="color: #909399">{{ item.cont }}</view>
  42. </view>
  43. </view>
  44. </view>
  45. </scroll-view>
  46. <oa-tabbar :tabbarValue="1"></oa-tabbar>
  47. </template>
  48. <script setup>
  49. /*----------------------------------依赖引入-----------------------------------*/
  50. import { onLoad, onShow } from "@dcloudio/uni-app";
  51. import { reactive, getCurrentInstance, toRefs } from "vue";
  52. /*----------------------------------接口引入-----------------------------------*/
  53. import { getMceReceiveStatic, getDictList, updateMceReceiveStatus } from "@/api/mine/info.js";
  54. /*----------------------------------组件引入-----------------------------------*/
  55. /*----------------------------------store引入-----------------------------------*/
  56. /*----------------------------------公共方法引入-----------------------------------*/
  57. import { storage_msgType } from "@/utils/storage";
  58. /*----------------------------------公共变量-----------------------------------*/
  59. const { proxy } = getCurrentInstance();
  60. /*----------------------------------变量声明-----------------------------------*/
  61. const data = reactive({
  62. infoList: {
  63. infoTypeStatic:[],
  64. total:0
  65. }
  66. });
  67. const { infoList } = toRefs(data);
  68. function init() {
  69. getMceReceiveStatic().then((res) => {
  70. getDictList({
  71. dictType: "message_type",
  72. }).then((res1) => {
  73. let receiveStatic = { infoTypeStatic:res.data.infoTypeStatic ,total:res.data.notReadCount }
  74. let dictList = res1.data.rows
  75. if(receiveStatic.infoTypeStatic.length>0){
  76. for (let i = 0; i < receiveStatic.infoTypeStatic.length; i++) {
  77. for (let j = 0; j < dictList.length; j++) {
  78. if(receiveStatic.infoTypeStatic[i].infoType == dictList[j].dictValue){
  79. receiveStatic.infoTypeStatic[i].label = dictList[j].dictLabel
  80. receiveStatic.infoTypeStatic[i].type = dictList[j].dictValue
  81. if(receiveStatic.infoTypeStatic[i].infoType == 1){
  82. receiveStatic.infoTypeStatic[i].img = "/static/images/common/noticeMessage.png"
  83. }
  84. if(receiveStatic.infoTypeStatic[i].infoType == 2){
  85. receiveStatic.infoTypeStatic[i].img = "/static/images/common/inspectionMessage.png"
  86. }
  87. if(receiveStatic.infoTypeStatic[i].infoType == 3){
  88. receiveStatic.infoTypeStatic[i].img = "/static/images/common/meetingMessage.png"
  89. }
  90. if(receiveStatic.infoTypeStatic[i].infoType == 4){
  91. receiveStatic.infoTypeStatic[i].img = "/static/images/common/alarmMessage.png"
  92. }
  93. }
  94. }
  95. }
  96. }
  97. infoList.value = receiveStatic
  98. storage_msgType.set("msgType",receiveStatic)
  99. });
  100. });
  101. }
  102. /**
  103. * 清除消息
  104. */
  105. function clearMsg(){
  106. if(infoList.value.total >0){
  107. updateMceReceiveStatus({id:0}).then(() => {
  108. init()
  109. })
  110. }
  111. }
  112. function goAppMessage(path) {
  113. proxy.$tab.navigateTo(path);
  114. }
  115. function handleIconClick(type) {
  116. if (type === "设置") {
  117. proxy.$tab.navigateTo("/pages/mine/msg/index")
  118. }
  119. }
  120. onShow(() => {
  121. init();
  122. });
  123. onLoad(() => {
  124. uni.hideTabBar(); //隐藏自带tabbar
  125. });
  126. </script>
  127. <style lang="scss" scoped>
  128. .topBadge{
  129. margin-top:-14px;
  130. margin-left:0px;
  131. }
  132. .image-bg-top{
  133. width:15px;
  134. height:19px;
  135. }
  136. .info-container {
  137. padding:0 12px;
  138. .content-area {
  139. display: flex;
  140. padding: 13px 13px 13px 0px;
  141. &-avatar {
  142. display: flex;
  143. margin: auto 20upx auto 0;
  144. position: relative;
  145. .image-bg {
  146. width: 40px;
  147. height: 40px;
  148. }
  149. .uni_top_right{
  150. position: absolute;
  151. right:-10px;
  152. top:-4px;
  153. }
  154. }
  155. &-child {
  156. width: calc(100% - (32px + 0.625rem));
  157. justify-content: center;
  158. margin: auto;
  159. .uni-item {
  160. display: flex;
  161. white-space: nowrap;
  162. .uni-item-text {
  163. margin-right: auto;
  164. overflow: hidden;
  165. text-overflow: ellipsis;
  166. }
  167. .uni-item-right {
  168. width: auto;
  169. text-align: right;
  170. }
  171. }
  172. }
  173. }
  174. }
  175. .list-cell-arrow::before{
  176. right:10rpx
  177. }
  178. </style>