scene1.js 16 KB

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