<template>
  <view class="card">
    <view class="head">
      <image class="imgBg" :src="shopCardData.shopLogo" mode="aspectFill" />
      <view class="containerBox">
        <image class="img" :src="shopCardData.shopLogo" mode="aspectFill" />
        <view class="right">
          <text class="text">{{ shopCardData.shopName }}</text>
          <view class="twoBxo">
            <text class="one-text">{{ shopCardData.grade }}推荐</text>
            <!-- <text class="two-text">￥30/人</text> -->
            <text class="three-text">销量{{ shopCardData.monthSoldNum }}</text>
            <text class="four-text">
              {{ getDistance(shopCardData.shopLat, shopCardData.shopLng, latF, lonF) }}
            </text>
          </view>
          <view class="threeBox">
            <image class="img2" :src="shopCardData.evaluationVos[0].avatar" mode="aspectFill" />
            <text class="one-text">“{{ shopCardData.evaluationVos[0].evaluation }}”</text>
          </view>
          <view class="labelBox">
            <view v-for="(item, index) in shopCardData.labels" :key="index">{{ item }}</view>
          </view>
        </view>
      </view>
    </view>
    <view class="nearby-bootom">
      <view
        class="contentBox"
        @tap="topFoodDetails(item.prodId)"
        v-for="(item, index) in shopCardData.simpleProds"
        :key="index"
      >
        <image class="img" :src="item.pic" mode="aspectFill" />
        <text class="one">{{ item.prodName }}</text>
        <view class="price">
          <image class="img" src="../../static/index/groupBuying.png" mode="aspectFill" />
          <text class="two">￥{{ item.price }}</text>
          <text class="three">{{ item.oriPrice }}</text>
        </view>
      </view>
    </view>
    <wd-status-tip image="content" tip="暂无内容" v-if="shopCardData.simpleProds.length === 0" />
  </view>
</template>

<script setup>
import { defineProps } from 'vue';
import { getDistance } from '../../utils/common';
import { getLocation } from '../../utils/tool';
const lonF = ref(0);
const latF = ref(0);
const props = defineProps({
  shopCardData: {
    type: Object,
    default: () => ({
      evaluationVos: [],
    }),
  },
});
onMounted(async () => {
  const { lon, lat } = await getLocation();
  lonF.value = lon;
  latF.value = lat;
});
const topFoodDetails = (id) => {
  xma.navigateTo({
    url: `/pages/packageDetails/packageDetails?prodId=${id}`,
  });
};
</script>

<style lang="scss" scoped>
.card {
  width: 710rpx;
  height: 536rpx;
  border-radius: 16rpx;
  background: #fdfdfd;
  margin: 10rpx auto;
  overflow: hidden;
  .head {
    width: 100%;
    height: 200rpx;
    position: relative;
    .imgBg {
      width: 100%;
      height: 200rpx;
      filter: blur(16rpx);
      position: absolute;
      top: 0;
    }
    .containerBox {
      display: flex;
      position: absolute;
      bottom: -35rpx;
      left: 20rpx;
      .img {
        width: 144rpx;
        height: 144rpx;
        border-radius: 18rpx;
      }
      .right {
        margin-left: 20rpx;
        display: flex;
        flex-direction: column;
        .text {
          font-size: 28rpx;
          font-weight: bold;
          color: rgba(255, 255, 255, 1);
        }
        .twoBxo {
          display: flex;
          align-items: center;
          margin-top: 10rpx;
          position: relative;
          width: 510rpx;
          .one-text {
            font-size: 22rpx;
            font-weight: bold;
            color: #fa5151;
          }
          .two-text {
            font-size: 20rpx;
            color: #ffffff;
            font-weight: 500;
            margin-left: 20rpx;
          }
          .three-text {
            font-size: 20rpx;
            color: #ffffff;
            font-weight: 500;
            margin-left: 8rpx;
          }
          .four-text {
            font-size: 20rpx;
            color: #ffffff;
            font-weight: 500;
            position: absolute;
            right: 20rpx;
          }
        }
        .threeBox {
          display: flex;
          align-items: center;
          margin-top: 10rpx;
          .img2 {
            width: 40rpx;
            height: 40rpx;
            border-radius: 50%;
          }
          .one-text {
            font-size: 22rpx;
            color: #ffffff;
            font-weight: 500;
            margin-left: 8rpx;
          }
        }
        .labelBox {
          margin-top: 10rpx;
          display: flex;
          align-items: center;
          view {
            margin-right: 8rpx;
            display: inline-block;
            height: 36rpx;
            padding: 0 8rpx;
            line-height: 36rpx;
            font-size: 18rpx;
            color: #767676;
            background: linear-gradient(90deg, #fcdbdb 0%, rgba(255, 255, 255, 0) 98%);
          }
        }
      }
    }
  }
  .nearby-bootom {
    margin-top: 74rpx;
    display: flex;
    padding: 0 20rpx;
    box-sizing: border-box;
    overflow: hidden;
    // justify-content: space-between;
    .contentBox {
      width: 180rpx;
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      margin-right: 40rpx;
      .img {
        width: 180rpx;
        height: 136rpx;
        border-radius: 16rpx;
      }
      .one {
        width: 100%;
        font-size: 28rpx;
        font-weight: bold;
        color: #3d3d3d;
        margin: 10rpx 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
      .price {
        display: flex;
        align-items: center;
        .img {
          width: 36rpx;
          height: 36rpx;
        }
        .two {
          font-size: 24rpx;
          color: #fa5151;
          font-weight: 500;
          margin-left: 12rpx;
          // margin: 10rpx 0;
        }
        .three {
          font-size: 20rpx;
          color: #abaaaa;
          margin-left: 8rpx;
          text-decoration: line-through;
        }
      }
    }
  }
}
</style>
