diff --git a/.gitignore b/.gitignore index 29fca42..7e13f14 100755 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ config/site.php app/command/Test.php .env runtime -vendor \ No newline at end of file +vendor +public/shunliao.apk diff --git a/app/api/controller/CommonController.php b/app/api/controller/CommonController.php index a774368..5a27bc2 100755 --- a/app/api/controller/CommonController.php +++ b/app/api/controller/CommonController.php @@ -57,6 +57,7 @@ class CommonController extends BaseController{ $config['recharge_status_list'] = \app\enum\RechargeStatus::toArray(); $config['withdrawl_status_list'] = \app\enum\WithdrawlStatus::toArray(); $config['server_status_list'] = \app\enum\ServerStatus::toArray(); + //$config['getFriendList'] = $request->IM->friend->getFriendList('100006'); return $this->success(__('successful'), $config); } @@ -144,20 +145,28 @@ class CommonController extends BaseController{ // }else{ // $extends['trade_password'] = \plugin\admin\app\common\Util::passwordHash($trade_password); // } + //邀请码 - if ($invite_code) - { + //$invite_code = 'TEAJXLEE'; + $extends = [ + 'role_id' => 1, + 'group_id' => 0, + 'region' => '86', + 'nickname' => input('nickname'), + 'avatar' => '/static/img/avatar.png', + ]; + if ($invite_code) { if(strlen($invite_code) == 12){ //系统生产的一次性推荐吗 $inviteModel = \app\model\Invitecode::where('code',$invite_code)->find(); if(!$inviteModel){ return $this->error(__('错误的邀请码')); } - $extends['group'] = 2; + $extends['group_id'] = 2; $extends['role_id'] = 1; $extends['parent_id'] = 0; }else{ - $inviter_user = UserModel::where('invite_code',$invite_code)->field('group,id')->find(); + $inviter_user = UserModel::where('invite_code',$invite_code)->field('group_id,id')->find(); if(!$inviter_user){ return $this->error(__('Invalid invite code')); } @@ -166,12 +175,6 @@ class CommonController extends BaseController{ }else{ //return $this->error(__('Invalid invite code')); } - $extends = [ - 'role_id' => 1, - 'group_id' => 0, - 'nickname' => input('nickname'), - 'avatar' => '/static/img/avatar.png', - ]; // validate(\app\validate\User::class) // ->scene('edit') // ->check([ @@ -209,26 +212,28 @@ class CommonController extends BaseController{ $email = input('email'); $password = input('password'); $type = input(param: 'type'); - if (!$password) { - return $this->fail(__('Invalid username or password').'0'); - } if($type == 'mobile'){ if (!$mobile ) { - return $this->fail(__('Invalid username or password').'1'); + return $this->fail(__('Invalid username or password')); } $username = $mobile; }else if($type == 'email'){ if (!$email ) { - return $this->fail(__('Invalid username or password').'2'); + return $this->fail(__('Invalid username or password')); } $username = $email; }else{ if (!$username ) { - return $this->fail(__('Invalid username or password').'3'); + return $this->fail(__('Invalid username or password')); } } try{ - $user = \support\Jwt::login($username, $password,$type); + if ($password) { + //return $this->fail(__('Invalid username or password')); + $user = \support\Jwt::login($username, $password,$type); + }else{ + $user = \support\Jwt::login($username, $password,$type,'code'); + } if($user === false){ return $this->fail(\support\Jwt::getError()); } @@ -421,7 +426,8 @@ class CommonController extends BaseController{ $key = 'captcha_'.$event.'_'.$mobile; $list = cache($key); $list = $list ?:[]; - $expris = 60; + $expris = 300; + if(cache('?exp_'.$key)){ if(cache('exp_'.$key)+$expris > time()){ return $this->fail(__('Only one verification code can be sent within %second% seconds',['%second%'=>$expris])); diff --git a/app/api/controller/FriendCircleController.php b/app/api/controller/FriendCircleController.php index 2cba832..cbb4c5a 100755 --- a/app/api/controller/FriendCircleController.php +++ b/app/api/controller/FriendCircleController.php @@ -1,5 +1,6 @@ fail('请先登录'); + } $res = $this->newcount($request); $response = $res->rawBody(); $json = json_decode($response,true); $json['data']['settings'] = [ 'bg' => '', ]; - $json['data']['last_unread_item'] = [ - 'user_id' => '1', - 'avatar' => '', - 'nickname' => '', - ]; + $top_unread_items = FriendCircleModel::whereIn('id',$json['data']['unread_item_ids']) + ->with(['user' => function($query) { + $query->field('id,nickname,avatar'); + }]) + ->order('id', 'desc') + ->limit(0,3) + ->select(); + $json['data']['top_unread_items'] = $top_unread_items ?: []; $res->withBody(json_encode($json)); return $res; } @@ -56,11 +64,14 @@ class FriendCircleController extends BaseController{ */ function list(Request $request): Response { + $current_user = \support\Jwt::getUser(); + $current_user_id = $current_user ? $current_user->id : 0; $page = (int)$request->get('page', 1); $limit = (int)$request->get('limit', 10); $user_id = $request->get('user_id', 0); $query = FriendCircleModel::where('status', 1) + ->whereIn('user_id',$this->getFriendUserIds($current_user_id)) ->with(['user' => function($query) { $query->field('id,nickname,avatar'); }]) @@ -75,30 +86,33 @@ class FriendCircleController extends BaseController{ 'list_rows' => $limit, 'page' => $page, ]); + cache('circle_last_read_id',$list[0]['id']); - $current_user = \support\Jwt::getUser(); - $current_user_id = $current_user ? $current_user->id : 0; // 处理每条朋友圈数据 $items = $list->items(); $list->each(function($item) use ($current_user_id){ // 获取点赞列表 - $likes = FriendCircleLikeModel::where('circle_id', $item->id) - ->with(['user' => function($query) { - $query->field('id,nickname,avatar'); - }]) - ->order('created_at', 'desc') + $likes = Db::name('friend_circle')->alias('f') + ->join('user u','u.id=f.user_id') + ->where('f.id', $item->id) + ->field('f.*,u.avatar,u.nickname') + ->order('f.created_at', 'desc') ->limit(20) ->select(); - + $likes = $likes ? $likes->toArray() : []; // 检查当前用户是否已点赞 $is_liked = false; if ($current_user_id > 0) { - $is_liked = FriendCircleLikeModel::where('circle_id', $item->id) - ->where('user_id', $current_user_id) - ->count() > 0; + $is_liked = null !== array_find($likes,function($item)use($current_user_id){ + return $item['user_id'] == $current_user_id; + }); + // FriendCircleLikeModel::where('circle_id', $item->id) + // ->where('user_id', $current_user_id) + // ->count() > 0; } + // 获取评论列表(最新10条) $comments = FriendCircleCommentModel::where('circle_id', $item->id) ->where('status', 1) @@ -137,8 +151,8 @@ class FriendCircleController extends BaseController{ // 处理点赞用户头像 foreach ($item->likes as $like) { - if ($like->user && $like->user->avatar) { - $like->user->avatar = cdnurl($like->user->avatar); + if ($like->user) { + $like->avatar = cdnurl($like->avatar); } } @@ -169,24 +183,19 @@ class FriendCircleController extends BaseController{ return $this->fail('请先登录'); } - $last_see = $request->post('last_see'); - if (empty($last_see)) { - $last_see = cache('last_see_' . $user->id); - } - - if (empty($last_see)) { - $last_see = time() - 86400; // 默认24小时前 - } else { - // 保存最后查看时间 - cache('last_see_' . $user->id, $last_see); - } - + $circle_last_read_id = cache('circle_last_read_id') ?: 0; // 统计从上次查看时间到现在新增的朋友圈数量 - $count = FriendCircleModel::where('status', 1) - ->where('created_at', '>', $last_see) - ->count(); + $unread_item_ids = FriendCircleModel::where('status', 1) + ->whereIn('user_id',$this->getFriendUserIds($user->id)) + ->where('id', '>', $circle_last_read_id) + ->order('id', 'desc') + ->column('id'); - return $this->success('ok', ['count' => $count]); + + return $this->success('ok', [ + 'unread_count' => count($unread_item_ids), + 'unread_item_ids'=>$unread_item_ids + ]); } /** @@ -301,8 +310,12 @@ class FriendCircleController extends BaseController{ ->where('status', 1) ->count(); $circle->save(); - - return $this->success('评论成功', ['id' => $comment->id]); + $comment->user = Db::name('user')->where('id',$comment->user_id)->find(); + $comment->replyUser=null; + if($comment->reply_user_id){ + $comment->replyUser = Db::name('user')->where('id',$comment->reply_user_id)->find(); + } + return $this->success('评论成功', $comment); } /** @@ -354,4 +367,19 @@ class FriendCircleController extends BaseController{ return $this->success('点赞成功', ['is_liked' => true]); } } + protected function getFriendUserIds($user_id):array{ + if (!$user_id) { + return []; + } + $result = cache('friend_id_list') ?: []; + if(count($result) === 0){ + $res = request()->IM->friend->getFriendList($user_id.''); + $friendsInfo = $res['friendsInfo']; + foreach($friendsInfo as $k=>$v){ + array_push($result,$v['friendUser']['userID']); + } + cache('friend_id_list',$result,3600); + } + return $result; + } } \ No newline at end of file diff --git a/app/api/controller/MessageController.php b/app/api/controller/MessageController.php new file mode 100644 index 0000000..019628a --- /dev/null +++ b/app/api/controller/MessageController.php @@ -0,0 +1,31 @@ +IM; + $data = $im->message->sendBusinessNotification('system',100007,[ + 'contentType' => 101, + 'textElem' => [ + 'content' => '欢迎使用4'.Config('site.name') + ] + ],'group'); + return $this->success('ok'); + } +} \ No newline at end of file diff --git a/app/api/controller/UserController.php b/app/api/controller/UserController.php index 28ee0a6..f36bcb0 100755 --- a/app/api/controller/UserController.php +++ b/app/api/controller/UserController.php @@ -42,7 +42,7 @@ class UserController extends BaseController{ if($nickname){ $save_data['nickname'] = $nickname; } - if($gender){ + if($gender!=null){ $save_data['sex'] = $gender; } if($faceURL){ diff --git a/app/controller/CommonController.php b/app/controller/CommonController.php new file mode 100644 index 0000000..c2dd397 --- /dev/null +++ b/app/controller/CommonController.php @@ -0,0 +1,31 @@ + Config('site'), + 'invite_code' => $code + ]); + }else{ + return $this->fail('404'); + } + } + +} diff --git a/app/controller/HookController.php b/app/controller/HookController.php index c5e458a..8b9bddb 100755 --- a/app/controller/HookController.php +++ b/app/controller/HookController.php @@ -28,7 +28,7 @@ class HookController{ 'host' => 'http://127.0.0.1:10002', // OpenIM API地址 'secret' => 'n1e5a6s6m7', // OpenIM密钥 ]); - $im->message->sendBusinessNotification('system',$userID,[ + $im->message->sendBusinessNotification('official_team',$userID,[ 'contentType' => 101, 'textElem' => [ 'content' => '欢迎使用'.Config('site.name') diff --git a/app/controller/IndexController.php b/app/controller/IndexController.php index 765c724..abe2bb1 100755 --- a/app/controller/IndexController.php +++ b/app/controller/IndexController.php @@ -2,15 +2,11 @@ namespace app\controller; -use app\model\Order; -use app\model\Withdrawl as WithdrawlModel; -use app\model\Address as AddressModel; use support\exception\BusinessException; use support\Request; use support\Response; -use Throwable; -use Web3\Contracts\Types\Address as TypesAddress; -use Workerman\Worker; +use Exception; +use app\model\Archives as ArchivesModel; class IndexController extends Crud { @@ -19,12 +15,11 @@ class IndexController extends Crud * 后台主页 * @param Request $request * @return Response - * @throws BusinessException|Throwable + * @throws BusinessException|Exception */ public function index(Request $request) { - return 'ok'; - return view(base_path().'/public/index.html'); + return view('public/index.html'); } public function user(Request $request,$code) { @@ -37,4 +32,32 @@ class IndexController extends Crud return 'group'; } + public function privacy_policy(Request $request) + { + return $this->siglepage($request); + } + + public function aboutus(Request $request) + { + return $this->siglepage($request); + } + function siglepage($request){ + $name = $request->action; + if(!$name){ + return $this->error(__("Article does not exist")); + } + /** @var ArchivesModel $vo */ + $vo = ArchivesModel::where('name',$name)->find(); + if(!$vo) { + return $this->error(__("Article does not exist")); + } + $addon = \app\model\Content::where('id', $vo->id)->find()->toArray(); + if ($addon) { + $vo->setAddonData($addon); + } + return view('common/siglepage',[ + 'vo' => $vo + ]); + } + } diff --git a/app/functions.php b/app/functions.php index 55eee4c..7ed643b 100755 --- a/app/functions.php +++ b/app/functions.php @@ -853,7 +853,17 @@ if(!function_exists('get_user_rights')){ } return $result; } - +} +if(!function_exists('array_find')){ + function array_find(array $array,callable $callbcak):mixed{ + foreach ($array as $key => $value) { + if ($callbcak($value, $key)) { + return $value; + } + } + + return null; + } } if(!function_exists('__my__template_inputs')){ function __my__template_inputs(&$template, &$vars, &$app, &$plugin){ diff --git a/app/queue/redis/Sms.php b/app/queue/redis/Sms.php index 40eab15..7d0376b 100755 --- a/app/queue/redis/Sms.php +++ b/app/queue/redis/Sms.php @@ -22,7 +22,7 @@ class Sms implements Consumer }else{ $body = $this->getTemplate($data); } - $url = 'http://api.smsbao.com/sms?u=shunliao&p='.md5('Aaa1231232').'&m='.$data['mobile'].'&c='.urlencode($body); + $url = 'http://api.smsbao.com/sms?u=shunliao&p='.md5('Aaa123123@').'&m='.$data['mobile'].'&c='.urlencode($body); $statusStr = array( "0" => "短信发送成功", "-1" => "参数不全", @@ -47,7 +47,7 @@ class Sms implements Consumer //var_export($data); // 输出 ['to' => 'tom@gmail.com', 'content' => 'hello'] } function getTemplate($data){ - $str = '【瞬聊】验证码:{$code},该验证码在5分钟内输入有效,若非您本人操作请尽快修改登录密码'; + $str = '【瞬聊科技】验证码:{$code},该验证码在5分钟内有效,如非本人操作,请忽略本短信。'; foreach($data as $k=>$v){ $str = str_replace('{$'.$k.'}',$v,$str); } diff --git a/app/view/common/register.html b/app/view/common/register.html new file mode 100644 index 0000000..0ce77bf --- /dev/null +++ b/app/view/common/register.html @@ -0,0 +1,978 @@ + + + +
+ + +使用手机号码注册您的账户
+应用名:瞬聊 - 黑ICP备2024020582号-3 - + 鄂ICP备2026000509号-1 +
- 黑ICP备2024020582号-3 + 鄂ICP备2026000509号-1
-+ @@ -399,11 +396,11 @@