<template>
    <view class="c-inline">
        <template-mars target="h5">
            <a
                :href="item.linkUrl"
                class="c-inline tel-color">{{ item.linkText }}</a>
        </template-mars>
        <template-mars target="swan">
            <view
                @tap="onTap"
                class="c-inline tel-color">{{ item.linkText }}</view>
        </template-mars>
    </view>
</template>

<script>
import {send} from '../../utils/log';

export default {
    config: {
        component: true
    },
    props: {
        item: {
            type: Object,
            default: {}
        }
    },
    data() {
        return {
        };
    },
    lifetimes: {
        attached() {
        }
    },
    methods: {
        onTap() {
            if (process.env.MARS_ENV === 'swan') {
                const api = this.$api;
                api.makePhoneCall({
                    phoneNumber: this.item.linkText,
                    fail() {
                        api.showToast({
                            title: '拨号失败',
                            icon: 'none'
                        });
                    }
                });
                send({
                    type: 'b',
                    action: 'makePhoneCall'
                })
            }
        }
    }
};
</script>

<style lang="less">
.tel-color {
    color: #02b7ca;
}
</style>