From 949a94ace90c710c99446037a8a88cde601c854f Mon Sep 17 00:00:00 2001 From: xiaochong0302 Date: Fri, 17 Jul 2020 20:35:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E7=90=86=E5=88=86=E4=BA=AB=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Web/Controllers/ChapterController.php | 10 +- app/Http/Web/Views/chapter/contents.volt | 23 ++++ app/Http/Web/Views/chapter/live.volt | 77 ++++++++++++ app/Http/Web/Views/chapter/live_chats.volt | 2 +- app/Http/Web/Views/chapter/live_stats.volt | 6 - app/Http/Web/Views/chapter/menu.volt | 25 ---- app/Http/Web/Views/chapter/read.volt | 53 ++++++++ app/Http/Web/Views/chapter/show.volt | 12 -- app/Http/Web/Views/chapter/show_live.volt | 69 ---------- app/Http/Web/Views/chapter/show_read.volt | 35 ------ .../Views/chapter/{show_vod.volt => vod.volt} | 35 +++--- app/Http/Web/Views/course/show.volt | 2 +- app/Http/Web/Views/course/show_consults.volt | 6 +- app/Http/Web/Views/course/show_reviews.volt | 6 +- app/Http/Web/Views/user/show.volt | 2 +- public/static/admin/js/common.js | 26 ++-- public/static/web/css/common.css | 118 +++++++----------- .../web/js/{live.im.js => chapter.live.im.js} | 2 +- ...{live.player.js => chapter.live.player.js} | 0 .../web/js/{read.js => chapter.read.js} | 0 .../{vod.player.js => chapter.vod.player.js} | 30 ++++- public/static/web/js/common.js | 22 +++- .../js/{chapter.action.js => course.share.js} | 55 ++++---- public/static/web/js/course.show.js | 59 +-------- public/static/web/js/im.find.js | 8 -- public/static/web/js/share.js | 17 --- 26 files changed, 328 insertions(+), 372 deletions(-) create mode 100644 app/Http/Web/Views/chapter/contents.volt create mode 100644 app/Http/Web/Views/chapter/live.volt delete mode 100644 app/Http/Web/Views/chapter/live_stats.volt delete mode 100644 app/Http/Web/Views/chapter/menu.volt create mode 100644 app/Http/Web/Views/chapter/read.volt delete mode 100644 app/Http/Web/Views/chapter/show.volt delete mode 100644 app/Http/Web/Views/chapter/show_live.volt delete mode 100644 app/Http/Web/Views/chapter/show_read.volt rename app/Http/Web/Views/chapter/{show_vod.volt => vod.volt} (78%) rename public/static/web/js/{live.im.js => chapter.live.im.js} (97%) rename public/static/web/js/{live.player.js => chapter.live.player.js} (100%) rename public/static/web/js/{read.js => chapter.read.js} (100%) rename public/static/web/js/{vod.player.js => chapter.vod.player.js} (90%) rename public/static/web/js/{chapter.action.js => course.share.js} (54%) delete mode 100644 public/static/web/js/share.js diff --git a/app/Http/Web/Controllers/ChapterController.php b/app/Http/Web/Controllers/ChapterController.php index d951a5d9..7837e2c6 100644 --- a/app/Http/Web/Controllers/ChapterController.php +++ b/app/Http/Web/Controllers/ChapterController.php @@ -35,22 +35,22 @@ class ChapterController extends Controller $service = new CourseChapterListService(); - $chapters = $service->handle($chapter['course']['id']); + $contents = $service->handle($chapter['course']['id']); $this->siteSeo->prependTitle([$chapter['title'], $chapter['course']['title']]); $this->siteSeo->setKeywords($chapter['title']); $this->siteSeo->setDescription($chapter['summary']); if ($chapter['model'] == 'vod') { - $this->view->pick('chapter/show_vod'); + $this->view->pick('chapter/vod'); } elseif ($chapter['model'] == 'live') { - $this->view->pick('chapter/show_live'); + $this->view->pick('chapter/live'); } elseif ($chapter['model'] == 'read') { - $this->view->pick('chapter/show_read'); + $this->view->pick('chapter/read'); } $this->view->setVar('chapter', $chapter); - $this->view->setVar('chapters', $chapters); + $this->view->setVar('contents', $contents); } /** diff --git a/app/Http/Web/Views/chapter/contents.volt b/app/Http/Web/Views/chapter/contents.volt new file mode 100644 index 00000000..ef537ab0 --- /dev/null +++ b/app/Http/Web/Views/chapter/contents.volt @@ -0,0 +1,23 @@ + \ No newline at end of file diff --git a/app/Http/Web/Views/chapter/live.volt b/app/Http/Web/Views/chapter/live.volt new file mode 100644 index 00000000..bebf89cf --- /dev/null +++ b/app/Http/Web/Views/chapter/live.volt @@ -0,0 +1,77 @@ +{% extends 'templates/full.volt' %} + +{% block content %} + + {% set chapter_full_url = full_url({'for':'web.chapter.show','id':chapter.id}) %} + {% set learning_url = url({'for':'web.chapter.learning','id':chapter.id}) %} + {% set live_chats_url = url({'for':'web.live.chats','id':chapter.id}) %} + {% set live_stats_url = url({'for':'web.live.stats','id':chapter.id}) %} + {% set send_msg_url = url({'for':'web.live.send_msg','id':chapter.id}) %} + {% set bind_user_url = url({'for':'web.live.bind_user','id':chapter.id}) %} + {% set like_url = url({'for':'web.chapter.like','id':chapter.id}) %} + {% set qrcode_url = url({'for':'web.qrcode_img'},{'text':chapter_full_url}) %} + + + +
+
+
+
+
+
+
+
+
直播讨论
+
+
+
+ {% if auth_user.id > 0 %} + + {% else %} + + {% endif %} + +
+
+
+
+
+ +
+ + + + + +
+ +
+ + + + +
+ +{% endblock %} + +{% block include_js %} + + + + {{ js_include('web/js/chapter.live.player.js') }} + {{ js_include('web/js/chapter.live.im.js') }} + {{ js_include('web/js/course.share.js') }} + +{% endblock %} \ No newline at end of file diff --git a/app/Http/Web/Views/chapter/live_chats.volt b/app/Http/Web/Views/chapter/live_chats.volt index 38362395..850ac2f9 100644 --- a/app/Http/Web/Views/chapter/live_chats.volt +++ b/app/Http/Web/Views/chapter/live_chats.volt @@ -1,7 +1,7 @@ {% for chat in chats %}
{% if chat.user.vip == 1 %} - + {% endif %} {{ chat.user.name }} {{ chat.content }} diff --git a/app/Http/Web/Views/chapter/live_stats.volt b/app/Http/Web/Views/chapter/live_stats.volt deleted file mode 100644 index 6ee69c02..00000000 --- a/app/Http/Web/Views/chapter/live_stats.volt +++ /dev/null @@ -1,6 +0,0 @@ -
-
- 登录:{{ stats.user_count }} 人 - 游客:{{ stats.guest_count }} 人 -
-
\ No newline at end of file diff --git a/app/Http/Web/Views/chapter/menu.volt b/app/Http/Web/Views/chapter/menu.volt deleted file mode 100644 index d9ed60b3..00000000 --- a/app/Http/Web/Views/chapter/menu.volt +++ /dev/null @@ -1,25 +0,0 @@ - \ No newline at end of file diff --git a/app/Http/Web/Views/chapter/read.volt b/app/Http/Web/Views/chapter/read.volt new file mode 100644 index 00000000..7f42e8a9 --- /dev/null +++ b/app/Http/Web/Views/chapter/read.volt @@ -0,0 +1,53 @@ +{% extends 'templates/full.volt' %} + +{% block content %} + + {% set chapter_full_url = full_url({'for':'web.chapter.show','id':chapter.id}) %} + {% set learning_url = url({'for':'web.chapter.learning','id':chapter.id}) %} + {% set like_url = url({'for':'web.chapter.like','id':chapter.id}) %} + {% set qrcode_url = url({'for':'web.qrcode_img'},{'text':chapter_full_url}) %} + + + +
+
+
{{ chapter.content }}
+
+
+ {{ partial('chapter/contents') }} +
+
+ +
+ + + +
+ +
+ + + + +
+ +{% endblock %} + +{% block include_js %} + + {{ js_include('web/js/chapter.read.js') }} + {{ js_include('web/js/course.share.js') }} + +{% endblock %} \ No newline at end of file diff --git a/app/Http/Web/Views/chapter/show.volt b/app/Http/Web/Views/chapter/show.volt deleted file mode 100644 index c4d52d73..00000000 --- a/app/Http/Web/Views/chapter/show.volt +++ /dev/null @@ -1,12 +0,0 @@ -{% extends 'templates/full.volt' %} - -{% block content %} - -
-
-
- {{ partial('chapter/menu') }} -
-
- -{% endblock %} \ No newline at end of file diff --git a/app/Http/Web/Views/chapter/show_live.volt b/app/Http/Web/Views/chapter/show_live.volt deleted file mode 100644 index 74f8606e..00000000 --- a/app/Http/Web/Views/chapter/show_live.volt +++ /dev/null @@ -1,69 +0,0 @@ -{% extends 'templates/full.volt' %} - -{% block content %} - - {% set learning_url = url({'for':'web.chapter.learning','id':chapter.id}) %} - {% set live_chats_url = url({'for':'web.live.chats','id':chapter.id}) %} - {% set live_stats_url = url({'for':'web.live.stats','id':chapter.id}) %} - {% set send_msg_url = url({'for':'web.live.send_msg','id':chapter.id}) %} - {% set bind_user_url = url({'for':'web.live.bind_user','id':chapter.id}) %} - - - -
-
-
-
-
-
-
-
-
-
    -
  • 讨论
  • -
  • 统计
  • -
-
-
-
- {% if auth_user.id > 0 %} -
-
- - -
-
- {% else %} - - {% endif %} -
-
-
-
-
-
-
- -
- - - - - -
- -{% endblock %} - -{% block include_js %} - - - - {{ js_include('web/js/live.player.js') }} - {{ js_include('web/js/live.im.js') }} - -{% endblock %} \ No newline at end of file diff --git a/app/Http/Web/Views/chapter/show_read.volt b/app/Http/Web/Views/chapter/show_read.volt deleted file mode 100644 index ec95c9cb..00000000 --- a/app/Http/Web/Views/chapter/show_read.volt +++ /dev/null @@ -1,35 +0,0 @@ -{% extends 'templates/full.volt' %} - -{% block content %} - - {% set learning_url = url({'for':'web.chapter.learning','id':chapter.id}) %} - - - -
-
-
{{ chapter.content }}
-
-
- {{ partial('chapter/menu') }} -
-
- -
- - - -
- -{% endblock %} - -{% block include_js %} - - {{ js_include('web/js/read.js') }} - -{% endblock %} \ No newline at end of file diff --git a/app/Http/Web/Views/chapter/show_vod.volt b/app/Http/Web/Views/chapter/vod.volt similarity index 78% rename from app/Http/Web/Views/chapter/show_vod.volt rename to app/Http/Web/Views/chapter/vod.volt index dba895ca..3d5b9d07 100644 --- a/app/Http/Web/Views/chapter/show_vod.volt +++ b/app/Http/Web/Views/chapter/vod.volt @@ -2,17 +2,24 @@ {% block content %} - {% set chapter_url = url({'for':'web.chapter.show','id':chapter.id}) %} - {% set danmu_url = url({'for':'web.chapter.danmu','id':chapter.id}) %} + {% set chapter_full_url = full_url({'for':'web.chapter.show','id':chapter.id}) %} {% set learning_url = url({'for':'web.chapter.learning','id':chapter.id}) %} + {% set danmu_url = url({'for':'web.chapter.danmu','id':chapter.id}) %} {% set like_url = url({'for':'web.chapter.like','id':chapter.id}) %} - {% set qrcode_url = url({'for':'web.qrcode_img'},{'text':'http://baidu.com','size':5}) %} + {% set qrcode_url = url({'for':'web.qrcode_img'},{'text':chapter_full_url}) %}
@@ -20,19 +27,10 @@
-
-
-
- {% if auth_user.id > 0 %} - + + {% else %} {% endif %} @@ -41,7 +39,7 @@
- {{ partial('chapter/menu') }} + {{ partial('chapter/contents') }}
@@ -103,7 +101,7 @@
- +
@@ -115,8 +113,7 @@ {{ js_include('lib/jquery.min.js') }} {{ js_include('lib/jquery.danmu.min.js') }} - {{ js_include('web/js/share.js') }} - {{ js_include('web/js/vod.player.js') }} - {{ js_include('web/js/chapter.action.js') }} + {{ js_include('web/js/course.share.js') }} + {{ js_include('web/js/chapter.vod.player.js') }} {% endblock %} \ No newline at end of file diff --git a/app/Http/Web/Views/course/show.volt b/app/Http/Web/Views/course/show.volt index 186b8c40..49507b0f 100644 --- a/app/Http/Web/Views/course/show.volt +++ b/app/Http/Web/Views/course/show.volt @@ -92,7 +92,7 @@ {% block include_js %} - {{ js_include('web/js/share.js') }} {{ js_include('web/js/course.show.js') }} + {{ js_include('web/js/course.share.js') }} {% endblock %} \ No newline at end of file diff --git a/app/Http/Web/Views/course/show_consults.volt b/app/Http/Web/Views/course/show_consults.volt index a73a906a..beaa2c1c 100644 --- a/app/Http/Web/Views/course/show_consults.volt +++ b/app/Http/Web/Views/course/show_consults.volt @@ -14,10 +14,10 @@
{{ item.answer }}
diff --git a/app/Http/Web/Views/course/show_reviews.volt b/app/Http/Web/Views/course/show_reviews.volt index a7d9d442..15be0c0c 100644 --- a/app/Http/Web/Views/course/show_reviews.volt +++ b/app/Http/Web/Views/course/show_reviews.volt @@ -22,10 +22,10 @@
{{ item.content }}
diff --git a/app/Http/Web/Views/user/show.volt b/app/Http/Web/Views/user/show.volt index 7413a5f7..8885cdee 100644 --- a/app/Http/Web/Views/user/show.volt +++ b/app/Http/Web/Views/user/show.volt @@ -4,7 +4,7 @@ {{ partial('partials/macro_course') }} - {% set vip_flag = user.vip ? '' : '' %} + {% set vip_flag = user.vip ? '' : '' %}
diff --git a/public/static/admin/js/common.js b/public/static/admin/js/common.js index 35afe27f..df4b7e01 100644 --- a/public/static/admin/js/common.js +++ b/public/static/admin/js/common.js @@ -15,6 +15,24 @@ layui.use(['jquery', 'form', 'element', 'layer', 'dropdown'], function () { $.ajaxSetup({ beforeSend: function (xhr) { xhr.setRequestHeader('X-Csrf-Token', $token.attr('content')); + }, + statusCode: { + 400: function (xhr) { + var res = JSON.parse(xhr.responseText); + layer.msg(res.msg, {icon: 2, anim: 6}); + }, + 401: function () { + layer.msg('操作之前请先登录', {icon: 2, anim: 6}); + }, + 403: function () { + layer.msg('操作受限', {icon: 2, anim: 6}); + }, + 404: function () { + layer.msg('资源不存在', {icon: 2, anim: 6}); + }, + 500: function () { + layer.msg('服务器内部错误', {icon: 2, anim: 6}); + } } }); @@ -92,10 +110,6 @@ layui.use(['jquery', 'form', 'element', 'layer', 'dropdown'], function () { data: {priority: priority}, success: function (res) { layer.msg(res.msg, {icon: 1}); - }, - error: function (xhr) { - var json = JSON.parse(xhr.responseText); - layer.msg(json.msg, {icon: 2}); } }); }); @@ -116,10 +130,6 @@ layui.use(['jquery', 'form', 'element', 'layer', 'dropdown'], function () { } else { window.location.reload(); } - }, - error: function (xhr) { - var json = JSON.parse(xhr.responseText); - layer.msg(json.msg, {icon: 2}); } }); }); diff --git a/public/static/web/css/common.css b/public/static/web/css/common.css index 7b42dcc1..2f542ed2 100644 --- a/public/static/web/css/common.css +++ b/public/static/web/css/common.css @@ -45,6 +45,7 @@ } .breadcrumb { + position: relative; margin-bottom: 20px; } @@ -419,6 +420,12 @@ body { margin-right: 20px; } +.breadcrumb .share { + position: absolute; + top: 2px; + right: -5px; +} + .course-meta .cover { float: left; margin-right: 10px; @@ -498,7 +505,7 @@ body { } .course-details { - font-size: 12px; + line-height: 1.8em; color: #666; } @@ -709,6 +716,10 @@ body { font-style: normal; } +.sidebar-card .layui-card-header { + text-align: center; +} + .sidebar-order .order { margin-bottom: 10px; } @@ -792,19 +803,6 @@ body { margin-right: 10px; } -.sidebar-chapter { - padding: 20px 15px; -} - -.sidebar-chapter .layui-field-title { - margin-top: 0; - margin-bottom: 0; -} - -.sidebar-chapter .layui-field-title legend { - text-align: center; -} - .sidebar-chapter-list { height: 405px; overflow-y: auto; @@ -822,7 +820,6 @@ body { .sidebar-lesson-list .lesson-title { line-height: 30px; - font-size: 12px; } .lesson-title .active { @@ -838,24 +835,10 @@ body { } .read-info { - min-height: 454px; + min-height: 428px; margin-bottom: 0; } -.chapter-action { - height: 32px; - line-height: 32px; - margin-bottom: 0; -} - -.chapter-action .share { - float: left; -} - -.chapter-action .danmu-form { - float: right; -} - .share .layui-icon { margin-right: 5px; cursor: pointer; @@ -878,35 +861,46 @@ body { color: #666; } -.danmu-form .icon-danmu-set { - margin-right: 5px; -} - -.danmu-form .layui-input { - width: 500px; - height: 32px; - display: inline; - line-height: 32px; - font-size: 12px; -} - .player-wrap { position: relative; width: 760px; height: 428px; + margin-bottom: 0; } -.chat-wrap { - padding: 10px 20px 20px 20px; - background-color: white; +.danmu-form { + position: relative; + left: 180px; + bottom: 38px; + width: 420px; + display: none; } -.vip-icon { - color: orange; +.danmu-form .icon-danmu-set { + margin-right: 5px; + color: white; +} + +.danmu-form .layui-input { + width: 380px; + height: 28px; + display: inline; + line-height: 28px; + font-size: 12px; + color: white; + background-color: rgba(255, 255, 255, 0.1); +} + +.chat-wrap .layui-card-header { + text-align: center; +} + +.chat-wrap .layui-card-body { + padding-bottom: 20px; } .chat-msg-list { - height: 380px; + height: 354px; margin-bottom: 10px; overflow-y: auto; } @@ -929,37 +923,21 @@ body { color: orange; } +.chat .icon-vip { + color: orange; +} + .chat .content { color: #666; } -.chat-login-tips { - border-top: 1px solid #f2f2f2; - padding-top: 10px; - text-align: center; - font-size: 12px; - color: #999; -} - .chat-msg-form .layui-input { height: 32px; + line-height: 32px; font-size: 12px; color: #666; } -.live-stats { - height: 420px; - color: #666; -} - -.live-stats .stats { - margin-bottom: 15px; -} - -.live-stats .count { - margin-right: 10px; -} - .vip-header { font-size: 18px; text-align: center; @@ -1213,7 +1191,7 @@ body { border-radius: 100px; } -.user-profile .vip-icon { +.user-profile .icon-vip { color: orange; } diff --git a/public/static/web/js/live.im.js b/public/static/web/js/chapter.live.im.js similarity index 97% rename from public/static/web/js/live.im.js rename to public/static/web/js/chapter.live.im.js index 57bd40b4..5555799c 100644 --- a/public/static/web/js/live.im.js +++ b/public/static/web/js/chapter.live.im.js @@ -66,7 +66,7 @@ layui.use(['jquery', 'form', 'helper'], function () { function showNewMessage(res) { var html = '
'; if (res.user.vip === 1) { - html += ''; + html += ''; } html += '' + res.user.name + ':'; html += '' + res.content + ''; diff --git a/public/static/web/js/live.player.js b/public/static/web/js/chapter.live.player.js similarity index 100% rename from public/static/web/js/live.player.js rename to public/static/web/js/chapter.live.player.js diff --git a/public/static/web/js/read.js b/public/static/web/js/chapter.read.js similarity index 100% rename from public/static/web/js/read.js rename to public/static/web/js/chapter.read.js diff --git a/public/static/web/js/vod.player.js b/public/static/web/js/chapter.vod.player.js similarity index 90% rename from public/static/web/js/vod.player.js rename to public/static/web/js/chapter.vod.player.js index 96b6c075..d8766fd2 100644 --- a/public/static/web/js/vod.player.js +++ b/public/static/web/js/chapter.vod.player.js @@ -56,10 +56,34 @@ layui.use(['jquery', 'form', 'layer', 'helper'], function () { player.currentTime(position); } + $('.icon-danmu-set').on('click', function () { + layer.open({ + type: 1, + title: '弹幕设置', + area: '600px', + shadeClose: true, + content: $('#my-danmu-set') + }); + }); + + var dt = null; + + /** + * 控制弹幕表单的可见性 + */ + $('#player').hover(function () { + clearTimeout(dt); + $('.danmu-form').show(); + }, function () { + dt = setTimeout(function () { + $('.danmu-form').hide(); + }, 2500); + }); + $('#danmu').danmu({ left: 20, top: 20, - width: 750, + width: 760, height: 380 }); @@ -101,10 +125,6 @@ layui.use(['jquery', 'form', 'layer', 'helper'], function () { isnew: 1 }); $danmuText.val(''); - }, - error: function (xhr) { - var res = JSON.parse(xhr.responseText); - layer.msg(res.msg, {icon: 2}); } }); return false; diff --git a/public/static/web/js/common.js b/public/static/web/js/common.js index 63f6b2cb..6ec73ea3 100644 --- a/public/static/web/js/common.js +++ b/public/static/web/js/common.js @@ -16,6 +16,24 @@ layui.use(['jquery', 'form', 'element', 'layer', 'helper'], function () { $.ajaxSetup({ beforeSend: function (xhr) { xhr.setRequestHeader('X-Csrf-Token', $token.attr('content')); + }, + statusCode: { + 400: function (xhr) { + var res = JSON.parse(xhr.responseText); + layer.msg(res.msg, {icon: 2, anim: 6}); + }, + 401: function () { + layer.msg('操作之前请先登录', {icon: 2, anim: 6}); + }, + 403: function () { + layer.msg('操作受限', {icon: 2, anim: 6}); + }, + 404: function () { + layer.msg('资源不存在', {icon: 2, anim: 6}); + }, + 500: function () { + layer.msg('服务器内部错误', {icon: 2, anim: 6}); + } } }); @@ -74,10 +92,6 @@ layui.use(['jquery', 'form', 'element', 'layer', 'helper'], function () { } else { window.location.reload(); } - }, - error: function (xhr) { - var json = JSON.parse(xhr.responseText); - layer.msg(json.msg, {icon: 2}); } }); }); diff --git a/public/static/web/js/chapter.action.js b/public/static/web/js/course.share.js similarity index 54% rename from public/static/web/js/chapter.action.js rename to public/static/web/js/course.share.js index 19d0b73d..5a99cc27 100644 --- a/public/static/web/js/chapter.action.js +++ b/public/static/web/js/course.share.js @@ -1,8 +1,7 @@ -layui.use(['jquery', 'layer', 'helper'], function () { +layui.use(['jquery', 'layer'], function () { var $ = layui.jquery; var layer = layui.layer; - var helper = layui.helper; var myShare = { title: $('input[name="share.title"]').val(), @@ -11,16 +10,28 @@ layui.use(['jquery', 'layer', 'helper'], function () { qrcode: $('input[name="share.qrcode"]').val() }; + $('.icon-heart').on('click', function () { + var $this = $(this); + $.ajax({ + type: 'POST', + url: $this.parent().data('url'), + success: function () { + if ($this.hasClass('active')) { + $this.removeClass('active'); + } else { + $this.addClass('active'); + } + } + }); + }); + $('.icon-praise').on('click', function () { var $this = $(this); var $likeCount = $this.next(); var likeCount = parseInt($likeCount.text()); $.ajax({ type: 'POST', - url: $this.data('url'), - beforeSend: function () { - return helper.checkLogin(); - }, + url: $this.parent().data('url'), success: function () { if ($this.hasClass('active')) { $this.removeClass('active'); @@ -31,10 +42,6 @@ layui.use(['jquery', 'layer', 'helper'], function () { $likeCount.text(likeCount + 1); likeCount += 1; } - }, - error: function (xhr) { - var res = JSON.parse(xhr.responseText); - layer.msg(res.msg, {icon: 2}); } }); }); @@ -52,22 +59,28 @@ layui.use(['jquery', 'layer', 'helper'], function () { $('.icon-qq').on('click', function () { var title = '推荐一门好课:' + myShare.title + ',快来和我一起学习吧!'; - Share.qq(title, myShare.url, myShare.pic); + qqShare(title, myShare.url, myShare.pic); }); $('.icon-weibo').on('click', function () { var title = '推荐一门好课:' + myShare.title + ',快来和我一起学习吧!'; - Share.weibo(title, myShare.url, myShare.pic); + weiboShare(title, myShare.url, myShare.pic); }); - $('.icon-danmu-set').on('click', function () { - layer.open({ - type: 1, - title: '弹幕设置', - area: '600px', - shadeClose: true, - content: $('#my-danmu-set') - }); - }); + function qqShare(title, url, pic) { + var shareUrl = 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?'; + shareUrl += 'title=' + encodeURIComponent(title || document.title); + shareUrl += '&url=' + encodeURIComponent(url || document.location); + shareUrl += '&pics=' + pic; + window.open(shareUrl, '_blank'); + } + + function weiboShare(title, url, pic) { + var shareUrl = 'http://v.t.sina.com.cn/share/share.php?'; + shareUrl += 'title=' + encodeURIComponent(title || document.title); + shareUrl += '&url=' + encodeURIComponent(url || document.location); + shareUrl += '&pic=' + encodeURIComponent(pic || ''); + window.open(shareUrl, '_blank'); + } }); \ No newline at end of file diff --git a/public/static/web/js/course.show.js b/public/static/web/js/course.show.js index d27c4469..ab0e5b20 100644 --- a/public/static/web/js/course.show.js +++ b/public/static/web/js/course.show.js @@ -4,13 +4,6 @@ layui.use(['jquery', 'layer', 'helper'], function () { var layer = layui.layer; var helper = layui.helper; - var myShare = { - title: $('input[name="share.title"]').val(), - pic: $('input[name="share.cover"]').val(), - url: $('input[name="share.url"]').val(), - qrcode: $('input[name="share.qrcode"]').val() - }; - $('.rating-btn').on('click', function () { var url = $(this).data('url'); layer.open({ @@ -21,59 +14,13 @@ layui.use(['jquery', 'layer', 'helper'], function () { }); }); - $('.icon-heart').on('click', function () { - var $this = $(this); - $.ajax({ - type: 'POST', - url: $this.parent().data('url'), - beforeSend: function () { - return helper.checkLogin(); - }, - success: function () { - if ($this.hasClass('active')) { - $this.removeClass('active'); - } else { - $this.addClass('active'); - } - }, - error: function (xhr) { - var res = JSON.parse(xhr.responseText); - layer.msg(res.msg, {icon: 2}); - } - }); - }); - - $('.icon-wechat').on('click', function () { - var content = '
分享到微信
'; - layer.open({ - type: 1, - title: false, - closeBtn: 0, - shadeClose: true, - content: content - }); - }); - - $('.icon-qq').on('click', function () { - var title = '推荐一门好课:' + myShare.title + ',快来和我一起学习吧!'; - Share.qq(title, myShare.url, myShare.pic); - }); - - $('.icon-weibo').on('click', function () { - var title = '推荐一门好课:' + myShare.title + ',快来和我一起学习吧!'; - Share.weibo(title, myShare.url, myShare.pic); - }); - $('body').on('click', '.icon-praise', function () { var $this = $(this); var $likeCount = $this.next(); var likeCount = parseInt($likeCount.text()); $.ajax({ type: 'POST', - url: $this.data('url'), - beforeSend: function () { - return helper.checkLogin(); - }, + url: $this.parent().data('url'), success: function () { if ($this.hasClass('active')) { $this.removeClass('active'); @@ -84,10 +31,6 @@ layui.use(['jquery', 'layer', 'helper'], function () { $likeCount.text(likeCount + 1); likeCount += 1; } - }, - error: function (xhr) { - var res = JSON.parse(xhr.responseText); - layer.msg(res.msg, {icon: 2}); } }); }); diff --git a/public/static/web/js/im.find.js b/public/static/web/js/im.find.js index 7ae3284d..ad209d4e 100644 --- a/public/static/web/js/im.find.js +++ b/public/static/web/js/im.find.js @@ -34,10 +34,6 @@ layui.use(['jquery', 'form', 'layer', 'layim', 'helper'], function () { success: function (res) { layer.msg(res.msg, {icon: 1}); layer.close(index); - }, - error: function (xhr) { - var res = JSON.parse(xhr.responseText); - layer.msg(res.msg, {icon: 2}); } }); } @@ -63,10 +59,6 @@ layui.use(['jquery', 'form', 'layer', 'layim', 'helper'], function () { success: function (res) { layer.msg(res.msg, {icon: 1}); layer.close(index); - }, - error: function (xhr) { - var res = JSON.parse(xhr.responseText); - layer.msg(res.msg, {icon: 2}); } }); } diff --git a/public/static/web/js/share.js b/public/static/web/js/share.js deleted file mode 100644 index 86466c9d..00000000 --- a/public/static/web/js/share.js +++ /dev/null @@ -1,17 +0,0 @@ -var Share = {}; - -Share.qq = function (title, url, pic) { - var shareUrl = 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?'; - shareUrl += 'title=' + encodeURIComponent(title || document.title); - shareUrl += '&url=' + encodeURIComponent(url || document.location); - shareUrl += '&pics=' + pic; - window.open(shareUrl, '_blank'); -}; - -Share.weibo = function (title, url, pic) { - var shareUrl = 'http://v.t.sina.com.cn/share/share.php?'; - shareUrl += 'title=' + encodeURIComponent(title || document.title); - shareUrl += '&url=' + encodeURIComponent(url || document.location); - shareUrl += '&pic=' + encodeURIComponent(pic || ''); - window.open(shareUrl, '_blank'); -}; \ No newline at end of file