<template>
    <div class="gift_card">
        <van-row
                style="border-bottom: solid 1px #e4e4e4; padding:5px"
        >
            <van-col span="8">
                <img :src="presentImg" style="max-width: 100%"/>
            </van-col>
            <van-col span="16">
                <van-row type="flex" justify="space-between">
                    <van-col class="c"><p><strong>{{owner ? '对方' : '我'}}的礼物</strong></p></van-col>
                    <van-col class="c"><p>{{place[placeId]}}</p></van-col>
                </van-row>
                <van-row type="flex" justify="space-between" v-if="gender !== -1">
                    <van-col class="c"><p>{{owner ? '对方' : '匹配'}}性别</p></van-col>
                    <van-col class="c"><p>{{genders[gender]}}</p></van-col>
                </van-row>
                <van-row type="flex" justify="space-between" v-if="status !== -1">
                    <van-col class="c"><p>礼物状态</p></van-col>
                    <van-col class="c" ><p :style="{ color: statusColor[status] }">{{statusString[status]}}</p></van-col>
                </van-row>
                <van-row type="flex" justify="space-between">
                    <van-col class="c"><p>微信</p></van-col>
                    <van-col class="c">
                        <p :style="owner ? 'color: #778899' : 'color: #191970' + '; float: left'" @click="toMe">
                            {{wechat}}</p>
                            <van-button round size="mini"
                                        v-if="owner" style="margin-left: 5px"
                                        v-clipboard:copy="wechat"
                                        v-clipboard:success="onCopy"
                                        v-clipboard:error="onError"
                            >复制</van-button>
                    </van-col>
                </van-row>
            </van-col>
        </van-row>
        <p style="text-align: left; font-size: 100%"><strong>{{presentName}}</strong></p>
        <p style="text-align: left">{{presentDesc}}</p>
    </div>
</template>

<script>
    import {Card, Row, Col, Button, Toast} from 'vant';
    export default {
        name: "giftCard",  //gift-card
        // luaOps 'lua-ops
        components: {
            [Card.name]: Card,
            [Row.name]: Row, [Col.name]: Col,
            [Button.name]: Button,
        },
        data() {
            return {
                place: ['斋区', '西南', '南区', '桂庙', '西丽'],
                statusString: ['审核中', '匹配中', '匹配成功', '交换成功', '审核失败'],
                statusColor: ['#fd6740', '#00ff00', '#00bfff', '#00fa9a', '#ff0000'],
                genders: ['未知', '男', '女']
            }
        },
        props: {
            presentImg: {
                type: String,
                default: "http://szugift.oss-cn-shenzhen.aliyuncs.com/image_load_fail.jpg"
            },
            presentName: {
                type: String,
                default: "礼物名称"
            },
            presentDesc: {
                type: String,
                default: '没有获取到对方的礼物！'
            },
            owner: {
                type: Number,
                default: 0 // 0: 我的; 1: 对方的
            },
            placeId: {
                type: Number,
                default: 0
            },
            gender: {
                type: Number,
                default: 0
            },
            status: {
                type: Number,
                default: 0
            },
            wechat: {
                type: String,
                default: 'undefined id'
            }
        },
        methods: {
            onCopy: function (e) {
                Toast.success('复制成功: ' + e.text)
            },
            onError: function (e) {
                Toast.fail('复制失败')
            },
            toMe: function () {
                if (this.owner === 0) this.$router.push('me');
            }
        }
    }
</script>

<style scoped>
    .c {
        height: 25px;
        margin-left: 10px;
        margin-right: 5px;
    }
    p {
        margin: 0;
        font-size: 80%;
    }
    .gift_card {
        margin: 20px 20px;
        background-color: white;
        padding: 10px;
    }
</style>