common-tabs.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <template>
  2. <view>
  3. <view class="border-bottom p-fixed left0 right0 zIndex">
  4. <view class="p-relative">
  5. <u-tabs name="label" :list="list" :current="current" @change="change" :gutter='50'>
  6. </u-tabs>
  7. <view v-if="list.length > 4" class="p-absolute d-flex j-center a-center right0 top0 bg-color-white" style="width: 50rpx;height: 88rpx;z-index: 1000000000;"
  8. @click.stop='maskState = !maskState'>
  9. <u-icon name="arrow-down-fill" size="28"></u-icon>
  10. </view>
  11. <view v-if="maskState">
  12. <view class=" d-flex f-wrap a-center" style="background-color: #fff;width: 750rpx;z-index: 100000000000;">
  13. <view v-for="(item,index) in list" :key='index' style="margin: 0 50rpx;height: 80rpx;line-height: 80rpx;"
  14. @click.stop="change(index)" :class="current == index?'select-color':''">
  15. {{item.label}}
  16. </view>
  17. </view>
  18. </view>
  19. </view>
  20. </view>
  21. <view v-if="maskState" @click.stop="maskState = false" class="p-fixed left0 right0 bottom0" style="background: rgba(0,0,0,.2);z-index: 10;"
  22. :style="'height:'+windowHeight+'px'"></view>
  23. </view>
  24. </template>
  25. <script>
  26. export default {
  27. data() {
  28. return {
  29. windowHeight: 0,
  30. maskState: false
  31. };
  32. },
  33. props: {
  34. list: {
  35. type: Array,
  36. default: () => []
  37. },
  38. current: {
  39. type: [String, Number],
  40. default: -1
  41. }
  42. },
  43. created() {
  44. try {
  45. const res = uni.getSystemInfoSync();
  46. this.windowHeight = res.windowHeight
  47. } catch (e) {}
  48. },
  49. methods: {
  50. change(index) {
  51. this.maskState = false
  52. this.$emit('change',index, this.list[index].value)
  53. }
  54. }
  55. }
  56. </script>
  57. <style scoped>
  58. .select-color {
  59. color: #2979ff;
  60. }
  61. </style>