|
@@ -168,96 +168,8 @@ class UserCenter extends Common
|
|
|
$this->success("获取成功!",$userInfo);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 添加关注
|
|
|
- */
|
|
|
- public function addFollows() {
|
|
|
- $user_id = $this->request->request("user_id",0,"intval");// 被关注者ID
|
|
|
- $type = $this->request->request("type",1);// 类型:1=关注,2=取消关注
|
|
|
- if (!$user_id || $user_id<=0) {
|
|
|
- $this->error(__('Invalid parameters'));
|
|
|
- }
|
|
|
- if($type == 1) {
|
|
|
- if($user_id == $this->auth->id) {
|
|
|
- $this->error("不需要关注自己哦!");
|
|
|
- }
|
|
|
- $fansfollowModel = new \app\common\model\UserFansFollow();
|
|
|
- $data = [];
|
|
|
- $data["user_id"] = $user_id;
|
|
|
- $data["fans_id"] = $this->auth->id;
|
|
|
- if($fansfollowModel->where($data)->find()) {
|
|
|
- $this->error("你已经关注过ta啦!");
|
|
|
- }
|
|
|
- $data["createtime"] = time();
|
|
|
- $id = $fansfollowModel->insertGetId($data);
|
|
|
-
|
|
|
- //关注通知
|
|
|
- $msgdata = [
|
|
|
- 'user_id'=>$user_id,
|
|
|
- 'title' => '有人刚刚关注了你',
|
|
|
- 'content'=> '打开[消息][最新关注]即可查看',
|
|
|
- 'createtime' => time(),
|
|
|
- ];
|
|
|
- Db::name('message')->insertGetId($msgdata);
|
|
|
-
|
|
|
- if($id > 0) {
|
|
|
- // 增加任务进度 +exp
|
|
|
- \app\common\model\TaskLog::tofinish($this->auth->id,"ebxLwnXj3L",1);
|
|
|
- // 增加任务进度 +exp
|
|
|
- \app\common\model\TaskLog::tofinish($this->auth->id,"iA1QgRhL",1);
|
|
|
- // 增加任务进度 +exp
|
|
|
- \app\common\model\TaskLog::tofinish($this->auth->id,"ghopE4Ou",1);
|
|
|
- // 增加任务进度 +exp
|
|
|
- \app\common\model\TaskLog::tofinish($this->auth->id,"TryNGc1x",1);
|
|
|
-
|
|
|
- $this->success("关注成功!");
|
|
|
- } else {
|
|
|
- $this->error("网络错误,请稍后重试!");
|
|
|
- }
|
|
|
- } else {
|
|
|
- $fansfollowModel = new \app\common\model\UserFansFollow();
|
|
|
- $where = [];
|
|
|
- $where["user_id"] = $user_id;
|
|
|
- $where["fans_id"] = $this->auth->id;
|
|
|
- $fansfollowInfo = $fansfollowModel->where($where)->find();
|
|
|
- if(!$fansfollowInfo) {
|
|
|
- $this->error("关注信息获取失败!");
|
|
|
- }
|
|
|
|
|
|
- $res = $fansfollowModel->where($where)->delete();
|
|
|
- if($res > 0) {
|
|
|
- $this->success("取消成功!");
|
|
|
- } else {
|
|
|
- $this->error("网络错误,请稍后重试!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 是否关注
|
|
|
- */
|
|
|
- public function isFollows() {
|
|
|
- $user_id = $this->request->request("user_id",0,"intval");// 关注者ID
|
|
|
-
|
|
|
- if (!$user_id || $user_id<=0) {
|
|
|
- $this->error(__('Invalid parameters'));
|
|
|
- }
|
|
|
-
|
|
|
- $fansfollowModel = new \app\common\model\UserFansFollow();
|
|
|
- $where = [];
|
|
|
- $where["user_id"] = $user_id;
|
|
|
- $where["fans_id"] = $this->auth->id;
|
|
|
- $fansfollowInfo = $fansfollowModel->where($where)->find();
|
|
|
- $data = [];
|
|
|
- if($fansfollowInfo) {
|
|
|
- $data["is_show_follow"] = 0;
|
|
|
- } else {
|
|
|
- $data["is_show_follow"] = 1;
|
|
|
- }
|
|
|
- $this->success("获取成功!",$data);
|
|
|
|
|
|
- }
|
|
|
|
|
|
/**
|
|
|
* 获取关注人列表.派对信息
|
|
@@ -307,112 +219,7 @@ class UserCenter extends Common
|
|
|
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 获取关注列表
|
|
|
- * (个人中心模块)(消息-最新关注)
|
|
|
- */
|
|
|
- public function getFollowsUser() {
|
|
|
- $type = $this->request->request('type',1); // 1=关注,2=粉丝,3=好友
|
|
|
- $page = $this->request->request('page',1); // 分页
|
|
|
- $pageNum = $this->request->request('pageNum',10); // 分页
|
|
|
- // 分页搜索构建
|
|
|
- $pageStart = ($page-1)*$pageNum;
|
|
|
- $pageEnd = $pageStart + $pageNum;
|
|
|
-
|
|
|
- $fanfollowModel = new \app\common\model\UserFansFollow();
|
|
|
-
|
|
|
- // 获取关注列表
|
|
|
- $where = [];
|
|
|
- $where["a.fans_id"] = $this->auth->id;
|
|
|
- $followlist = $fanfollowModel->alias("a")
|
|
|
- ->field("a.id,a.user_id,a.createtime,u.avatar,u.nickname,u.level,u.gender,u.desc")
|
|
|
- ->join("hx_user u","u.id = a.user_id")
|
|
|
-// ->limit($pageStart,$pageNum)
|
|
|
- ->where($where)->order('a.id desc')->select();
|
|
|
- $followlist = list_domain_image($followlist,['avatar']);
|
|
|
|
|
|
- // 获取粉丝列表
|
|
|
- $where = [];
|
|
|
- $where["a.user_id"] = $this->auth->id;
|
|
|
- $fanslist = $fanfollowModel->alias("a")
|
|
|
- ->field("a.id,a.fans_id,a.createtime,u.avatar,u.nickname,u.level,u.gender,u.desc")
|
|
|
- ->join("hx_user u","u.id = a.fans_id")
|
|
|
-// ->limit($pageStart,$pageNum)
|
|
|
- ->where($where)->order('a.id desc')->select();
|
|
|
- $fanslist = list_domain_image($fanslist,['avatar']);
|
|
|
-
|
|
|
-// print_r(json_encode($followlist));exit;
|
|
|
- if($type == 1) {
|
|
|
- $ids = [];
|
|
|
- if($fanslist) {
|
|
|
- foreach($fanslist as $k => $v) {
|
|
|
- $ids[] = $v["fans_id"];
|
|
|
- }
|
|
|
- }
|
|
|
- if($followlist) {
|
|
|
- foreach($followlist as $k => $v) {
|
|
|
- $followlist[$k]['createtime_text'] = get_last_time($v['createtime']);
|
|
|
- $followlist[$k]["is_follow"] = 1;
|
|
|
- if(in_array($v["user_id"],$ids)) {
|
|
|
- $followlist[$k]["is_hu"] = 1;
|
|
|
- } else {
|
|
|
- $followlist[$k]["is_hu"] = 0;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- $fansfollow = $followlist;
|
|
|
- } elseif($type == 2) {
|
|
|
- $ids = [];
|
|
|
- if($followlist) {
|
|
|
- foreach($followlist as $k => $v) {
|
|
|
- $ids[] = $v["user_id"];
|
|
|
- }
|
|
|
- }
|
|
|
- if($fanslist) {
|
|
|
- foreach($fanslist as $k => $v) {
|
|
|
- $fanslist[$k]['createtime_text'] = get_last_time($v['createtime']);
|
|
|
- if(in_array($v["fans_id"],$ids)) {
|
|
|
- $fanslist[$k]["is_hu"] = 1;
|
|
|
- $fanslist[$k]["is_follow"] = 1;
|
|
|
- } else {
|
|
|
- $fanslist[$k]["is_hu"] = 0;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- $fansfollow = $fanslist;
|
|
|
- }else {
|
|
|
- $ids = [];
|
|
|
- if($followlist) {
|
|
|
- foreach($followlist as $k => $v) {
|
|
|
- $ids[] = $v["user_id"];
|
|
|
- }
|
|
|
- }
|
|
|
- if($fanslist) {
|
|
|
- foreach($fanslist as $k => $v) {
|
|
|
- $fanslist[$k]['createtime_text'] = get_last_time($v['createtime']);
|
|
|
- $fanslist[$k]["is_follow"] = 1;
|
|
|
- if(in_array($v["fans_id"],$ids)) {
|
|
|
- $fanslist[$k]["is_hu"] = 1;
|
|
|
- } else {
|
|
|
- unset($fanslist[$k]); //不是好友的 直接unset掉
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- $fansfollow = $fanslist;
|
|
|
- }
|
|
|
-
|
|
|
- if($fansfollow) {
|
|
|
- $data = [];
|
|
|
- foreach($fansfollow as $k => $v) {
|
|
|
- if($k >= $pageStart && $k < $pageEnd) {
|
|
|
- $data[] = $v;
|
|
|
- }
|
|
|
- }
|
|
|
- $this->success("获取成功!",$data);
|
|
|
- } else {
|
|
|
- $this->success("数据为空!",[]);
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
/**
|
|
|
* 获取最近访客
|