-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmusic.html
188 lines (170 loc) · 4.09 KB
/
music.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body {
margin: auto;
padding: 0;
}
.div {
width: 100%;
max-width: 430px;
height: 48px;
padding: 0, 100px;
background-color: black;
}
input {
width: 78%;
height: 40px;
}
button {
width: 20%;
height: 44px;
}
.music {
display: flex;
width: 390px;
height: 80px;
padding: 10px;
border-radius: 20px;
background-color: #4ab4ff;
margin: auto;
}
audio {
margin-left: 5px;
position: relative;
top: 50%;
transform: translateY(-50%);
}
img {
width: 80px;
border-radius: 50%;
animation: rotate 6s linear infinite;
}
@keyframes rotate {
0% {
transform: rotateZ(0deg);
/*从0度开始*/
}
100% {
transform: rotateZ(360deg);
/*360度结束*/
}
}
h3 {
text-align: center;
}
p {
text-align: center;
}
.a {
width: 100%;
}
.a:hover {
color: #0073de !important;
}
.hid {
width: 100%;
max-width: 430px;
height: 30px;
line-height: 30px;
background-color: #93fffd;
text-align: center;
}
table {
width: 100%;
max-width: 430px;
}
.box {
margin: auto;
display: inline-block;
}
</style>
</head>
<body>
<div class="box">
<div class="div">
<input value="歌单搜索"><button class="btn">搜索</button>
</div>
<br>
<div class="hid">搜索结果隐藏</div>
<table></table>
<h3></h3>
<p></p>
<br>
<div class="music"><img src="" alt=""><audio src="" controls="controls"></audio></div>
</div>
<script src="2/lib/jquery-3.6.0.js"></script>
<script>
const audio = document.querySelector('audio')
const h2 = document.querySelector('h3')
const p = document.querySelector('p')
const btn = document.querySelector('.btn')
const hid = document.querySelector('.hid')
const input = document.querySelector('input')
const table = document.querySelector('table')
const img = document.querySelector('img')
let id = 'collection_3_1133718572_31_0'
audio.loop = false;
let hidden = 1
hid.addEventListener('click', () => {
if (hidden === 1) {
hidden = 0
table.style.display = 'none'
} else {
hidden = 1
table.style.display = 'block'
}
})
btn.addEventListener('click', () => {
let msg = input.value
qx(msg)
})
const qx = (msg) => {
$.ajax({
url: `https://www.hhlqilongzhu.cn/api/dg_kglist.php?type=search&msg=${msg}`,
// url: `https://www.hhlqilongzhu.cn/api/dg_kglist.php?type=search&msg=2024`,
type: 'get',
}).then(res => {
console.log(res);
let list = res.data
const htmlStr = list.map((item, index) => {
return `<tr>
<td class='a'>${item.title}</td>
</tr>`
}).join('')
table.innerHTML = htmlStr
let a = document.querySelectorAll('.a')
for (let i = 0; i < a.length; i++) {
a[i].addEventListener('click', function () {
id = list[i].id
console.log(id);
music(id)
})
}
})
}
const music = (id) => {
console.log(id);
$.ajax({
url: `https://www.hhlqilongzhu.cn/api/dg_kglist.php?id=${id}`,
type: 'get',
}).then(res => {
console.log(res);
h2.innerHTML = res.title
p.innerHTML = `歌手:${res.singer}`
img.src = res.song_cover
audio.src = res.song_url
audio.play();
})
}
audio.addEventListener('ended', function () {
music(id)
}, false);
music(id)
</script>
</body>
</html>