MMB-Gallery Detail-dev

Source: https://global.rokid.com/pages/mmb-gallery-detail-dev

const iframe = document.querySelector('#detail-iframe') const search = window.location.search iframe.src = iframe.src + search window.addEventListener('message', function(event) {   const data = JSON.parse(event.data);   const action = data.type   switch(action){     case 'redirect':{       window.location.href = `https://global.rokid.com/account/login?return_to=${window.location.href}`;       break;     } case 'homepage': { window.location.href = `https://global.rokid.com/pages/mmb-homepage-2025`; break; }     case 'gallery':{       window.location.href = `https://global.rokid.com/pages/mmb-gallery`;       break;     }     case 'resize':{       const value = data.value;       // height容错,考虑滚动条问题       iframe.style.height = value + 'px'       break;     }     case 'shopping':{       const url = data.url       window.open(url,'_blank');       break;     }     case 'toTop':{       timer = setTimeout(() => {         window.scrollTo(0,0);       },300)       break;     }     case 'toast': {       const value = data.value;       const toast = document.createElement('div');       toast.style.position = 'fixed';       toast.style.top = '45vh';       toast.style.left = 'calc(50vw - 125px)';       toast.style.width = '250px';       toast.style.color = '#fff';       toast.style.fontSize = '14px';       toast.style.textAlign = 'center';       toast.style.padding = '10px';       toast.style.borderRadius = '16px';       toast.style.backgroundColor = 'rgba(0, 0, 0, 0.8)';       toast.innerText = value       document.body.appendChild(toast);       setTimeout(() => {          document.body.removeChild(toast);       }, 2000);       break;     }   } }) window.addEventListener('message', function(event) {   const data = JSON.parse(event.data);   const action = data.type   const url = data.url   switch (action) {     case 'facebook':       window.open(url,'_blank');       break;     case 'twitter':       window.open(url,'_blank');       break;     case 'instagram':       const clipboard = data.clipboard       const width = document.documentElement.clientWidth;       window.navigator &&         window.navigator.clipboard &&         window.navigator.clipboard.writeText(clipboard);       setTimeout(()=>{         if(width > 500){           window.open(url,'_blank');         }else{           window.location.href = url         }       },1500)       break;   } })   const area = document.querySelector('.py-section')   area.style.setProperty('padding','0','important')   const container = area.querySelector('.container')   container.style.padding= '0'   container.style.margin= '0'   container.style.maxWidth= '100%'   const title = container.querySelector('.page-title')   title.style.display = 'none'   function getUrlParamsByKey(str){     const url = window.location.search     const array = url.replace('?','').split('&')     for(let item of array){       const [key, value] = item.split('=')       if(key === str) return value     }     return ''   }   const id = getUrlParamsByKey('id')   const platform = getUrlParamsByKey('platform')   const date = getUrlParamsByKey('date')   if(id && platform && date){     const headers = {       // 定义应用类型给账户中心service区分是web还是app,这里默认是web-n       type: 'web-n',       'Content-Type': 'application/json',     }     fetch('https://rcs.rokid.com/mmb/creation/shareNotify',{       method: 'post',       credentials: 'include',       body:JSON.stringify({id:parseInt(id), platform, date}),       headers     })   }