warndata.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template name="warndata">
  2. <view>
  3. <scroll-view>
  4. <!-- 轮播 -->
  5. <swiper class="screen-swiper square-dot" :indicator-dots="true" :circular="true"
  6. :autoplay="true" interval="5000" duration="500" :style="[{animation: 'show 0.2s 1'}]">
  7. <swiper-item v-for="(item,index) in swiperList" :key="index">
  8. <image :src="item.url" mode="aspectFill" v-if="item.type=='image'"></image>
  9. <video :src="item.url" autoplay loop muted :show-play-btn="false" :controls="false" objectFit="cover" v-if="item.type=='video'"></video>
  10. </swiper-item>
  11. </swiper>
  12. <!-- 常用服务 -->
  13. <view class="cu-bar bg-white solid-bottom" :style="[{animation: 'show 0.5s 1'}]">
  14. <view class="action">
  15. <text class='cuIcon-title text-blue'></text>常用服务
  16. </view>
  17. </view>
  18. <view class="cu-list grid col-4 text-sm">
  19. <view class="cu-item animation-slide-bottom" :style="[{animationDelay: (index + 1)*0.05 + 's'}]" v-for="(item,index) in usList" :key="index" @tap="goPage(item.page)">
  20. <view class="padding text-center">
  21. <image :src="item.icon" style="width:28px;height:28px;">
  22. <view class="cu-tag badge margin-top-sm" style="margin-left:1.2em" v-if="getTtemDotInfo(item)">
  23. <block v-if="getTtemDotInfo(item)">{{getTtemDotInfo(item)}}</block>
  24. </view>
  25. </image>
  26. <view class="margin-top-xs">{{item.title}}</view>
  27. </view>
  28. </view>
  29. </view>
  30. <!-- 其他服务 -->
  31. <view class="cu-bar bg-white solid-bottom margin-top" :style="[{animation: 'show 0.6s 1'}]">
  32. <view class="action">
  33. <text class='cuIcon-title text-yellow'></text>其他服务
  34. </view>
  35. </view>
  36. <view class="cu-list grid col-4 text-sm">
  37. <view class="cu-item animation-slide-bottom" :style="[{animationDelay: (index + 1)*0.1 + 's'}]" v-for="(item,index) in osList" :key="index" @tap="goPage(item.page)">
  38. <view class="padding text-center">
  39. <image :src="item.icon" style="width:28px;height:28px;"/>
  40. <view class="margin-top-xs">{{item.title}}</view>
  41. </view>
  42. </view>
  43. </view>
  44. </scroll-view>
  45. <view class="cu-tabbar-height margin-top"></view>
  46. </view>
  47. </template>
  48. <script>
  49. import { us,os } from '@/common/util/work.js'
  50. import socket from '@/common/js-sdk/socket/socket.js'
  51. export default {
  52. name: 'home',
  53. props:{
  54. cur:String,
  55. },
  56. watch: {
  57. cur: {
  58. immediate: true,
  59. handler:function(val,oldVal){
  60. console.log('cur',val,oldVal)
  61. this.initMenu()
  62. },
  63. },
  64. },
  65. data() {
  66. return {
  67. swiperList: [
  68. {id:1,type: 'image',url: '/static/banner/banner1.png', link: ''},
  69. {id:2,type: 'image',url: '/static/banner/banner2.jpg', link: ''},
  70. {id:3,type: 'image',url: '/static/banner/banner3.jpg', link: ''},
  71. {id:4,type: 'image',url: '/static/banner/banner4.jpg', link: ''},
  72. ],
  73. middleApps: [
  74. {icon: 'line2_icon1.png', title: '审批', 'text': '个人审批'},
  75. {icon: 'line2_icon2.png', title: '审批稿', 'text': '审批草稿箱'},
  76. ],
  77. usList:us.data,
  78. osList:os.data,
  79. msgCount:0,
  80. dot:{
  81. mailHome:false
  82. }
  83. }
  84. },
  85. methods: {
  86. initMenu(){
  87. console.log("-----------home------------")
  88. this.onSocketOpen()
  89. this.onSocketReceive()
  90. this.loadCount(0);
  91. },
  92. goPage(page){
  93. if(!page){
  94. return false;
  95. }
  96. if(page==='annotationList'){
  97. this.msgCount = 0
  98. }
  99. this.dot[page]=false
  100. this.$Router.push({name: page})
  101. },
  102. // 启动webSocket
  103. onSocketOpen() {
  104. socket.init('websocket');
  105. },
  106. onSocketReceive() {
  107. var _this=this
  108. socket.acceptMessage = function(res){
  109. // console.log("页面收到的消息", res);
  110. if(res.cmd == "topic"){
  111. //系统通知
  112. _this.loadCount('1')
  113. }else if(res.cmd == "user"){
  114. //用户消息
  115. _this.loadCount('2')
  116. } else if(res.cmd == 'email'){
  117. //邮件消息
  118. _this.loadEmailCount()
  119. }
  120. }
  121. },
  122. loadCount(flag){
  123. console.log("loadCount::flag",flag)
  124. let url = '/sys/annountCement/listByUser';
  125. this.$http.get(url).then(res=>{
  126. console.log("res::",res)
  127. if(res.data.success){
  128. let msg1Count = res.data.result.anntMsgTotal;
  129. let msg2Count = res.data.result.sysMsgTotal;
  130. this.msgCount = msg1Count + msg2Count
  131. console.log("this.msgCount",this.msgCount)
  132. }
  133. })
  134. },
  135. loadEmailCount(){
  136. this.dot.mailHome = true
  137. },
  138. getTtemDotInfo(item){
  139. if(item.page==='annotationList' && this.msgCount>0){
  140. return this.msgCount
  141. }
  142. return '';
  143. }
  144. }
  145. }
  146. </script>
  147. <style scoped>
  148. .cu-list.grid>.cu-item {
  149. padding: 0px 0px;
  150. }
  151. .line2-icon {
  152. width: 60px;
  153. height: 60px;
  154. }
  155. </style>