<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 tab-item 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.icon"
						mode="aspectFill">
					</image>
					<view class="m-t16 sys-size-24 text-center sys-weight-600"
						:class="{'default-text':index===current}">
						{{item.name}}
					</view>
					<!-- <view class="half-circle m-t20" :class="{'half-circle1':current==1}" v-if="current==index"></view> -->
				</view>
				<view class="half-circle m-t20"></view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				current: 0,
				navList: [{
					name: '垫资还款',
					icon: '/static/img/task/task-refund.png'
				}, {
					name: '房抵业务',
					icon: '/static/img/task/task-loan.png'
				}, {
					name: '消费金融',
					icon: '/static/img/task/task-financial.png'
				}, {
					name: '其他服务',
					icon: '/static/img/task/task-else.png'
				}, ]
			}
		},
		methods: {
			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
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.task-tab {
		margin: 0 20rpx;
		border-radius: 30rpx;
		background: #fff;
	}

	.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>