<template>
	<view class="group_company">
		<view class="group_head">
			<view class="group_item">
				<view>职务</view>
				<view class="text">{{info && info.post?info.post : '--'}}</view>
			</view>
			<view class="group_item">
				<view>手机号</view>
				<view class="text">{{info && info.mobile?info.mobile : '--'}}</view>
			</view>
			<view class="group_item">
				<view>下次跟进时间</view>
				<view class="text">{{info && info.next_time ?info.next_time : '--'}}</view>
			</view>
		</view>
		<view class="tabinfo" @click="toKehuInfo">
			<view class="tableft">
				<image :src="BASE_IMG_URL+'headImg.png'" class="headerimg"  mode="scaleToFill"></image>
				<view class="name">{{info && info.customer.name}}</view>
			</view>
			<image :src="BASE_IMG_URL+'right.png'" class="rightimg"  mode="scaleToFill"></image>
		</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" :kehuid="info.id" :type="2"></customer-dynamic>
		</view>
		<view class="processing_title" v-if="current == 1">
			<base-info v-if="info" :info="info"></base-info>
		</view>
		<view class="processing_title" v-if="current == 2">
			<related-info v-if="info" :contactid="info.id"></related-info>
		</view>
		</view>
		<!-- 底部导航栏 -->
		<view class="bottom_nav" v-if="type == 1">
			<view class="bottom_item" @click="followClick(info.id,2)">
				<view class="iconfont icon-task"></view>
				<view>写新跟进</view>
			</view>
			<view class="bottom_item" @click="ToCall">
				<view class="iconfont icon-task"></view>
				<view>拨打电话</view>
			</view>
			<view class="bottom_item" @click="toEditInfo">
				<view class="iconfont icon-task"></view>
				<view>编辑信息</view>
			</view>
			<view class="bottom_item" @click="delContact">
				<view class="iconfont icon-task"></view>
				<view>删除</view>
			</view>
		</view>
	</view>
</template>

<script>
	import customerDynamic from 'components/content/customerDynamic/customerDynamic.vue';
	import baseInfo from './baseInfo.vue'

	import { BASE_IMG_URL } from '@/util/api.js'
	import relatedInfo from './relatedInfo.vue';
	import {pageJumps} from "../group_page_jumps.js";
	import { netConcatDetailInfo, netRemoveSeas, netReceiveKehu, netKeyCollect, netDelContact, netRemoveColect } from '@/api/kehu.js'
	export default {
		mixins:[pageJumps],
		data() {
			return {
				show: false,
				taskShow: true,
				statusShow: false,
				BASE_IMG_URL:BASE_IMG_URL,
				telShow: false,
				telname:'',
				id:'',   //客户id
				info:null,
				current: 0,
				list: [{
						name: '跟进记录',
						status: 0
					},
					{
						name: '基本信息',
						status: 1
					},
					{
						name:'相关信息',
						status:2
					}
				],
				type:1,  //1我的客户   2公海客户
			}
		},
		onLoad(options) {
			this.id = options.id
			this.type = options.type
			
		},
		onShow() {
			this.info = null
			this.getInfo()
		},
		components: {
			customerDynamic,
			baseInfo,
			relatedInfo
		},
		methods: {
			change(index) {
				this.current = index;
			},
			tabs_change(e) {
				this.current = e;
				this.mescroll.resetUpScroll();
			},
			changeTabs(e) {
				let index = e.detail.index
			},
			//新增合同
			addContract(id) {
				uni.navigateTo({
					url:'/pagesA/crm/contract/contract?id='+id
				})
			},
			//获取客户信息
			getInfo() {
				netConcatDetailInfo({id:this.id}).then(res=>{
					this.info = res.data
					uni.setNavigationBarTitle({
						title:res.data.name
					})
				})
			},
			//拨打电话
			ToCall() {
				// #ifdef MP-ALIPAY
				dd.showCallMenu({
				    phoneNumber: this.info.mobile, 
				    code: '+86'
				})
				// #endif
				// #ifndef APP-PLUS || MP-ALIPAY 
				uni.makePhoneCall({
					phoneNumber: this.info.mobile
				})
				// #endif
				// #ifdef APP-PLUS
				plus.device.dial(this.info.mobile, true);
				// #endif
			},
			//编辑信息
			toEditInfo() {
				uni.navigateTo({
					url:'/pages/index/groupCompany/contact/editInfo?id='+this.info.id
				})
			},
			//客户信息
			toKehuInfo() {
				uni.navigateTo({
					url:'/pages/index/groupCompany/groupCompany?id='+this.info.customer.id
				})
			},
			//删除 联系人
			delContact() {
				uni.showModal({
					title:'提示',
					content:'请确认是否删除？',
					success:(res)=>{
						if(res.confirm){
							netDelContact({id:this.info.id}).then(res=>{
								uni.showToast({
									title:res.msg,
									icon:'none'
								})
								setTimeout(()=>{
									uni.navigateBack({
										delta:1
									})
								},2000)
							})
						}
					}
				})
			}
		}
	}
</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;
			}
		}
	}
	.tabinfo{
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding:20rpx;
		background:#fff;
		border-top:1rpx solid #C0C0C0;
		.tableft{
			display: flex;
			justify-content: flex-start;
			align-items: center;
			.headerimg{
				width:45rpx;
				height:45rpx;
				border-radius: 50%;
			}
			.name{
				font-size:26rpx;
				color:$uni-text-color;
				margin-left:24rpx;
			}
		}
		.rightimg{
			width:32rpx;
			height:32rpx;
		}
	}

	.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: 9;
		.bottom_item {
			// width: 25%;

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

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