<template>
	<view class="phone" v-if="phone" @click.stop="callPhone">
		<image src="/static/image/home/phone.png" mode="widthFix"></image>
		{{ title || '联系' + ta[sexName] }}
	</view>
</template>

<script>
	import mixinsSex from '@/mixins/sex.js'
	export default {
		mixins: [mixinsSex],
		props: ['phone', 'title', 'sexName', 'type', 'phoneTitle', 'pid'],
		data() {
			return {

			}
		},
		methods: {
			callPhone(){
				
				let data = {
					title : this.phoneTitle,
					type : this.type,
					id : this.pid
				}
				
				console.log(data);
				
				if(!data.id || !data.title){
					return uni.showToast({
						title: '缺少参数',
						icon: 'none'
					})
				}
				
				this.$api('checkGivePhone', data, res => {
					if(res.code == 200){
						uni.makePhoneCall({
							phoneNumber: this.phone
						})
					}
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	.phone {
		background-color: rgba($uni-color, 0.2);
		color: $uni-color;
		padding: 8rpx 16rpx;
		border-radius: 10rpx;
		margin-left: auto;
		font-size: 26rpx;

		image {
			width: 20rpx;
			height: 20rpx;
		}
	}
</style>