1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
| <template> <view class="tag_view"> <scroll-view show-scrollbar="false" scroll-x="true" :scroll-into-view="targetViewId" scroll-with-animation="true"> <view class="tag_outer"> <view class="tag_item" v-for="(tag, index) in tagList" :key="index" :class="{ selected: index === selectIndex }" @click="itemSelectClick(index)" :id="'scroll' + tag.tagId" > <view class="tag_name">{{ tag.tagName }}</view> <view class="tag_bar"></view> </view> </view> </scroll-view> </view> </template>
<script> export default { name: 'comp-tag-view', data() { return { targetViewId: '', tagList: [ { tagId: '0', tagName: '全部' }, { tagId: '1', tagName: '待付款' }, { tagId: '2', tagName: '待发货' }, { tagId: '3', tagName: '待收货' }, { tagId: '4', tagName: '待归还' }, { tagId: '5', tagName: '归还中' }, { tagId: '6', tagName: '已完成' }, { tagId: '7', tagName: '已取消' } ], selectIndex: 0 }; }, methods: { itemSelectClick(index) { let tempIndex = index; if (tempIndex > 1) { tempIndex -= 2; } else if (tempIndex > 0) { tempIndex -= 1; } let item = this.tagList[tempIndex]; this.targetViewId = 'scroll' + item.tagId;
this.selectIndex = index; } } }; </script>
<style lang="scss"> .tag_view { background-color: white; } .tag_outer { display: flex; background-color: white; overflow-x: visible;
.tag_item { padding-left: 20rpx; padding-right: 20rpx; flex: none; display: flex; flex-direction: column; align-items: center;
.tag_name { height: 80rpx; display: flex; align-items: center; justify-content: center; } }
.tag_item.selected { .tag_bar { height: 9rpx; width: 48rpx; border-radius: 8rpx; opacity: 1; background: #fa7e31; } } } </style>
|