Browse Source

好友待审核列表

lizhen_gitee 1 year ago
parent
commit
b87d1089d2

+ 1 - 0
application/api/controller/Message.php

@@ -20,6 +20,7 @@ class Message extends Api
         $map = [
             'user_id' => $this->auth->id,
             'status' => 0,
+            'infotype' => ['neq','newfriend']
         ];
         Db::name('message')->where($map)->update(['status'=>1]);
         $this->success('success',$list);

+ 39 - 1
application/api/controller/Userfollow.php

@@ -100,7 +100,10 @@ class Userfollow extends Api
     }
 
     //好友审核列表。粉丝列表改的。关注了我,我还没关注他的
+    //接口转移了,使用 newfriend_list
     public function my_fans_unfollow_list(){
+
+        $this->newfriend_list();
         //我的关注uids
         $my_follow_uids = $this->my_follow_uids();
 
@@ -127,6 +130,41 @@ class Userfollow extends Api
         $this->success('success',$list);
     }
 
+    //好友待审核列表。
+    public function newfriend_list(){
+        //我的关注uids
+        $my_follow_uids = $this->my_follow_uids();
+//        dump($my_follow_uids);
+        //向我发起好友消息的人,未读
+        $user_ids = Db::name('message')->where('infotype','newfriend')->where('user_id',$this->auth->id)->where('status',0)->order('id desc')->column('infotype_id');
+//        dump($user_ids);
+        $list = [];
+        if(!empty($user_ids)){
+            $user_ids_str = implode(',',$user_ids);
+            $list = Db::name('user')->alias('user')
+                ->join('user_wallet uw','user.id = uw.user_id','LEFT')
+                ->field('user.id,user.username,user.nickname,user.avatar,user.bio,user.birthday,user.gender,user.attribute,uw.vip_endtime')
+                ->where('user.id','IN',$user_ids)
+                ->where('user.id','NOT IN',$my_follow_uids)
+                ->orderRaw('field(user.id,'.$user_ids_str.')')->autopage()->select();
+
+            $list = list_domain_image($list,['avatar']);
+            $list = list_birthday_age($list);
+
+            if(!empty($list)){
+                foreach($list as $key => &$val){
+                    //用户vip
+                    $val['is_vip'] = $val['vip_endtime'] > time() ? 1 : 0;
+                    unset($val['vip_endtime']);
+                    //是否关注
+                    $val['is_follow'] = in_array($val['id'],$my_follow_uids) ? 1 : 0;
+                }
+            }
+        }
+
+        $this->success('success',$list);
+    }
+
 
     //关注某人
     public function follow_one(){
@@ -178,7 +216,7 @@ class Userfollow extends Api
                 'createtime' => time(),
                 'status' => 0,
                 'infotype' => 'newfriend',//关注,请求好友
-                'infotype_id' => 0,
+                'infotype_id' => $this->auth->id,
             ];
             Db::name('message')->insertGetId($message);
         }

+ 1 - 1
public/assets/js/backend/message.js

@@ -31,7 +31,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {field: 'title', title: __('Title'), operate: 'LIKE'},
                         {field: 'content', title: __('Content'), operate: 'LIKE'},
                         {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
-                        {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"0":__('Status 0')}, formatter: Table.api.formatter.status},
+//                        {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"0":__('Status 0')}, formatter: Table.api.formatter.status},
 //                        {field: 'infotype', title: __('Infotype'), operate: 'LIKE'},
 //                        {field: 'infotype_id', title: __('Infotype_id')},
 //                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}