home.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template name="home">
  2. <view>
  3. <!-- 其他页面内容 -->
  4. <view v-if="currentTab === 0">
  5. <Firstmodel></Firstmodel>
  6. </view>
  7. <scroll-view class="cu-tabbar-height margin-top">
  8. <button size="default" type="default" style="color:#ffffff;backgroundColor:#1AAD19;borderColor:#1AAD19" @click="SendGet">12345</button>
  9. </scroll-view>
  10. </view>
  11. </template>
  12. <script>
  13. import Firstmodel from './firstmodel.vue'
  14. import { us,os } from '@/common/util/work.js'
  15. import socket from '@/common/js-sdk/socket/socket.js'
  16. import { mapActions } from "vuex"
  17. export default {
  18. components: {
  19. Firstmodel,
  20. },
  21. name: 'home',
  22. watch: {
  23. },
  24. data() {
  25. return {
  26. usList:us.data,
  27. osList:os.data,
  28. msgCount:0,
  29. dot:{
  30. mailHome:false
  31. },
  32. currentTab: 0, // 当前选中的选项卡索引
  33. }
  34. },
  35. methods: {
  36. // 启动webSocket
  37. onSocketOpen() {
  38. socket.init('websocket');
  39. },
  40. onSocketReceive() {
  41. var _this=this
  42. socket.acceptMessage = function(res){
  43. // console.log("页面收到的消息", res);
  44. if(res.cmd == "topic"){
  45. //系统通知
  46. _this.loadCount('1')
  47. }else if(res.cmd == "user"){
  48. //用户消息
  49. _this.loadCount('2')
  50. } else if(res.cmd == 'email'){
  51. //邮件消息
  52. _this.loadEmailCount()
  53. }
  54. }
  55. },
  56. switchTab(index) {
  57. // 切换选项卡时触发的事件
  58. this.currentTab = index;
  59. },
  60. SendGet(){
  61. uni.request({
  62. url:'http://182.92.126.35:9999/ventanaly-device/safety/ventanalyDeviceInfo/DeviceKind/queryBySystem',
  63. method:'GET',
  64. success:function(data){
  65. console.log(data);
  66. }
  67. })
  68. }
  69. },
  70. onLoad() {
  71. }
  72. }
  73. </script>
  74. <style scoped>
  75. .cu-list.grid>.cu-item {
  76. padding: 0px 0px;
  77. }
  78. .line2-icon {
  79. width: 60px;
  80. height: 60px;
  81. }
  82. .tab-bar {
  83. display: flex;
  84. justify-content: space-around;
  85. padding: 10px;
  86. background-color: #eee;
  87. }
  88. .tab-bar view {
  89. flex: 1;
  90. text-align: center;
  91. padding: 10px;
  92. border-radius: 5px;
  93. cursor: pointer;
  94. }
  95. .tab-bar view.active {
  96. background-color: #007BFF;
  97. color: #fff;
  98. }
  99. </style>