home.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <template name="home">
  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. <view class="cu-bar bg-white solid-bottom margin-top" :style="[{animation: 'show 0.6s 1'}]">
  31. <view class="action">
  32. <text class='cuIcon-title text-yellow'></text>售后服务
  33. </view>
  34. </view>
  35. <view class="cu-list grid col-4 text-sm">
  36. <view class="cu-item animation-slide-bottom" :style="[{animationDelay: (index + 1)*0.05 + 's'}]" v-for="(item,index) in shList" :key="index" @tap="goPage(item.page)">
  37. <view class="padding text-center">
  38. <image :src="item.icon" style="width:28px;height:28px;">
  39. <view class="cu-tag badge margin-top-sm" style="margin-left:1.2em" v-if="getTtemDotInfo(item)">
  40. <block v-if="getTtemDotInfo(item)">{{getTtemDotInfo(item)}}</block>
  41. </view>
  42. </image>
  43. <view class="margin-top-xs">{{item.title}}</view>
  44. </view>
  45. </view>
  46. </view>
  47. <!-- 其他服务 -->
  48. <view class="cu-bar bg-white solid-bottom margin-top" :style="[{animation: 'show 0.6s 1'}]">
  49. <view class="action">
  50. <text class='cuIcon-title text-yellow'></text>个人中心
  51. </view>
  52. </view>
  53. <view class="cu-list grid col-4 text-sm">
  54. <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)">
  55. <view class="padding text-center">
  56. <image :src="item.icon" style="width:28px;height:28px;"/>
  57. <view class="margin-top-xs">{{item.title}}</view>
  58. </view>
  59. </view>
  60. </view>
  61. </scroll-view>
  62. <view class="cu-tabbar-height margin-top"></view>
  63. </view>
  64. </template>
  65. <script>
  66. import { us,os ,sh} from '@/common/util/work.js'
  67. import socket from '@/common/js-sdk/socket/socket.js'
  68. export default {
  69. name: 'home',
  70. props:{
  71. cur:String,
  72. },
  73. watch: {
  74. cur: {
  75. immediate: true,
  76. handler:function(val,oldVal){
  77. console.log('cur',val,oldVal)
  78. this.initMenu()
  79. },
  80. },
  81. },
  82. data() {
  83. return {
  84. swiperList: [
  85. {id:2,type: 'image',url: '/static/banner/banner2.jpg', link: ''},
  86. {id:3,type: 'image',url: '/static/banner/banner3.jpg', link: ''},
  87. ],
  88. middleApps: [
  89. {icon: 'line2_icon1.png', title: '审批', 'text': '个人审批'},
  90. {icon: 'line2_icon2.png', title: '审批稿', 'text': '审批草稿箱'},
  91. ],
  92. usList:us.data,
  93. osList:os.data,
  94. shList:sh.data,
  95. msgCount:0,
  96. dot:{
  97. mailHome:false
  98. }
  99. }
  100. },
  101. methods: {
  102. initMenu(){
  103. console.log("-----------home------------")
  104. //this.onSocketOpen()
  105. // this.onSocketReceive()
  106. this.loadCount(0);
  107. },
  108. goPage(page){
  109. if(!page){
  110. return false;
  111. }
  112. if(page==='annotationList'){
  113. this.msgCount = 0
  114. }
  115. this.dot[page]=false
  116. console.log(page)
  117. this.$Router.push({name: page})
  118. },
  119. // 启动webSocket
  120. onSocketOpen() {
  121. socket.init('websocket');
  122. },
  123. onSocketReceive() {
  124. var _this=this
  125. socket.acceptMessage = function(res){
  126. // console.log("页面收到的消息", res);
  127. if(res.cmd == "topic"){
  128. //系统通知
  129. _this.loadCount('1')
  130. }else if(res.cmd == "user"){
  131. //用户消息
  132. _this.loadCount('2')
  133. } else if(res.cmd == 'email'){
  134. //邮件消息
  135. _this.loadEmailCount()
  136. }
  137. }
  138. },
  139. loadCount(flag){
  140. console.log("loadCount::flag",flag)
  141. let url = '/sys/annountCement/listByUser';
  142. /*
  143. this.$http.get(url).then(res=>{
  144. console.log("res::",res)
  145. if(res.data.success){
  146. let msg1Count = res.data.result.anntMsgTotal;
  147. let msg2Count = res.data.result.sysMsgTotal;
  148. this.msgCount = msg1Count + msg2Count
  149. console.log("this.msgCount",this.msgCount)
  150. }
  151. })
  152. */
  153. },
  154. loadEmailCount(){
  155. this.dot.mailHome = true
  156. },
  157. getTtemDotInfo(item){
  158. if(item.page==='annotationList' && this.msgCount>0){
  159. return this.msgCount
  160. }
  161. return '';
  162. }
  163. }
  164. }
  165. </script>
  166. <style scoped>
  167. .cu-list.grid>.cu-item {
  168. padding: 0px 0px;
  169. }
  170. .line2-icon {
  171. width: 60px;
  172. height: 60px;
  173. }
  174. </style>