<template>
  <div class="content">
    <el-descriptions :column="4" border  >
      <el-descriptions-item label="封面"  >
          <span v-if="package!=null">
            <el-popover
            placement="right"
            title=""
            trigger="hover"
          >
            <img slot="reference" :src="package.imgUrl" width="100">
            <img :src="package.imgUrl" style="max-width: 150px;">
          </el-popover>
          </span>
      </el-descriptions-item>
      <el-descriptions-item label="标题"  >
          <span v-if="package!=null">
            {{package.title}}
          </span>
      </el-descriptions-item>
      <el-descriptions-item label="描述"  >
          <span v-if="package!=null" >
            {{package.descs}}
          </span>
      </el-descriptions-item>
      <el-descriptions-item label="原价"  >
          <span v-if="package!=null">
            {{package.money.toFixed(2)}}
          </span>
      </el-descriptions-item>
      <el-descriptions-item label="套餐价格"  >
          <span v-if="package!=null">
            {{package.payMoney.toFixed(2)}}
          </span>
      </el-descriptions-item>
      <el-descriptions-item label="支付类型"  >
          <span v-if="package!=null">
            <el-tag prop="payType" v-for="(item, index) in storePayTypeOptions"    v-if="package.payType==item.dictValue">{{item.dictLabel}}</el-tag>
          </span>
      </el-descriptions-item>
      <el-descriptions-item label="限购次数"  >
          <span v-if="package!=null">
            {{package.limitCount}}
          </span>
      </el-descriptions-item>
       
    </el-descriptions>
    <div style="margin: 20px 0px"  v-if="items!=null">
        <span class="font-small">
          商品列表
        </span>
    </div>
    <el-table
      border
      v-if="items!=null"
      :data="items"
      size="small"
      style="width: 100%;margin-top: 20px" >
      <el-table-column label="ID"  align="center">
        <template slot-scope="scope">
          <p>{{scope.row.id}}</p>
        </template>
      </el-table-column>
      <el-table-column label="商品图片"   align="center">
          <template slot-scope="scope">
            <img :src="scope.row.image" style="height: 80px">
          </template>
      </el-table-column>
      <el-table-column label="商品名称"   align="center">
        <template slot-scope="scope">
          <p>{{scope.row.productName}}</p>
        </template>
      </el-table-column>
      <el-table-column label="规格"   align="center">
        <template slot-scope="scope">
          <p>{{scope.row.sku}}</p>
        </template>
      </el-table-column>
      <el-table-column label="售价"   align="center">
        <template slot-scope="scope">
          <p>￥{{scope.row.price.toFixed(2)}}</p>
        </template>
      </el-table-column>
      <el-table-column label="商品编码"   align="center">
        <template slot-scope="scope">
          {{scope.row.barCode}}
        </template>
      </el-table-column>
      <el-table-column label="数量" width="180" align="center">
        <template slot-scope="scope">
          {{scope.row.count}}
        </template>
      </el-table-column>
    </el-table>
    <div v-html="package.content"></div>
  </div>
</template>

<script>
import {  getStoreProductPackage  } from "@/api/store/storeProductPackage";

export default {
  name: "product",
  data() {
    return {
      cateOptions:[],
      storePayTypeOptions:[],
      package:null,
      items:[],
    };
  },
  created() {
    this.getDicts("store_product_package_cate").then((response) => {
      this.cateOptions = response.data;
    });
    this.getDicts("store_pay_type").then((response) => {
      this.storePayTypeOptions = response.data;
    });
  },
  methods: {
    getStoreProductPackage(id) {
      getStoreProductPackage(id).then(response => {
        this.package = response.productPckage;
        this.items = response.productList;
      });
    },
  }
};
</script>
<style scoped>
.content{
  margin: 10px;
}
 
</style>
