until.js 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. var userDown = false //用户鼠标判断
  2. var bgMove = false
  3. var indexPath = $('body').attr('data-path')
  4. var until = {
  5. handleModel() {
  6. // m新增,点击区域隐藏
  7. $(document).on('click', '.pub-hide-modal', function() {
  8. $(this).fadeOut()
  9. })
  10. $(document).on('click', '.fullscreen-video', function() {
  11. until.pauseVideo()
  12. $(this).fadeOut()
  13. return false
  14. })
  15. $(document).on('click', '.full-pic-modal', function() {
  16. $(this).fadeOut()
  17. })
  18. // 点击背景关闭弹窗
  19. $(document).on('click', '.pub-modal-mask', function() {
  20. until.pauseVideo()
  21. $(this).fadeOut()
  22. })
  23. $(document).on('click', '.part-screen', function(e) {
  24. return false
  25. })
  26. $(document).on('click', '.close-mask-icon', function() {
  27. until.pauseVideo()
  28. $(this).parents('.pub-modal-mask').fadeOut()
  29. })
  30. $(document).on('click', '.close-full-video', function() {
  31. until.pauseVideo()
  32. $(this).parents('.fullscreen-video').fadeOut()
  33. })
  34. $(document).on('click', '.close-icon', function() {
  35. $(this).parents('.pub-modal').fadeOut()
  36. })
  37. $(document).on('click', '.go-back', function() {
  38. $('.mod-full-picture').fadeOut()
  39. return false
  40. })
  41. },
  42. // 重力感应
  43. acceler() {
  44. if (window.DeviceOrientationEvent) {
  45. window.addEventListener('deviceorientation', handleOrientation, false);
  46. function handleOrientation(event) {
  47. var x = event.beta; // 范围是[-180, 180]
  48. var y = event.gamma; // 范围是[-90, 90]
  49. // 这里我们把x的数值控制在-90到90,因为我们不需要让设备翻转倒过来。
  50. if (x > 60) {x = 60};
  51. if (x < -60) {x = -60};
  52. // 设置偏移最大值
  53. var max = 50;
  54. var pics = document.getElementsByClassName('bg-move')
  55. for(let i = 0; i < pics.length; i++) {
  56. pics[0].style = 'transform: translate3d('+max*x/120+'px, '+max*y/120+'px, 0px)'
  57. }
  58. }
  59. }
  60. },
  61. pauseVideo() {
  62. // video暂停播放
  63. var videoDom = document.getElementsByTagName('video')
  64. for(let i = 0; i < videoDom.length; i++) {
  65. videoDom[i].pause()
  66. }
  67. },
  68. decr(r) {
  69. var e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@!~*-_.()'".split("");
  70. var n = [];
  71. var a = [];
  72. r.split("").reverse().forEach(function (r, t) {
  73. var o = e.indexOf(r);
  74. if (parseInt((t + 1) % 2) == 1) {
  75. a.push(o)
  76. } else {
  77. var p = parseInt(o - a[(t + 1) / 2 - 1]);
  78. n.push(e[p])
  79. }
  80. });
  81. var t = n.join("").replace(/@/g, "%");
  82. return decodeURIComponent(t)
  83. },
  84. /**
  85. * 解密数据
  86. */
  87. deCodeArg(target) {
  88. var srcMap = {};
  89. if (JSON.parse) {
  90. srcMap = JSON.parse(until.decr(target));
  91. } else {
  92. srcMap = eval('(' + until.decr(target) + ')');
  93. }
  94. return srcMap;
  95. },
  96. //立即预约
  97. bookClick() {
  98. $('.book-icon').click(function() {
  99. $('.comment-page').fadeIn()
  100. })
  101. // 返回
  102. $('#book-gack-btn').click(function() {
  103. $('.comment-page').fadeOut()
  104. })
  105. // 预约成功
  106. var successModal = `<div class="progress-modal reset-modal book-success-modal" style="display: block;">
  107. <p class="tips">预约成功!</p>
  108. <div class="btn-wrap">
  109. <div class="btn success-btn book-success-btn">是</div>
  110. </div>
  111. </div>`
  112. $('.book-btn-bottom').click(function() {
  113. $('.comment-page').append(successModal)
  114. })
  115. $('.comment-page').on('click', '.book-success-btn', function() {
  116. $('.book-success-modal').remove()
  117. })
  118. // 视频播放
  119. $('.poster-lake').click(function() {
  120. $('.book-video').hide()
  121. $('#book-video-wrapper').show()
  122. $('#book-lake-video').show()
  123. document.getElementById('book-lake-video').play()
  124. })
  125. $('.poster-taiga').click(function() {
  126. $('.book-video').hide()
  127. $('#book-video-wrapper').show()
  128. $('#book-taiga-video').show()
  129. document.getElementById('book-taiga-video').play()
  130. })
  131. $('.poster-elden').click(function() {
  132. $('.book-video').hide()
  133. $('#book-video-wrapper').show()
  134. $('#book-elden-video').show()
  135. document.getElementById('book-elden-video').play()
  136. })
  137. },
  138. // 右上角工具栏
  139. toolbarClick() {
  140. // 暂停
  141. $('.toolbar-box').find('.bgm-icon').click(function() {
  142. var $this = $(this)
  143. var audio = document.getElementById('bgm-audio')
  144. if($this.hasClass('pause')) {
  145. audio.play()
  146. $this.removeClass('pause')
  147. } else {
  148. audio.pause()
  149. $this.addClass('pause')
  150. }
  151. })
  152. // 评论
  153. $('.toolbar-box').find('.comment-icon').click(function() {
  154. window.open('http://hdzt.duowan.com/1806/m_393864686995.html')
  155. })
  156. // 重置进度
  157. $('.toolbar-box').find('.reset-icon').click(function() {
  158. $('.reset-modal').fadeIn()
  159. })
  160. $('.yes-btn').click(function() {
  161. localStorage.removeItem('hunter_permision')
  162. localStorage.removeItem('entry')
  163. window.location.href = indexPath
  164. })
  165. $('.no-btn').click(function() {
  166. $('.reset-modal').fadeOut()
  167. })
  168. },
  169. //确认装备
  170. shooting() {
  171. var huntVideo = document.getElementById('hunt-video')
  172. var huntVideoB = document.getElementById('hunt-video-b')
  173. $('.start-equit-btn').click(function() {
  174. var bag = $('#equit-modal').attr('data-bag')
  175. $('#equit-video-wrap').find('video').hide()
  176. if(bag == 'A') {
  177. $(huntVideo).show()
  178. huntVideo.play()
  179. }
  180. if(bag == 'B') {
  181. $(huntVideoB).show()
  182. huntVideoB.play()
  183. }
  184. $('#equit-video-wrap').fadeIn()
  185. })
  186. huntVideo.addEventListener('ended', function() {
  187. $('#equit-video-wrap').fadeOut()
  188. })
  189. huntVideoB.addEventListener('ended', function() {
  190. $('#equit-video-wrap').fadeOut()
  191. })
  192. // 开始狩猎
  193. $('.hunt-btn').click(function(){
  194. $('.fullscreen-modal').hide()
  195. $('#equit-modal').show()
  196. })
  197. $('.nav-item-wrap').click(function() {
  198. $('.nav-item-wrap').removeClass('active')
  199. $(this).parents('.container').find('.main').hide()
  200. $(this).addClass('active')
  201. var ind = $(this).attr('data-ind')
  202. var bag = $('#equit-modal').attr('data-bag')
  203. if(ind == 1 && bag == 'A'){
  204. $('#weapon-modal').show()
  205. }
  206. if(ind == 2 && bag == 'A'){
  207. $('#fodder-modal').show()
  208. }
  209. if(ind == 1 && bag == 'B'){
  210. $('#weapon-modal-b').show()
  211. }
  212. if(ind == 2 && bag == 'B'){
  213. $('#fodder-modal-b').show()
  214. }
  215. })
  216. $('.bag-a').click(function() {
  217. var $this = $(this)
  218. if(!$this.hasClass('bag-a-active')) {
  219. $this.addClass('bag-a-active')
  220. $('.bag-b').removeClass('bag-b-active')
  221. $('#equit-modal').attr('data-bag', 'A')
  222. $('.nav-item-wrap').eq(0).trigger('click')
  223. }
  224. })
  225. $('.bag-b').click(function() {
  226. var $this = $(this)
  227. if(!$this.hasClass('bag-b-active')) {
  228. $this.addClass('bag-b-active')
  229. $('.bag-a').removeClass('bag-a-active')
  230. $('#equit-modal').attr('data-bag', 'B')
  231. $('.nav-item-wrap').eq(0).trigger('click')
  232. }
  233. })
  234. },
  235. handleReady(x, y, viewer, view_lgt = 6, view_lat = 0) {
  236. var lakeFlag = false
  237. viewer.on('ready', function() {
  238. $('.loading-bg').hide()
  239. viewer.rotate({
  240. x: 0,
  241. y: 0
  242. });
  243. viewer.animate({
  244. x,
  245. y
  246. },2000);
  247. // 自动旋转
  248. var container = document.getElementsByClassName('psv-hud-svg-container')[0]
  249. var $toolbar = $('.toolbar-box')
  250. var $progress = $('.progress-modal-moblie')
  251. var $nav = $('.nav')
  252. var timer = null
  253. container.addEventListener('touchstart', function() {
  254. clearTimeout(timer)
  255. $toolbar.fadeIn()
  256. $progress.fadeIn()
  257. $nav.fadeIn()
  258. timer = setTimeout(() => {
  259. $toolbar.fadeOut()
  260. $progress.fadeOut()
  261. $nav.fadeOut()
  262. viewer.startAutorotate()
  263. }, 5000);
  264. })
  265. });
  266. viewer.on('position-updated', function(position) {
  267. let lgt = position.longitude
  268. let lat = position.latitude
  269. if(lgt > view_lgt && lat < view_lat && !lakeFlag) {
  270. lakeFlag = true
  271. $('.progress-modal-moblie').fadeIn()
  272. $('.suggest-modal').fadeIn()
  273. $('.nav').fadeIn()
  274. viewer.startAutorotate()
  275. }
  276. })
  277. },
  278. }
  279. export default until