entry.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import '../scss/entry.scss'
  2. import util from './until'
  3. class Enter {
  4. constructor() {
  5. this.initPage()
  6. this.mouseMove()
  7. this.entryGame()
  8. }
  9. initPage() {
  10. $.ajax({
  11. type: "GET",
  12. dataType: "json",
  13. url: `//video.duowan.com/jsapi/playPageVideoInfo/?vids=8890861`,
  14. success: function(data) {
  15. for(var i in data) {
  16. let resouce = util.deCodeArg(data[i].c).all,
  17. source = resouce.yuanhua || resouce[1300] || resouce[1000] || resouce[350];
  18. document.getElementById('entry-video').src = source.src
  19. }
  20. }
  21. })
  22. }
  23. mouseMove() {
  24. //获取div元素
  25. var rec = document.getElementById("rec")
  26. document.onmousemove = function(e){
  27. var ev = e || event;
  28. rec.style.top = ev.clientY - 97 + 'px';
  29. rec.style.left = ev.clientX - 97 + 'px';
  30. }
  31. }
  32. entryGame() {
  33. $(document).click(function(e) {
  34. var top = $('.aim-glass').css('top')
  35. top = top.replace('px','')
  36. var origin = top
  37. top = Number(top) - 100
  38. document.getElementById('hunt-audio').play()
  39. $('.aim-glass').animate({top: top + 'px'}, 50).animate({top: origin + 'px'}, 400, function() {
  40. let link = $('.entry-text').attr('data-href')
  41. localStorage.setItem('entry', 'index');
  42. window.location.href = link
  43. });
  44. })
  45. }
  46. }
  47. new Enter