videoDetail.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import 'css/newMenu/public.css';
  2. import 'css/newMenu/header.css'
  3. import 'css/search.css';
  4. import '../css/videoDetail.css';
  5. import './public.js';
  6. $(function(){
  7. "use strict";
  8. init();
  9. function init(){
  10. share();
  11. search();
  12. }
  13. //分享
  14. function share(){
  15. $('.share div>span').hover(function(){
  16. $('.share ul').show(100).addClass('active');
  17. })
  18. $('.share').mouseleave(function(){
  19. $(this).find('ul').hide(100).removeClass('active')
  20. })
  21. //好友
  22. document.querySelector('.qqHy').onclick=function(){
  23. let title = $('.videoList li.active .txt h4').text(),
  24. img=$('.videoList li.active img').attr('src');
  25. shareQQ_friend(title, window.location.href, img)
  26. };
  27. //qq
  28. document.querySelector('.qqKj').onclick=function(){
  29. let title = $('.videoList li.active .txt h4').text(),
  30. img=$('.videoList li.active img').attr('src');
  31. shareToQq(title, window.location.href, img)
  32. };
  33. //微博
  34. document.querySelector('.xlWb').onclick=function(){
  35. let title = $('.videoList li.active .txt h4').text(),
  36. img=$('.videoList li.active img').attr('src');
  37. shareToXl(title,window.location.href,img)
  38. };
  39. }
  40. //搜索
  41. function search(){
  42. $('.searchBtn').click(function(){
  43. let val = $('.demandSearch').val();
  44. window.location.href= globalConfig.context+'/portal/video.html?name='+escape(val);
  45. })
  46. }
  47. //防止下载
  48. $('#videoDe').hover(function(){
  49. document.oncontextmenu=function(e){
  50. return false
  51. }
  52. },function(){
  53. document.oncontextmenu=function(e){
  54. }
  55. })
  56. //分享
  57. function shareToQq(title, url, picurl) {
  58. var shareqqzonestring = 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?summary=' + encodeURIComponent(title) + '&url=' +
  59. encodeURIComponent(url) + '&pics=' + encodeURIComponent(picurl)+'&title='+title;
  60. window.open(shareqqzonestring);
  61. }
  62. //微博
  63. function shareToXl(title,url,picurl){
  64. var sharesinastring='http://v.t.sina.com.cn/share/share.php?title='+title+'&url='+url+'&content=utf-8&sourceUrl='+url+'&pic='+picurl;
  65. window.open(sharesinastring);
  66. }
  67. //qq好友
  68. function shareQQ_friend(_title,_url,picurl){
  69. var _shareUrl = 'http://connect.qq.com/widget/shareqq/iframe_index.html?';
  70. _shareUrl += 'url=' + encodeURIComponent(_url); //分享的链接
  71. _shareUrl += '&title=' + encodeURIComponent(_title); //分享的标题
  72. _shareUrl+='&pics=' + encodeURIComponent(picurl)
  73. window.open(_shareUrl,'_blank','height=520, width=720');
  74. }
  75. })