| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448 | <template>    <!-- @touchstart="touchstartFunc" -->    <div class="panoramic-components">        <!-- 刷新按钮 -->        <!-- <div class="refresh-btn" @click="refreshPage">            <img src="https://dm.static.elab-plus.com/refresh-btn.png">        </div> -->        <!-- 引导用户  触屏图片 -->        <div v-if="pvCurPageName!='webgl_clipImg'" class="prompt-720-img" :class="isTouchstart ? 'img-hide' : ''">            <img src="https://dm.static.elab-plus.com/guide-mask.png" />        </div>        <!-- 封面引导 蒙层图 -->        <div class="krpano-img-before" :class="videoBefore ? '' : 'hide'">            <img src="https://dm.static.elab-plus.com/hqc-loading.png" />        </div>        <!-- <div class="play-img" :class="isPlayImg ? 'play-img-show': ''">            <img src="https://dm.static.elab-plus.com/hqc-img/play-img.png" />        </div> -->        <!-- 免责声明 -->        <!-- <div class="disclaimer">            <a                href="https://dm-mng.elab-plus.cn/touFangBao/index.html#/pages/preview?id=3176&templateCode=0&brandId=52&foot=no">本资料仅供宣传参考示意</a>        </div> -->        <!-- krpano -->        <div id="panoramic-krpano" :style="{'height':canvasHeight+'px'}"></div>    </div></template><script>    // import BScroll from 'better-scroll';    const panoramicXML = require("./panoramic.xml");    const panoramicNODragXML = require("./panoramic_no_drag.xml");	const util = require('@/utils/util.js').default;    export default {        data() {            return {                tabList: [],                selectTabIndex: 0,                isPayVoice: false,                isPromptShow: true,                sceneObj: { id: '', name: '' },                isTouchstart: false, // 是否触屏一次                isShowOneGuideMask: false, //是否显示过一次引导用户出的操作                videoBefore: true,//显示引导蒙层图				sceneLoaded:false,//场景是否加载完毕了				peopleData:null,				petData:null,				redBoxData:null,				bgMusicData:null,            }        },		props:{			videoUrl: {				type: String,				default: '',			},			bgUrl: {				type: String,				default: '',			},			muted: {				type: [Boolean,String],				default: true,			},			// scale: {			// 	type: [Number,String],			// 	default: 1,			// },			coordinate: {				type: String,				default: '',			},		},		watch: {			videoUrl: {				handler(newVal,oldVal) {					if (newVal && newVal.length>0) {						console.warn("***videoUrl-webgl_rxdz_krpanoVideo***", newVal,oldVal)						if(this.sceneLoaded){							// this.playVideo(newVal)						}					}				},				immediate:true,			},			bgUrl: {				handler(newVal,oldVal) {					console.warn("***bgUrl-webgl_rxdz_krpanoVideo***", newVal,oldVal)					if(this.panoramicKrpano){						this.setSphereUrl(newVal)					}				},				immediate: true,			},			muted: {				handler(newVal,oldVal) {					console.warn("***muted-webgl_rxdz_krpanoVideo***", newVal,oldVal)					if(this.panoramicKrpano){						this.panoramicKrpano.call(`toggleMute(${newVal})`);					}				},				immediate: true,			},			// coordinate: {			// 	handler(newVal,oldVal) {			// 		console.warn("***coordinate-webgl_rxdz_krpanoVideo***", newVal,oldVal)			// 	},			// 	immediate: true,			// },		},        methods: {			redBoxChange(type){				// console.warn("**redBoxChange****",type)				if(type=='add'){					let url = "https://dm.static.elab-plus.com/miniProgram/redbox.mp4"					if(this.$parent.isIOS){						wx.config({							debug: false,							appId: '',							timestamp: '',							nonceStr: '',							signature: '',							jsApiList: []						})						wx.ready(()=> {							// 在这里面进行操作即可,估计应该是微信的sdk对Safari的内核做了一些对应的操作吧							this.panoramicKrpano.call(`showRedBox(${url})`);						})					}else{						this.panoramicKrpano.call(`showRedBox(${url})`);					}				}else if(type=='canel'){					this.panoramicKrpano.call(`hideRedBox()`);				}			},			scaleChange(scale,tabIndex){				console.warn("**scaleChange****",scale,tabIndex)				if(tabIndex==0){//数字人					this.panoramicKrpano.call(`scalePeopleChange(${scale})`);				}else if(tabIndex==1){//数字宠物					this.panoramicKrpano.call(`scalePetChange(${scale})`);				}			},			initPeople(item){				if(item.url){					this.playVideo(item.url)				}				if(item.scale){					this.panoramicKrpano.call(`scalePeopleChange(${item.scale})`);				}				if(item.ath){					let object = this.panoramicKrpano.get("hotspot[video]");					object.ath = item.ath;					object.atv = item.atv;					//移动视角到AI人物上					this.panoramicKrpano.set('view.hlookat', item.ath);					this.panoramicKrpano.set('view.vlookat', item.atv);				}			},			initPet(item){				if(item.url){					this.playPetVideo(item.url)				}				if(item.scale){					this.panoramicKrpano.call(`scalePetChange(${item.scale})`);				}				if(item.ath){					let object = this.panoramicKrpano.get("hotspot[petVideo]");					object.ath = item.ath;					object.atv = item.atv;				}			},			initRedBox(item){				if(item.url){					this.redBoxChange('add')				}				if(item.ath){					let object = this.panoramicKrpano.get("hotspot[redBox]");					object.ath = item.ath;					object.atv = item.atv;				}			},			initbgMusic(item){				if(item.url){					this.playBgMusic(item.url)				}			},			aiChange(item,type,tabIndex){				console.warn("**aiChange****",item,type,tabIndex)				if(tabIndex==0){					if(type=='add'){						this.playVideo(item.url)					}else if(type=='canel'){						this.stopPeopleVideo()					}				}else if(tabIndex==1){					if(type=='add'){						this.playPetVideo(item.url)					}else if(type=='canel'){						this.stopPetVideo()					}				}else if(tabIndex==3){					if(type=='add'){						this.playBgMusic(item.url)					}else if(type=='canel'){						this.stopBgMusic()					}				}			},			playVideo(url){				if(this.$parent.isIOS){					wx.config({						debug: false,						appId: '',						timestamp: '',						nonceStr: '',						signature: '',						jsApiList: []					})					wx.ready(()=> {						// 在这里面进行操作即可,估计应该是微信的sdk对Safari的内核做了一些对应的操作吧						this.panoramicKrpano.call(`playSceneName(${url})`);					})				}else{					this.panoramicKrpano.call(`playSceneName(${url})`);				}				console.warn("***playSceneName-playVideo***")			},			stopPeopleVideo(){				this.panoramicKrpano.call(`stopPeopleVideo()`);				console.warn("***playSceneName-stopPeopleVideo***")			},			playPetVideo(url){				// this.panoramicKrpano.call(`playPetVideo(${url})`);				if(this.$parent.isIOS){					wx.config({						debug: false,						appId: '',						timestamp: '',						nonceStr: '',						signature: '',						jsApiList: []					})					wx.ready(()=> {						// 在这里面进行操作即可,估计应该是微信的sdk对Safari的内核做了一些对应的操作吧						this.panoramicKrpano.call(`playPetVideo(${url})`);					})				}else{					this.panoramicKrpano.call(`playPetVideo(${url})`);				}				console.warn("***playSceneName-playPetVideo***")			},			stopPetVideo(){				this.panoramicKrpano.call(`stopPetVideo()`);				console.warn("***playSceneName-stopPetVideo***")			},            playBgMusic(url){				this.panoramicKrpano.call(`playBgMusic(${url})`);			},			stopBgMusic(url){				this.panoramicKrpano.call(`closeVoice()`);			},			panoramic() {				console.warn("***panoramicKrpano***",this.videoUrl)                this.panoramicKrpano = document.getElementById('panoramic');				if(this.bgUrl){					// 设置全景图的路径					this.setSphereUrl(this.bgUrl)				}                // 场景加载完毕了				window.sceneload = ()=>{					console.warn("***sceneLoad***")					this.videoBefore = false;					this.sceneLoaded = true;					// this.playVideo();//播放绿幕视频					if(this.peopleData && this.peopleData.ath){						this.initPeople(this.peopleData)					}					if(this.petData && this.petData.ath){						this.initPet(this.petData)					}					if(this.redBoxData && this.redBoxData.ath){						this.initRedBox(this.redBoxData)					}					if(this.bgMusicData && this.bgMusicData.url){						this.initbgMusic(this.bgMusicData)					}				}                // 视频加载完                window.videoready = () => {					console.warn("***videoready***",this.$parent.isIOS,this.isTouchstart)                    // 兼容苹果手机, 当视频加载完也算触屏了, 显示引导用户触屏					if(this.$parent.isIOS){						if (!this.isShowOneGuideMask) {						    // 视频加载完						    this.isTouchstart = true;						}					}                };                // 视频暂停了,自动刷新页面, 并且保存,当前的参数                window.videopausedFunc = () => {                }				//截图成功了				window.show_img = (shottingImg) => {					console.warn("***show_img***",shottingImg)					let param = {						type: 'CLK', //埋点类型						clkId: 'clk_2cmina_23121401', //点击ID						clkName: 'webgl_cover_clk', //点击前往的页面名称						clkParams: {							locusName: "封面确认",							locusValue: shottingImg						}					};					util.trackRequest(param);					if(window.__wxjs_environment === 'miniprogram'){						wx.miniProgram.postMessage({data: {bgUrl:shottingImg}})						wx.miniProgram.navigateBack();					}else{						window.location.href = shottingImg					}				}								// 视频播放				window.onvideoplay = () => {					console.warn("***onvideoplay***")				}				document.addEventListener("touchend", ()=> {					if(this.isShowOneGuideMask==false){						this.isShowOneGuideMask = true;						this.isTouchstart = true;					}					// console.warn("***kpanoraTouch***",this.isTouchstart)				})				window.getScaleHandle = (scale) => {					console.warn("***getScaleHandle***",scale)				}            },			makescreenshot(){				// let screenshotcanvas = this.panoramicKrpano.webGL("krpano[webGL]");				let pix = 1 || window.devicePixelRatio;				let x = parseInt(this.$parent.bottomLeftX*pix);				let y = parseInt(this.$parent.top*pix);				let width = parseInt(this.$parent.width*pix);				let height = parseInt(this.$parent.height*pix);				console.warn("***screenshotcanvas***",x,y,width,height)				this.panoramicKrpano.call("makescreenshot("				+ x+','				+ y+','				+ width+','				+ height+")");			},			// getScale(){			// 	let video = this.panoramicKrpano.get("hotspot[video]");			// 	console.warn("***getPeolpeScale***",video.scale);			// },			// getPetScale(){			// 	let petVideo = this.panoramicKrpano.get("hotspot[petVideo]");			// 	console.warn("***getPetScale***",petVideo.scale);			// },			getPosition(){				let posi = {}				let video = this.panoramicKrpano.get("hotspot[video]");				if(video && video.visible){					posi.peopleAth = video.ath;					posi.peopleAtv = video.atv;				}				let petVideo = this.panoramicKrpano.get("hotspot[petVideo]");				if(petVideo && petVideo.visible){					posi.petAth = petVideo.ath;					posi.petAtv = petVideo.atv;				}				let redBox = this.panoramicKrpano.get("hotspot[redBox]");				if(redBox && redBox.visible){					posi.redBoxAth = redBox.ath;					posi.redBoxAtv = redBox.atv;				}				// console.warn("***getPosition***",posi);				return posi			},			setPosition(position){				let video = this.panoramicKrpano.get("hotspot[video]");				let image_hotspot = this.panoramicKrpano.get("hotspot[image_hotspot]");				video.ath = position.ath;				video.atv = position.atv;				if(image_hotspot){					image_hotspot.ath = position.ath;					image_hotspot.atv = position.atv;				}				//移动视角到AI人物上				this.panoramicKrpano.set('view.hlookat', position.ath);				this.panoramicKrpano.set('view.vlookat', position.atv);				console.warn("***setPosition***",position);			},			//设置全景图图片地址			setSphereUrl(url){				if(!url){					return false				}				this.panoramicKrpano.set("panorama_url",url)				console.warn("***setSphereUrl***",url);			},			//设置视频地址			// setVideoUrl(url){			// 	if(!url){			// 		return false			// 	}			// 	this.panoramicKrpano.set("video_url",url)			// 	console.warn("***setVideoUrl***",url);			// },        },        mounted() {            embedpano({                swf: "https://dm.static.elab-plus.com/krpano.swf",                xml: this.$parent.pvCurPageName == 'add_AI_people' ? panoramicXML : panoramicNODragXML,                bgcolor: "#fff",                target: "panoramic-krpano",                passQueryParameters: false,                consolelog: true,                id: "panoramic",                mobilescale: 0.5, //移动设备缩放,1表示不缩放,默认0.5                onready: this.panoramic,            });        },        created() {			console.warn("***this.type***")			let screenWidth = window.screen.width;			let screenHeight = window.screen.height;			if (window.innerWidth && window.screen.width) {				screenWidth = Math.min(window.innerWidth, window.screen.width)			}			if (window.innerHeight && window.screen.height) {				screenHeight = Math.min(window.innerHeight, window.screen.height)			}			this.canvasHeight = this.$parent.pvCurPageName == 'add_AI_people' ? screenWidth : screenHeight;			this.pvCurPageName = this.$parent.pvCurPageName            // // 监听屏幕大小变化            // window.addEventListener('resize', ()=>{            // });        },        beforeDestroy() {            // this.panoramicKrpano.call(`closeVoice()`);        }    }</script><style scoped lang="scss">    @import "index.scss";</style>
 |