| // +------------------------------------------------+ namespace app\common\service; use app\common\model\MemberInfo as MemberInfoModel; class MemberInfo extends _Init { public static function show($uid) { $info = MemberInfoModel::get($uid); if (!$info) { return []; } if ($info->is_vip == 1) { return $info; } else { return [ 'nickname' => self::hideSub($info->nickname, 1), 'position' => $info->position ?: '未设置', 'mobile' => self::hideSub($info->mobile, 4), 'qq' => self::hideSub($info->qq), 'wechat' => self::hideSub($info->wechat), 'province' => self::hideSub($info->province), 'city' => self::hideSub($info->city), 'avatar' => $info->avatar, 'is_vip' => $info->is_vip, 'uid' => $info->uid, 'qrcode' => $info->qrcode, 'index_tpl' => $info->index_tpl, 'click' => $info->click, 'tags' => $info->tags, 'email' => self::hideSub($info->email), 'signature' => $info->signature, 'message_count' => $info->message_count, ]; } } /** * 隐藏后半段的字符串 * @param [type] $str [description] * @return [type] [description] */ private static function hideSub($str, $len = 0) { if (empty($str)) { return '未设置'; } $leng = mb_strlen($str); if (!empty($len)) { // $pre = ceil($len / 2); $ext = $leng - $len; return mb_substr($str, 0, $len) . str_repeat("*", $ext); } else { $len = $leng; return str_repeat('*', $len ?: 1); } } }