| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- <template>
- <view class="task-tab">
- <scroll-view class="scroll-Y row" scroll-x="true">
- <view class="z-tabs-scroll-view row-justify-sb center" style="position: relative;">
- <view class="column-c p-lr30 p-t30 p-b20" v-for="(item,index) in navList" :key="index"
- @click="setType(index)">
- <image class="wh-60 r-circle" :class="index===current?'double-border':''" :src="item.product_icon"
- mode="aspectFill">
- </image>
- <view class="m-t16 sys-size-24 sys-weight-600" :class="{'default-text':index===current}">
- {{item.briefness_name}}
- </view>
- </view>
- <view class="half-circle m-t20"></view>
- </view>
- </scroll-view>
- </view>
- </template>
- <script>
- import {
- getTaskType
- } from "@/api/task";
- export default {
- export default {
- name: 'task-ima-tab',
- data() {
- return {
- current: 0,
- navList: [{
- id: 0,
- briefness_name: '全部',
- product_icon: '/static/img/task/task-all.png'
- }]
- }
- },
- mounted() {
- this.getTaskType()
- },
- methods: {
- getTaskType() {
- getTaskType().then(res => {
- if (res.code === 1) {
- this.navList.push(...res.data)
- }
- })
- },
- setType(current) {
- // this.$nextTick(() => {
- // uni.createSelectorQuery().in(this).select(".z-tabs-scroll-view").fields({
- // scrollOffset: true
- // }, data => {
- // if (data) {
- // this.currentScrollLeft = data.scrollLeft;
- // console.log(data);
- // } else {}
- // }).exec();
- // })
- if (current !== this.current) {
- this.current = current
- this.$emit('setProductId', this.navList[current].id)
- }
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- .task-tab {
- margin: 0 20rpx;
- border-radius: 30rpx;
- background: #fff;
- width: calc(100% - 40rpx);
- }
- .default-text {
- color: #10B261;
- }
- .half-circle {
- width: 20rpx;
- height: 10rpx;
- background-color: #3eaf7c;
- border-top-left-radius: 10rpx;
- border-top-right-radius: 10rpx;
- position: absolute;
- bottom: 0;
- left: calc(25%/2 - 10rpx);
- }
- .half-transition {
- transition: all .5s ease;
- }
- .tab-item {
- // width: 25%;
- }
- .double-border {
- box-shadow: 0 0 0 6rpx #fff, 0 0 0 12rpx #10B261;
- }
- </style>
|