<!-- 自定义消息弹窗 -->
<div id="customMessage"></div>
.customMessage {
opacity: 0;
position: absolute;
top: 15px;
left: 50%;
transform: translateX(-50%);
color: #000000e0;
font-size: 14px;
padding: 10px 20px;
z-index: 9999;
border-radius: 8px;
background-color: #ffffff;
transition: opacity 0.5s ease;
}
.messageSuccess {
color: #5eb11e;
border: 1px solid #b7eb8f;
background-color: #f6ffed;
}
.messageInfo {
color: #1966ae;
border: 1px solid #91caff;
background-color: #e6f4ff;
}
.messageWarning {
color: #c9a223;
border: 1px solid #ffe58f;
background-color: #fffbe6;
}
.messageError {
color: #d01a0a;
border: 1px solid #ffccc7;
background-color: #fff2f0;
}
.customLoading {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 60px;
height: 60px;
z-index: 9999;
}
// 弹窗的方法
const showMessage = (text, className) => {
const customMessageElement = document.getElementById("customMessage");
customMessageElement.style.opacity = "1";
customMessageElement.className = className;
customMessageElement.innerHTML = `<p>${text}</p>`;
setTimeout(() => {
customMessageElement.style.opacity = "0";
}, 5000);
};
const message = {
success: (text) => {
showMessage(text, "customMessage messageSuccess");
},
info: (text) => {
showMessage(text, "customMessage messageInfo");
},
warning: (text) => {
showMessage(text, "customMessage messageWarning");
},
error: (text) => {
showMessage(text, "customMessage messageError");
},
};
// 搜索地名
const searchPlace = () => {
const keyWord = document.getElementById("searchPlaceInput").value;
if (keyWord === "") {
message.error("请输入地名");
return;
}
localsearch.search(keyWord);
};
<!-- 自定义Loading-->
<svg viewBox="0 0 50 50" class="customLoading" id="customLoading">
<circle cx="25" cy="25" r="20" fill="none" class="path"></circle>
</svg>
.path {
stroke: #409eff; /*给画笔设置一个颜色*/
stroke-width: 3; /*设置线条的宽度*/
stroke-dasharray: 95, 126; /*设置实现长95,虚线长126*/
stroke-dashoffset: 0; /*设置虚线的偏移位置*/
animation: loading-dash 1.5s ease-in-out infinite;
}
@keyframes loading-dash {
0% {
stroke-dasharray: 1, 126; /*实线部分1,虚线部分126*/
stroke-dashoffset: 0; /*前面1/126显示实线,后面125显示空白*/
}
50% {
stroke-dasharray: 95, 126; /*实线部分95,虚线部分126*/
stroke-dashoffset: -31px; /*顺时针偏移31/126,即前31/126显示空白,后面3/4显示线条*/
}
to {
stroke-dasharray: 6, 120; /*实线部分6,虚线部分120*/
stroke-dashoffset: -120px; /*最后顺时针偏移120/126,即前120/126显示空白,后面6点显示线条部分*/
}
}
// Loading的显示隐藏
const handleLoading = (isShow) => {
document.getElementById("customLoading").style.display = isShow ? "block" : "none";
};
const initMap = () => {
...其他代码
initSearch();
handleLoading(false);
};
此页面不支持夜间模式!
已进入夜间模式!
已进入普通模式!
搜索框不允许为空
签到成功!经验+5!芋圆币+2!
签到失败!今日已签到!
需要登录社区账号才可以进入!