问星数据小程序

tab-bar.vue 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <view>
  3. <view class="tabbar-box">
  4. <view class="tabbar-container">
  5. <view v-for="(item,index) in tabBar.list" :key="index" @click.top="openWxApplet(item)">
  6. <view class="image_box">
  7. <image class="tabbar-image" :src="selected===index?item.selectedIconPath:item.iconPath" lazy-load="false"> </image>
  8. </view>
  9. <text :style="{color: (selected === index ? tabBar.selectedColor : tabBar.color)}">{{item.text}}</text>
  10. </view>
  11. </view>
  12. </view>
  13. <view class="center" style="bottom:34rpx"></view>
  14. <applet-mask v-if="appletMaskFlag" @closeMask='closeMask'></applet-mask>
  15. </view>
  16. </template>
  17. <script>
  18. export default {
  19. name:'tab-bar',
  20. data() {
  21. return {
  22. appletMaskFlag:false,
  23. tabBar: {
  24. color: '#999999',
  25. selectedColor: '#2662FF',
  26. list: [{
  27. "urlScheme":"weixin://dl/business/?t=o3aIVwrmPmt",
  28. "pagePath": "/pages/index/index",
  29. "iconPath": "/static/tabbar/home.png",
  30. "selectedIconPath": "/static/tabbar/home_yes.png",
  31. "text": "首页"
  32. },
  33. {
  34. "urlScheme":"weixin://dl/business/?t=4HtwsBfu3Bj",
  35. "pagePath": "/pages/sphRank/sphRank",
  36. "iconPath": "/static/tabbar/sphRank.png",
  37. "selectedIconPath": "/static/tabbar/sphRank_yes.png",
  38. "text": "视频号榜单"
  39. },
  40. {
  41. "urlScheme":"weixin://dl/business/?t=MORR0T2Seih",
  42. "pagePath": "/pages/live/live",
  43. "iconPath": "/static/tabbar/live.png",
  44. "selectedIconPath": "/static/tabbar/live.png",
  45. "text": "直播大厅"
  46. },
  47. {
  48. "urlScheme":"weixin://dl/business/?t=vh7GswoTCIa",
  49. "pagePath": "/pages/cyRank/cyRank",
  50. "iconPath": "/static/tabbar/cyRank.png",
  51. "selectedIconPath": "/static/tabbar/cyRank_yes.png",
  52. "text": "创意中心"
  53. },
  54. {
  55. "urlScheme":"weixin://dl/business/?t=p79W84aUqrm",
  56. "pagePath": "/pages/mine/mine",
  57. "iconPath": "/static/tabbar/wode.png",
  58. "selectedIconPath": "/static/tabbar/wode_yes.png",
  59. "text": "我的"
  60. },
  61. ]
  62. },
  63. selected: this.current //当前激活项
  64. };
  65. },
  66. props: {
  67. current: {
  68. type: [Number, String],
  69. default: 0
  70. }
  71. },
  72. methods: {
  73. closeMask(){
  74. this.appletMaskFlag = false
  75. },
  76. openWxApplet(data){
  77. uni.redirectTo({
  78. url:data.pagePath
  79. })
  80. }
  81. },
  82. watch: {
  83. // current: {
  84. // handler(val) { //
  85. // this.selected = val
  86. // const _this = this
  87. // uni.setNavigationBarTitle({ // 设置顶部bar的标题
  88. // title: _this.tabBar.list[val].text
  89. // })
  90. // },
  91. // immediate: true
  92. // }
  93. }
  94. }
  95. </script>
  96. <style>
  97. /* components/tabbar/tabbar.wxss */
  98. .tabbar-box{
  99. position: fixed;
  100. bottom: 0;
  101. width: 100%;
  102. height: 110rpx;
  103. background-color: #fff;
  104. box-shadow: 0 0rpx 6rpx rgba(194, 194, 194, 0.5);
  105. z-index: 99;
  106. padding-bottom: 16rpx;
  107. }
  108. .ipx_button {
  109. height: 130rpx;
  110. }
  111. .tabbar-container{
  112. display: flex;
  113. justify-content: space-between;
  114. }
  115. .tabbar-container>view{
  116. width: 20%;
  117. text-align: center;
  118. padding-top: 16rpx;
  119. }
  120. .tabbar-container>view>text{
  121. display: block;
  122. margin-top: 4rpx;
  123. font-size: 22rpx;
  124. line-height: 20rpx;
  125. }
  126. .tabbar-image{
  127. display: inline-block;
  128. width: 46rpx;
  129. height: 46rpx;
  130. }
  131. .tabbar-container>view:nth-child(3) {
  132. margin-top: -54rpx;
  133. }
  134. .tabbar-container>view:nth-child(3) .image_box {
  135. width: 108rpx;
  136. background: #fff;
  137. border-radius: 50%;
  138. text-align: center;
  139. margin: auto;
  140. padding-top: 15rpx;
  141. }
  142. .tabbar-container>view:nth-child(3) image {
  143. width: 80rpx;
  144. height: 80rpx;
  145. }
  146. .center {
  147. width: 108rpx;
  148. height: 108rpx;
  149. border-radius: 50%;
  150. position: fixed;
  151. bottom: 40rpx;
  152. left: 0;
  153. right: 0;
  154. margin: auto;
  155. box-shadow: 0 -4rpx 14rpx rgba(194, 194, 194, 0.5);
  156. z-index: 1;
  157. }
  158. </style>