<template>
    <div>
        <div style="position: relative;">
            <img :src="indexTop" style="max-width: 100%; position: relative;"/>
        </div>
        <van-row type="flex" justify="space-between" align="center" style="margin: 0 10px 0 15px">
            <van-col>
                <p><strong>我的礼物</strong></p>
            </van-col>
            <van-col>
                <van-button round type="primary" size="small" @click="toShare">邀请好友赢大奖</van-button>
            </van-col>
        </van-row>

        <ul style="background-color: #fff6e3">
            <li
                    is="index-present"
                    v-for="(present, index) in presents"
                    :key="present.id"
                    :present-name="present.presentName"
                    :present-desc="present.desc"
                    :publish-time="present.time"
                    :status="present.status"
                    @to-detail="toDetail(index)"
            ></li>
        </ul>
        <div style="margin: 50px 10px;">
            <p style="text-align: left; margin-left: 5px"><strong>简单四步，轻松互赠圣诞礼物</strong></p>
            <img src="../assets/declare_icons/declare.jpg"/>
        </div>
        <add-present-button :can_add="button_active"/>
    </div>
</template>

<script>
    import IndexPresent from "../components/IndexPresent";
    import { Button, Row, Col} from "vant"
    import AddPresentButton from "../components/addPresentButton";

    export default {
        name: "index",
        components: {
            AddPresentButton,
            IndexPresent,
            [Button.name]: Button,
            [Row.name]: Row, [Col.name]: Col
        },
        data() {
            return {
                active: 0,
                indexTop: require('../assets/banner.png'),
                button_active: true,
            }
        },
        computed: {
            presents: function() {
                // return get_present_data()
                return [
                    {
                        id: 0,
                        presentName: '礼物1',
                        desc: '描述1blabla',
                        time: '2018-01-02',
                        status: 1
                    },
                    {
                        id: 1,
                        presentName: '礼物2',
                        desc: '描述2blabla啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊(max45)',
                        time: '2018-11-02',
                        status: 2
                    }
                ]
            }
        },
        methods: {
            toShare() {
                this.$router.push('share')
            },
            toDetail(id) {
                this.$router.push({ path: 'giftDetail', query: { presentId: id } })
            }
        }
    }
</script>

<style scoped>

</style>