diff --git a/app/Caches/IndexLiveList.php b/app/Caches/IndexLiveList.php index 238c0d05..bff95fb3 100644 --- a/app/Caches/IndexLiveList.php +++ b/app/Caches/IndexLiveList.php @@ -60,10 +60,10 @@ class IndexLiveList extends Cache $chapters = $chapterRepo->findByIds($chapterIds); - $chapterMappings = []; + $chapterMapping = []; foreach ($chapters as $chapter) { - $chapterMappings[$chapter->id] = $chapter; + $chapterMapping[$chapter->id] = $chapter; } $courseIds = kg_array_column($lives->toArray(), 'course_id'); @@ -72,10 +72,10 @@ class IndexLiveList extends Cache $courses = $courseRepo->findByIds($courseIds); - $courseMappings = []; + $courseMapping = []; foreach ($courses as $course) { - $courseMappings[$course->id] = $course; + $courseMapping[$course->id] = $course; } foreach ($lives as $live) { @@ -90,8 +90,8 @@ class IndexLiveList extends Cache continue; } - $chapter = $chapterMappings[$live->chapter_id]; - $course = $courseMappings[$chapter->course_id]; + $chapter = $chapterMapping[$live->chapter_id]; + $course = $courseMapping[$chapter->course_id]; $chapterInfo = [ 'id' => $chapter->id, diff --git a/app/Http/Admin/Controllers/SessionController.php b/app/Http/Admin/Controllers/SessionController.php index 89c85d9f..d868f531 100644 --- a/app/Http/Admin/Controllers/SessionController.php +++ b/app/Http/Admin/Controllers/SessionController.php @@ -4,6 +4,7 @@ namespace App\Http\Admin\Controllers; use App\Http\Admin\Services\Session as SessionService; use App\Http\Admin\Services\Setting as SettingService; +use App\Library\AppInfo as AppInfo; use App\Traits\Auth as AuthTrait; use App\Traits\Response as ResponseTrait; use App\Traits\Security as SecurityTrait; @@ -23,9 +24,9 @@ class SessionController extends \Phalcon\Mvc\Controller */ public function loginAction() { - $currentUser = $this->getCurrentUser(); + $user = $this->getCurrentUser(); - if ($currentUser->id > 0) { + if ($user->id > 0) { $this->response->redirect(['for' => 'admin.index']); } @@ -43,11 +44,14 @@ class SessionController extends \Phalcon\Mvc\Controller return $this->jsonSuccess(['location' => $location]); } + $appInfo = new AppInfo(); + $settingService = new SettingService(); $captcha = $settingService->getSectionSettings('captcha'); $this->view->pick('public/login'); + $this->view->setVar('app_info', $appInfo); $this->view->setVar('captcha', $captcha); } @@ -56,9 +60,9 @@ class SessionController extends \Phalcon\Mvc\Controller */ public function logoutAction() { - $service = new SessionService(); + $sessionService = new SessionService(); - $service->logout(); + $sessionService->logout(); $this->response->redirect(['for' => 'admin.login']); } diff --git a/app/Http/Admin/Views/public/login.volt b/app/Http/Admin/Views/public/login.volt index 94b2979b..9cf3247d 100644 --- a/app/Http/Admin/Views/public/login.volt +++ b/app/Http/Admin/Views/public/login.volt @@ -2,33 +2,54 @@ {% block content %} -
-
-
- + + + + +{% endblock %} + +{% block inline_css %} + + {% endblock %} diff --git a/app/Http/Admin/Views/student/edit.volt b/app/Http/Admin/Views/student/edit.volt index a282de84..2784befc 100644 --- a/app/Http/Admin/Views/student/edit.volt +++ b/app/Http/Admin/Views/student/edit.volt @@ -2,6 +2,8 @@ {% block content %} + {% set expiry_editable = relation.source_type in [1,3] %} +
编辑学员 @@ -18,12 +20,21 @@
{{ student.name }}
-
- -
- + {% if expiry_editable %} +
+ +
+ +
-
+ {% else %} +
+ +
+
{{ date('Y-m-d H:i:s',relation.expiry_time) }}
+
+
+ {% endif %}
diff --git a/app/Http/Admin/Views/user/edit.volt b/app/Http/Admin/Views/user/edit.volt index 1c38c41e..93af9891 100644 --- a/app/Http/Admin/Views/user/edit.volt +++ b/app/Http/Admin/Views/user/edit.volt @@ -42,23 +42,6 @@
{% endif %} -
- -
- - -
-
-
- -
- {% if user.vip_expiry_time > 0 %} - - {% else %} - - {% endif %} -
-
@@ -132,25 +115,11 @@ var form = layui.form; var laydate = layui.laydate; - laydate.render({ - elem: 'input[name=vip_expiry_time]', - type: 'datetime' - }); - laydate.render({ elem: 'input[name=lock_expiry_time]', type: 'datetime' }); - form.on('radio(vip)', function (data) { - var block = $('#vip-expiry-block'); - if (data.value === '1') { - block.show(); - } else { - block.hide(); - } - }); - form.on('radio(locked)', function (data) { var block = $('#lock-expiry-block'); if (data.value === '1') { diff --git a/app/Http/Admin/Views/user/list.volt b/app/Http/Admin/Views/user/list.volt index 2d862e55..2e64d83c 100644 --- a/app/Http/Admin/Views/user/list.volt +++ b/app/Http/Admin/Views/user/list.volt @@ -4,9 +4,9 @@ {%- macro gender_info(value) %} {% if value == 1 %} - + {% elseif value == 2 %} - + {% elseif value == 3 %} {% endif %} diff --git a/app/Http/Web/Controllers/ImController.php b/app/Http/Web/Controllers/ImController.php index 5ae21432..a4e71501 100644 --- a/app/Http/Web/Controllers/ImController.php +++ b/app/Http/Web/Controllers/ImController.php @@ -29,6 +29,18 @@ class ImController extends Controller public function indexAction() { $this->seo->prependTitle('微聊'); + + $service = new ImService(); + + $activeGroups = $service->getActiveGroups(); + $activeUsers = $service->getActiveUsers(); + $newGroups = $service->getNewGroups(); + $newUsers = $service->getNewUsers(); + + $this->view->setVar('active_users', $activeUsers); + $this->view->setVar('active_groups', $activeGroups); + $this->view->setVar('new_groups', $newGroups); + $this->view->setVar('new_users', $newUsers); } /** @@ -74,7 +86,7 @@ class ImController extends Controller { $service = new ImService(); - $pager = $service->getSystemMessages(); + $pager = $service->getNotices(); $this->view->pick('im/msgbox'); $this->view->setVar('pager', $pager); diff --git a/app/Http/Web/Controllers/ImGroupController.php b/app/Http/Web/Controllers/ImGroupController.php index d123f706..5dddebf7 100644 --- a/app/Http/Web/Controllers/ImGroupController.php +++ b/app/Http/Web/Controllers/ImGroupController.php @@ -46,6 +46,8 @@ class ImGroupController extends Controller $group = $service->getGroup($id); + $this->seo->prependTitle([$group['name'], '群组']); + $this->view->pick('im/group/show'); $this->view->setVar('group', $group); } diff --git a/app/Http/Web/Services/Im.php b/app/Http/Web/Services/Im.php index 6dc3940d..bd9e9320 100644 --- a/app/Http/Web/Services/Im.php +++ b/app/Http/Web/Services/Im.php @@ -2,7 +2,6 @@ namespace App\Http\Web\Services; -use App\Caches\Setting as SettingCache; use App\Models\ImUser as ImUserModel; use App\Repos\ImGroup as ImGroupRepo; use App\Repos\ImUser as ImUserRepo; @@ -13,55 +12,13 @@ use GatewayClient\Gateway; class Im extends Service { + use ImCsTrait; use ImFriendTrait; use ImGroupTrait; use ImMessageTrait; use ImNoticeTrait; use ImStatTrait; - public function getCsUser() - { - $csUserIds = []; - $onlineUserIds = []; - - $cache = new SettingCache(); - - $imInfo = $cache->get('im'); - - Gateway::$registerAddress = $this->getRegisterAddress(); - - if (!empty($imInfo['cs_user1_id'])) { - $csUserIds[] = $imInfo['cs_user1_id']; - if (Gateway::isUidOnline($imInfo['cs_user1_id'])) { - $onlineUserIds[] = $imInfo['cs_user1_id']; - } - } - - if (!empty($imInfo['cs_user2_id'])) { - $csUserIds[] = $imInfo['cs_user2_id']; - if (Gateway::isUidOnline($imInfo['cs_user2_id'])) { - $onlineUserIds[] = $imInfo['cs_user2_id']; - } - } - - if (!empty($imInfo['cs_user3_id'])) { - $csUserIds[] = $imInfo['cs_user3_id']; - if (Gateway::isUidOnline($imInfo['cs_user3_id'])) { - $onlineUserIds[] = $imInfo['cs_user3_id']; - } - } - - if (count($onlineUserIds) > 0) { - $key = array_rand($onlineUserIds); - $userId = $onlineUserIds[$key]; - } else { - $key = array_rand($csUserIds); - $userId = $csUserIds[$key]; - } - - return $this->getImUser($userId); - } - public function getInitInfo() { $loginUser = $this->getLoginUser(); @@ -295,26 +252,29 @@ class Im extends Service $users = $userRepo->findByIds($ids); - $mappings = []; + $baseUrl = kg_ci_base_url(); + + $mapping = []; /** * 用户可以设置状态为 ['online', 'hide'] * 列表在线状态识别为 ['online', 'offline'] */ - foreach ($users as $user) { - $status = in_array($user->status, ['online', 'offline']) ? $user->status : 'offline'; - $mappings[$user->id] = [ - 'id' => $user->id, - 'username' => $user->name, - 'avatar' => $user->avatar, - 'sign' => $user->sign, + foreach ($users->toArray() as $user) { + $status = in_array($user['status'], ['online', 'offline']) ? $user['status'] : 'offline'; + $user['avatar'] = $baseUrl . $user['avatar']; + $mapping[$user['id']] = [ + 'id' => $user['id'], + 'username' => $user['name'], + 'avatar' => $user['avatar'], + 'sign' => $user['sign'], 'status' => $status, ]; } foreach ($items as $key => $item) { foreach ($friendUsers as $friendUser) { - $friend = $mappings[$friendUser->friend_id]; + $friend = $mapping[$friendUser->friend_id]; if ($item['id'] == $friendUser->group_id) { $friend['msg_count'] = $friendUser->msg_count; $items[$key]['list'][] = $friend; @@ -331,23 +291,34 @@ class Im extends Service { $userRepo = new ImUserRepo(); - $groups = $userRepo->findGroups($user->id); + $groupUsers = $userRepo->findGroupUsers($user->id); - if ($groups->count() == 0) { + if ($groupUsers->count() == 0) { return []; } + $groupRepo = new ImGroupRepo(); + + $ids = kg_array_column($groupUsers->toArray(), 'group_id'); + + $groups = $groupRepo->findByIds($ids); + $baseUrl = kg_ci_base_url(); + $mapping = []; + + foreach ($groups->toArray() as $group) { + $mapping[$group['id']] = [ + 'id' => $group['id'], + 'groupname' => $group['name'], + 'avatar' => $baseUrl . $group['avatar'], + ]; + } + $result = []; - foreach ($groups->toArray() as $group) { - $group['avatar'] = $baseUrl . $group['avatar']; - $result[] = [ - 'id' => $group['id'], - 'groupname' => $group['name'], - 'avatar' => $group['avatar'], - ]; + foreach ($groupUsers as $groupUser) { + $result[] = $mapping[$groupUser->group_id]; } return $result; diff --git a/app/Http/Web/Services/ImCsTrait.php b/app/Http/Web/Services/ImCsTrait.php new file mode 100644 index 00000000..4dcfe926 --- /dev/null +++ b/app/Http/Web/Services/ImCsTrait.php @@ -0,0 +1,54 @@ +get('im'); + + Gateway::$registerAddress = $this->getRegisterAddress(); + + if (!empty($imInfo['cs_user1_id'])) { + $csUserIds[] = $imInfo['cs_user1_id']; + if (Gateway::isUidOnline($imInfo['cs_user1_id'])) { + $onlineUserIds[] = $imInfo['cs_user1_id']; + } + } + + if (!empty($imInfo['cs_user2_id'])) { + $csUserIds[] = $imInfo['cs_user2_id']; + if (Gateway::isUidOnline($imInfo['cs_user2_id'])) { + $onlineUserIds[] = $imInfo['cs_user2_id']; + } + } + + if (!empty($imInfo['cs_user3_id'])) { + $csUserIds[] = $imInfo['cs_user3_id']; + if (Gateway::isUidOnline($imInfo['cs_user3_id'])) { + $onlineUserIds[] = $imInfo['cs_user3_id']; + } + } + + if (count($onlineUserIds) > 0) { + $key = array_rand($onlineUserIds); + $userId = $onlineUserIds[$key]; + } else { + $key = array_rand($csUserIds); + $userId = $csUserIds[$key]; + } + + return $this->getImUser($userId); + } + +} \ No newline at end of file diff --git a/app/Http/Web/Services/ImMessageTrait.php b/app/Http/Web/Services/ImMessageTrait.php index 8a91e42d..864a6e2e 100644 --- a/app/Http/Web/Services/ImMessageTrait.php +++ b/app/Http/Web/Services/ImMessageTrait.php @@ -6,6 +6,7 @@ use App\Builders\ImMessageList as ImMessageListBuilder; use App\Library\Paginator\Query as PagerQuery; use App\Models\ImFriendUser as ImFriendUserModel; use App\Models\ImGroup as ImGroupModel; +use App\Models\ImGroupUser as ImGroupUserModel; use App\Models\ImMessage as ImMessageModel; use App\Repos\ImFriendUser as ImFriendUserRepo; use App\Repos\ImMessage as ImMessageRepo; @@ -24,52 +25,6 @@ use GatewayClient\Gateway; Trait ImMessageTrait { - public function pullUnreadFriendMessages($id) - { - $user = $this->getLoginUser(); - - $validator = new ImUserValidator(); - - $friend = $validator->checkUser($id); - - $userRepo = new ImUserRepo(); - - $messages = $userRepo->findUnreadFriendMessages($friend->id, $user->id); - - if ($messages->count() == 0) { - return; - } - - Gateway::$registerAddress = $this->getRegisterAddress(); - - foreach ($messages as $message) { - - $message->update(['viewed' => 1]); - - $content = kg_json_encode([ - 'type' => 'show_chat_msg', - 'message' => [ - 'username' => $friend->name, - 'avatar' => $friend->avatar, - 'id' => $friend->id, - 'fromid' => $friend->id, - 'content' => $message->content, - 'timestamp' => 1000 * $message->create_time, - 'type' => 'friend', - 'mine' => false, - ], - ]); - - Gateway::sendToUid($user->id, $content); - } - - $repo = new ImFriendUserRepo(); - - $friendUser = $repo->findFriendUser($user->id, $friend->id); - - $friendUser->update(['msg_count' => 0]); - } - public function getChatMessages() { $user = $this->getLoginUser(); @@ -86,7 +41,7 @@ Trait ImMessageTrait $page = $pagerQuery->getPage(); $limit = $pagerQuery->getLimit(); - if ($params['type'] == ImMessageModel::TYPE_FRIEND) { + if ($params['type'] == 'friend') { $chatId = ImMessageModel::getChatId($user->id, $params['id']); @@ -98,7 +53,7 @@ Trait ImMessageTrait return $this->handleChatMessagePager($pager); - } elseif ($params['type'] == ImMessageModel::TYPE_GROUP) { + } elseif ($params['type'] == 'group') { $where = [ 'receiver_type' => $params['type'], @@ -161,6 +116,8 @@ Trait ImMessageTrait 'viewed' => $online ? 1 : 0, ]); + $this->updateFriendUserChatTime($relation); + if ($online) { Gateway::sendToUid($to['id'], $content); } else { @@ -177,7 +134,7 @@ Trait ImMessageTrait $validator = new ImGroupUserValidator(); - $validator->checkGroupUser($group->id, $user->id); + $relation = $validator->checkGroupUser($group->id, $user->id); $messageModel = new ImMessageModel(); @@ -188,6 +145,8 @@ Trait ImMessageTrait 'content' => $from['content'], ]); + $this->updateGroupUserChatTime($relation); + $this->incrGroupMsgCount($group); $excludeClientId = null; @@ -254,6 +213,52 @@ Trait ImMessageTrait $this->sendChatMessage($from, $to); } + public function pullUnreadFriendMessages($id) + { + $user = $this->getLoginUser(); + + $validator = new ImUserValidator(); + + $friend = $validator->checkUser($id); + + $userRepo = new ImUserRepo(); + + $messages = $userRepo->findUnreadFriendMessages($friend->id, $user->id); + + if ($messages->count() == 0) { + return; + } + + Gateway::$registerAddress = $this->getRegisterAddress(); + + foreach ($messages as $message) { + + $message->update(['viewed' => 1]); + + $content = kg_json_encode([ + 'type' => 'show_chat_msg', + 'message' => [ + 'username' => $friend->name, + 'avatar' => $friend->avatar, + 'id' => $friend->id, + 'fromid' => $friend->id, + 'content' => $message->content, + 'timestamp' => 1000 * $message->create_time, + 'type' => 'friend', + 'mine' => false, + ], + ]); + + Gateway::sendToUid($user->id, $content); + } + + $repo = new ImFriendUserRepo(); + + $friendUser = $repo->findFriendUser($user->id, $friend->id); + + $friendUser->update(['msg_count' => 0]); + } + protected function handleChatMessagePager($pager) { if ($pager->total_items == 0) { @@ -283,6 +288,34 @@ Trait ImMessageTrait return $pager; } + protected function updateFriendUserChatTime(ImFriendUserModel $hisFriendUser) + { + /** + * 用于联系人排序,近期有联系的排上面 + */ + if (time() - $hisFriendUser->update_time > 15 * 60) { + + $hisFriendUser->update(['update_time' => time()]); + + $repo = new ImFriendUserRepo(); + + $myFriendUser = $repo->findFriendUser($hisFriendUser->friend_id, $hisFriendUser->user_id); + + $myFriendUser->update(['update_time' => time()]); + } + } + + protected function updateGroupUserChatTime(ImGroupUserModel $groupUser) + { + /** + * 用于联系人排序,近期有联系的排上面 + */ + if (time() - $groupUser->update_time > 15 * 60) { + $groupUser->update_time = time(); + $groupUser->update(); + } + } + protected function incrFriendUserMsgCount(ImFriendUserModel $friendUser) { $friendUser->msg_count += 1; diff --git a/app/Http/Web/Services/ImStatTrait.php b/app/Http/Web/Services/ImStatTrait.php index d0fa379b..1abcfdef 100644 --- a/app/Http/Web/Services/ImStatTrait.php +++ b/app/Http/Web/Services/ImStatTrait.php @@ -2,27 +2,40 @@ namespace App\Http\Web\Services; +use App\Caches\ImActiveGroupList; +use App\Caches\ImActiveUserList; +use App\Caches\ImNewGroupList; +use App\Caches\ImNewUserList; + trait ImStatTrait { public function getActiveGroups() { + $cache = new ImActiveGroupList(); + return $cache->get(); } public function getActiveUsers() { + $cache = new ImActiveUserList(); + return $cache->get(); } public function getNewGroups() { + $cache = new ImNewGroupList(); + return $cache->get(); } public function getNewUsers() { + $cache = new ImNewUserList(); + return $cache->get(); } } diff --git a/app/Http/Web/Views/account/login.volt b/app/Http/Web/Views/account/login.volt index b1f24d85..893232cd 100644 --- a/app/Http/Web/Views/account/login.volt +++ b/app/Http/Web/Views/account/login.volt @@ -37,4 +37,14 @@ {{ js_include('web/js/captcha.login.js') }} {{ js_include('web/js/captcha.verify.js') }} +{% endblock %} + +{% block inline_js %} + + + {% endblock %} \ No newline at end of file diff --git a/app/Http/Web/Views/im/group/list.volt b/app/Http/Web/Views/im/group/list.volt index 80eeabc2..cafa61fb 100644 --- a/app/Http/Web/Views/im/group/list.volt +++ b/app/Http/Web/Views/im/group/list.volt @@ -16,5 +16,6 @@ {% block include_js %} {{ js_include('web/js/im.group.list.js') }} + {{ js_include('web/js/im.apply.js') }} {% endblock %} \ No newline at end of file diff --git a/app/Http/Web/Views/im/group/pager.volt b/app/Http/Web/Views/im/group/pager.volt index f90b7510..e369a51a 100644 --- a/app/Http/Web/Views/im/group/pager.volt +++ b/app/Http/Web/Views/im/group/pager.volt @@ -1,40 +1,33 @@ -{%- macro type_info(value) %} - {% if value == 'course' %} - - {% elseif value == 'chat' %} - - {% elseif value == 'staff' %} - - {% endif %} -{%- endmacro %} +{{ partial('macros/group') }} -
-
- {% for item in pager.items %} - {% set group_url = url({'for':'web.group.show','id':item.id}) %} - {% set owner_url = url({'for':'web.user.show','id':item.owner.id}) %} - {% set item.about = item.about ? item.about : '这家伙真懒,什么都没留下!' %} -
-
- {{ type_info(item.type) }} -
- - {{ item.name }} - -
- -
- 组长:{{ item.owner.name }} -
-
- 成员:{{ item.user_count }} - 讨论:{{ item.msg_count }} +{% if pager.total_pages > 0 %} +
+
+ {% for item in pager.items %} + {% set group_url = url({'for':'web.group.show','id':item.id}) %} + {% set item.about = item.about ? item.about : '这家伙真懒,什么都没留下!' %} +
+
+ {{ type_info(item.type) }} +
+ + {{ item.name }} + +
+ +
+ 成员:{{ item.user_count }} + 讨论:{{ item.msg_count }} +
+
+ 加入群组 +
-
- {% endfor %} + {% endfor %} +
-
-{{ partial('partials/pager_ajax') }} \ No newline at end of file + {{ partial('partials/pager_ajax') }} +{% endif %} \ No newline at end of file diff --git a/app/Http/Web/Views/im/index.volt b/app/Http/Web/Views/im/index.volt index 185f77ea..323130c5 100644 --- a/app/Http/Web/Views/im/index.volt +++ b/app/Http/Web/Views/im/index.volt @@ -2,19 +2,30 @@ {% block content %} + {{ partial('macros/group') }} + {{ partial('macros/user') }} +
    -
  • 活跃群组
  • -
  • 活跃用户
  • -
  • 新进群组
  • +
  • 新进群组
  • 新进用户
  • +
  • 活跃群组
  • +
  • 活跃用户
-
-
-
-
+
+ {{ partial('im/index_groups',{'groups':new_groups}) }} +
+
+ {{ partial('im/index_users',{'users':new_users}) }} +
+
+ {{ partial('im/index_groups',{'groups':active_groups}) }} +
+
+ {{ partial('im/index_users',{'users':active_users}) }} +
@@ -24,5 +35,6 @@ {% block include_js %} {{ js_include('web/js/im.js') }} + {{ js_include('web/js/im.apply.js') }} {% endblock %} \ No newline at end of file diff --git a/app/Http/Web/Views/im/index_groups.volt b/app/Http/Web/Views/im/index_groups.volt new file mode 100644 index 00000000..7841c87c --- /dev/null +++ b/app/Http/Web/Views/im/index_groups.volt @@ -0,0 +1,28 @@ +
+
+ {% for group in groups %} + {% set group_url = url({'for':'web.group.show','id':group.id}) %} + {% set group.about = group.about ? group.about : '这家伙真懒,什么都没留下!' %} +
+
+ {{ type_info(group.type) }} +
+ + {{ group.name }} + +
+ +
+ 成员:{{ group.user_count }} + 讨论:{{ group.msg_count }} +
+
+ 加入群组 +
+
+
+ {% endfor %} +
+
\ No newline at end of file diff --git a/app/Http/Web/Views/im/index_users.volt b/app/Http/Web/Views/im/index_users.volt new file mode 100644 index 00000000..884ce86e --- /dev/null +++ b/app/Http/Web/Views/im/index_users.volt @@ -0,0 +1,26 @@ +
+
+ {% for user in users %} + {% set user.title = user.title ? user.title : '暂露头角' %} + {% set user.about = user.about ? user.about : '这个人很懒,什么都没留下' %} + {% set user_url = url({'for':'web.user.show','id':user.id}) %} +
+
+ {{ vip_info(user.vip) }} +
+ + {{ user.name }} + +
+ +
{{ user.title }}
+
+ 添加好友 +
+
+
+ {% endfor %} +
+
\ No newline at end of file diff --git a/app/Http/Web/Views/macros/group.volt b/app/Http/Web/Views/macros/group.volt new file mode 100644 index 00000000..88ad63b9 --- /dev/null +++ b/app/Http/Web/Views/macros/group.volt @@ -0,0 +1,9 @@ +{%- macro type_info(value) %} + {% if value == 'course' %} + + {% elseif value == 'chat' %} + + {% elseif value == 'staff' %} + + {% endif %} +{%- endmacro %} \ No newline at end of file diff --git a/app/Http/Web/Views/macros/user.volt b/app/Http/Web/Views/macros/user.volt new file mode 100644 index 00000000..90a9df36 --- /dev/null +++ b/app/Http/Web/Views/macros/user.volt @@ -0,0 +1,5 @@ +{%- macro vip_info(value) %} + {% if value == 1 %} + + {% endif %} +{%- endmacro %} \ No newline at end of file diff --git a/app/Http/Web/Views/user/friends.volt b/app/Http/Web/Views/user/friends.volt index 3ac102d5..1c32c578 100644 --- a/app/Http/Web/Views/user/friends.volt +++ b/app/Http/Web/Views/user/friends.volt @@ -1,3 +1,5 @@ +{{ partial('macros/user') }} + {% if pager.total_pages > 0 %}
@@ -7,9 +9,7 @@ {% set user_url = url({'for':'web.user.show','id':item.id}) %}
- {% if item.vip == 1 %} - VIP - {% endif %} + {{ vip_info(item.vip) }}
{{ item.name }} diff --git a/app/Http/Web/Views/user/groups.volt b/app/Http/Web/Views/user/groups.volt index 8f7fe371..4e029281 100644 --- a/app/Http/Web/Views/user/groups.volt +++ b/app/Http/Web/Views/user/groups.volt @@ -1,3 +1,5 @@ +{{ partial('macros/group') }} + {% if pager.total_pages > 0 %}
@@ -6,11 +8,7 @@ {% set item.about = item.about ? item.about : '这家伙真懒,什么都没留下!' %}
- {% if item.type == 'course' %} - - {% elseif item.type == 'chat' %} - - {% endif %} + {{ type_info(item.type) }}
{{ item.name }} diff --git a/app/Http/Web/Views/vip/users.volt b/app/Http/Web/Views/vip/users.volt index b61cbc54..b4b6e9dd 100644 --- a/app/Http/Web/Views/vip/users.volt +++ b/app/Http/Web/Views/vip/users.volt @@ -1,3 +1,5 @@ +{{ partial('macros/user') }} + {% if pager.total_pages > 0 %}
@@ -7,9 +9,7 @@ {% set item.about = item.about ? item.about : '这个人很懒,什么都没留下' %}
- {% if item.vip == 1 %} - VIP - {% endif %} + {{ vip_info(item.vip) }}
{{ item.name }} diff --git a/app/Repos/ImUser.php b/app/Repos/ImUser.php index aa3bf924..f7d179db 100644 --- a/app/Repos/ImUser.php +++ b/app/Repos/ImUser.php @@ -76,6 +76,18 @@ class ImUser extends Repository ->execute(); } + /** + * @param int $userId + * @return ResultsetInterface|Resultset|ImGroupUserModel[] + */ + public function findGroupUsers($userId) + { + return ImGroupUserModel::query() + ->where('user_id = :user_id:', ['user_id' => $userId]) + ->orderBy('update_time DESC') + ->execute(); + } + /** * @param int $userId * @return ResultsetInterface|Resultset|ImFriendUserModel[] diff --git a/app/Services/Frontend/Course/ChapterList.php b/app/Services/Frontend/Course/ChapterList.php index 7533649f..b4eaa074 100644 --- a/app/Services/Frontend/Course/ChapterList.php +++ b/app/Services/Frontend/Course/ChapterList.php @@ -36,13 +36,13 @@ class ChapterList extends FrontendService } if ($user->id > 0 && $this->courseUser) { - $mappings = $this->getLearningMappings($course->id, $user->id, $this->courseUser->plan_id); + $mapping = $this->getLearningMapping($course->id, $user->id, $this->courseUser->plan_id); foreach ($chapters as &$chapter) { foreach ($chapter['children'] as &$lesson) { $lesson['me'] = [ 'owned' => $this->ownedCourse || $lesson['free'] ? 1 : 0, - 'progress' => $mappings[$lesson['id']]['progress'] ?? 0, - 'duration' => $mappings[$lesson['id']]['duration'] ?? 0, + 'progress' => $mapping[$lesson['id']]['progress'] ?? 0, + 'duration' => $mapping[$lesson['id']]['duration'] ?? 0, ]; } } @@ -61,7 +61,7 @@ class ChapterList extends FrontendService return $chapters; } - protected function getLearningMappings($courseId, $userId, $planId) + protected function getLearningMapping($courseId, $userId, $planId) { $courseRepo = new CourseRepo(); @@ -71,17 +71,17 @@ class ChapterList extends FrontendService return []; } - $mappings = []; + $mapping = []; foreach ($userLearnings as $learning) { - $mappings[$learning->chapter_id] = [ + $mapping[$learning->chapter_id] = [ 'progress' => $learning->progress, 'duration' => $learning->duration, 'consumed' => $learning->consumed, ]; } - return $mappings; + return $mapping; } } diff --git a/app/Services/Frontend/Teaching/LiveList.php b/app/Services/Frontend/Teaching/LiveList.php index 9be177cb..7ba46285 100644 --- a/app/Services/Frontend/Teaching/LiveList.php +++ b/app/Services/Frontend/Teaching/LiveList.php @@ -25,10 +25,10 @@ class LiveList extends FrontendService return []; } - $courseMappings = []; + $courseMapping = []; foreach ($courses as $course) { - $courseMappings[$course->id] = [ + $courseMapping[$course->id] = [ 'id' => $course->id, 'title' => $course->title, ]; @@ -51,7 +51,7 @@ class LiveList extends FrontendService foreach ($pager->items as $item) { $items[] = [ - 'course' => $courseMappings[$item->course_id], + 'course' => $courseMapping[$item->course_id], 'chapter' => [ 'id' => $item->id, 'title' => $item->title, diff --git a/public/static/admin/css/common.css b/public/static/admin/css/common.css index 52a6422d..eeb6ba19 100644 --- a/public/static/admin/css/common.css +++ b/public/static/admin/css/common.css @@ -27,15 +27,26 @@ text-align: center; } -.kg-login-form { +.kg-login-wrap { width: 400px; margin: 100px auto; } +.kg-login-form { + padding: 15px 10px 5px 10px; +} + .kg-login-form .layui-input-block { margin-left: 0; } +.kg-login-copyright { + margin-top: -80px; + color: #999; + font-size: 12px; + text-align: center; +} + .kg-input-inline { float: left; width: 250px; diff --git a/public/static/web/css/common.css b/public/static/web/css/common.css index 5e3ddd03..4b5f4e5c 100644 --- a/public/static/web/css/common.css +++ b/public/static/web/css/common.css @@ -1345,6 +1345,7 @@ body { height: 16px; line-height: 16px; padding: 0 3px; + font-size: 10px; } .user-card .type { @@ -1379,7 +1380,7 @@ body { } .group-list .user-card { - height: 250px; + height: 240px; } .group-about {