scene1.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  1. import '../scss/index.scss'
  2. import '../scss/page/scene1.scss'
  3. import PhotoSphereViewer from 'photo-sphere-viewer'
  4. import util from './until'
  5. // import imgUrl from '../img/P1.jpg'
  6. import location from '../img/location.png';
  7. import glass from '../img/glass.png'; //望远镜
  8. import eUrl from '../img/E.png';
  9. var viewer = null
  10. var lakeFlag = false
  11. var indexPath = $('body').attr('data-path')
  12. // 进度相关
  13. var progressNum = 0
  14. var progressFlag = {
  15. 'foot': false,
  16. 'deer': false,
  17. 'rabbit': false,
  18. 'lake': false,
  19. 'lookout': false
  20. }
  21. var videoMap = {
  22. 'lookup': '8884585',
  23. 'lake': '8887637',
  24. 'aim': '8887375',
  25. 'shoot': '8887379',
  26. 'open': '8887381'
  27. }
  28. var mp4UrlMap = {
  29. }
  30. var lakeV = {
  31. init() {
  32. this.initLakeView()
  33. this.handleReady()
  34. this.getVideoSource()
  35. this.handleNav()
  36. },
  37. initLakeView() {
  38. viewer = new PhotoSphereViewer({
  39. container: 'photosphere',
  40. panorama: 'http://hdzt.duowan.com/s/1806hunter/P1.jpg',
  41. // panorama: imgUrl,
  42. min_fov: 50,
  43. max_fov: 70,
  44. navbar: false,
  45. time_anim: false,
  46. markers: [
  47. // 多边形
  48. {
  49. id: 'deer-polygon',
  50. polygon_px: [
  51. [3660, 1544], [4060, 1544], [4060, 1968],[3660, 1968]
  52. ],
  53. svgStyle: {
  54. fill: 'rgba(0, 0, 0, 0)',
  55. }
  56. },
  57. {
  58. id: 'location-deer',
  59. x: 3844,
  60. y: 1781,
  61. image: location,
  62. width: 35,
  63. height: 35,
  64. anchor: 'bottom center',
  65. },
  66. // 脚印
  67. {
  68. id: 'foot-polygon',
  69. polygon_px: [
  70. [120, 2094], [120, 2382], [500, 2382],[500, 2094]
  71. ],
  72. svgStyle: {
  73. fill: 'rgba(255, 255, 255, 0)'
  74. }
  75. },
  76. {
  77. id: 'location-foot',
  78. x: 286,
  79. y: 2228,
  80. image: location,
  81. width: 35,
  82. height: 35,
  83. anchor: 'bottom center',
  84. },
  85. // 兔子
  86. {
  87. id: 'rabit-polygon',
  88. polygon_px: [
  89. [2026, 1808], [2026, 1930], [2138, 1930],[2138, 1808]
  90. ],
  91. svgStyle: {
  92. fill: 'rgba(255, 255, 255, 0)'
  93. }
  94. },
  95. {
  96. id: 'location-rabit',
  97. x: 2080,
  98. y: 1860,
  99. image: location,
  100. width: 35,
  101. height: 35,
  102. anchor: 'bottom center',
  103. },
  104. //望远镜
  105. {
  106. id: 'glass',
  107. x: 3641,
  108. y: 1500,
  109. image: glass,
  110. width: 56,
  111. height: 59,
  112. anchor: 'bottom center',
  113. },
  114. // 湖
  115. {
  116. id: 'location-lake',
  117. x: 150,
  118. y: 1965,
  119. image: location,
  120. width: 35,
  121. height: 35,
  122. anchor: 'bottom center',
  123. },
  124. ],
  125. })
  126. },
  127. handleReady() {
  128. viewer.on('ready', function() {
  129. $('.loading-bg').hide()
  130. viewer.rotate({
  131. x: 0,
  132. y: 0
  133. });
  134. viewer.animate({
  135. x: 3500,
  136. y: 1900
  137. },2000);
  138. });
  139. viewer.on('position-updated', function(position) {
  140. let lgt = position.longitude
  141. let lat = position.latitude
  142. if(lgt > 6 && lat < 0 && !lakeFlag) {
  143. lakeFlag = true
  144. $('#lake-suggest-modal').fadeIn()
  145. $('.nav').fadeIn()
  146. }
  147. })
  148. },
  149. getVideoSource() {
  150. let vids = ['8892551', '8887637', '8887375', '8887379', '8887381','8890691','8890693','8890695','8897789','8897793','8897795','8897797']
  151. var videoEls = {
  152. '8892551': 'lookup',
  153. '8887637': 'lake',
  154. '8887375': 'aim',
  155. '8887379': 'shoot',
  156. '8887381': 'open',
  157. '8890691': 'book-lake',
  158. '8890693': 'book-taiga',
  159. '8890695': 'book-elden',
  160. '8897789': 'picVideo',
  161. '8897793': 'openB',
  162. '8897795': 'aimB',
  163. '8897797': 'shootB'
  164. }
  165. $.ajax({
  166. type: "GET",
  167. dataType: "json",
  168. url: `//video.duowan.com/jsapi/playPageVideoInfo/?vids=${vids.join(',')}`,
  169. success: function(data) {
  170. for(var i in data) {
  171. let resouce = util.deCodeArg(data[i].c).all,
  172. source = resouce.yuanhua || resouce[1300] || resouce[1000] || resouce[350]
  173. let name = videoEls[i]
  174. mp4UrlMap[name] = source.src
  175. }
  176. document.getElementById('open-video').src = mp4UrlMap['open']
  177. document.getElementById('aim-video').src = mp4UrlMap['aim']
  178. document.getElementById('shoot-video').src = mp4UrlMap['shoot']
  179. document.getElementById('open-video-b').src = mp4UrlMap['openB']
  180. document.getElementById('aim-video-b').src = mp4UrlMap['aimB']
  181. document.getElementById('shoot-video-b').src = mp4UrlMap['shootB']
  182. document.getElementById('book-lake-video').src = mp4UrlMap['book-lake']
  183. document.getElementById('book-taiga-video').src = mp4UrlMap['book-taiga']
  184. document.getElementById('book-elden-video').src = mp4UrlMap['book-elden']
  185. lakeC.lookoutClick()
  186. lakeC.playVideo()
  187. }
  188. })
  189. },
  190. // 导航权限处理
  191. handleNav() {
  192. // 初始化加载时
  193. let permision = localStorage.getItem('hunter_permision')
  194. if(permision) {
  195. progressFlag = {
  196. 'foot': true,
  197. 'deer': true,
  198. 'rabbit': true,
  199. 'lake': true,
  200. 'lookout': true
  201. }
  202. $('#cur-progress').html(5)
  203. if(permision == 2) {
  204. $('#scene-nav2').removeClass('disable')
  205. } else if(permision == 3 || permision == 4){
  206. $('#scene-nav2').removeClass('disable')
  207. $('#scene-nav3').removeClass('disable')
  208. }
  209. }
  210. }
  211. }
  212. var lakeC = {
  213. init() {
  214. this.modalShow()
  215. util.shooting()
  216. util.bookClick()
  217. util.toolbarClick()
  218. },
  219. modalShow() {
  220. // 点击显示介绍弹窗
  221. $('.nav').find('.current').click(function() {
  222. $('#lake-suggest-modal').fadeIn()
  223. })
  224. // 脚印
  225. function footModal() {
  226. if($('#lake-foot-modal').css('display') == 'none') {
  227. $('.pub-modal').hide()
  228. $('#lake-foot-modal').fadeIn()
  229. viewer.animate({
  230. longitude: 3.2,
  231. latitude: -0.27
  232. },600);
  233. }
  234. if(!progressFlag['foot']){
  235. progressFlag['foot'] = true
  236. $('#cur-progress').html(++progressNum)
  237. progressNum == 5 ? $('#scene-nav2').removeClass('disable') : ''
  238. progressNum == 5 ? localStorage.setItem('hunter_permision', '2') : ''
  239. }
  240. }
  241. $(document).on('click', '#psv-marker-foot-polygon', function() {
  242. footModal()
  243. })
  244. $(document).on('click', '#psv-marker-location-foot', function() {
  245. footModal()
  246. })
  247. // 鹿
  248. function deerModal() {
  249. if($('#lake-deer-modal').css('display') == 'none') {
  250. $('.pub-modal').hide()
  251. $('#lake-deer-modal').fadeIn()
  252. viewer.animate({
  253. longitude: 0.1,
  254. latitude: -0.05
  255. },600);
  256. }
  257. if(!progressFlag['deer']){
  258. progressFlag['deer'] = true
  259. $('#cur-progress').html(++progressNum)
  260. progressNum == 5 ? $('#scene-nav2').removeClass('disable') : ''
  261. progressNum == 5 ? localStorage.setItem('hunter_permision', '2') : ''
  262. }
  263. }
  264. $(document).on('click', '#psv-marker-deer-polygon', function(e) {
  265. deerModal()
  266. })
  267. $(document).on('click', '#psv-marker-location-deer', function() {
  268. deerModal()
  269. })
  270. // 野兔
  271. function rabitModal() {
  272. if($('#lake-rabbit-modal').css('display') == 'none') {
  273. $('.pub-modal').hide()
  274. $('#lake-rabbit-modal').fadeIn()
  275. viewer.animate({
  276. longitude: 4.87,
  277. latitude: -0.07
  278. },600);
  279. }
  280. if(!progressFlag['rabbit']){
  281. progressFlag['rabbit'] = true
  282. $('#cur-progress').html(++progressNum)
  283. progressNum == 5 ? $('#scene-nav2').removeClass('disable') : ''
  284. progressNum == 5 ? localStorage.setItem('hunter_permision', '2') : ''
  285. }
  286. }
  287. $(document).on('click', '#psv-marker-rabit-polygon', function(e) {
  288. rabitModal()
  289. })
  290. $(document).on('click', '#psv-marker-location-rabit', function() {
  291. rabitModal()
  292. })
  293. //湖
  294. $(document).on('click', '#psv-marker-location-lake', function() {
  295. if(!$('#lake-pic')[0]){
  296. var lakeHtml = ` <div class="mod-full-picture" id="lake-pic" style="display:none">
  297. <div class="pub-btn go-back">返回</div>
  298. <div class="full-pic-modal small-modal">
  299. <div class="top-bar">
  300. 莱顿湖
  301. </div>
  302. <div class="container clearfix">
  303. <p>地球上湖泊总面积为270万平方公里,占陆地面积的1.8%,面积大于5000平方公里的湖</p>
  304. <p>青海湖泊有35个。芬兰的湖泊最多,被称为“万湖之国”,拥有大小湖泊6万多个。</p>
  305. <p>湖泊一旦形成,就受到外部自然因素和内部各种过程的持续作用而不断演变。入湖河流携带的大量泥沙和生物残骸年复一年在湖内沉积,湖盆逐渐淤浅,变成陆地,或随着沿岸带水生植物的发展,逐渐变成沼泽。</p>
  306. <div class="eyes-btn"></div>
  307. </div>
  308. </div>
  309. <div class="fullscreen-video fullscreen-video-picture" style="display: none">
  310. <video id="picture-video" preload="metadata" width="100%">
  311. <source src="${mp4UrlMap['picVideo']}">
  312. </video>
  313. <div class="close-icon close-full-video"></div>
  314. </div>
  315. </div>`
  316. $('body').append(lakeHtml)
  317. util.bgMove($('.mod-full-picture'))
  318. }
  319. $('#lake-pic').fadeIn()
  320. if(!progressFlag['lake']){
  321. progressFlag['lake'] = true
  322. $('#cur-progress').html(++progressNum)
  323. progressNum == 5 ? $('#scene-nav2').removeClass('disable') : ''
  324. progressNum == 5 ? localStorage.setItem('hunter_permision', '2') : ''
  325. }
  326. })
  327. $(document).on('click', '.eyes-btn', function() {
  328. $('.fullscreen-video-picture').show()
  329. var video = document.getElementById('picture-video')
  330. video.play()
  331. video.addEventListener("ended",function(){
  332. video.load()
  333. $('.fullscreen-video-picture').hide()
  334. })
  335. })
  336. },
  337. playVideo() {
  338. $('#rabbit-video-play').click(function() {
  339. if(!$('#lake-video-suggest')[0]){
  340. var lakeVideoHtml = `<div class="video-wrapper pub-modal-mask" id="lake-video-suggest">
  341. <div class="part-screen">
  342. <video controls autoplay id="lake-video">
  343. <source src="${mp4UrlMap['lake']}">
  344. </video>
  345. <div class="close-icon close-mask-icon"></div>
  346. </div>
  347. </div>`
  348. $('body').append(lakeVideoHtml)
  349. } else {
  350. $('#lake-video-suggest').show()
  351. document.getElementById('lake-video').play()
  352. }
  353. })
  354. },
  355. // 瞭望台
  356. lookoutClick() {
  357. var videoHtml = `<div class="fullscreen-video fullscreen-video-lookout">
  358. <video id="lookout-video" autoplay width="100%">
  359. <source src="${mp4UrlMap['lookup']}">
  360. </video>
  361. <div class="close-icon close-full-video"></div>
  362. </div>`
  363. $(document).on('click', '#psv-marker-glass', function() {
  364. if(!$('#lookout-pic')[0]){
  365. var lookOutHtml = ` <div class="mod-full-picture" id="lookout-pic" style="display:none">
  366. <div class="pub-btn go-back">返回</div>
  367. <img class="e-tips" src="${eUrl}" alt="">
  368. </div>`
  369. $('body').append(lookOutHtml)
  370. }
  371. $('#lookout-pic').fadeIn()
  372. if(!progressFlag['lookout']){
  373. progressFlag['lookout'] = true
  374. $('#cur-progress').html(++progressNum)
  375. progressNum == 5 ? $('#scene-nav2').removeClass('disable') : ''
  376. progressNum == 5 ? localStorage.setItem('hunter_permision', '2') : ''
  377. }
  378. })
  379. // 监听E键
  380. $(document).on('keyup', function(e) {
  381. var lookVideo = document.getElementById('lookout-video')
  382. var isShow = $('#lookout-pic').css('display') == 'none' ? false : true;
  383. if(isShow) {
  384. if(e.keyCode == 69) {
  385. if(lookVideo) {
  386. $('#lookout-pic').find('.fullscreen-video').fadeIn()
  387. lookVideo.play()
  388. } else{
  389. $('#lookout-pic').append(videoHtml)
  390. lookVideo = document.getElementById('lookout-video')
  391. lookVideo.play()
  392. }
  393. lookVideo.addEventListener("ended",function(){
  394. lookVideo.load()
  395. lookVideo.pause()
  396. $('.fullscreen-video-lookout').hide()
  397. $('#lookout-pic').hide()
  398. })
  399. }
  400. }
  401. })
  402. },
  403. }
  404. let entry = localStorage.getItem('entry')
  405. if(entry == 'index') {
  406. util.animateModal()
  407. util.handleModel()
  408. lakeV.init()
  409. lakeC.init()
  410. } else {
  411. window.location.href = indexPath
  412. }