<!-- eslint-disable vue/no-mutating-props -->
<template>
  <view class="shop-item-wrapper" @click="navigateToDetails(item)">
    <view class="item-left-wrap">
      <image :src="pathPre + item.content?.image" mode="aspectFill" />
    </view>
    <view class="item-right-wrap">
      <view class="top">
        <view class="title u-line-1">{{ item.title }}</view>
        <view class="rate-box">
          <uni-rate allow-half :value="item.content?.rate || 0" disabled color="#ddd" disabledColor="#ff5702" activeColor="#ff5702" size="20" />
          <text class="rate-text">{{ (Number(item.content?.rate) || 0).toFixed(1) }}</text>
        </view>
        <view class="price" v-if="price">¥{{ item.content?.price }}/人</view>
      </view>
      <view class="bottom">
        <view class="tag-item" v-for="(tag, index) in item.content?.tags" :key="index">{{ tag }}</view>
      </view>
    </view>
  </view>
</template>

<script lang="ts" setup>
import { useGlobal } from '@/composables/index'

const { pathPre } = useGlobal()

const props = defineProps({
  price: {
    type: Boolean,
    default: false
  },
  item: {
    type: Object,
    default: () => ({})
  }
})

const navigateToDetails = (item: any) => {
  if (props.price) {
    uni.navigateTo({
      url: '/base/shop/details?id=' + item.id
    })
  } else {
    uni.navigateTo({
      url: '/base/shop/detailsShop?id=' + item.id
    })
  }
}
</script>

<style lang="scss" scoped>
.shop-item-wrapper {
  width: 100%;
  box-sizing: border-box;
  padding: 30rpx;
  background-color: #fff;
  border-radius: 14rpx;
  display: flex;
  margin-bottom: 32rpx;
  .item-left-wrap {
    width: 188rpx;
    height: 188rpx;
    background-color: #f6f7fb;
    border-radius: 14rpx;
    margin-right: 28rpx;
    image {
      width: 188rpx;
      height: 199rpx;
      border-radius: 14rpx;
    }
  }
  .item-right-wrap {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    .top {
      .title {
        font-size: 28rpx;
        color: #333;
        font-weight: 500;
        width: 400rpx;
        margin-bottom: 10rpx;
      }
      .rate-box {
        display: flex;
        align-items: flex-end;
        .rate-text {
          margin-left: 14rpx;
        }
      }
      .price {
        font-size: 25rpx;
        color: #ff5704;
        margin-top: 4rpx;
      }
    }
    .bottom {
      display: flex;
      align-items: center;
      .tag-item {
        font-size: 26rpx;
        color: #999;
        margin-right: 22rpx;
      }
    }
  }
}
</style>
