until.js 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. var userDown = false //用户鼠标判断
  2. var bgMove = false
  3. var indexPath = $('body').attr('data-path')
  4. var until = {
  5. // 浮层动画
  6. animateModal() {
  7. var w = document.body.offsetWidth/2;
  8. var h = document.body.offsetHeight/2;
  9. var modal = document.getElementsByClassName('animate-wrap');
  10. var $moveBg = $('.comment-page').find('.move-bg') //评论背景移动
  11. var $fullBg = $('.mod-full-picture')
  12. document.body.onmousedown = function (event) {
  13. userDown = true
  14. }
  15. document.body.onmouseup = function (event) {
  16. userDown = false
  17. }
  18. document.body.onmousemove = function (event) {
  19. var mx = event.clientX,
  20. my = event.clientY;
  21. if(userDown) {
  22. for (var i=0; i<modal.length; i++) {
  23. modal[i].style.marginLeft=(w-mx)/60 +'px';
  24. modal[i].style.marginTop=(h-my)/40 +'px';
  25. }
  26. }
  27. if(bgMove) {
  28. $moveBg.css({
  29. 'backgroundPositionX': (w-mx)/120,
  30. 'backgroundPositionY': (h-my)/80
  31. })
  32. }
  33. $fullBg.css({
  34. 'backgroundPositionX': (w-mx)/100,
  35. 'backgroundPositionY': (h-my)/60
  36. })
  37. }
  38. },
  39. bgMove($item) {
  40. var w = document.body.offsetWidth/2;
  41. var h = document.body.offsetHeight/2;
  42. document.body.onmousemove = function (event) {
  43. var mx = event.clientX,
  44. my = event.clientY;
  45. $item.css({
  46. 'backgroundPositionX': (w-mx)/100,
  47. 'backgroundPositionY': (h-my)/60
  48. })
  49. }
  50. },
  51. handleModel() {
  52. // 点击背景关闭弹窗
  53. $(document).on('click', '.pub-modal-mask', function() {
  54. until.pauseVideo()
  55. $(this).fadeOut()
  56. })
  57. $(document).on('click', '.part-screen', function(e) {
  58. return false
  59. })
  60. $(document).on('click', '.close-mask-icon', function() {
  61. until.pauseVideo()
  62. $(this).parents('.pub-modal-mask').fadeOut()
  63. })
  64. $(document).on('click', '.close-full-video', function() {
  65. until.pauseVideo()
  66. $(this).parents('.fullscreen-video').fadeOut()
  67. })
  68. $(document).on('click', '.close-icon', function() {
  69. $(this).parents('.pub-modal').fadeOut()
  70. })
  71. $(document).on('click', '.go-back', function() {
  72. $('.mod-full-picture').fadeOut()
  73. })
  74. },
  75. pauseVideo() {
  76. // video暂停播放
  77. var videoDom = document.getElementsByTagName('video')
  78. for(let i = 0; i < videoDom.length; i++) {
  79. videoDom[i].pause()
  80. }
  81. },
  82. decr(r) {
  83. var e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@!~*-_.()'".split("");
  84. var n = [];
  85. var a = [];
  86. r.split("").reverse().forEach(function (r, t) {
  87. var o = e.indexOf(r);
  88. if (parseInt((t + 1) % 2) == 1) {
  89. a.push(o)
  90. } else {
  91. var p = parseInt(o - a[(t + 1) / 2 - 1]);
  92. n.push(e[p])
  93. }
  94. });
  95. var t = n.join("").replace(/@/g, "%");
  96. return decodeURIComponent(t)
  97. },
  98. /**
  99. * 解密数据
  100. */
  101. deCodeArg(target) {
  102. var srcMap = {};
  103. if (JSON.parse) {
  104. srcMap = JSON.parse(until.decr(target));
  105. } else {
  106. srcMap = eval('(' + until.decr(target) + ')');
  107. }
  108. return srcMap;
  109. },
  110. //立即预约
  111. bookClick() {
  112. function bookAnimate() {
  113. $('.book-modal-1').removeClass('fade-in').addClass('bounceInLeft')
  114. $('.book-modal-2').removeClass('fade-in').addClass('bounceInRight')
  115. $('.poster-wrapper').removeClass('fade-in').addClass('bounceInUp')
  116. $('.bear').removeClass('fade-in').addClass('bounceInLeft')
  117. $('.deer').removeClass('fade-in').addClass('bounceInRight')
  118. }
  119. $('.book-icon').click(function() {
  120. $('.page-comment').hide()
  121. $('.page-book').show()
  122. $('.mod-btn').removeClass('active')
  123. $('.book-btn').addClass('active')
  124. $('.comment-page').fadeIn()
  125. bookAnimate()
  126. bgMove= true
  127. })
  128. // 返回
  129. $('#book-gack-btn').click(function() {
  130. $('.comment-page').fadeOut()
  131. bgMove = false
  132. })
  133. // 切换评论页
  134. $('.book-header').find('.mod-btn').click(function() {
  135. var $this = $(this)
  136. $('.mod-btn').removeClass('active')
  137. $this.addClass('active')
  138. var tab = $this.attr('data-tab')
  139. if(tab == 'comment') {
  140. $('.page-book').hide()
  141. $('.page-comment').show()
  142. } else if(tab == 'book') {
  143. bookAnimate()
  144. $('.page-comment').hide()
  145. $('.page-book').show()
  146. }
  147. })
  148. // 预约成功
  149. var successModal = `<div class="progress-modal reset-modal book-success-modal" style="display: block;">
  150. <p class="tips">预约成功!</p>
  151. <div class="btn-wrap">
  152. <div class="btn success-btn book-success-btn">是</div>
  153. </div>
  154. </div>`
  155. $('.book-btn-bottom').click(function() {
  156. $('.comment-page').append(successModal)
  157. })
  158. $('.comment-page').on('click', '.book-success-btn', function() {
  159. $('.book-success-modal').remove()
  160. })
  161. // 视频播放
  162. $('.poster-lake').click(function() {
  163. $('.book-video').hide()
  164. $('#book-video-wrapper').show()
  165. $('#book-lake-video').show()
  166. document.getElementById('book-lake-video').play()
  167. })
  168. $('.poster-taiga').click(function() {
  169. $('.book-video').hide()
  170. $('#book-video-wrapper').show()
  171. $('#book-taiga-video').show()
  172. document.getElementById('book-taiga-video').play()
  173. })
  174. $('.poster-elden').click(function() {
  175. $('.book-video').hide()
  176. $('#book-video-wrapper').show()
  177. $('#book-elden-video').show()
  178. document.getElementById('book-elden-video').play()
  179. })
  180. },
  181. // 右上角工具栏
  182. toolbarClick() {
  183. // 暂停
  184. $('.toolbar-box').find('.bgm-icon').click(function() {
  185. var $this = $(this)
  186. var audio = document.getElementById('bgm-audio')
  187. if($this.hasClass('pause')) {
  188. audio.play()
  189. $this.removeClass('pause')
  190. } else {
  191. audio.pause()
  192. $this.addClass('pause')
  193. }
  194. })
  195. // 评论
  196. $('.toolbar-box').find('.comment-icon').click(function() {
  197. $('.comment-btn').trigger('click')
  198. $('.comment-page').fadeIn()
  199. bgMove = true
  200. })
  201. // 重置进度
  202. $('.toolbar-box').find('.reset-icon').click(function() {
  203. $('.reset-modal').fadeIn()
  204. })
  205. $('.yes-btn').click(function() {
  206. localStorage.removeItem('hunter_permision')
  207. localStorage.removeItem('entry')
  208. window.location.href = indexPath
  209. })
  210. $('.no-btn').click(function() {
  211. $('.reset-modal').fadeOut()
  212. })
  213. },
  214. //确认装备
  215. shooting() {
  216. var step = 1 //步骤
  217. var openVideo = document.getElementById('open-video')
  218. var aimVideo = document.getElementById('aim-video')
  219. var shootVideo = document.getElementById('shoot-video')
  220. $('.start-equit-btn').click(function() {
  221. $('#equit-video-wrap').fadeIn()
  222. if(step == 3) {
  223. shootVideo.play()
  224. }
  225. })
  226. $('.close-equit-btn').click(function() {
  227. $('#equit-video-wrap').hide()
  228. $('.equit-success').hide()
  229. $('.open-jin-tips').show()
  230. $('#equit-modal').hide()
  231. $(openVideo).show()
  232. $(shootVideo).hide()
  233. openVideo.currentTime = 0
  234. aimVideo.currentTime = 0
  235. shootVideo.currentTime = 0
  236. step = 1
  237. })
  238. openVideo.addEventListener("ended",function(){
  239. if(step == 1) {
  240. $(openVideo).hide();
  241. $(aimVideo).show();
  242. $('.space-tips').show()
  243. }
  244. step ++
  245. })
  246. aimVideo.addEventListener("ended",function(){
  247. if(step == 2) {
  248. $(aimVideo).hide();
  249. $(shootVideo).show();
  250. $('.space-tips').hide();
  251. $('.open-qiang-tips').show()
  252. }
  253. step ++
  254. })
  255. shootVideo.addEventListener("ended",function(){
  256. $('.equit-success').fadeIn()
  257. document.getElementById('hunter-audio').play()
  258. })
  259. $(document).on('keyup', function(e) {
  260. var isShow = $('#equit-video-wrap').css('display') == 'none' ? false : true
  261. console.log(e.keyCode)
  262. if(isShow) {
  263. if(e.keyCode == 70 && step == 1){
  264. $('.open-jin-tips').hide()
  265. openVideo.play()
  266. }
  267. if(e.keyCode == 32 && step == 2){
  268. $('.space-tips').show()
  269. aimVideo.pause()
  270. }
  271. if(e.keyCode == 70 && step == 3){
  272. $('.open-qiang-tips').hide()
  273. shootVideo.play()
  274. }
  275. }
  276. })
  277. $(document).on('keydown', function(e) {
  278. if(e.keyCode == 32 && step == 2){
  279. $('.space-tips').hide()
  280. aimVideo.play()
  281. }
  282. })
  283. },
  284. }
  285. export default until