Ver Fonte

fix:
- 登入信息接口

zhengzhibin há 2 anos atrás
pai
commit
c6af940319

+ 0 - 18
app/admin/controller/User.php

@@ -193,24 +193,6 @@ class User extends Permissions
         }
     }
 
-    public function setVips()
-    {
-        if ($this->request->isAjax()) {
-            $post = $this->request->param();
-            $ids = $post['ids'];
-            $vip_id = $this->request->param("vip", 0);
-            $model = new userModel();
-            $users = $model->where('id', 'in', $ids)->select();
-            /** @var userModel $user */
-            foreach ($users as $user) {
-                $user->save([
-                    'level' => $vip_id,
-                    'stop_time' => $vip_id ? $user->createStopTime($vip_id) : 0
-                ]);
-            }
-            $this->success('修改成功');
-        }
-    }
 
     //重置密码
     public function resetpass()

+ 4 - 4
app/api/controller/Common.php

@@ -43,10 +43,10 @@ class Common extends Base
             ['unionid', 'max:50'],
             ['nickname|昵称', 'max:50'],
             ['head_pic|头像', 'max:255'],
-            ['sex|性别', 'in:0,1,2'],
-            ['country|国家', 'max:50'],
-            ['province|省份', 'max:50'],
-            ['city|城市', 'max:50'],
+//            ['sex|性别', 'in:0,1,2'],
+//            ['country|国家', 'max:50'],
+//            ['province|省份', 'max:50'],
+//            ['city|城市', 'max:50'],
         ]);
         if (!$validate->check($post)) {
             $this->json_error('提交失败:' . $validate->getError());

+ 10 - 1
app/api/controller/User.php

@@ -21,7 +21,16 @@ class User extends Permissions
     //个人资料接口
     public function info()
     {
-        $this->json_success('success', $this->getUser());
+        $user = $this->getUser();
+        $info = [
+            "nickname" => $user->nickname,
+            "head_pic" => $user->head_pic,
+            "sex" => $user->sex,
+            "country" =>$user->country,
+            "province" => $user->province,
+            "city" =>$user->city
+        ];
+        $this->json_success('success', $info);
     }
 
     //预约申请

+ 31 - 0
app/api/controller/接口文档.md

@@ -29,6 +29,37 @@
 }
 ```
 
+# 用户信息接口
+
+接口地址:/api/user/info
+
+请求方式:post / get
+
+请求数据:
+
+| 参数名 | 说明  | 备注  |
+| ---   | ---   | ---  |
+| x-token   | 登入令牌jwt |  必填 |
+
+响应数据:(json格式)
+```json
+{
+    "code": 1,
+    "err_code": 0,
+    "msg": "success",
+    "time": "1682778816",
+    "data": {
+        "nickname": "111", //昵称
+        "head_pic": "",  //头像,目前微信不返回头像
+        "sex": 0,   //性别:0未知,1男,2女
+        "country": "", //国家
+        "province": "", //省份
+        "city": ""   //城市
+    }
+}
+```
+
+
 # 提交反馈
 
 接口地址:/api/user/feedback

+ 0 - 97
app/common/model/User.php

@@ -47,8 +47,6 @@ class User extends Model
         self::STATUS_UNPASS => '已被封'
     ];
 
-    const GRADE = ["非会员", "月度会员", "季度会员", "年度会员"];
-
 
     const SEX_UNKNOW = 0;
     const SEX_MAN = 1;
@@ -67,75 +65,12 @@ class User extends Model
     }
 
 
-    /**
-     * 是否为会员
-     * @return bool
-     */
-    public function isVip()
-    {
-        return !empty($this->level) && !$this->isVipExpire();
-    }
-
-    /**
-     * 是否过期,如果stop_time为空不算过期
-     * @return bool
-     */
-    public function isVipExpire()
-    {
-        if (empty($this->stop_time))
-            return false;
-        return $this->stop_time < time();
-    }
-
-    /**
-     * 是否为代理
-     * @return bool
-     */
-    public function isAgent()
-    {
-        return $this->user_cate == self::CATE_AGENT;
-    }
-
-    /**
-     * 是否为管理
-     * @return bool
-     */
-    public function isManage()
-    {
-        return $this->user_cate == self::CATE_MANAGE;
-    }
-
-    /**
-     * 计算会员到期时间
-     * @param $vipId
-     * @return false|int|mixed
-     */
-    public function createStopTime($vipId)
-    {
-        $starttime = $this->isVip() ? $this->stop_time : time();
-        switch ($vipId) {
-            case 1: //月
-                return $starttime + 31 * 24 * 3600;
-            case 2: //季度
-                return $starttime + 93 * 24 * 3600;
-            case 3: //年
-                return strtotime('+1 year', $starttime);
-            default:
-                return $starttime;
-        }
-    }
-
     //nickname
     public function getNicknameAttr($value, $data)
     {
         return htmlspecialchars($value);
     }
 
-    //level_text
-    public function getLevelTextAttr($value, $data)
-    {
-        return self::GRADE[$data['level']]??'';
-    }
 
     //status_text
     public function getStatusTextAttr($value, $data)
@@ -143,20 +78,6 @@ class User extends Model
         return self::STATUS[$data['status']]??'';
     }
 
-    //stop_time_text
-    public function getStopTimeTextAttr($value, $data)
-    {
-        if (empty($this->level)) {
-            return '';
-        }
-        if (empty($this->stop_time)) {
-            return '永久';
-        }
-        if ($this->stop_time < time()) {
-            return '已过期';
-        }
-        return $this->stop_time ? date('Y-m-d H:i:s', $this->stop_time) : '';
-    }
 
     //register_time
     public function getRegisterTimeAttr($value, $data)
@@ -181,22 +102,4 @@ class User extends Model
     {
         return self::USER_CATES[$data['user_cate']]??"";
     }
-
-    //invite_code 邀请码
-    public function getInviteCodeAttr($value, $data)
-    {
-        return inviteEncode($this->id);
-    }
-
-    //child_count 邀请人数
-    public function getChildCountAttr()
-    {
-        return $this->hasMany('User', 'pid')->where('status', self::STATUS_PASS)->count();
-    }
-
-    //推荐人
-    public function parent()
-    {
-        return $this->belongsTo('User', 'pid');
-    }
 }