代码拉取完成,页面将自动刷新
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
.content {
width: 400px;
height: 400px;
border: 1px solid #eee;
border-radius: 6px;
box-shadow: 5px 5px 5px #ccc;
}
button {
width: 60px;
height: 30px;
line-height: 30px;
text-align: center;
background-color: #56a5f1;
color: white;
border: 1px solid #eee;
border-radius: 6px;
outline: none;
}
.mask {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(1,1,1,0.6);
}
.loading {
position: absolute;
top: 100px;
margin-left: 50%;
left: -50px;
width: 0px;
height: 0px;
border-top: 40px solid red;
border-right: 40px solid pink;
border-bottom: 40px solid greenyellow;
border-left: 40px solid orange;
border-radius: 50%;
}
.triangle {
display: inline-block;
width: 0px;
height: 0px;
border-top: 50px solid transparent;
border-right: 50px solid transparent;
border-bottom: 50px solid transparent;
border-left: 50px solid red;
transform: rotate(30deg);
}
</style>
<title>Document</title>
</head>
<body>
<label for="">音乐ID:</label>
<input type="text" placeholder="请输入id" class="id" value="28012031">
<p>
<label for="">请选择查看类型:</label>
<label for="song">歌曲</label>
<input type="radio" name="type" id="song" value="song">
<label for="lyric">歌词</label>
<input type="radio" name="type" id="lyric" value="lyric">
<label for="comments">评论</label>
<input type="radio" name="type" id="comments" value="comments">
<label for="detail">详情</label>
<input type="radio" name="type" id="detail" value="detail">
</p>
<br>
<button class="btn">搜索</button>
<div class="triangle"></div>
<p class="content"></p>
<div class="mask">
<div class="loading"></div>
</div>
<script src="./js/jquery-3.3.1.min.js"></script>
<script>
$(function() {
$('.btn').click(function() {
$('.mask').toggle()
var id = $('.id').val();
var type = $('input[type=radio]:checked').val();
let url = `https://api.imjad.cn/cloudmusic/`;
$.ajax({
// url: `https://api.imjad.cn/cloudmusic/?type=${type}&id=${id}&br=128000`,
url,
method: 'GET',
data: {
type: type,
id,
br: '128000'
},
success: function(result) {
$('.mask').toggle()
console.log(result)
let text = ''
if(type == 'song') {
text = `<a href=${result.data[0].url} target=_blank>点击试听</a>`
}else if(type == 'lyric') {
text = ''
}else if(type == 'comments') {
text = ''
}else if(type == 'detail') {
text = `<img width=350 height=350 src=${result.songs[0].al.picUrl}>`;
}
$('.content').html(text)
}
})
})
})
</script>
</body>
</html>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。