feature-selector.vue 2.59 KB
<style src="./css/feature-selector.css"></style>
<template>
    <div class="feature-selector" v-bind:class="{ 'slide-in': isVisible }">
        <div class="header">
            <div class="image-box">
                <img src=""/>
            </div>
            <div class="text-box">
                <h3>{{title}}</h3>
                <h4>¥{{price}}</h4>
            </div>
        </div>
        <hr>

        <div>
            <section>
                <h4>颜色</h4>
                <feature-options :options="colors"></feature-options>
            </section>
            <section>
                <h4>尺码</h4>
                <feature-options :options="sizes"></feature-options>
            </section>
            <button v-on:click="addToCart(product.id)" class="button button-solid add-to-cart">加入购物袋</button>
        </div>
    </div>
</template>

<script>
    module.exports = {
        init() {
        },
        props: {
            isVisible: Boolean
        },
        watch: {
            isVisible() {
                const self = this;

                if (this.isVisible) {
                    this.overlay = $.overlay({
                        onClose: function() {
                            self.isVisible = false;
                        }
                    });

                    this.overlay.show();
                } else {
                    this.overlay.hide();
                    this.$parent.$emit('featureselector.close');
                }
            }
        },
        data() {
            return {
                title: 'Supreme经典夹克Supreme经典夹克Supreme经典夹克Supreme经典夹克',
                price: '1289.00',
                colors: [
                    {
                        text: '炫酷黑',
                        value: '#333333'
                    },
                    {
                        text: '象牙白',
                        value: '#EFEFEF'
                    },
                    {
                        text: '深海蓝',
                        value: '#330000'
                    }
                ],
                sizes: [
                    {
                        text: 'S',
                        value: 'S'
                    },
                    {
                        text: 'M',
                        value: 'M'
                    },
                    {
                        text: 'L',
                        value: 'L'
                    }
                ]
            };
        },
        components: {
            'feature-options': require('./feature-options.vue')
        }
    };
</script>