<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'
	import { mapState } from 'vuex'
	export default {
		mixins: [mixinsSex],
		props: ['phone', 'title', 'sexName', 'type', 'phoneTitle', 'pid'],
		data() {
			return {

			}
		},
		computed : {
			...mapState(['priceMap']),
		},
		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'
					})
				}
				
				uni.showModal({
					title: `确定消耗${this.priceMap.phone}积分呼叫吗？`,
					success : (r) => {
						if(r.confirm){
							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>