<template>
	<view class="group_company">
		<view class="group_head">
			<view class="group_item">
				<view>线索名称</view>
				<view class="text">{{info && info.name}}</view>
			</view>
			<view class="group_item">
				<view>线索来源</view>
				<view class="text">{{info && info.source}}</view> 
			</view>
			<view class="group_item">
				<view>下次跟进时间</view>
				<view class="text">{{info && info.next_time ? info.next_time : '--'}}</view>
			</view>
		</view>
		<!-- 标签栏 -->
		<view class="group_tab"> 
			<u-tabs name="cate_name" :list="list" :is-scroll="false" active-color="#008EFF" :current="current"
				@change="change"></u-tabs>
			<view class="processing_title" v-if="current == 0">
				<customer-dynamic v-if="info && info.id" :kehuid="info.id" :type="4"></customer-dynamic>
			</view>
			<view class="processing_title" v-if="current == 1">
				<info-detail v-if="info" :info="info"></info-detail>
			</view>
			<view class="processing_title" v-if="current == 2">
				<cust-detail v-if="info" :kehuid="info.id"></cust-detail>
			</view>
		</view>
		<view style="height:100rpx"></view>
		<!-- 底部导航栏 -->
		<view class="bottom_nav">
			<view class="bottom_item" @click="newFollowClick">
				<image :src="BASE_IMG_URL+'clus_add.png'" class="botimg" mode=""></image>
				<view>写新跟进</view>
			</view>
			<view class="bottom_item" @click="editClues">
				<image :src="BASE_IMG_URL+'clus_edit.png'" class="botimg" mode=""></image>
				<view>编辑线索</view>
			</view>
			<view class="bottom_item" @click="deleteClueClick">
				<image :src="BASE_IMG_URL+'clus_del.png'" class="botimg" mode=""></image>
				<view>删除线索</view>
			</view>
		</view>
	</view>
</template>

<script>
	import customerDynamic from 'components/content/customerDynamic/customerDynamic.vue';
	import infoDetail from './baseInfo.vue';
	import custDetail from './relateInfo.vue';
	import { netCluesPoolDetail, netDelCluesPool } from '@/api/clues.js'
	import { BASE_IMG_URL } from '@/util/api.js'
	export default {
		data() {
			return {
				BASE_IMG_URL:BASE_IMG_URL,
				id:'',   //线索
				info:null,
				current: 0,
				list: [{
						name: '跟进记录',
						status: 0
					},
					{
						name: '基本信息',
						status: 1
					},
					{
						name: '相关信息',
						status: 2
					},
				],
			}
		},
		onLoad(options) {
			this.id = options.id
		},
		onShow() {
			this.info = null
			this.getInfo()
		},
		created() {
			
		},
		components: {
			customerDynamic,
			infoDetail,
			custDetail,
		},
		methods: {
			change(index) {
				this.current = index;
			},
			tabs_change(e) {
				this.current = e;
				this.mescroll.resetUpScroll();
			},
			//获取客户信息
			getInfo() {
				netCluesPoolDetail({id:this.id}).then(res=>{
					this.info = res.data
					uni.setNavigationBarTitle({
						title:res.data.name
					})
				})
			},
			//写  新跟进
			newFollowClick() {
				uni.navigateTo({
					url:'/pagesA/crm/customerManagement/newFllow/newFllow?id='+this.info.id+'&type=4'
				})
			},
			//编辑 线索
			editClues() {
				uni.navigateTo({
					url:'/pagesB/cluepool/editInfo?id='+this.id
				})
			},
			//拨打电话
			selectPhone(e) {
				let obj = e.detail
				// #ifdef MP-ALIPAY
				dd.showCallMenu({
				    phoneNumber: obj.mobile, 
				    code: '+86'
				})
				// #endif
				// #ifndef MP-ALIPAY || APP-PLUS
				uni.makePhoneCall({
					phoneNumber: obj.mobile
				})
				// #endif
				// #ifdef APP-PLUS
				plus.device.dial(obj.mobile, true);
				// #endif
			},
			
			// 任务
			taskClick() {
				this.taskShow = true;
				this.show = false;
			},
			// 取消底部弹出框
			onCancel() {
				this.taskShow = false;
				this.statusShow = false;
				this.telShow = false;
				this.show = false;
			},
			// 变更状态
			statusClick() {
				this.statusShow = true;
				this.show = false;
			},
			// 电话
			telClick() {
				this.telShow = true;
				this.show = false;
			},
			// 领取线索
			getCluesClick() {
				this.show = false;
				uni.showModal({
					title: '是否确定领取公池客户',
					content: '领取后长时间未跟进，客户将自动转为公共客户',
					cancelColor: "#008EFF",
					confirmColor: "#008EFF",
					success: function(res) {
						if (res.confirm) {
							netReceiveKehu().then(res=>{
								uni.showToast({
									title:res.msg,
									icon:'none'
								})
								setTimeout(()=>{
									uni.navigateTo({
										url: '/pages/index/groupCompany/groupCompany?id='+res.data.id
									})
								},1000)
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				})
			},
			// 删除线索
			deleteClueClick() {
				uni.showModal({
					title: '提示',
					content: '请确认是否删除吗？',
					cancelColor: "#008EFF",
					confirmColor: "#008EFF",
					success: (res) => {
						if (res.confirm) {
							netDelCluesPool({id:this.id}).then(res=>{
								uni.showToast({
									title:res.msg,
									icon:'none'
								})
								setTimeout(()=>{
									uni.navigateBack({
										delta:1
									})
								},2000)
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				})
			},
			// 隐藏遮罩层
			onClickHide() {
				this.overShow = false;
			},
		}
	}
</script>

<style lang="scss">
	.group_head {
		display: flex;
		flex-wrap: wrap;
		padding: 20rpx 0;
		background-color: #fff;
		text-align: center;

		.group_item {
			width: 33.33%;
			color: #ccc;
			margin-bottom:15rpx;
			.text{
				line-height:48rpx;
				color: #999;
			}
			.group_htz{
				margin-top: 8rpx;
			}
		}
	}

	.group_tab {
		margin: 20rpx 0;
	}

	.bottom_nav {
		position: fixed;
		display: flex;
		bottom: 0;
		left: 0;
		right: 0;
		padding: 20rpx 0;
		background-color: #fff;
		text-align: center;
		color: #999;
		display: flex;
		justify-content: space-around;
		align-items: center;
		z-index: 2;
		.bottom_item {
			.botimg{
				width:40rpx;
				height:40rpx;
				margin-bottom:5rpx;
			}
		}
	}

	.pull_con {
		padding: 40rpx 0 10rpx;
		display: flex;
		flex-wrap: wrap;
		text-align: center;
		color: #999;

		.pull_item {
			width: 25%;

			:first-child {
				padding-bottom: 10rpx;
			}

			:last-child {
				padding-bottom: 50rpx;
			}
		}
	}
</style>
