You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
<!DOCTYPE html><html lang="zh-CN"> <head> <meta charset="UTF-8" /> <link rel="icon" href="/favicon.ico" /> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> <title>新时代、新龙头、新节奏</title> <style> * { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: "Microsoft Yahei", sans-serif; } /* 落地页 */ .landing-page { width: 375px; height: auto; margin: 0 auto; overflow-y: auto; overflow-x: hidden; } .landing-page img { width: 100%; height: auto; display: block; } /* 弹窗 */ .popup { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.7); justify-content: center; align-items: center; z-index: 999; } .popup.show { display: flex; } .popup-content { width: 320px; text-align: center; } .popup-content img { width: 100%; height: auto; margin-bottom: 15px; } .popup-content img#closeBtn { width: 60%; margin-bottom: 5px; } </style> </head> <body> <!-- 落地页 --> <div class="landing-page"> <img id="landingImage" /> </div>
<!-- 弹窗样式 --> <div class="popup" id="popup"> <div class="popup-content"> <img id="popupImage" /> <img src="./assent/开心收下.png" id="closeBtn"/> </div> </div>
<script type="module"> // 导入API函数 import { getImageApi } from './src/api/member.js';
// 获取弹窗元素 const landingImage = document.getElementById('landingImage'); const popupImage = document.getElementById('popupImage'); const popup = document.getElementById("popup"); const closeBtn = document.getElementById("closeBtn");
// 获取图片方法 async function getImage() { try { const res = await getImageApi(); if (res.code == 200 && response.data) { return { landingImageUrl: response.data.landingImage, popupImageUrl: response.data.popupImage }; } else { console.warn('网络错误,请稍后重试'); } } catch (error) { console.error('网络错误,请稍后重试'); } }
// 加载 window.onload = async function () { try { const imagePaths = await getImage(); // landingImage.src = imagePaths.landingImageUrl; // popupImage.src = imagePaths.popupImageUrl; landingImage.src = './assent/8折页面.png'; popupImage.src = './assent/弹窗样式2.png';
// 弹窗展示 setTimeout(() => { popup.classList.add("show"); }, 500); } catch (err) { console.error('页面初始化失败'); } };
// 点击"开心收下",关闭弹窗 closeBtn.addEventListener('click', function() { popup.classList.remove("show"); });
// 点击弹窗空白处,关闭弹窗 popup.addEventListener('click', function(e) { if (e.target === popup) { popup.classList.remove("show"); } }); </script> </body></html>
|