home.vue 9.23 KB
<template>
    <div class="main">
        <!--轮播广告-->
        <template v-for="vm in weiIndex.fields">
            <template v-if="vm.fieldType=='imageAdv'">
                <mt-swipe :auto="4000" style="height:4.2rem" v-if="vm.content.imageType==2">
                    <mt-swipe-item :style="{'background-image':'url('+item.image+')'}"
                                   v-for="item in vm.content.navList" @click.native="gotopage(item.prefix,item.url)">
                        <div class="component-swipe-title" v-if="item.title!=''">{{item.title}}</div>
                    </mt-swipe-item>
                </mt-swipe>

                <!--轮播广告分开显示-->
                <ul v-else>
                    <no-swpie-adv :style="{'background-image':'url('+item.image+')'}" v-for="item in vm.content.navList"
                                  @click.native="gotopage(item.prefix,item.url)">
                        <div class="component-swipe-title" ref="title" v-if="item.title!=''">
                            斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达斯柯达
                        </div>
                    </no-swpie-adv>
                </ul>
            </template>

            <!--商品-->
            <template v-if="vm.fieldType=='product'">
                <!--商品大图-->
                <ul v-if="vm.content.listType==4">
                    <big-pic v-for="item in vm.content.goods" :item="item" :showType="vm.content.showType"
                             :showTitle="vm.content.showTitle" :isShowPrice="vm.content.isShowPrice"
                             :siteUnitName="weiIndex.siteUnitName"></big-pic>
                </ul>

                <!--商品小图-->
                <ul class="goods-small-ul" v-if="vm.content.listType==1">
                    <small-pic v-for="item in vm.content.goods" :item="item" :showType="vm.content.showType"
                               :showTitle="vm.content.showTitle" :isShowPrice="vm.content.isShowPrice"
                               :siteUnitName="weiIndex.siteUnitName"></small-pic>

                </ul>

                <!--商品详细列表-->
                <ul class="goods-piclist-ul" v-if="vm.content.listType==3">
                    <small-pic-list v-for="item in vm.content.goods" :item="item" :showType="vm.content.showType"
                                    :showTitle="vm.content.showTitle" :isShowPrice="vm.content.isShowPrice"
                                    :siteUnitName="weiIndex.siteUnitName"></small-pic-list>
                </ul>

                <!--商品一大两小-->
                <div v-if="vm.content.listType==2">
                    <mix-pic :data="vm.content.goods" :showType="vm.content.showType" :showTitle="vm.content.showTitle"
                             :isShowPrice="vm.content.isShowPrice" :siteUnitName="weiIndex.siteUnitName"></mix-pic>
                </div>
            </template>

            <!--商品组-->
            <template v-if="vm.fieldType=='productList'">
                <router-link
                        :to="{ name: 'goodsGroup',params: {typer:'productGroup',productListId: vm.content.groupId}}"
                        tag="div" class="component-text-nav">
                    <span>{{vm.content.groupTitle}}</span><img src="../../static/images/arr.svg"/>
                </router-link>
                <!--商品大图-->
                <ul v-if="vm.content.listType==4">
                    <big-pic v-for="item in vm.content.goods" :item="item" :showType="vm.content.showType"
                             :showTitle="vm.content.showTitle" :isShowPrice="vm.content.isShowPrice"
                             :siteUnitName="weiIndex.siteUnitName"></big-pic>
                </ul>

                <!--商品小图-->
                <ul class="goods-small-ul" v-if="vm.content.listType==1">
                    <small-pic v-for="item in vm.content.goods" :item="item" :showType="vm.content.showType"
                               :showTitle="vm.content.showTitle" :isShowPrice="vm.content.isShowPrice"
                               :siteUnitName="weiIndex.siteUnitName"></small-pic>

                </ul>

                <!--商品详细列表-->
                <ul class="goods-piclist-ul" v-if="vm.content.listType==3">
                    <small-pic-list v-for="item in vm.content.goods" :item="item" :showType="vm.content.showType"
                                    :showTitle="vm.content.showTitle" :isShowPrice="vm.content.isShowPrice"
                                    :siteUnitName="weiIndex.siteUnitName"></small-pic-list>
                </ul>

                <!--商品一大两小-->
                <div v-if="vm.content.listType==2">
                    <mix-pic :data="vm.content.goods" :showType="vm.content.showType" :showTitle="vm.content.showTitle"
                             :isShowPrice="vm.content.isShowPrice" :siteUnitName="weiIndex.siteUnitName"></mix-pic>
                </div>
            </template>


            <!--标题-->

            <titler v-if="vm.fieldType=='title'" :data="vm.content"></titler>

            <!--文本导航-->
            <template v-if="vm.fieldType=='textNav'">
                <text-nav v-for="item in vm.content" :item="item"></text-nav>
            </template>

            <!--辅助线-->
            <div class="component-Guide" v-if="vm.fieldType=='line'"></div>

            <!--辅助空白-->
            <div class="component-blank" v-if="vm.fieldType=='white'" :style="{'height':vm.content.height+'px'}"></div>

            <!--富文本-->
            <div class="component-Rich-text" v-if="vm.fieldType=='richText'" :style="{'background':vm.content.bgColor}"
                 v-html="vm.content.textContent"></div>

            <!--图片导航-->
            <div class="component-picNav-table" v-if="vm.fieldType=='imageNav'">
                <pic-nav v-for="item in vm.content" :item="item"></pic-nav>
            </div>

            <!--商品搜索-->
            <router-link to="/search" tag="div" class="component-search" v-if="vm.fieldType=='search'">
                <button>请输入商品名称或分类</button>
            </router-link>


            <!--公告组件-->
            <notice v-if="vm.fieldType=='notice'" :data="vm.content"></notice>

            <!--优惠券组件-->
            <template v-if="vm.fieldType=='coupons'">
                <index-coupon-item v-for="item in vm.content.couponArr" :item="item"
                                   :siteUnitName="weiIndex.siteUnitName"></index-coupon-item>
            </template>

            <!--优惠券中心-->
            <router-link to="/couponCenter" tag="div" class="coupon-center"
                         v-if="vm.fieldType=='couponCenter'"></router-link>
        </template>

        <!--底部导航-->
        <bottom-nav></bottom-nav>
    </div>
</template>


<style>
    .main .mint-swipe-indicators {
        left: auto !important;
        bottom: 5px !important;
        right: -16px;
    }

    image[lazy=loading] {
        width: 40px !important;
        height: 50vw;
        margin: auto;
    }


</style>
<script type="text/ecmascript-6">
    import noSwpieAdv from '../adv/noSwpieAdv.vue';
    import bigPic from '../goods/bigPic.vue';
    import smallPic from '../goods/smallPic.vue';
    import smallPicList from '../goods/smallPicList.vue';
    import mixPic from '../goods/mixPic.vue';
    import titler from '../index/title.vue';
    import textNav from '../index/textNav.vue';
    import picNav from '../index/picNav.vue';
    import notice from '../index/notice.vue';
    import indexCouponItem from '../coupon/indexCouponItem.vue';
    import bottomNav from '../common/bottomNav.vue';
    import {getweiIndext} from '../../vuex/actions';
    import {goto}  from '../../utils/commonUtil';

    export default {
        data() {
            return {}
        },
        components: {
            noSwpieAdv,
            bigPic,
            smallPic,
            smallPicList,
            mixPic,
            titler,
            textNav,
            picNav,
            notice,
            indexCouponItem,
            bottomNav
        },
        methods: {
            gotopage(type, url){
                goto.gotopage(this, type, url);
            }
        },
        vuex: {
            getters: {
                weiIndex: ({weiPageData}) => {
                    return weiPageData.weiIndex;
                }
            },
            actions: {
                getweiIndext,
            }
        },
        beforeRouteEnter (to, from, next){
            next(vm => {
                vm.getweiIndext(0);
            });
        },
        beforeRouteLeave (to, from, next){
            next();
        }
    }
</script>