123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541 |
- <template>
-
- <div class="panoramic-components">
-
-
-
- <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 id="panoramic-krpano" :style="{'height':canvasHeight+'px'}"></div>
- </div>
- </template>
- <script>
-
- 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,
- scale:1,
- }
- },
- props:{
- videoUrl: {
- type: String,
- default: '',
- },
- bgUrl: {
- type: String,
- default: '',
- },
- muted: {
- type: [Boolean,String],
- default: true,
- },
-
-
-
-
- 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){
-
- }
- }
- },
- 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})`);
- let video = this.panoramicKrpano.get("hotspot[video]");
- if(video && video.visible){
- console.warn("**peopleAtv***",video.ath,video.atv)
- }
- }
- },
- immediate: true,
- },
-
-
-
-
-
-
- },
- methods: {
- 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(()=> {
-
- 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})`);
- let image_hotspot = this.panoramicKrpano.get("hotspot[image_hotspot]");
- if(image_hotspot){
- image_hotspot.scale = scale;
- }
- this.scale = 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})`);
- let image_hotspot = this.panoramicKrpano.get("hotspot[image_hotspot]");
- if(image_hotspot){
- image_hotspot.scale = item.scale;
- }
- this.scale = item.scale;
- }
- if(item.ath){
- let object = this.panoramicKrpano.get("hotspot[video]");
- object.ath = item.ath;
- object.atv = item.atv;
- let image_hotspot = this.panoramicKrpano.get("hotspot[image_hotspot]");
- if(image_hotspot){
- image_hotspot.ath = item.ath;
- image_hotspot.atv = item.atv;
- }
-
- this.panoramicKrpano.set('view.hlookat', item.ath);
- this.panoramicKrpano.set('view.vlookat', item.atv);
- }
- if(item.deg){
- this.panoramicKrpano.call(`rotateVideo(${item.deg})`);
- }
- },
- 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)
- }
- },
- rotateVideo(deg){
- this.panoramicKrpano.call(`rotateVideo(${deg})`);
- },
- updataVideoSize(item){
-
- if(!item.width || !item.height){
- item.width = 180;
- item.height = 320;
- }
- let object = this.panoramicKrpano.get("hotspot[video]");
- let image_hotspot = this.panoramicKrpano.get("hotspot[image_hotspot]");
- if(Number(item.width)>= Number(item.height)){
- let realWidth = 480;
- let realHeight = item.height/(item.width/480);
- object.width = realWidth;
- object.height = realHeight;
- object.scale = this.scale;
- if(image_hotspot){
-
- image_hotspot.width = realWidth;
- image_hotspot.height = realHeight;
- image_hotspot.scale = this.scale;
- image_hotspot.url = 'https://dm.static.elab-plus.com/miniProgram/shadow22.png';
- }
- }else{
- let realWidth = 180;
- let realHeight = item.height/(item.width/180);
- object.width = realWidth;
- object.height = realHeight;
- object.scale = this.scale;
- if(image_hotspot){
-
- image_hotspot.width = realWidth;
- image_hotspot.height = realHeight;
- image_hotspot.scale = this.scale;
- image_hotspot.url = 'https://dm.static.elab-plus.com/miniProgram/shadow11.png';
- }
- }
- console.warn("**updataVideoSize****",item.width,item.height,Number(item.width)>= Number(item.height),this.scale);
- },
- aiChange(item,type,tabIndex){
- console.warn("**aiChange****",item,type,tabIndex)
- if(tabIndex==0){
- if(type=='add'){
- this.playVideo(item.url);
- this.updataVideoSize(item);
- }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(()=> {
-
- 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){
-
- if(this.$parent.isIOS){
- wx.config({
- debug: false,
- appId: '',
- timestamp: '',
- nonceStr: '',
- signature: '',
- jsApiList: []
- })
- wx.ready(()=> {
-
- 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},${this.muted})`);
- },
- 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;
-
- setTimeout(()=>{
- if(this.peopleData && this.peopleData.ath){
- this.initPeople(this.peopleData)
- this.updataVideoSize(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)
- }
- console.warn("***sceneLoad1***",this.peopleData,this.petData,this.redBoxData,this.bgMusicData)
- },200)
-
- }
-
- window.videoready = () => {
- console.warn("***videoready***",this.$parent.isIOS,this.isTouchstart)
-
- if(this.$parent.isIOS){
- if (!this.isShowOneGuideMask) {
-
- this.isTouchstart = true;
- }
- }
- };
-
- window.videopausedFunc = () => {
- }
-
- window.toggleRedBox = () => {
- console.warn("***winLottery***")
- this.$parent.winLottery();
- }
-
- window.show_img = (shotImg='',shareImg='') => {
- console.warn("***show_img***",shotImg,shareImg)
- let param = {
- type: 'CLK',
- clkId: 'clk_2cmina_23121401',
- clkName: 'webgl_cover_clk',
- clkParams: {
- locusName: "封面确认",
- locusValue: shotImg
- }
- };
- util.trackRequest(param);
- this.$parent.closeToast();
- if(window.__wxjs_environment === 'miniprogram'){
- wx.miniProgram.postMessage({data: {bgUrl:shotImg,shareImg:shareImg}})
- wx.miniProgram.navigateBack();
- }else{
-
- window.open(shotImg)
- }
- }
-
-
- window.onvideoplay = () => {
- console.warn("***onvideoplay***")
- }
-
- document.addEventListener("touchend", ()=> {
- if(this.isShowOneGuideMask==false){
- this.isShowOneGuideMask = true;
- this.isTouchstart = true;
- }
-
- })
-
- document.addEventListener("click", ()=> {
- if(this.isShowOneGuideMask==false){
- this.isShowOneGuideMask = true;
- this.isTouchstart = true;
- }
-
- })
- window.getScaleHandle = (scale) => {
- console.warn("***getScaleHandle***",scale)
- }
- },
- makescreenshot(){
-
- 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);
- let hasRedBox = this.redBoxData && this.redBoxData.ath?true:false;
- console.warn("***screenshotcanvas***",x,y,width,height,hasRedBox)
- this.panoramicKrpano.call("makescreenshot("
- + x+','
- + y+','
- + width+','
- + height+','
- + hasRedBox+")");
- },
-
-
-
-
-
-
-
-
- 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;
- }
-
- 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;
- }
-
- 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);
- },
-
-
-
-
-
-
-
-
- },
- 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,
- onready: this.panoramic,
- });
- this.scale = this.$parent.peopleScale;
-
-
-
-
-
- },
- 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
-
-
-
- },
- beforeDestroy() {
-
- }
- }
- </script>
- <style scoped lang="scss">
- @import "index.scss";
- </style>
|