<template>
    <el-popover placement="bottom" :width="674" trigger="click" popper-style="padding:0;border-radius: 10px;">
        <template #reference>
            <div class="btn" @click="transmit"></div>
        </template>

        <div class="transmit-unfold-box">
            <div class="transmit-item">
                <div class="transmit-head">转发网页版</div>
                <div class="transmit-box transmit-webpage-box">
                    <div class="transmit-webpage-title">{{ props['title'] }}</div>
                    <div class="transmit-link">{{ url }}</div>
                </div>
                <div class="copy-link-btn flexcenter" @click="copy">复制链接</div>
            </div>
            <div class="transmit-item">
                <div class="transmit-head">转发小程序版</div>
                <div class="transmit-box transmit-QRCode-box"><img :src="props['qrcode']" class="QRCode">
                    <div class="hint">
                        <img class="saoma-icom" src="@/assets/img/apartmentDetail/scan-icon.png">

                        手机查看该房源
                    </div>
                </div>
            </div>
        </div>
        <!-- <img v-if="user.identity == 1" style="width: 360px;"
            src="@/assets/img/publicImage/mediation-authentication-code.svg">
        <img v-else style="width: 360px;" src="@/assets/img/publicImage/housing-certification-code.svg"> -->
    </el-popover>
</template>

<script setup>
import { defineProps } from 'vue';
import { copyToClipboard } from '@/utils/util.js'
import { ElMessage } from 'element-plus'

const props = defineProps({
    title: String,
    qrcode: String,
})

let url = location.href


const copy = () => {
    copyToClipboard(`${props['title']} - ${url}`).then(() => {
        ElMessage.success("复制成功！！！")
    })
}



</script>

<style lang="less" scoped>
.btn {
    // background-color: antiquewhite;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.transmit-unfold-box,
.transmit-unfold-box * {
    box-sizing: content-box;
}

.transmit-unfold-box {
    background-color: #fff;
    padding: 42px 54px 12px 44px;
    display: flex;
    border-radius: 10px;
    font-family: "PingFang SC", "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
    // box-shadow: 0px 2px 11px -2px #dcebef;
    // border: 1px solid #e0e0e0;
}

.transmit-unfold-box .transmit-unfold-close {
    display: flex;
    justify-content: flex-end;
    position: absolute;
    top: 0;
    right: 0;
}

.transmit-unfold-box .transmit-unfold-close .transmit-close-icon {
    width: 16px;
    height: 16px;
    padding: 10px 12px;
    cursor: pointer;
}

.transmit-unfold-box .transmit-item {
    display: flex;
    flex-direction: column;
}

.transmit-unfold-box .transmit-item:last-of-type {
    margin-left: 74px;
}

.transmit-unfold-box .transmit-item .transmit-head {
    font-size: 16px;
    line-height: 16px;
    font-weight: 550;
    color: #000;
}

.transmit-unfold-box .transmit-item .transmit-box {
    border-radius: 16px;
    border: 1px solid #f0f0f0;
    margin-top: 28px;
    margin-bottom: 32px;
}

.transmit-unfold-box .transmit-item .transmit-webpage-box {
    width: 265px;
    padding: 12px 18px 12px 15px;
    font-size: 14px;
}

.transmit-unfold-box .transmit-item .transmit-webpage-box .transmit-webpage-title {
    line-height: 24px;
    word-break: break-word;
    color: #000;
}

.transmit-unfold-box .transmit-item .transmit-webpage-box .transmit-link {
    line-height: 18px;
    color: #a0a0a0;
    word-wrap: break-word;
}

.transmit-unfold-box .transmit-item .transmit-QRCode-box {
    width: 198px;
    height: 128px;
    flex-direction: column;
    padding: 20px 0;
    display: flex;
    justify-content: space-between;
}

.transmit-unfold-box .transmit-item .transmit-QRCode-box .QRCode {
    width: 98px;
    height: 98px;
    margin: 0 auto;
}

.transmit-unfold-box .transmit-item .transmit-QRCode-box .hint {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    text-align: center;
}

.transmit-unfold-box .transmit-item .transmit-QRCode-box .hint .saoma-icom {
    width: 14px;
    height: 14px;
    margin-right: 8px;
}

.transmit-unfold-box .copy-link-btn {
    background-color: #46dfba;
    border-radius: 5px;
    width: 120px;
    height: 38px;
    user-select: none;
    cursor: pointer;
    color: #000;
}
</style>