article-body.vue 3.44 KB
<template>
  <Scroll class="scroll-wrapper" :options="scrollOpts">
    <Author v-if="articleDetail" :data="articleDetail.getAuthor"></Author>

    <div class="post-content" v-if="articleDetail">
      <template v-for="item in articleDetail.getArticleContent">
        <template v-if="item.text">
          <div class="text" v-html="item.text"></div>
        </template>

        <template v-if="item.bigImage">
          <div class="big-img-block">
            <ImageFormat :lazy="false" :src="item.bigImage" width="640" height="640" ></ImageFormat>
          </div>
        </template>

        <template v-if="item.smallImage">
          <div class="small-img-block clearfix">
            <ImageFormat :lazy="false" :src="i.src" width="315" height="420" v-for="i in item.smallImage" ></ImageFormat>
          </div>
        </template>

        <template v-if="item.video">
          <video src="item.video.src" controls="controls" :poster="item.video.cover_image" preload="none">
            不好意思,您的浏览器不支持此视频!
          </video>
        </template>

        <template v-if="item.relatedReco">
          <div class="products">
            <ProductItem class="product-item" v-for="p in item.relatedReco.goods" :src="p.default_images" :price="p.sales_price" :name="p.product_name"></ProductItem>
          </div>
        </template>
      </template>
    </div>

    <ZanBar class="zanbar" v-if="articleDetail" v-bind="articleDetail.zanBar"></ZanBar>
    <TagBar class="tagbar" v-if="articleDetail" :list="articleDetail.tagBar"></TagBar>

    <Recommend v-if="articleDetail && articleDetail.getRecommendProducts.length > 0">
      <RecommendProductList :list="articleDetail.getRecommendProducts"></RecommendProductList>
    </Recommend>
  </Scroll>
</template>

<script>

import {Scroll} from 'cube-ui';
import RecommendProductList from './recommend-product-list';
import Recommend from './recommend';
import Author from './author';
import ZanBar from './zan-bar';
import TagBar from './tag-bar';
import { createNamespacedHelpers } from 'vuex';

const { mapState } = createNamespacedHelpers('article');

export default {
  name: 'ArticleBody',
  components: {
    Scroll,
    RecommendProductList,
    Recommend,
    Author,
    ZanBar,
    TagBar
  },
  data() {
    return {
      scrollOpts: {
        eventPassthrough: 'horizontal'
      }
    };
  },
  computed: {
    ...mapState(['articleDetail'])
  },
  mounted() {
  },
  methods: {
  }
};
</script>

<style lang="scss" scoped>
.scroll-wrapper {
  background-color: white;
}

.post-content {
  padding-left: 30px;
  padding-right: 30px;
  padding-top: 26px;

  /deep/ .normal {
    width: 100% !important;
    margin-top: 30px;
    margin-bottom: 30px;
  }

  /deep/ .large {
    width: 100% !important;
    margin-top: 30px;
    margin-bottom: 30px;
  }

  /deep/ p {
    font-size: 24px;
    color: #444;
    text-align: left;
    line-height: 44px;
  }
}

.zanbar {
  margin-bottom: 40px;
  padding-left: 30px;
  padding-right: 30px;
}

.tagbar {
  margin-bottom: 50px;
  padding-left: 30px;
  padding-right: 30px;
}

.products {
  margin-top: 40px;
  margin-bottom: 40px;
}

.product-item + .product-item {
  margin-top: 64px;
}

.big-img-block {
  background: #fff;
  position: relative;
  padding-bottom: 10px;

  /deep/ img {
    width: 100%;
  }
}

.small-img-block {
  padding-bottom: 16px;
  background: #fff;

  /deep/ img {
    float: right;
    width: 50%;

    &:first-child {
      float: left;
    }
  }
}

</style>