until.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  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 stepB = 1
  218. var openVideo = document.getElementById('open-video')
  219. var aimVideo = document.getElementById('aim-video')
  220. var shootVideo = document.getElementById('shoot-video')
  221. var openVideoB = document.getElementById('open-video-b')
  222. var aimVideoB = document.getElementById('aim-video-b')
  223. var shootVideoB = document.getElementById('shoot-video-b')
  224. openVideo.addEventListener("ended",openVideoEnd)
  225. aimVideo.addEventListener("ended",aimVideoEnd)
  226. shootVideo.addEventListener("ended",shootVideoEnd)
  227. openVideoB.addEventListener("ended",openVideoEndB)
  228. aimVideoB.addEventListener("ended",aimVideoEndB)
  229. shootVideoB.addEventListener("ended",shootVideoEndB)
  230. var bag
  231. $('.start-equit-btn').click(function() {
  232. bag = $('#equit-modal').attr('data-bag')
  233. if(bag == 'A') {
  234. $('.group-A').show()
  235. $('.group-B').hide()
  236. }
  237. if(bag == 'B') {
  238. $('.group-B').show()
  239. $('.group-A').hide()
  240. }
  241. $('#equit-video-wrap').fadeIn()
  242. if(stepB == 1 && bag == 'B') {
  243. openVideoB.play()
  244. }
  245. })
  246. function openVideoEnd() {
  247. if(step == 1) {
  248. $(openVideo).hide();
  249. $(aimVideo).show();
  250. $('.space-tips').show()
  251. }
  252. step = 2
  253. }
  254. function aimVideoEnd() {
  255. if(step == 2) {
  256. $(aimVideo).hide();
  257. $(shootVideo).show();
  258. $('.space-tips').hide();
  259. $('.open-qiang-tips').show()
  260. }
  261. step = 3
  262. }
  263. function shootVideoEnd() {
  264. $('.equit-success-a').fadeIn()
  265. document.getElementById('hunter-audio').play()
  266. }
  267. function openVideoEndB() {
  268. if(stepB == 1) {
  269. $(openVideoB).hide();
  270. $(aimVideoB).show();
  271. $('.space-tips-B').show()
  272. }
  273. stepB = 2
  274. }
  275. function aimVideoEndB() {
  276. if(stepB == 2) {
  277. $(aimVideoB).hide();
  278. $(shootVideoB).show();
  279. $('.space-tips-B').hide();
  280. $('.open-qiang-tips-B').show()
  281. }
  282. stepB = 3
  283. }
  284. function shootVideoEndB() {
  285. $('.equit-success-b').fadeIn()
  286. document.getElementById('hunter-audio').play()
  287. }
  288. $('.close-equit-a').click(function() {
  289. $('#equit-video-wrap').hide()
  290. $('.equit-success').hide()
  291. $('.open-jin-tips').show()
  292. $('#equit-modal').hide()
  293. $(openVideo).show()
  294. $(shootVideo).hide()
  295. openVideo.currentTime = 0
  296. aimVideo.currentTime = 0
  297. shootVideo.currentTime = 0
  298. step = 1
  299. })
  300. $('.close-equit-b').click(function() {
  301. $('#equit-video-wrap').hide()
  302. $('.equit-success').hide()
  303. $('#equit-modal').hide()
  304. $(openVideoB).show()
  305. $(shootVideoB).hide()
  306. openVideoB.currentTime = 0
  307. aimVideoB.currentTime = 0
  308. shootVideoB.currentTime = 0
  309. stepB = 1
  310. })
  311. $(document).on('keyup', function(e) {
  312. var isShow = $('#equit-video-wrap').css('display') == 'none' ? false : true
  313. if(isShow) {
  314. if(e.keyCode == 70 && step == 1 && bag == 'A'){
  315. $('.open-jin-tips').hide()
  316. openVideo.play()
  317. }
  318. if(e.keyCode == 32 && step == 2 && bag == 'A'){
  319. $('.space-tips').show()
  320. aimVideo.pause()
  321. }
  322. if(e.keyCode == 70 && step == 3 && bag == 'A'){
  323. $('.open-qiang-tips').hide()
  324. shootVideo.play()
  325. }
  326. if(e.keyCode == 32 && stepB == 2 && bag == 'B'){
  327. $('.space-tips-B').show()
  328. aimVideoB.pause()
  329. }
  330. if(e.keyCode == 70 && stepB == 3 && bag == 'B'){
  331. $('.open-qiang-tips-B').hide()
  332. shootVideoB.play()
  333. }
  334. }
  335. // console.log(step)
  336. })
  337. $(document).on('keydown', function(e) {
  338. if(e.keyCode == 32 && step == 2 && bag == 'A'){
  339. $('.space-tips').hide()
  340. aimVideo.play()
  341. }
  342. if(e.keyCode == 32 && stepB == 2 && bag == 'B'){
  343. $('.space-tips-B').hide()
  344. aimVideoB.play()
  345. }
  346. })
  347. // 开始狩猎
  348. $('.hunt-btn').click(function(){
  349. $('.big-modal').hide()
  350. $('#equit-modal').show()
  351. })
  352. $('.nav-item-wrap').click(function() {
  353. $('.nav-item-wrap').removeClass('active')
  354. $(this).parents('.container').find('.main').hide()
  355. $(this).addClass('active')
  356. var ind = $(this).attr('data-ind')
  357. var bag = $('#equit-modal').attr('data-bag')
  358. if(ind == 1 && bag == 'A'){
  359. $('#weapon-modal').show()
  360. }
  361. if(ind == 2 && bag == 'A'){
  362. $('#fodder-modal').show()
  363. }
  364. if(ind == 1 && bag == 'B'){
  365. $('#weapon-modal-b').show()
  366. }
  367. if(ind == 2 && bag == 'B'){
  368. $('#fodder-modal-b').show()
  369. }
  370. })
  371. $('.bag-a').click(function() {
  372. var $this = $(this)
  373. if(!$this.hasClass('bag-a-active')) {
  374. $this.addClass('bag-a-active')
  375. $('.bag-b').removeClass('bag-b-active')
  376. $('#equit-modal').attr('data-bag', 'A')
  377. $('.nav-item-wrap').eq(0).trigger('click')
  378. }
  379. })
  380. $('.bag-b').click(function() {
  381. var $this = $(this)
  382. if(!$this.hasClass('bag-b-active')) {
  383. $this.addClass('bag-b-active')
  384. $('.bag-a').removeClass('bag-a-active')
  385. $('#equit-modal').attr('data-bag', 'B')
  386. $('.nav-item-wrap').eq(0).trigger('click')
  387. }
  388. })
  389. },
  390. }
  391. export default until