<!--
 * @Author: PoJun
 * @Date: 2023-12-19 14:57:48
 * @LastEditors: PoJun
 * @LastEditTime: 2024-01-04 16:25:00
 * @Message: 排名, 只展示5个
-->
<template>
    <uv-cell-group :border="false" :customStyle="{ padding: '5px 0' }">
        <uv-cell :border="false" :arrow="false" value="查看更多" :isLink="true" url="/subpkg/home/supplier">
            <uv-text slot="title" text="优质供应商" :customStyle="{ 'font-weight': 'bold' }"></uv-text>
        </uv-cell>

        <template v-if="supplierList.length">
            <uv-cell
                v-for="(item, index) in supplierList"
                :key="index"
                :title="item.name"
                :isLink="true"
                arrow-direction="right"
                :border="false"
                @click="checkSupplier(item)"
            >
                <uv-badge
                    slot="value"
                    :type="index == 0 ? 'error' : index == 1 ? 'warning' : index == 2 ? 'success' : 'info'"
                    max="100"
                    :value="item.mark"
                ></uv-badge>
                <uv-text
                    slot="icon"
                    :type="index == 0 ? 'error' : index == 1 ? 'warning' : index == 2 ? 'success' : 'info'"
                    :text="index + 1"
                    :customStyle="{ 'font-weight': 'bold' }"
                ></uv-text>
            </uv-cell>
        </template>

        <view v-else class="uv-m-b-50">
            <uv-empty marginTop="30" mode="data" text="暂无供应商数据"></uv-empty>
        </view>
    </uv-cell-group>
</template>

<script>
import { getSuppliersList } from "@/config/http.js";
export default {
    data() {
        return {
            supplierList: [],
        };
    },
    methods: {
        checkSupplier(item) {
            uni.$uv.route({
                url: "/subpkg/home/supplier-detail",
                params: { id: item.id },
            });
        },
        getList() {
            getSuppliersList({
                params: {
                    pageSize: 5,
                    pageNum: 1,
                    query: {},
                },
                custom: { toast: false },
            }).then(res => {
                this.supplierList = res.list;
            });
        },
    },
    created() {
        this.getList();
    },
};
</script>

<style lang="scss" scoped></style>
