import '../scss/index.scss' import '../scss/page/scene1.scss' import PhotoSphereViewer from 'photo-sphere-viewer' import util from './until' import Pic from '../img/P3.jpg' import location from '../img/location.png'; import glass from '../img/glass.png'; //望远镜 import eUrl from '../img/E.png'; var viewer = null var huntFlag = false var indexPath = $('body').attr('data-path') // 进度相关 var progressNum = 0 var allStep = 5 var progressFlag = { 'bear': false, 'lynx': false, 'road': false, 'lookout': false, 'fox': false } var mp4UrlMap = { } var huntV = { init() { this.initSnowView() this.handleReady() this.getVideoSource() this.handleNav() }, initSnowView() { viewer = new PhotoSphereViewer({ container: 'photosphere', panorama: Pic, min_fov: 50, max_fov: 70, navbar: false, time_anim: false, markers: [ // 野牛 { id: 'beer-polygon', polygon_px: [ [4115, 1487], [4115, 1696], [4410, 1696],[4410, 1487] ], svgStyle: { fill: 'rgba(255, 255, 255, 0)' } }, { id: 'location-beer', x: 4247, y: 1514, image: location, width: 35, height: 35, anchor: 'bottom center', }, // 野猪 { id: 'lynx-polygon', polygon_px: [ [2160, 1696], [2160, 1834], [2324, 1834],[2324, 1696] ], svgStyle: { fill: 'rgba(255, 255, 255, 0)' } }, { id: 'location-lynx', x: 2225, y: 1726, image: location, width: 35, height: 35, anchor: 'bottom center', }, // 狐狸 { id: 'fox-polygon', polygon_px: [ [5394, 1470], [5394, 1706], [5614, 1706],[5614, 1470] ], svgStyle: { fill: 'rgba(255, 255, 255, 0)' } }, { id: 'location-fox', x: 5546, y: 1514, image: location, width: 35, height: 35, anchor: 'bottom center', }, // 望远镜 { id: 'glass', x: 310, y: 1000, image: glass, width: 56, height: 59, anchor: 'bottom center', }, // 铁路 { id: 'location-road', x: 3506, y: 1772, image: location, width: 35, height: 35, anchor: 'bottom center', }, ] }) }, handleReady() { viewer.on('ready', function() { $('.loading-bg').hide() viewer.rotate({ x: 0, y: 0 }); viewer.animate({ x: 4194, y: 1562 },2000); }); viewer.on('position-updated', function(position) { let lgt = position.longitude let lat = position.latitude if(lgt < 1.07 && lat < 0.008 && !huntFlag) { huntFlag = true $('#hunter-suggest-modal').fadeIn() $('.nav').fadeIn() } }) }, getVideoSource() { let vids = ['8893041','8892081','8893039','8892073','8892091','8890691','8890693','8890695','8892919'] var videoEls = { '8892073': 'lookup', '8892091': 'hunt', '8893041': 'aim', '8892081': 'shoot', '8893039': 'open', '8890691': 'book-lake', '8890693': 'book-taiga', '8890695': 'book-elden', '8892919': 'picVideo' } $.ajax({ type: "GET", dataType: "json", url: `//video.duowan.com/jsapi/playPageVideoInfo/?vids=${vids.join(',')}`, success: function(data) { for(var i in data) { let resouce = util.deCodeArg(data[i].c).all, source = resouce.yuanhua || resouce[1300] || resouce[1000] || resouce[350] let name = videoEls[i] mp4UrlMap[name] = source.src } document.getElementById('open-video').src = mp4UrlMap['open'] document.getElementById('aim-video').src = mp4UrlMap['aim'] document.getElementById('shoot-video').src = mp4UrlMap['shoot'] document.getElementById('book-lake-video').src = mp4UrlMap['book-lake'] document.getElementById('book-taiga-video').src = mp4UrlMap['book-taiga'] document.getElementById('book-elden-video').src = mp4UrlMap['book-elden'] huntC.lookoutClick() huntC.playVideo() } }) }, // 导航权限处理 handleNav() { // 初始化加载时 let permision = localStorage.getItem('hunter_permision') if(permision < 3) { window.location.href = indexPath } if(permision == 4) { progressFlag = { 'bear': true, 'lynx': true, 'road': true, 'lookout': true, 'fox': true } $('#cur-progress').html(5) } } } var huntC = { init() { this.modalShow() util.bookClick() util.toolbarClick() util.shooting() }, modalShow() { // 点击显示介绍弹窗 $('.nav').find('.current').click(function() { $('#hunter-suggest-modal').fadeIn() }) // 黑熊 function beerModal() { if($('#hunter-beer-modal').css('display') == 'none') { $('.pub-modal').hide() $('#hunter-beer-modal').fadeIn() viewer.animate({ x: 4194, y: 1562 },600); } if(!progressFlag['bear']){ progressFlag['bear'] = true $('#cur-progress').html(++progressNum) progressNum == allStep ? localStorage.setItem('hunter_permision', '4') : '' progressNum == allStep ? $('.complete-modal').fadeIn() : '' } } $(document).on('click', '#psv-marker-beer-polygon', function() { beerModal() }) $(document).on('click', '#psv-marker-location-beer', function() { beerModal() }) // lynx function lynxModal() { if($('#hunter-lynx-modal').css('display') == 'none') { $('.pub-modal').hide() $('#hunter-lynx-modal').fadeIn() viewer.animate({ x: 2231, y: 1756 },600); } if(!progressFlag['lynx']){ progressFlag['lynx'] = true $('#cur-progress').html(++progressNum) progressNum == allStep ? localStorage.setItem('hunter_permision', '4') : '' progressNum == allStep ? $('.complete-modal').fadeIn() : '' } } $(document).on('click', '#psv-marker-lynx-polygon', function() { lynxModal() }) $(document).on('click', '#psv-marker-location-lynx', function() { lynxModal() }) // fox function foxModal() { if($('#hunter-fox-modal').css('display') == 'none') { $('.pub-modal').hide() $('#hunter-fox-modal').fadeIn() viewer.animate({ x: 5514, y: 1598 },600); } if(!progressFlag['fox']){ progressFlag['fox'] = true $('#cur-progress').html(++progressNum) progressNum == allStep ? localStorage.setItem('hunter_permision', '4') : '' progressNum == allStep ? $('.complete-modal').fadeIn() : '' } } $(document).on('click', '#psv-marker-fox-polygon', function() { foxModal() }) $(document).on('click', '#psv-marker-location-fox', function() { foxModal() }) // 开始狩猎 $('.hunt-btn').click(function(){ $('#hunter-beer-modal').hide() $('#equit-modal').show() }) $('.nav-item-wrap').click(function() { $('.nav-item-wrap').removeClass('active') $(this).parents('.container').find('.main').hide() $(this).addClass('active') var ind = $(this).attr('data-ind') if(ind == 1){ $('#weapon-modal').show() } if(ind == 2){ $('#fodder-modal').show() } if(ind == 3){ $('#aim-modal').show() } }) $(document).on('click', '#psv-marker-location-road', function() { if(!$('#p3-road-pic')[0]){ var roadHtml = `
` $('body').append(roadHtml) util.bgMove($('.mod-full-picture')) } $('#p3-road-pic').fadeIn() if(!progressFlag['road']){ progressFlag['road'] = true $('#cur-progress').html(++progressNum) progressNum == allStep ? localStorage.setItem('hunter_permision', '4') : '' } }) $(document).on('click', '.eyes-btn', function() { $('.fullscreen-video-picture').show() var video = document.getElementById('picture-video') video.play() video.addEventListener("ended",function(){ video.load() $('.fullscreen-video-picture').hide() }) }) // 完成任务提示弹窗 $(document).on('click', '.go-back', function() { progressNum == allStep ? $('.complete-modal').fadeIn() : '' }) $('.complete-success-btn').click(function() { $('.complete-modal').remove() }) }, playVideo() { $('#hunter-video-play').click(function() { if(!$('#hunter-video-suggest')[0]){ var hunterVideoHtml = `