<template>
    <view class="order-supplier-area">
        <!-- 供应商信息 -->
        <view class="area-top">
            <image class="shop-logo" :src="shopData.logo" mode="widthFix"></image>
            <view class="shop-name" v-text="shopData.name"></view>
        </view>
        <!-- 商品列表 -->
        <view class="product" v-for="product in shopData.productList" :key="product.productId">
            <order-product :productInfo="product" :numType="numType" @countChange="onCountChange"></order-product>
        </view>
    </view>
</template>

<script>
// import OrderProduct from '../order-product/order-product.vue'

export default {
    name: 'order-supplier-area',
    props: {
        shopInfo: {
            type: Object,
            default: () => {}
        },
        submitType: {
            type: String,
            default: 'cart'
        }
    },
    computed: {
        shopData() {
            return {
                logo: this.shopInfo.logo || this.shopInfo.shopLogo,
                name: this.shopInfo.name || this.shopInfo.shopName,
                productList: this.shopInfo.productList || this.shopInfo.orderProductList
            }
        },
        numType() {
            return this.submitType === 'shareBuy' ? 2 : 1
        }
    },
    methods: {
        onCountChange(value) {
            this.$emit('countChange', value)
        }
    }
}
</script>

<style lang="scss">
.order-supplier-area {
    background-color: #fff;
    .area-top {
        @extend .cm-flex-between;
        justify-content: flex-start;
        margin-bottom: 24rpx;
        .shop-logo {
            width: 56rpx;
            height: 56rpx;
            border-radius: 4rpx;
        }
        .shop-name {
            margin-left: 24rpx;
            font-size: 30rpx;
            color: #333333;
            font-weight: bold;
        }
    }

    .product {
        margin-bottom: 24rpx;
        &:last-child {
            margin-bottom: 0;
        }
    }
}
</style>
