index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <view class="container body">
  3. <view class="info">
  4. <scroll-view scroll-y="true" class="scroll-view">
  5. <view class="list-scroll-view">
  6. <slot></slot>
  7. </view>
  8. </scroll-view>
  9. </view>
  10. <view class="foot" v-if="frameStyle&&frameStyle.useBar||false">
  11. <view class="list" v-for="(item,index) in list" :key="index" @tap="toPath(index,item)"
  12. v-if="item.is_use=='0'">
  13. <uni-badge :is-dot="true" :text="item.num" absolute="rightTop" size="small">
  14. <image class="image" :src="item.normal.length>0?item.normal[0].url:''" mode="" v-if="active!=index">
  15. </image>
  16. <image class="image" :src="item.active.length>0?item.active[0].url:''" mode="" v-else></image>
  17. <view class="name" :style="{color:active==index?frameStyle.barActive||'#FB1438':''}">{{item.name}}
  18. </view>
  19. </uni-badge>
  20. </view>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. export default {
  26. props: {
  27. frameStyle: {
  28. type: Object
  29. }
  30. },
  31. data() {
  32. return {
  33. list: [],
  34. active: 0,
  35. };
  36. },
  37. created: function() {
  38. const that = this;
  39. that.search()
  40. },
  41. computed: {
  42. listenWebsocket() {
  43. return this.$store.state.websocketData;
  44. }
  45. },
  46. watch: {
  47. listenWebsocket: function(newstr) {
  48. if (newstr.type == 'chat') {
  49. for (let val of this.list) {
  50. if (val.route == 'pages/message/index') val.num = 1
  51. }
  52. }
  53. }
  54. },
  55. methods: {
  56. search() {
  57. const that = this;
  58. let pages = getCurrentPages();
  59. let currentPage = pages[pages.length - 1];
  60. uni.getStorage({
  61. key: 'config',
  62. success: function(res) {
  63. if (res.data) {
  64. let bottom_menu = res.data.bottom_menu;
  65. let list = bottom_menu.list.sort((a, b) => {
  66. return a.sort - b.sort
  67. });
  68. for (let val of list) {
  69. if (val.route == 'pages/message/index') val.num = 0
  70. }
  71. that.$set(that, `list`, list);
  72. let data = list.find((i) => i.route == currentPage.route);
  73. if (data) {
  74. let index =
  75. list.findIndex((i) => i.route == currentPage.route);
  76. that.$set(that, `active`, index);
  77. }
  78. }
  79. },
  80. fail: function(err) {
  81. console.log(err);
  82. }
  83. })
  84. },
  85. toPath(index, item) {
  86. const that = this;
  87. if (item.route == 'pages/message/index') {
  88. for (let val of that.list) {
  89. if (val.route == 'pages/message/index') val.num = 0
  90. }
  91. }
  92. that.$set(that, `active`, index);
  93. that.$emit('toPath', item)
  94. }
  95. }
  96. }
  97. </script>
  98. <style lang="scss">
  99. .body {
  100. .info {
  101. position: relative;
  102. flex-grow: 1;
  103. }
  104. .foot {
  105. height: 8vh;
  106. overflow: hidden;
  107. background-color: var(--fffColor);
  108. display: flex;
  109. flex-direction: row;
  110. align-items: center;
  111. justify-content: space-around;
  112. border-top: 1px solid var(--f1Color);
  113. .list {
  114. padding: 1vw 0;
  115. text-align: center;
  116. .image {
  117. width: 7vw;
  118. height: 6vw;
  119. }
  120. .name {
  121. font-size: 12px;
  122. }
  123. }
  124. }
  125. }
  126. .scroll-view {
  127. position: absolute;
  128. top: 0;
  129. left: 0;
  130. right: 0;
  131. bottom: 0;
  132. .list-scroll-view {
  133. display: flex;
  134. flex-direction: column;
  135. }
  136. }
  137. </style>