123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- <template>
- <view class="list-tab-header linear-gradient">
- <view class="container">
- <view class="nav">
- <text
- v-for="(item, i) in list"
- :key="i"
- :class="{active: value === i}"
- class="nav-item"
- @click="handleClick(i, item)">
- {{ item.label }}
- </text>
- <!-- #ifdef MP-WEIXIN -->
- <slot />
- <!-- #endif -->
- </view>
- <!-- #ifndef MP-WEIXIN -->
- <slot />
- <view v-if="showSearch" class="header-control">
- <button class="search-btn" @click="handleSearch">
- <text class="icon wk wk-search" />
- </button>
- </view>
- <!-- #endif -->
- </view>
-
- <!-- #ifdef MP-WEIXIN -->
- <view v-if="showSearch" class="search-box">
- <view class="box" @click="handleSearch">
- <text class="wk wk-search" />
- <text class="wk-placeholder">
- {{ placeholder }}
- </text>
- </view>
- </view>
- <!-- #endif -->
- <uni-popup ref="popup" :mask-click="false" type="dialog">
- <wk-popup-expiration />
- </uni-popup>
- </view>
- </template>
- <script>
- import { mapGetters } from 'vuex'
-
- export default {
- name: 'ListTabHeader',
- props: {
- navList: {
- type: Array,
- default: () => []
- },
- value: {
- type: Number,
- default: 0
- },
- showSearch: {
- type: Boolean,
- default: true
- },
- placeholder: {
- type: String,
- default: ''
- },
- hasBorder: {
- type: Boolean,
- default: true
- }
- },
- data() {
- return {}
- },
- computed: {
- ...mapGetters({
- showExpiration: 'user/showExpiration'
- }),
- list() {
- return this.navList.filter(o => {
- if (this.$isEmpty(o.action) || o.noCheck) return true
- return this.$auth(o.action)
- })
- }
- },
- watch: {
- list: {
- handler() {
- if (this.list.length === 0) return
- if (this.value > this.list.length - 1) {
- this.handleClick(0, this.list[0])
- }
- },
- deep: true
- },
- showExpiration: {
- handler() {
- if (this.showExpiration) {
- this.$nextTick(function() {
- this.$refs.popup.open()
- })
- }
- },
- immediate: true,
- deep: true
- }
- },
- methods: {
- handleClick(index, item) {
- this.$emit('input', index)
- this.$emit('change', {
- index: index,
- item: item
- })
- },
- handleSearch() {
- this.$emit('search')
- }
- }
- }
- </script>
- <style scoped lang="scss">
- .list-tab-header {
- width: 100%;
- padding: 0 34rpx;
- .container {
- width: 100%;
- color: white;
- @include left;
- .nav {
- flex: 1;
- height: 96rpx;
- font-size: 32rpx;
- @include left;
- .nav-item {
- position: relative;
- line-height: 96rpx;
- margin-right: 36rpx;
- &.active {
- font-weight: 500;
- font-size: 42rpx;
- }
- }
- }
- .header-control {
- @include right;
- .search-btn {
- .icon {
- font-weight: 400;
- font-size: 42rpx;
- }
- }
- }
- }
-
- .search-box {
- width: 100%;
- padding-top: 10rpx;
- padding-bottom: 20rpx;
-
- .box {
- width: 100%;
- height: 62rpx;
- color: #BBBBBB;
- background-color: white;
- border-radius: 12rpx;
- padding: 0 20rpx;
- @include left;
-
- .wk-search {
- margin-right: 15rpx;
- }
- }
- }
- }
- </style>
|