test1.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template name="home">
  2. <view>
  3. <!-- 其他页面内容 -->
  4. <view v-if="currentTab === 0">
  5. <Firstmodel></Firstmodel>
  6. </view>
  7. <scroll-view>
  8. </scroll-view>
  9. <view class="cu-tabbar-height margin-top"></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: 'test1',
  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. },
  61. onLoad() {
  62. }
  63. }
  64. </script>
  65. <style scoped>
  66. .cu-list.grid>.cu-item {
  67. padding: 0px 0px;
  68. }
  69. .line2-icon {
  70. width: 60px;
  71. height: 60px;
  72. }
  73. .tab-bar {
  74. display: flex;
  75. justify-content: space-around;
  76. padding: 10px;
  77. background-color: #eee;
  78. }
  79. .tab-bar view {
  80. flex: 1;
  81. text-align: center;
  82. padding: 10px;
  83. border-radius: 5px;
  84. cursor: pointer;
  85. }
  86. .tab-bar view.active {
  87. background-color: #007BFF;
  88. color: #fff;
  89. }
  90. </style>