MMB-Design-dev

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

const iframe = document.querySelector('#design-iframe') 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 'gallery':{ window.location.href = `https://global.rokid.com/pages/mmb-gallery-dev`; 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 'windowOpen':{ const url = data.url const a = document.createElement('a'); a.href = url; a.target = '_blank'; a.rel = 'nofollow'; a.click() document.removeChild(a); 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'