<template>
	<view>
		<view class="card-box clearfix" v-if="!loading">
			<image class="card-bottom" src="/static/images/card_bottom.png" mode="widthFix"></image>
			<view class="hearder">
				<image :src="cardInfo.avatar" style="border-radius: 100%;"></image>
			</view>
			<view class="user-name">{{ cardInfo.realName }}</view>
			<view class="user-tag ddflex">
				<view class="user-tag-item">{{ cardInfo.jobName }}</view>
				<view class="user-tag-item">入司{{cardInfo.inDate?getAge(cardInfo.inDate):1}}年</view>
			</view>
			<view class="pf">
				<view class="pf-title">综合评分</view>
				<uni-rate style="justify-content: center;" class="ddflex" color="#999999" active-color="#FF4600" :readonly="true" size="18" allow-half :value="evaluateInfo.evaluateDTO.serveScore/2" />
			</view>
			<view class="user-data ddflex">
				<view>
					<view class="user-data-num">{{cardInfo.cntCust?cardInfo.cntCust:0}}</view>
					<view class="user-data-label ddflex">
						<image src="/static/pages/images/fw_hui.png"></image>
						<view>服务客户</view>
					</view>
				</view>
				<view style="margin-left: 109rpx;">
					<view class="user-data-num">{{cardInfo.cntCntr?cardInfo.cntCntr:0}}</view>
					<view class="user-data-label ddflex">
						<image src="/static/pages/images/cy_hui.png"></image>
						<view>保单件数</view>
					</view>
				</view>
				<view style="margin-left: 109rpx;">
					<view class="user-data-num">{{cardInfo.thumbs?cardInfo.thumbs:0}}</view>
					<view class="user-data-label ddflex">
						<image src="/static/pages/images/dz_hui.png"></image>
						<view>点赞量</view>
					</view>
				</view>
			</view>
			<view class="user-des">
				<rich-text :nodes="cardInfo.brief ? cardInfo.brief : ''"></rich-text>
			</view>
			<image class="user-code" src="/static/images/lj_img.png"></image>
			<view class="user-btn" @click="submit">
				选TA做专属顾问
			</view>
			<view class="user-btn-text" @click="jumpUrl('/card/cardFound/cardFound')">
				更多专属顾问>
			</view>
		</view>
	</view>
</template>

<script>
	const app = getApp();
	const req = require("../../utils/request.js");
	import util from '../../utils/util.js';

	export default {
		components: {},
		props: {},
		data() {
			return {
				systems: {},
				isTop:0,
				id:null,
				cardInfo:{},
				evaluateInfo:{},
				loading:true
			}
		},
		onLoad(options) {
			this.id = options.id
			uni.showLoading({
				title:'加载中'
			})
			this.getCardInfo()
		},
		onShow() {
			
		},
		methods: {
			jumpUrl(url){
				uni.navigateTo({
					url:url
				})
			},
			getCardInfo() {
				var url = '';
				var dataP = {
					id:this.id
				};
				url = '/api/visiting/card/info';
				req.getRequest(url, dataP, data => {
					this.cardInfo = data;
					uni.hideLoading()
					this.loading = false
					this.getEvaluate()
				});
			},
			// 获取评论
			getEvaluate(){
				req.getRequest('/api/evaluate/cardInfo',{bindId:this.id,type:2},res=>{
					this.evaluateInfo = res
				})
			},
			getAge(date) {
				return util.getAge(date)
			},
			submit(){
				req.postRequest('/api/visiting/card/bindManageSaleNo',{manageSaleNo:this.cardInfo.jobNumber},res=>{
					req.msg('已切换专属顾问')
					setTimeout(()=>{
						uni.switchTab({
							url:'/pages/index/index'
						})
					},1000)
				})
			}
		},
		mounted() {
			const systemInfo = uni.getSystemInfoSync();
			// px转换到rpx的比例
			let pxToRpxScale = 750 / systemInfo.windowWidth;
			let systems = {
				ktxStatusHeight: systemInfo.statusBarHeight * pxToRpxScale, // 状态栏的高度
				navigationHeight: 44 * pxToRpxScale // 导航栏的高度
			};
			systems.barHeight = systems.ktxStatusHeight + systems.navigationHeight;
			this.systems = systems;
		},
		onPageScroll: function(e) {
			if (e.scrollTop > this.systems.barHeight) {
				this.isTop = 1;
			} else {
				this.isTop = 0;
			}
		}
	}
</script>

<style>
	@import "./cardDetail.css";
</style>