<template>
  <view class="product-similar">
    <view class="product-similar-card">
      <card :goods="goods" />
    </view>

    <view class="product-similar-goods">
      <list :goods-list.sync="goodsList" show-cart title="相似推荐" />
    </view>
  </view>
</template>
<script>
import { goodsLike } from "@/api/home.api.js";
import card from "./components/loseCard";
import list from "./components/goodsCard";
export default {
  components: {
    card,
    list
  },
  data() {
    return {
      searchData: {
        goodsId: ""
      },
      goods: {},
      goodsList: []
    };
  },
  onLoad(option) {
    uni.setNavigationBarTitle({ title: this.$config("defaultTitle") });
    this.goods = option;
    console.log("option", option);
    this.loadData();
  },
  methods: {
    async loadData() {
      // 商品详情没有无限流 只有20条数据
      this.searchData.goodsId = this.goods.skuNo || "";
      if (this.searchData.goodsId) {
        const [res] = await goodsLike(this.searchData);
        this.goodsList = this.goodsList.concat((res && res.goodsList) || []);
      }
    }
  }
};
</script>
<style lang="scss" scoped>
.product-similar {
  padding: 20rpx;
  &-card {
    border-radius: 6rpx;
    background: #fff;
    padding: 15rpx;
  }
  &-goods {
    // padding: 0 20rpx;
  }
}
</style>
