<template>
    <view title="热门服务">
        <block v-for="item1 in lists" :key="item1.id">
            <view
                class="goods-item mr-[20rpx]"
                @click="goPage(`/pages/goods/index?id=${item1.id}`)"
            >
                <view class="info-column">
                    <view style="text-align: left">
                        <view class="goods-title">{{ item1.name }}</view>
                        <view class="goods-desc">{{ item1.remarks || ' ' }}</view>
                    </view>
                </view>

                <view class="image-column">
                    <u-image
                        :src="item1.image"
                        class="good-img"
                        width="100%"
                        height="350"
                        border-radius="20"
                    ></u-image>
                </view>

                <view class="price-column">
                    <view class="price-wrap"
                        >活动价 ¥ <span class="price">{{ numFilter(item1.price) }}</span
                        >元</view
                    >
                    <view class="btn_con">
                        <view class="btn">立即抢购</view>
                    </view>
                </view>
            </view>
        </block>
    </view>
</template>

<script lang="ts" setup>

defineProps({
    lists: {
        type: Array,
        default: []
    }
})

const goPage = (url: string) => {
    uni.navigateTo({ url: url })
}
//截取当前数据到小数点后两位
const numFilter = (value) =>{
    const realVal = parseFloat(value).toFixed(2)
    return realVal
}
</script>

<style lang="scss" scoped>
// 商品列表
.goods-item {
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    // padding: 20rpx;
    border-radius: 17rpx;
    background-color: #fff;
    //box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin: 20rpx;

    .image-column {
        margin-left: 20rpx;
        margin-right: 20rpx;
        width: 94%;

        .good-img{
            width: 100%;
            //border-radius: 20rpx; //u-image故从属性中传入
            border-radius: 25px;
            border-radius: 50%;
        }
    }

    .info-column {
        display: flex;
        flex-direction: column;
        border-radius: 10rpx;
        justify-content: space-between;

        text-align: left;
        padding-left: 26rpx;
        margin-top: 20rpx;
        margin-bottom: 20rpx;

        .goods-title {
            font-size: 1.1rem;
            margin-bottom: 10rpx;
        }

        .goods-desc {
            font-size: 0.775rem;
            color: #808695;
        }
    }

    .price-column {
        display: flex;
        flex-direction: row;
        border-radius: 10rpx;
        justify-content: space-between;
        margin: 20rpx;

        .price-wrap {
            margin-top: 10rpx;
            color: red;

            .price {
                font-size: 1.5rem; //¥
            }
        }

        .btn {
            margin-top: auto;
            display: flex;
            justify-content: center;
            align-items: center;
            color: #fff;
            width: 180rpx;
            height: 66rpx;
            background-color: #34afff;
            border-radius: 50rpx;
            margin-right: 10rpx;

            font-size: 0.79rem;
            font-weight: bold;
        }
    }
}
</style>
