浏览代码

用户贡献等级和魅力等级

lizhen_gitee 1 年之前
父节点
当前提交
9047c340e3
共有 2 个文件被更改,包括 23 次插入2 次删除
  1. 11 1
      application/api/controller/Usercenter.php
  2. 12 1
      application/common/library/Auth.php

+ 11 - 1
application/api/controller/Usercenter.php

@@ -47,7 +47,7 @@ class UserCenter extends Common
         $where = [];
         $where["id"] = $user_id;
         $userInfo = $this->userModel->field("id,nickname,pre_nickname,image,mobile,avatar,pre_avatar,gender,money,age,u_id,level,jewel,
-        age_id,constellation_id,province_id,city_id,desc,ipaddress,is_cool,is_manager,is_stealth")->where($where)->find();
+        age_id,constellation_id,province_id,city_id,desc,ipaddress,is_cool,is_manager,is_stealth,charm_level,wealth_level")->where($where)->find();
         $userInfo['nickname_status'] = $userInfo['avatar_status'] = 0;
         if (!empty($userInfo['pre_nickname']) && $userInfo['pre_nickname'] != $userInfo['nickname']) {
             $userInfo['nickname_status'] = 1;
@@ -141,6 +141,16 @@ class UserCenter extends Common
             }
         }
 
+        //贡献等级
+        $charm_info = Db::name('user_config_charm')->where('level',$userInfo['charm_level'])->find();
+        $userInfo['charm_image'] = localpath_to_netpath($charm_info['image']);
+        $userInfo['charm_color'] = $charm_info['color'];
+
+        //财富等级
+        $wealth_info = Db::name('user_config_wealth')->where('level',$userInfo['wealth_level'])->find();
+        $userInfo['wealth_image'] = localpath_to_netpath($wealth_info['image']);
+        $userInfo['wealth_color'] = $wealth_info['color'];
+
         $this->success("获取成功!",$userInfo);
     }
 

+ 12 - 1
application/common/library/Auth.php

@@ -27,7 +27,7 @@ class Auth
     //默认配置
     protected $config = [];
     protected $options = [];
-    protected $allowFields = ['id', 'u_id', 'username', 'nickname', 'mobile', 'pre_userid', 'has_info', 'is_auth', 'is_anchor', 'is_guild', 'guild_id', 'avatar', 'empirical', 'image', 'money', 'level', 'gender', 'age', 'jewel','ipaddress'];
+    protected $allowFields = ['id', 'u_id', 'username', 'nickname', 'mobile', 'pre_userid', 'has_info', 'is_auth', 'is_anchor', 'is_guild', 'guild_id', 'avatar', 'empirical', 'image', 'money', 'level', 'gender', 'age', 'jewel','ipaddress','wealth_level','charm_level'];
 
     public function __construct($options = [])
     {
@@ -603,6 +603,17 @@ class Auth
         if (!empty($user['pre_avatar']) && $user['pre_avatar'] != $user['avatar']) {
             $userinfo['avatar_status'] = 1;
         }
+
+        //贡献等级
+        $charm_info = Db::name('user_config_charm')->where('level',$this->charm_level)->find();
+        $userinfo['charm_image'] = localpath_to_netpath($charm_info['image']);
+        $userinfo['charm_color'] = $charm_info['color'];
+
+        //财富等级
+        $wealth_info = Db::name('user_config_wealth')->where('level',$this->wealth_level)->find();
+        $userinfo['wealth_image'] = localpath_to_netpath($wealth_info['image']);
+        $userinfo['wealth_color'] = $wealth_info['color'];
+
         //
         return $userinfo;
     }