index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <view class="">
  3. <view class="u-demo">
  4. <view class="u-config-wrap">
  5. <view class="u-config-title u-border-bottom">
  6. 参数配置
  7. </view>
  8. <view class="u-config-item">
  9. <view class="u-item-title">状态</view>
  10. <u-subsection :list="['显示', '隐藏']" @change="showChange"></u-subsection>
  11. </view>
  12. <view class="u-config-item">
  13. <view class="u-item-title">凸起按钮</view>
  14. <u-subsection :list="['显示', '隐藏']" @change="minButtonChange"></u-subsection>
  15. </view>
  16. <view class="u-config-item">
  17. <view class="u-item-title">背景色</view>
  18. <u-subsection :list="['#ffffff', '#1f1f1d']" @change="bgColorChange"></u-subsection>
  19. </view>
  20. <view class="u-config-item">
  21. <view class="u-item-title">顶部边框</view>
  22. <u-subsection :list="['显示', '隐藏']" @change="borderTopChange"></u-subsection>
  23. </view>
  24. <view class="u-config-item">
  25. <view class="u-item-title">提示角标</view>
  26. <u-subsection :list="['显示', '隐藏']" @change="badgeChange"></u-subsection>
  27. </view>
  28. </view>
  29. </view>
  30. <u-tabbar
  31. v-model="current"
  32. :show="show"
  33. :bg-color="bgColor"
  34. :border-top="borderTop"
  35. :list="list"
  36. :mid-button="midButton"
  37. :inactive-color="inactiveColor"
  38. :activeColor="activeColor"
  39. ></u-tabbar>
  40. </view>
  41. </template>
  42. <script>
  43. export default {
  44. data() {
  45. return {
  46. current: 0,
  47. show: true,
  48. bgColor: '#ffffff',
  49. borderTop: true,
  50. list: [{
  51. iconPath: "home",
  52. selectedIconPath: "home-fill",
  53. text: '首页',
  54. count: 2,
  55. isDot: true,
  56. customIcon: false,
  57. },
  58. {
  59. iconPath: "photo",
  60. selectedIconPath: "photo-fill",
  61. text: '放映厅',
  62. customIcon: false,
  63. },
  64. {
  65. iconPath: "/static/uview/example/min_button.png",
  66. selectedIconPath: "/static/uview/example/min_button_select.png",
  67. text: '发布',
  68. midButton: true,
  69. customIcon: false,
  70. },
  71. {
  72. iconPath: "play-right",
  73. selectedIconPath: "play-right-fill",
  74. text: '直播',
  75. customIcon: false,
  76. },
  77. {
  78. iconPath: "account",
  79. selectedIconPath: "account-fill",
  80. text: '我的',
  81. count: 23,
  82. isDot: false,
  83. customIcon: false,
  84. },
  85. ],
  86. midButton: true,
  87. inactiveColor: '#909399',
  88. activeColor: '#5098FF'
  89. }
  90. },
  91. methods: {
  92. beforeSwitch(index) {
  93. return true;
  94. },
  95. showChange(index) {
  96. this.show = !index;
  97. },
  98. bgColorChange(index) {
  99. if(index == 0) {
  100. this.activeColor = '#5098FF';
  101. this.inactiveColor = '#909399';
  102. }
  103. if(index == 1) {
  104. this.activeColor = '#D0D0D0';
  105. this.inactiveColor = '#5A5A5A';
  106. }
  107. this.bgColor = ['#ffffff', '#1f1f1d'][index];
  108. },
  109. borderTopChange(index) {
  110. this.borderTop = !index;
  111. },
  112. badgeChange(index) {
  113. if (index == 1) {
  114. this.list[0].count = 0;
  115. this.list[4].count = 0;
  116. } else {
  117. this.list[0].count = 2;
  118. this.list[4].count = 23;
  119. }
  120. },
  121. minButtonChange(index) {
  122. this.midButton = !index;
  123. }
  124. }
  125. }
  126. </script>
  127. <style scoped lang="scss">
  128. .u-demo-area {
  129. margin: 0 -40rpx;
  130. }
  131. </style>