scene3.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  1. import '../scss/index.scss'
  2. import '../scss/page/scene1.scss'
  3. import PhotoSphereViewer from 'photo-sphere-viewer'
  4. import util from './until'
  5. var attachFastClick = require('fastclick');
  6. import Pic from '../img/P3-mini.jpg'
  7. import location from '../img/location.png';
  8. import glass from '../img/glass.png'; //望远镜
  9. import eUrl from '../img/m/screen-tap-tips.png';
  10. var viewer = null
  11. var indexPath = $('body').attr('data-path')
  12. // 进度相关
  13. var progressNum = 0
  14. var allStep = 5
  15. var progressFlag = {
  16. 'bear': false,
  17. 'lynx': false,
  18. 'road': false,
  19. 'lookout': false,
  20. 'fox': false
  21. }
  22. var mp4UrlMap = {
  23. }
  24. var huntV = {
  25. init() {
  26. this.initSnowView()
  27. this.handleNav()
  28. this.getVideoSource()
  29. util.handleReady(2654, 1050, viewer, 0, 0.008)
  30. },
  31. initSnowView() {
  32. viewer = new PhotoSphereViewer({
  33. container: 'photosphere',
  34. // panorama: 'http://hdzt.duowan.com/s/1806hunter/moblie/P3.jpg',
  35. panorama: Pic,
  36. min_fov: 50,
  37. max_fov: 70,
  38. navbar: false,
  39. time_anim: false,
  40. move_speed: 1.7, //m
  41. anim_speed: '1rpm',
  42. markers: [
  43. // 野牛
  44. {
  45. id: 'beer-polygon',
  46. polygon_px: [
  47. [2626, 950], [2626, 1068], [2807, 1068],[2807, 950]
  48. ],
  49. svgStyle: {
  50. fill: 'rgba(255, 255, 255, 0)'
  51. }
  52. },
  53. {
  54. id: 'location-beer',
  55. x: 2725,
  56. y: 990,
  57. image: location,
  58. width: 35,
  59. height: 35,
  60. anchor: 'bottom center',
  61. },
  62. // 野猪
  63. {
  64. id: 'lynx-polygon',
  65. polygon_px: [
  66. [1376, 1082], [1376, 1168], [1474, 1168],[1474, 1082]
  67. ],
  68. svgStyle: {
  69. fill: 'rgba(255, 255, 255, 0)'
  70. }
  71. },
  72. {
  73. id: 'location-lynx',
  74. x: 1422,
  75. y: 1122,
  76. image: location,
  77. width: 35,
  78. height: 35,
  79. anchor: 'bottom center',
  80. },
  81. // 狐狸
  82. {
  83. id: 'fox-polygon',
  84. polygon_px: [
  85. [3456, 950], [3456, 1088], [3592, 1088],[3592, 950]
  86. ],
  87. svgStyle: {
  88. fill: 'rgba(255, 255, 255, 0)'
  89. }
  90. },
  91. {
  92. id: 'location-fox',
  93. x: 3530,
  94. y: 1010,
  95. image: location,
  96. width: 35,
  97. height: 35,
  98. anchor: 'bottom center',
  99. },
  100. // 望远镜
  101. {
  102. id: 'glass',
  103. x: 202,
  104. y: 610,
  105. image: glass,
  106. width: 56,
  107. height: 59,
  108. anchor: 'bottom center',
  109. },
  110. // 铁路
  111. {
  112. id: 'location-road',
  113. x: 2250,
  114. y: 1120,
  115. image: location,
  116. width: 35,
  117. height: 35,
  118. anchor: 'bottom center',
  119. },
  120. ]
  121. })
  122. },
  123. getVideoSource() {
  124. let vids = ['8896623','8896631','8896635','8896637','8896639','8896535','8896617', '8897763']
  125. var videoEls = {
  126. '8896623': 'lookup',
  127. '8896631': 'hunt',
  128. '8896635': 'book-lake',
  129. '8896637': 'book-taiga',
  130. '8896639': 'book-elden',
  131. '8896535': 'picVideo',
  132. '8896617': 'huntVideo',
  133. '8897763': 'huntVideoB'
  134. }
  135. $.ajax({
  136. type: "GET",
  137. dataType: "json",
  138. url: `//video.duowan.com/jsapi/playPageVideoInfo/?vids=${vids.join(',')}`,
  139. success: function(data) {
  140. for(var i in data) {
  141. let resouce = util.deCodeArg(data[i].c).all,
  142. source = resouce.yuanhua || resouce[1300] || resouce[1000] || resouce[350]
  143. let name = videoEls[i]
  144. mp4UrlMap[name] = source.src
  145. }
  146. document.getElementById('hunt-video').src = mp4UrlMap['huntVideo']
  147. document.getElementById('hunt-video-b').src = mp4UrlMap['huntVideoB']
  148. document.getElementById('book-lake-video').src = mp4UrlMap['book-lake']
  149. document.getElementById('book-taiga-video').src = mp4UrlMap['book-taiga']
  150. document.getElementById('book-elden-video').src = mp4UrlMap['book-elden']
  151. huntC.lookoutClick()
  152. huntC.playVideo()
  153. }
  154. })
  155. },
  156. // 导航权限处理
  157. handleNav() {
  158. // 初始化加载时
  159. let permision = localStorage.getItem('hunter_permision')
  160. if(permision < 3) {
  161. window.location.href = indexPath
  162. }
  163. if(permision == 4) {
  164. progressFlag = {
  165. 'bear': true,
  166. 'lynx': true,
  167. 'road': true,
  168. 'lookout': true,
  169. 'fox': true
  170. }
  171. $('#cur-progress').html(5)
  172. }
  173. }
  174. }
  175. var huntC = {
  176. init() {
  177. this.modalShow()
  178. util.bookClick()
  179. util.toolbarClick()
  180. util.shooting()
  181. },
  182. modalShow() {
  183. // 点击显示介绍弹窗
  184. $('.nav').find('.current').click(function() {
  185. $('#hunter-suggest-modal').fadeIn()
  186. })
  187. // 黑熊
  188. function beerModal() {
  189. if($('#hunter-beer-modal').css('display') == 'none') {
  190. $('.pub-modal').hide()
  191. $('#hunter-beer-modal').fadeIn()
  192. viewer.animate({
  193. x: 2725,
  194. y: 990
  195. },600);
  196. }
  197. if(!progressFlag['bear']){
  198. progressFlag['bear'] = true
  199. $('#cur-progress').html(++progressNum)
  200. progressNum == allStep ? localStorage.setItem('hunter_permision', '4') : ''
  201. progressNum == allStep ? $('.complete-modal').fadeIn() : ''
  202. }
  203. }
  204. $(document).on('click', '#psv-marker-beer-polygon', function() {
  205. beerModal()
  206. })
  207. $(document).on('click', '#psv-marker-location-beer', function() {
  208. beerModal()
  209. })
  210. // lynx
  211. function lynxModal() {
  212. if($('#hunter-lynx-modal').css('display') == 'none') {
  213. $('.pub-modal').hide()
  214. $('#hunter-lynx-modal').fadeIn()
  215. viewer.animate({
  216. x: 1422,
  217. y: 1122
  218. },600);
  219. }
  220. if(!progressFlag['lynx']){
  221. progressFlag['lynx'] = true
  222. $('#cur-progress').html(++progressNum)
  223. progressNum == allStep ? localStorage.setItem('hunter_permision', '4') : ''
  224. progressNum == allStep ? $('.complete-modal').fadeIn() : ''
  225. }
  226. }
  227. $(document).on('click', '#psv-marker-lynx-polygon', function() {
  228. lynxModal()
  229. })
  230. $(document).on('click', '#psv-marker-location-lynx', function() {
  231. lynxModal()
  232. })
  233. // fox
  234. function foxModal() {
  235. if($('#hunter-fox-modal').css('display') == 'none') {
  236. $('.pub-modal').hide()
  237. $('#hunter-fox-modal').fadeIn()
  238. viewer.animate({
  239. x: 3530,
  240. y: 1010
  241. },600);
  242. }
  243. if(!progressFlag['fox']){
  244. progressFlag['fox'] = true
  245. $('#cur-progress').html(++progressNum)
  246. progressNum == allStep ? localStorage.setItem('hunter_permision', '4') : ''
  247. progressNum == allStep ? $('.complete-modal').fadeIn() : ''
  248. }
  249. }
  250. $(document).on('click', '#psv-marker-fox-polygon', function() {
  251. foxModal()
  252. })
  253. $(document).on('click', '#psv-marker-location-fox', function() {
  254. foxModal()
  255. })
  256. $(document).on('click', '#psv-marker-location-road', function() {
  257. if(!$('#p3-road-pic')[0]){
  258. var roadHtml = ` <div class="mod-full-picture" id="p3-road-pic" style="display:none">
  259. <div class="bg-move"></div>
  260. <div class="pub-btn go-back">返回</div>
  261. <div class="eyes-btn" id="open-eyes-modal"></div>
  262. <div class="full-pic-modal small-modal">
  263. <div class="top-bar">
  264. 北欧森林
  265. </div>
  266. <div class="container clearfix">
  267. <p>虽然北欧人最喜欢到地中海度假,享受这里的阳光和沙滩。不过南欧的地中海人也是很羡慕北欧的人口稀少,森林密布的环境,那些难忘的原始森林,河流,湖泊,小动物等等。</p>
  268. <p>米兰·昆德拉说,生活在别处。倘若有一处,萃集了生活的美好,又何必另觅他乡? 冰岛的极光,瑞典的冰雪,目眩神驰的北欧风光里,最让人向往的还是森林里一口深呼吸带来的焕然一新。在这个世界上,还有什么比生命的健康活力更重。</p>
  269. <div class="eyes-btn" id="screen-open-video"></div>
  270. </div>
  271. </div>
  272. <div class="fullscreen-video fullscreen-video-picture" style="display: none">
  273. <video x5-playsinline="" webkit-playsinline playsinline controls id="picture-video" preload="metadata" width="100%">
  274. <source src="${mp4UrlMap['picVideo']}">
  275. </video>
  276. </div>
  277. </div>`
  278. $('body').append(roadHtml)
  279. }
  280. util.acceler()
  281. $('#p3-road-pic').fadeIn()
  282. if(!progressFlag['road']){
  283. progressFlag['road'] = true
  284. $('#cur-progress').html(++progressNum)
  285. progressNum == allStep ? localStorage.setItem('hunter_permision', '4') : ''
  286. }
  287. })
  288. //moblie 
  289. $(document).on('click', '#open-eyes-modal', function() {
  290. var showFlag = $('.full-pic-modal').css('display') == 'none' ? false : true
  291. showFlag ? $('.full-pic-modal').fadeOut() : $('.full-pic-modal').fadeIn()
  292. })
  293. $(document).on('click', '#screen-open-video', function() {
  294. $('.fullscreen-video-picture').show()
  295. var video = document.getElementById('picture-video')
  296. video.play()
  297. video.addEventListener("ended",function(){
  298. video.load()
  299. $('.fullscreen-video-picture').hide()
  300. })
  301. return false
  302. })
  303. // 完成任务提示弹窗
  304. $(document).on('click', '.go-back', function() {
  305. progressNum == allStep ? $('.complete-modal').fadeIn() : ''
  306. })
  307. $('.complete-success-btn').click(function() {
  308. $('.complete-modal').remove()
  309. $('.book-icon').trigger('click')
  310. })
  311. },
  312. playVideo() {
  313. $('#hunter-video-play').click(function() {
  314. if(!$('#hunter-video-suggest')[0]){
  315. var hunterVideoHtml = `<div class="video-wrapper pub-modal-mask" id="hunter-video-suggest">
  316. <div class="part-screen">
  317. <video x5-playsinline="" webkit-playsinline playsinline controls autoplay id="hunter-video">
  318. <source src="${mp4UrlMap['hunt']}">
  319. </video>
  320. </div>
  321. </div>`
  322. $('body').append(hunterVideoHtml)
  323. } else {
  324. $('#hunter-video-suggest').show()
  325. }
  326. return false
  327. })
  328. },
  329. // 瞭望台
  330. lookoutClick() {
  331. var videoHtml = `<div class="fullscreen-video fullscreen-video-lookout">
  332. <video x5-playsinline="" webkit-playsinline playsinline id="lookout-video" controls autoplay width="100%">
  333. <source src="${mp4UrlMap['lookup']}">
  334. </video>
  335. </div>`
  336. $(document).on('click', '#psv-marker-glass', function() {
  337. if(!$('#lookout-hunt-pic')[0]){
  338. var lookOutHtml = ` <div class="mod-full-picture" id="lookout-hunt-pic" style="display:none">
  339. <div class="pub-btn go-back">返回</div>
  340. <img class="e-tips" src="${eUrl}" alt="">
  341. </div>`
  342. $('body').append(lookOutHtml)
  343. }
  344. $('#lookout-hunt-pic').fadeIn()
  345. if(!progressFlag['lookout']){
  346. progressFlag['lookout'] = true
  347. $('#cur-progress').html(++progressNum)
  348. progressNum == allStep ? localStorage.setItem('hunter_permision', '4') : ''
  349. }
  350. })
  351. // 轻触屏幕
  352. $(document).on('click', '#lookout-hunt-pic', function(e) {
  353. var lookVideo = document.getElementById('lookout-video')
  354. if(lookVideo) {
  355. $('#lookout-hunt-pic').find('.fullscreen-video').fadeIn()
  356. lookVideo.play()
  357. } else{
  358. $('#lookout-hunt-pic').append(videoHtml)
  359. lookVideo = document.getElementById('lookout-video')
  360. lookVideo.play()
  361. }
  362. lookVideo.addEventListener("ended",function(){
  363. lookVideo.load()
  364. lookVideo.pause()
  365. $('.fullscreen-video-lookout').hide()
  366. $('#lookout-hunt-pic').hide()
  367. })
  368. })
  369. },
  370. }
  371. function screenInit() {
  372. // 竖屏
  373. if(window.orientation==180||window.orientation==0){
  374. $('.across-modal').show()
  375. }
  376. // 横屏
  377. if(window.orientation==90||window.orientation==-90){
  378. $('.across-modal').hide()
  379. if(viewer) return
  380. let entry = localStorage.getItem('entry')
  381. if(entry == 'index') {
  382. util.handleModel()
  383. huntV.init()
  384. huntC.init()
  385. } else {
  386. window.location.href = indexPath
  387. }
  388. }
  389. }
  390. screenInit()
  391. window.addEventListener("onorientationchange" in window ? "orientationchange" : "resize", screenInit, false);
  392. $(function() {
  393. attachFastClick(document.body);
  394. });