搜索 内容详情
电脑网页弹窗提示下载app二维码
lan988 级别:管理员  + 关注    收藏 支持(0) | 反对(0)原内容


 <!--弹窗提示下载app二维码-->
<style>
   .app-popup {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #f9f9f9; /* 更柔和的背景色 */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); /* 添加阴影增加立体感 */
    padding: 25px; /* 增加内边距 */
    border-radius: 8px; /* 圆角边框 */
    z-index: 9999;
    max-width: 400px; /* 限制最大宽度,避免在大屏幕上显得过大 */
    text-align: center; /* 内容居中 */
}

.app-popup p {
    font-size: 18px; /* 增大提示文字字体大小 */
    margin-bottom: 20px; /* 增加提示文字与二维码之间的间距 */
}

.app-popup img {
    max-width: 100%; /* 确保二维码图片不超出弹窗宽度 */
}

.app-popup button {
    padding: 10px 20px; /* 增大按钮内边距 */
    background-color: #007bff; /* 按钮背景色 */
    color: white; /* 按钮文字颜色 */
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease; /* 添加过渡效果 */
}

.app-popup button:hover {
    background-color: #0056b3; /* 鼠标悬停时按钮背景色变化 */
}
  </style>
 <script>
    // 检查是否在 1 小时内已选择不再提示
    var oneHourAgo = new Date(Date.now() - 60 * 60 * 1000);
    var shouldShowPopup =!localStorage.getItem('popupClosedFor1Hour') || new Date(localStorage.getItem('popupClosedFor1Hour')) < oneHourAgo;

    window.onload = function () {
      if (shouldShowPopup) {
        // 创建弹窗元素
        var popup = document.createElement('div');
        popup.className = 'app-popup';

        // 提示语
        var text = document.createElement('p');
        text.innerHTML = '用手机扫一扫二维码<br>下载我们 APP 浏览更方便!';
        popup.appendChild(text);

        // 二维码容器
        var qrContainer = document.createElement('div');
        popup.appendChild(qrContainer);

        // 创建二维码图片元素
        var qrImage = document.createElement('img');
        qrImage.src = '/images/跳转下载app.png';
        qrContainer.appendChild(qrImage);

        // 关闭按钮
        var closeButton = document.createElement('button');
        closeButton.textContent = '关闭';
        closeButton.onclick = function () {
          popup.style.display = 'none';
        };
        popup.appendChild(closeButton);

        // “1 小时内不再提示”按钮
        var dontShowFor1HourButton = document.createElement('button');
        dontShowFor1HourButton.textContent = '1 小时内不再提示';
        dontShowFor1HourButton.onclick = function () {
          localStorage.setItem('popupClosedFor1Hour', new Date().toISOString());
          popup.style.display = 'none';
        };
        popup.appendChild(dontShowFor1HourButton);

        // 将弹窗添加到页面中
        document.body.appendChild(popup);

        // 显示弹窗
        popup.style.display = 'block';
      }
    };
  </script>


回到顶部顶端 回到底部底部