<template>
  <view class="rounded-xs box-show" @tap.stop="handleDetail(goods)">
   <!-- <u-image  width="100%" height="345rpx" :src="goods.cover" :lazy-load="true"></u-image> -->
    <cu-image :borderTopLeftRadius="24" :borderTopRightRadius="24" width="100%" height="345rpx" :src="`${goods.cover}?x-oss-process=image/resize,h_375,m_lfit`" :lazy-load="true"></cu-image>
    <view class="px-base">
      <view class="text-txBase line-2 mt-10rpx">{{ goods.name }}</view>
      <view class="text-md text-txBase flex items-center justify-between">
        <view>￥{{ goods.sell_price }}</view>
        <block v-if="showShrough">
          <view v-if="goods['market_price']!=undefined && goods.market_price"  class="fontFam line-through text-txGray text-20rpx">￥{{goods.market_price}}</view>
        </block>
        <view v-if="cart" @click.stop="onCart">
          <u-icon size="46" color="#f0ad4e" name="shopping-cart"></u-icon>
        </view>
      </view>
      <view class="flex items-center justify-between">
        <view class="flex items-center">
          <view class="text-lg -mt-5rpx text-txSvip">￥{{ goods.vip_price }}</view>
          <image class="w-58rpx h-58rpx ml-10rpx" src="/static/svg/svip.svg" mode=""></image>
        </view>
        <!-- 收藏按钮 -->
        <view v-if="isCollection">
          <u-icon size="36" color="#f0ad4e" name="star-fill"></u-icon>
        </view>

      </view>
    </view>
  </view>
</template>

<script>
  //obj[key]==undefined
export default {
  props: {
    //是否显示收藏
    isCollection: {
      type: Boolean,
      default: false,
    },
    //数据
    goods: {
      type: Object,
      default: () => {},
    },
    //是否显示店铺直通车才显示删除的市场价格
    showShrough:{
      type:Boolean,
      default:false
    },
    cart:{
      type:Boolean,
      default:false
    },
    detail: {
      type: Boolean | String,
      default: true
    }
  },
  data() {
    return {};
  },
  methods: {
    onCart(){
      this.$emit('cartClick',this.goods)
    },
    handleDetail(goods) {
      if (this.detail === false) {
        this.onCart()
        return;
      }
      let url = '/pages/product_details/index'
      let params = { skuId: goods.id, showShrough: this.showShrough }
      if (this.detail !== true) {
        url = this.detail
      }
      this.$u.route(url, params)
    }
  },
};
</script>
<style lang="scss" scoped>
.box-show {
  box-shadow: 0px 2px 6px rgba(0, 0, 0, 0.12);
}
.fontFam{
  /* #ifdef APP-PLUS  */
  font-family: "宋体";
  /* #endif  */
  }
</style>
