<template>
    <view class="content arc-content" >
        <statusNav returnColor="#c2c2c2" navBarTitle="客户详情"></statusNav>
          <container-subgroup-two>
        <view  slot="content" style="margin: 0 -30rpx;">
            <view class="details-nav">
                <view class="li"  @click="essentialInformation('listOne')">
                    <image class="icon"  src="../../static/iocn/ty.png" mode=""></image>
                    <view class="text">基本信息</view>
                </view>
                <view class="li" @click="essentialInformation('listTwo')">
                    <image class="icon" src="../../static/iocn/kh.png" mode=""></image>
                    <view class="text">联系人</view>
                </view>
                <view class="li" @click="essentialInformation('listThree ')">
                    <image class="icon" src="../../static/iocn/xs.png" mode=""></image>
                    <view class="text">项目列表</view>
                </view>
            </view>
            <view class="details-content listOne">
                
                <view class="title">
                    <image class="img" src="../../static/iocn/dn.png" mode=""></image>
                    <text class="text">基本信息</text>
                </view>
            
                <view class="text-content">
                    <view class="li clips1">
                        客户名称：<text class="cor">{{dataObj.customerName}}</text>
                    </view>
                    <view class="li">
                        客户编号：<text class="cor">{{dataObj.customerCode}}</text>
                    </view>
                    <view class="li">
                        客户等级：<text class="cor">{{dataObj.customerVIP}}</text>
                    </view>
                    <view class="li">
                        所属行业：<text class="cor">{{dataObj.industryInvolved}}</text>
                    </view>
                    <view class="li">
                        客户类型：<text class="cor">{{dataObj.customerType}}</text>
                    </view>
                    <view class="li">
                        入库时间：<text class="cor">{{dataObj.warehouseTime}}</text>
                    </view>
                    <view class="li">
                        项目数量：<text class="cor1 bold">{{dataObj.projectNum}}</text>
                    </view>
                    <view class="li">
                        所属区域：<text class="cor">{{dataObj.area}}</text>
                    </view>
                    <view class="li">
                        详细地址：<text class="cor">{{dataObj.address}}</text>
                    </view>
            
                </view>
            </view>
            <view class="details-content listTwo">
                <view class="title">
                    <image class="img" src="../../static/iocn/lxr.png" mode=""></image>
                    <text class="text">联系人</text>
                </view>
            
                <view class="text-content">
                    <view class="li">
                        姓名：<text class="cor">{{concatObj.name}}</text>
                    </view>
                    <view class="li">
                        所属部门：<text class="cor">{{concatObj.department}}</text>
                    </view>
                    <view class="li">
                        职务：<text class="cor">{{concatObj.job}}</text>
                    </view>
                    <view class="li">
                        电话：<text class="cor">{{concatObj.phone}}</text>
                    </view>
                    <view class="li">
                        微信：<text class="cor">{{concatObj.wx}}</text>
                    </view>
                    <view class="li">
                        qq：<text class="cor">{{concatObj.qq}}</text>
                    </view>
                    <view class="li">
                        邮箱：<text class="cor">{{concatObj.email}}</text>
                    </view>
                    <view class="li">
                        负责时间段：<text class="cor">{{concatObj.time}}</text>
                    </view>
            
            
                </view>
            </view>
            <view class="project-list listThree">
                <view class="title-content">
                    <view class="title">
                        <image class="icon" src="../../static/iocn/xmlb.png" mode=""></image>
                        <view class="text" style="font-size: 28rpx;">项目列表</view>
                    </view>
                    <picker :value="currentyear" :range="yearArr" @change="bindTimeChange">
                        <view class="date disac" :style="{color: chooseyear ? '#000000' : '#999999',border: chooseyear ? '2rpx solid #000000' : '2rpx solid #999999'}">
                            {{chooseyear ? chooseyear+'年' : '选择年份'}} <i class="icon icon-zsj" style="font-size: 18rpx;"></i>
							<!-- <image class="icon flexs" src="../../static/iocn/sjx.png" mode=""></image> -->
                        </view>
                    </picker>
                </view>
				<view class="project-list-box">
					<view class="project-list-content" v-for="(item,index) in projectList" :key="index">
					    <view class="li">
					        <view class="text">{{item.project_name}}</view>
					        <view class="date">{{item.create_time}}</view>
					    </view>
					</view>
					<view v-if="!projectList.length" class="disjcac fc" style="height: 120rpx;">
						<pitera textStr="查询无果"></pitera>
					</view>
				</view>
            </view>
            <view class="contact-way" @click="copyWxFun()">
                <view class="title">
                    客户微信
                </view>
                <image class="icon" src="../../static/iocn/wx.png" mode=""></image>
            </view>
            <view class="contact-way" @click="telFun()">
                <view class="title">
                    客户电话
                </view>
                <image class="icon1" src="../../static/iocn/dh.png" mode=""></image>
            </view>
                
        </view>
 </container-subgroup-two>

    </view>
</template>

<script>
     import containerSubgroupTwo from '@/components/containers/container-subgroup-two.vue';
    import statusNav from '../../components/status-nav.vue';
	import {queryDetail} from '@/jsFile/public-api.js';
	import pitera from '@/components/nothing/pitera.vue';
    export default {
        components: {
            statusNav,
            containerSubgroupTwo,
			pitera
        },
        data() {
            return {
                dataObj:{
                    customerName:"长沙警校",
                    customerCode:"xxxxxxxxx",
                    customerVIP:"VIP1",
                    industryInvolved:"安防",
                    customerType:"xxxx",
                    warehouseTime:"2022.3.1" ,
                    projectNum:"50",
                    area:"成华区",
					address:'四川省成都市成华区双店路B口'
                },
				concatObj:{
					name:'Eveal',
					department:'产品研发部',
					job:'职务',
					phone:'17366921088',
					wx:'1234987',
					qq:'1209384',
					email:'234@qq.com',
					time:'2022-02-02'
				},
				clientId:'',//客户id
				yearArr:[],//年份
				currentyear: '',//当前年份
				chooseyear:'',//选中的年份
				projectList:[]//项目列表
            }
        },
		onLoad(op){
			if(op.id!=undefined) {
				this.clientId = op.id;
				console.log(this.clientId);
				// 调用查询客户详情信息事件
				this.queryDetailEv();
			}
			let date = new Date();
			this.currentyear = date.getFullYear();
			for (let i = this.currentyear-10; i <= this.currentyear; i++) {
				this.yearArr.push(i);
			}
			// 调用项目列表查询
			this.getProjectList(this.currentyear);
		},
        methods: {
			// 查询客户详情信息
			queryDetailEv(){
				queryDetail({type_id:1,member_id:this.clientId}).then(res=>{
					if(res.code) {
						
					} else {
						this.$toolAll.tools.showToast(res.msg);
					}
				})
			},
            // 选择年份
            bindTimeChange(data) {
				let index = data.detail.value;
				this.chooseyear = this.yearArr[index];
				// 调用项目列表查询
				this.getProjectList(this.chooseyear);
            },
			// 项目列表查询
			getProjectList(year) {
				this.$requst.post('/universal/api.search/project_year',{year}).then(res=>{
					if(res.code) {
						this.projectList = res.data;
					}
				})
			},
            essentialInformation(classText){
				uni.createSelectorQuery().select('.'+classText).boundingClientRect(data=>{//目标位置的节点：类或者id
					uni.createSelectorQuery().select(".arc-content").boundingClientRect(res=>{//最外层盒子的节点：类或者id
						uni.pageScrollTo({
							duration: 100,//过渡时间
							scrollTop:data.top - res.top -uni.getSystemInfoSync().statusBarHeight-50,//到达距离顶部的top值
						})
					}).exec()
				}).exec();  
            },
            // 复制微信
            copyWxFun(){
				uni.setClipboardData({
					data: 'hello',
					success: function () {}
				});  
            },
			// 拨打电话
			telFun(){
			    uni.makePhoneCall({
			    	phoneNumber: '13608235524' //仅为示例
			    });
			}
        }
    }
</script>

<style>
	 .project-list-box {
		 min-height: 120rpx;
		 max-height: 520rpx;
		 overflow: hidden;
		 overflow-y: scroll;
	 }
	 .project-list-box::-webkit-scrollbar{
		 display: none;
	 }
    .content {
        padding-right: 27rpx;
        padding-left: 27rpx;
    }

    .details-nav {
        display: flex;
        justify-content: space-between;
        padding: 23rpx 63rpx;
        background-color: #FFFFFF;
    }

    .details-nav .li .icon {
        width: 79rpx;
        height: 79rpx;
    }

    .details-nav .li {
        text-align: center;
    }

    .details-nav .li .text {
        font-size: 24rpx;
        color: #333333;
    }

    .details-content {
        margin-top: 20rpx;
        background-color: #FFFFFF;
        padding: 20rpx 18rpx;
        border-bottom: 2rpx solid #DFDFDF;
        border-radius: 0rpx 0rpx 10rpx 10rpx;
    }

    .details-content .title {
        display: flex;
        align-items: center;
        padding-bottom: 15rpx;
        border-bottom: 2rpx solid #E5E5E5;
    }

    .details-content .title .img {
        width: 27rpx;
        height: 26rpx;
        margin-right: 9rpx;
    }

    .details-content .title .text {
        font-size: 28rpx;
        color: #999999;

    }

    .text-content {
        display: flex;
        flex-wrap: wrap;
    }

    .text-content .li {
        width: 50%;
        font-size: 24rpx;
        color: #999999;
        margin-top: 22rpx;
    }

    .cor {
        color: #333333;
    }

    .cor1 {
        color: #FF4C4C;
    }

    .project-list {
        background-color: #FFFFFF;
        padding: 22rpx 18rpx;
        margin-top: 20rpx;
    }

    .project-list .title-content {
        display: flex;
        justify-content: space-between;
        padding-bottom: 16rpx;
        font-size: 24rpx;
        border-bottom: 2rpx solid #E5E5E5;
        color: #999999;
    }

    .project-list .title-content .title {
        display: flex;
        align-items: center;
    }

    .project-list .title-content .title .icon {
        width: 23rpx;
        height: 25rpx;
        margin-right: 10rpx;
    }

    .project-list .title-content .date {
        height: 40rpx;
		padding: 2rpx 10rpx;
        display: flex;
        justify-content: center;
        align-items: center;
        border-radius: 10rpx;
        font-size: 24rpx;
        display: flex;
        align-items: center;
    }

    .project-list .title-content .date .icon {
        /* width: 12rpx;
        height: 12rpx; */
        margin-left: 5rpx;
    }

    .project-list-content .li {
        display: flex;
        justify-content: space-between;
        border-bottom: 2rpx solid #E5E5E5;
        padding: 18rpx;
    }

    .project-list-content .li .text {
        font-weight: bold;
        color: #4ca5ff;
        font-size: 24rpx
    }

    .project-list-content .li .date {
        color: #888888;
        font-size: 24rpx
    }

    .contact-way {
        display: flex;
        align-items: center;
        padding: 40rpx 20rpx 34rpx;
        color: #696666;
        justify-content: space-between;
        font-size: 28rpx;
        border-bottom: 2rpx solid #E5E5E5;
    }

    .contact-way .icon {
        width: 41rpx;
        height: 32rpx;
    }

    .contact-way .icon1 {
        width: 35rpx;
        height: 39rpx;
    }
</style>
