<template>
	<movable-area class="minimize-botton" v-if="form.caseId">
		<movable-view class="drag" :x="x" :y="y" direction="vertical" @change="handleChange">
			<!-- <u-icon name="mic" color="#FFFFFF" size="28" ></u-icon> -->
			<view class="minimize_wrap" @click="handleClick">
				<image src="../../static/caseDetail/icon-call.png" mode="" class="image_icon" v-if="dialing"></image>
				<image src="../../static/follow/phone.png" mode="" class="image_icon" v-else></image>
				<text class="text">通话跟进</text>
			</view>
		</movable-view>
	</movable-area>
</template>

<script>
	import {
		mapState,
		mapGetters
	} from 'vuex'
	import qs from 'qs';
	export default {
		name: 'minimize-botton',
		data() {
			return {
				timer : null
			}
		},
		computed: {
			...mapState({
				x: (state) => state.follow.dragOption.x,
				y: (state) => state.follow.dragOption.y,
				form: (state) => state.follow.form,
				params: (state) => state.follow.params,
				dialing: (state) => state.app.dialing,
			}),
		},
		mounted() {
		},
		methods: {
			handleClick(){
				this.handleAllocation(this.params);
			},
			handleChange({detail}) {
				const { y } = detail;
				clearTimeout(this.timer);
				this.timer = setTimeout(() => {
					this.$store.commit("follow/SET_DRAGOPTION_Y", y);
				    clearTimeout(this.timer);
				}, 200);
			},
		}
	}
</script>

<style lang="scss">
	.minimize_wrap{
		width: 120rpx;
		height: 120rpx;
		background: #108cff;
		border-radius: 24rpx;
		box-shadow: 0px 0px 12px 0px rgba(0,95,203,0.70); 
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		margin-right: 20rpx;
		.image_icon{
			width: 44rpx;
			height: 44rpx;
			margin-bottom: 10rpx;
		}
		.text{
			font-size: 22rpx;
			color: #fff;
		}
	}
	.minimize-botton {
		width: 750rpx;
		height: 82vh;
		position: fixed;
		right: 0;
		top: 100rpx;
		pointer-events: none;
		z-index: 2001;
	}

	.drag {
		display: flex;
		align-items: center;
		justify-content: flex-end;
		width: 140rpx;
		height: 130rpx;
		// width: 90rpx;
		// height: 80rpx;
		// background: rgba(63, 163, 255, 0.8);
		background: transparent;
		border-radius: 40px 0px 0px 40px;
		pointer-events: auto;
	}
</style>
