<template>
	<view v-if="!loading">
		<view v-if="recommendCard&&userInfo.id!=recommendCard.userId">
			<view style="height: 136rpx;"></view>
			<view class="sc-box ddflex">
				<image class="sc-header" :src="recommendCard.avatar?recommendCard.avatar:'../../static/images/userimg.png'">
				</image>
				<view class="sc-name">
					<view>{{recommendCard.realName}}</view>
					<view class="sc-tag">{{recommendCard.jobName}}</view>
				</view>
				<view class="sc-line"></view>
				<view class="sc-contact" @click="jumpSingleChatRoom()">
					<image src="/static/images/wxChat.png"></image>
					<view>聊一聊</view>
				</view>
				<view class="sc-btn flex" @click="toIndex">进入我的微页</view>
			</view>
		</view>
	</view>
</template>

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

	export default {
		data() {
			return {
				userInfo:{},
				recommendCard: {},
				loading:true
			};
		},

		components: {},
		props: {
			userId:String
		},
		watch: {},

		mounted() {
			this.userInfo = req.getStorage('userInfo')
			this.getRecommendCard()
		},

		methods: {
			// 获取推荐销售
			getRecommendCard() {
				if(this.userId){
					req.getRequest('/api/user/userInfoById', {userId:this.userId}, res => {
						if(res.visitingCardDTO){
							this.recommendCard = res.visitingCardDTO
							this.loading = false
						}else{
							req.getRequest('/api/visiting/card/recommendCardInfo', {shareSaleNo:req.getStorage("shareId")?req.getStorage("shareId"):null}, res => {
								this.recommendCard = res
								this.loading = false
							})
						}
					})
				}else{
					req.getRequest('/api/visiting/card/recommendCardInfo', {shareSaleNo:req.getStorage("shareId")?req.getStorage("shareId"):null}, res => {
						this.recommendCard = res
						this.loading = false
					})
				}
			},


			jumpSingleChatRoom() {
				if (this.recommendCard) {
					req.jumpSingleChatRoom(this.recommendCard.userId, this.recommendCard.avatar, this.recommendCard
						.realName);
				}

			},
			// jumpConversation() {
			// 	req.jumpConversation();
			// },
			toIndex() {
				uni.switchTab({
					url: '/pages/index/index'
				})
			}
		}
	};
</script>
<style>
	@import "./index.css";
</style>