PHP根据信誉点数获取对应商家等级图标【原创

来源:https://www.sucaihuo.com/php/5204.html 2021-02-09 20:55浏览(21) 收藏

PHP仿淘宝卖家等级图标,有星星、钻石和黄钻三个等级,不同的分数可以匹配不同的图标等级,这里的图标都是动态的,直接拿来使用,已经存放到images文件夹

PHP根据信誉点数或者分数来匹配对应商家或者卖家的等级,仿淘宝多商家信誉等级
PHP根据信誉点数获取对应商家等级图标
分类:PHP > 函数 难易:入门级
查看演示 下载资源: 2 下载资源 下载积分: 50 积分

核心函数

function getCreditScore($credit_score) {
    $pic = "";
    $rank = "";
    $diamond_bei = intval($credit_score / 50); //钻石倍数
    $cron_bei = intval($credit_score / 250); //皇冠倍数

    $rank_star = "";
    if ($cron_bei > 0) { //皇冠显示
        if ($cron_bei == 1) {
            $pic .= "<img title src='images/s_crown_1.gif'>";
            $rank .= "一皇冠";
        } elseif ($cron_bei == 2) {
            $pic .= "<img title src='images/s_crown_2.gif'>";
            $rank .= "二皇冠";
        } elseif ($cron_bei == 3) {
            $pic .= "<img title src='images/s_crown_3.gif'>";
            $rank .= "三皇冠";
        } elseif ($cron_bei == 4) {
            $pic .= "<img title src='images/s_crown_4.gif'>";
            $rank .= "四皇冠";
        } else {
            $pic .= "<img title src='images/s_crown_5.gif'>";
            $rank .= "五皇冠";
        }
        $rank_star = $credit_score % 250;
        $diamond_bei = intval(($credit_score - intval($credit_score / 250) * 250) / 50); //钻石倍数
    }
    if ($diamond_bei > 0) { //钻石显示
        $diamond_style = "";
        if ($cron_bei > 0) {
            $diamond_style = "style='margin:0 2px 0 5px'";
        }
        if ($diamond_bei == 1) {
            $pic .= "<img title src='images/s_blue_1.gif' $diamond_style>";
            $rank .= "一钻";
        } elseif ($diamond_bei == 2) {
            $pic .= "<img title src='images/s_blue_2.gif' $diamond_style>";
            $rank .= "二钻";
        } elseif ($diamond_bei == 3) {
            $pic .= "<img title src='images/s_blue_3.gif' $diamond_style>";
            $rank .= "三钻";
        } elseif ($diamond_bei == 4) {
            $pic .= "<img title src='images/s_blue_4.gif' $diamond_style>";
            $rank .= "四钻";
        } elseif ($diamond_bei == 5) {
            $pic .= "<img title src='images/s_blue_5.gif' $diamond_style>";
            $rank .= "五钻";
        }
        $rank_star = $credit_score % 50;
    }
    if ($cron_bei == 0 && $diamond_bei == 0) {
        $rank_star = $credit_score;
    }
    if (0 <= $rank_star && $rank_star <= 10) {
        $pic .= "<img class='xy' title  src='images/s-star-1.gif'>";
        $rank .= "一星";
    } elseif (11 < $rank_star && $rank_star <= 20) {
        $pic .= "<img class='xy' title src='images/s-star-2.gif'>";
        $rank .= "两星";
    } elseif (21 < $rank_star && $rank_star <= 30) {
        $pic .= "<img class='xy' title src='images/s-star-3.gif'>";
        $rank .= "三星";
    } elseif (31 < $rank_star && $rank_star <= 40) {
        $pic .= "<img class='xy' title src='images/s-star-4.gif'>";
        $rank .= "四星";
    } elseif (41 < $rank_star && $rank_star <= 50) {
        $pic .= "<img class='xy' title src='images/s-star-5.gif'>";
        $rank .= "五星";
    }
    $title = "title= '" . $rank . "(" . $credit_score . "个信誉点) '";
    $a = $pic . "<span class='credit_stars'>" . $credit_score . "个信誉点</span>";
    $b = str_replace("title", $title, $a);
    return $b;
}
标签: 分数等级
声明:本文为原创文章,如需转载,请注明来源sucaihuo.com并保留原文链接:https://www.sucaihuo.com/php/5204.html
评论0
头像

系统已开启自动识别垃圾评论机制,识别到的自动封号,下载出错或者资源有问题请联系全栈客服QQ 1915635791

1 2