Vue应用之网抑云在线版

本人是一个网抑云深度爱好者,因此,学了Vue框架后,自己写了一个网抑云在线版
api是用网易云的,支持mv播放的

  1. html代码
<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta http-equiv="X-UA-Compatible" content="ie=edge" /><title>Document</title><!-- 样式 --><link rel="stylesheet" href="./css/index.css">
</head><body><div class="nav"></div><div class="wrap"><div class="play_wrap" id="player"><div class="search_bar"><img src="data:images/tittle.png" alt="" /><!-- 搜索歌曲 --><input type="text" autocomplete="off" v-model='query' @keyup.enter="searchMusic();" /></div><div class="center_con"><!-- 搜索歌曲列表 --><div class='song_wrapper' ref='song_wrapper'><ul class="song_list"><li v-for="item in musicList"><!-- 点击放歌 --><a href="javascript:;" @click='playMusic(item.id)'></a><b>{{item.name}}</b><span><i @click="playMv(item.mvid)" v-if="item.mvid!=0"></i></span></li></ul><img src="data:images/line.png" class="switch_btn" alt=""></div><!-- 歌曲信息容器 --><div class="player_con" :class="{playing:isPlay}"><img src="data:images/player_bar.png" class="play_bar" /><!-- 黑胶碟片 --><img src="data:images/disc.png" class="disc autoRotate" /><img :src="coverUrl==''?'./images/cover.png':coverUrl" class="cover autoRotate" /></div><!-- 评论容器 --><div class="comment_wrapper" ref='comment_wrapper'><h5 class='title'>热门留言</h5><div class='comment_list'><dl v-for="item in hotComments"><dt><img :src="item.user.avatarUrl" alt="" /></dt><dd class="name">{{item.user.nickname}}</dd><dd class="detail">{{item.content}}</dd></dl></div><img src="data:images/line.png" class="right_line"></div></div><div class="audio_con"><audio ref='audio' @play="play" @pause="pause" :src="musicUrl" controls autoplay loop class="myaudio"></audio></div><div class="video_con" v-show="showVideo"><video ref='video' :src="mvUrl" controls="controls" ></video><div class="mask" @click="closeMv"></div></div></div></div><!-- 开发环境版本,包含了有帮助的命令行警告 --><script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script><!-- 官网提供的 axios 在线地址 --><script src="https://unpkg.com/axios/dist/axios.min.js"></script><script type="text/javascript">// 设置axios的基地址axios.defaults.baseURL = 'https://autumnfish.cn';// axios.defaults.baseURL = 'http://localhost:3000';// 实例化vuevar app = new Vue({el: "#player",data: {// 搜索关键字query: '',// 歌曲列表musicList: [],// 歌曲urlmusicUrl: '',// 是否正在播放isPlay: false,// 歌曲热门评论hotComments: [],// 歌曲封面地址coverUrl: '',// 显示视频播放showVideo: false,// mv地址mvUrl: ''},// 方法methods: {// 搜索歌曲searchMusic() {if (this.query == 0) {return}axios.get('/search?keywords=' + this.query).then(response => {// 保存内容this.musicList = response.data.result.songs;})// 清空搜索this.query = ''},// 播放歌曲playMusic(musicId) {// 获取歌曲urlaxios.get('/song/url?id=' + musicId).then(response => {// 保存歌曲url地址this.musicUrl = response.data.data[0].url})// 获取歌曲热门评论axios.get('/comment/hot?type=0&id=' + musicId).then(response => {// console.log(response)// 保存热门评论this.hotComments = response.data.hotComments})// 获取歌曲封面axios.get('/song/detail?ids=' + musicId).then(response => {// console.log(response)// 设置封面this.coverUrl = response.data.songs[0].al.picUrl})},// audio的play事件play() {this.isPlay = true// 清空mv的信息this.mvUrl = ''},// audio的pause事件pause() {this.isPlay = false},// 播放mvplayMv(vid) {if (vid) {this.showVideo = true;// 获取mv信息axios.get('/mv/url?id=' + vid).then(response => {// console.log(response)// 暂停歌曲播放this.$refs.audio.pause()// 获取mv地址this.mvUrl = response.data.data.url})}},// 关闭mv界面closeMv() {this.showVideo = falsethis.$refs.video.pause()},// 搜索历史记录中的歌曲historySearch(history) {this.query = historythis.searchMusic()this.showHistory = false;}},})</script>
</body></html>
  1. index的css文件
body,
ul,
dl,
dd {margin: 0px;padding: 0px;
}.wrap {position: fixed;left: 0;top: 0;width: 100%;height: 100%;background: url("../images/bgpic.jpg") no-repeat;background-size: 100% 100%;
}.play_wrap {width: 800px;height: 544px;position: fixed;left: 50%;top: 50%;margin-left: -400px;margin-top: -272px;/* background-color: #f9f9f9; */
}.search_bar {height: 60px;background-color: #000000;border-top-left-radius: 4px;border-top-right-radius: 4px;display: flex;align-items: center;justify-content: space-between;position: relative;z-index: 11;
}.search_bar img {margin-left: 23px;
}.search_bar input {margin-right: 23px;width: 296px;height: 34px;border-radius: 17px;border: 0px;background: url("../images/zoom.png") 265px center no-repeatrgba(255, 255, 255, 0.45);text-indent: 15px;outline: none;
}.center_con {height: 435px;background-color: rgba(255, 255, 255, 0.5);display: flex;position: relative;
}.song_wrapper {width: 200px;height: 435px;box-sizing: border-box;padding: 10px;list-style: none;position: absolute;left: 0px;top: 0px;z-index: 1;
}.song_stretch {width: 600px;
}.song_list {width: 100%;overflow-y: auto;overflow-x: hidden;height: 100%;
}
.song_list::-webkit-scrollbar {display: none;
}.song_list li {font-size: 12px;color: #333;height: 40px;display: flex;flex-wrap: wrap;align-items: center;width: 580px;padding-left: 10px;
}.song_list li:nth-child(odd) {background-color: rgba(240, 240, 240, 0.3);
}.song_list li a {display: block;width: 17px;height: 17px;background-image: url("../images/play.png");background-size: 100%;margin-right: 5px;box-sizing: border-box;
}.song_list li b {font-weight: normal;width: 122px;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;
}.song_stretch .song_list li b {width: 200px;
}.song_stretch .song_list li em {width: 150px;
}.song_list li span {width: 23px;height: 17px;margin-right: 50px;
}
.song_list li span i {display: block;width: 100%;height: 100%;cursor: pointer;background: url("../images/table.png") left -48px no-repeat;
}.song_list li em,
.song_list li i {font-style: normal;width: 100px;
}.player_con {width: 400px;height: 435px;position: absolute;left: 200px;top: 0px;
}.player_con2 {width: 400px;height: 435px;position: absolute;left: 200px;top: 0px;
}.player_con2 video {position: absolute;left: 20px;top: 30px;width: 355px;height: 265px;
}.disc {position: absolute;left: 73px;top: 60px;z-index: 9;
}
.cover {position: absolute;left: 125px;top: 112px;width: 150px;height: 150px;border-radius: 75px;z-index: 8;
}
.comment_wrapper {width: 180px;height: 435px;list-style: none;position: absolute;left: 600px;top: 0px;padding: 25px 10px;
}
.comment_wrapper .title {position: absolute;top: 0;margin-top: 10px;
}
.comment_wrapper .comment_list {overflow: auto;height: 410px;
}
.comment_wrapper .comment_list::-webkit-scrollbar {display: none;
}
.comment_wrapper dl {padding-top: 10px;padding-left: 55px;position: relative;margin-bottom: 20px;
}.comment_wrapper dt {position: absolute;left: 4px;top: 10px;
}.comment_wrapper dt img {width: 40px;height: 40px;border-radius: 20px;
}.comment_wrapper dd {font-size: 12px;
}.comment_wrapper .name {font-weight: bold;color: #333;padding-top: 5px;
}.comment_wrapper .detail {color: #666;margin-top: 5px;line-height: 18px;
}
.audio_con {height: 50px;background-color: #f1f3f4;border-bottom-left-radius: 4px;border-bottom-right-radius: 4px;
}
.myaudio {width: 800px;height: 40px;margin-top: 5px;outline: none;background-color: #f1f3f4;
}
/* 旋转的动画 */
@keyframes Rotate {from {transform: rotateZ(0);}to {transform: rotateZ(360deg);}
}
/* 旋转的类名 */
.autoRotate {animation-name: Rotate;animation-iteration-count: infinite;animation-play-state: paused;animation-timing-function: linear;animation-duration: 5s;
}
/* 是否正在播放 */
.player_con.playing .disc,
.player_con.playing .cover {animation-play-state: running;
}.play_bar {position: absolute;left: 200px;top: -10px;z-index: 10;transform: rotate(-25deg);transform-origin: 12px 12px;transition: 1s;
}
/* 播放杆 转回去 */
.player_con.playing .play_bar {transform: rotate(0);
}
/* 搜索历史列表 */
.search_history {position: absolute;width: 296px;overflow: hidden;background-color: rgba(255, 255, 255, 0.3);list-style: none;right: 23px;top: 50px;box-sizing: border-box;padding: 10px 20px;border-radius: 17px;
}
.search_history li {line-height: 24px;font-size: 12px;cursor: pointer;
}
.switch_btn {position: absolute;right: 0;top: 0;cursor: pointer;
}
.right_line {position: absolute;left: 0;top: 0;
}
.video_con video {position: fixed;width: 800px;height: 546px;left: 50%;top: 50%;margin-top: -273px;transform: translateX(-50%);z-index: 990;
}
.video_con .mask {position: fixed;width: 100%;height: 100%;left: 0;top: 0;z-index: 980;background-color: rgba(0, 0, 0, 0.8);
}
.video_con .shutoff {position: fixed;width: 40px;height: 40px;background: url("../images/shutoff.png") no-repeat;left: 50%;margin-left: 400px;margin-top: -273px;top: 50%;z-index: 995;
}
  1. js文件
/*1:歌曲搜索接口请求地址:https://autumnfish.cn/search请求方法:get请求参数:keywords(查询关键字)响应内容:歌曲搜索结果2:歌曲url获取接口请求地址:https://autumnfish.cn/song/url请求方法:get请求参数:id(歌曲id)响应内容:歌曲url地址3.歌曲详情获取请求地址:https://autumnfish.cn/song/detail请求方法:get请求参数:ids(歌曲id)响应内容:歌曲详情(包括封面信息)4.热门评论获取请求地址:https://autumnfish.cn/comment/hot?type=0请求方法:get请求参数:id(歌曲id,地址中的type固定为0)响应内容:歌曲的热门评论5.mv地址获取请求地址:https://autumnfish.cn/mv/url请求方法:get请求参数:id(mvid,为0表示没有mv)响应内容:mv的地址
*/
var app = new Vue({el: "#player",data: {// 查询关键字query: "",// 歌曲数组musicList: [],// 歌曲地址musicUrl: "",// 歌曲封面musicCover: "",// 歌曲评论hotComments: [],// 动画播放状态isPlaying: false,// 遮罩层的显示状态isShow: false,// mv地址mvUrl: ""},methods: {// 歌曲搜索searchMusic: function() {var that = this;axios.get("https://autumnfish.cn/search?keywords=" + this.query).then(function(response) {// console.log(response);that.musicList = response.data.result.songs;console.log(response.data.result.songs);},function(err) {});},// 歌曲播放playMusic: function(musicId) {//   console.log(musicId);var that = this;// 获取歌曲地址axios.get("https://autumnfish.cn/song/url?id=" + musicId).then(function(response) {// console.log(response);// console.log(response.data.data[0].url);that.musicUrl = response.data.data[0].url;},function(err) {});// 歌曲详情获取axios.get("https://autumnfish.cn/song/detail?ids=" + musicId).then(function(response) {// console.log(response);// console.log(response.data.songs[0].al.picUrl);that.musicCover = response.data.songs[0].al.picUrl;},function(err) {});// 歌曲评论获取axios.get("https://autumnfish.cn/comment/hot?type=0&id=" + musicId).then(function(response) {// console.log(response);// console.log(response.data.hotComments);that.hotComments = response.data.hotComments;},function(err) {});},// 歌曲播放play: function() {// console.log("play");this.isPlaying = true;},// 歌曲暂停pause: function() {// console.log("pause");this.isPlaying = false;},// 播放mvplayMV: function(mvid) {var that = this;axios.get("https://autumnfish.cn/mv/url?id=" + mvid).then(function(response) {// console.log(response);console.log(response.data.data.url);that.isShow = true;that.mvUrl = response.data.data.url;},function(err) {});},// 隐藏hide: function() {this.isShow = false;}}
});

因为代码隔了好久,以后注释再补充吧.背景图片什么的,自己百度找找,或者自己ps设计,亦或者可以私我要

下面贴测试图

视频要停止,点旁边的黑色边框就行了

Vue小应用之在线网易云(支持mv播放)相关推荐

  1. YesPlayMusic for Mac(高颜值网易云音乐第三方播放器)

    YesPlayMusic是一款在线第三方网易云播放器,软件的界面颜值更高更精简,对歌曲信息.歌词等做了极大的显示优化,同时也会有无损优质的音乐播放表现,软件支持mv播放,会显示歌曲的专辑信息,作为一款 ...

  2. 高颜值网易云音乐第三方播放器 YesPlayMusic Mac中文版 支持m1

    YesPlayMusic,一款高颜值的第三方网易云播放器,不仅设计精美,播放体验很优秀,而且可以听一些灰色和 VIP 的歌曲,支持网易云账号登录,还可以进行 MV 播放和歌词显示.支持 Unblock ...

  3. Vue.js 安装及其环境搭建,webpack-simple支持热更新

    1.先安装node.js 安装官网最新的即可 版本应该要大于6.0版本 nodejs的官网:https://nodejs.org/en/ 2.安装git Git的官网:https://git-scm. ...

  4. 适合初学者练手的vue小项目(附github源码)

    vue慢慢的成为了前端最受欢迎的框架之一,在很多项目之中开发都能用得到,如今也已经发展到3.0了,可能是因为这个框架可以提高工作效率,因此受到大家的追捧,在之前的文章里面也说过,2019年,大前端学习 ...

  5. 牛皮!竟然有大佬基于 Spring Boot + Vue 开发了一套网易云amp;QQ音乐(附源码)。。。...

    来源:segmentfault.com/a/1190000021376934 # 前言 虽然 B/S 是目前开发的主流,但是 C/S 仍然有很大的市场需求.受限于浏览器的沙盒限制,网页应用无法满足某些 ...

  6. 超级实用的vue小技巧,用了之后直呼好棒~

    实用的vue小技巧,来源于真实企业实战 -- 记得收藏~ 1. 原型注入 2. 对象冻结 3.img 加载失败 4. 递归组件 5. 解决繁乱的template -- render函数 6. 延迟更新 ...

  7. 互联网早报:腾讯小微推新功能,支持在微信中进行硬件管理和音乐分享....

    行业热点 1.腾讯小微推新功能,支持在微信中进行硬件管理和音乐分享: 2.泄露40万条个人信息 圆通速递被上海网信办约谈: 3.字节跳动全量上线搜索广告:整合头条.抖音.西瓜等产品线: 4.361度公 ...

  8. vue小程序开发(一) uni-app基本学习

    vue小程序开发(一) uni-app基本学习 脚手架搭建项目 新建页面 样式和sass 基本语法 数据展示 数据循环 条件编译 计算属性 事件 传参方式 组件 组件的简单使用 示例 组件传递参数 父 ...

  9. Vue中使用can-autoplay插件实现浏览器不支持自动播放音频时提示点击

    场景 Vue中使用speak-tts插件实现点击按钮后进行语音播报(TTS/文字转语音): Vue中使用speak-tts插件实现点击按钮后进行语音播报(TTS/文字转语音)_BADAO_LIUMAN ...

最新文章

  1. 25,000,000行的代码就问你敢不敢动?!
  2. 插件框架Extensible Framework for Delphi
  3. 4.1 - 并发编程 - 进程练习题
  4. mysql的driver和url_数据库连接driverClass和jdbcUrl大全
  5. sqlite学习笔记5:插入数据,查询数据和删除数据
  6. Codeforces Round #497 (Div. 1)
  7. beanshell断言_JMeter使用BeanShell断言
  8. 论文阅读 - Jukebox: A Generative Model for Music
  9. 写给大一大二大三还在迷惘中的学生
  10. 进阶篇:3.4.1)机械加工件-不同制造工艺详解和对应设备
  11. 2021-08-04 Mysql自连接
  12. zoj 3747 dp递推
  13. Linux 怎么找回管理员密码?
  14. 利用Echarts+百度地图API绘制可交互的行政区划地图(2021)
  15. 室内导航html,室内定位导航地图一体化设计
  16. 离线部署GitLab
  17. Node-RED中建立Websocket客户端连接
  18. 机器学习从入门到创业手记-初识sklearn
  19. 为什么打开计算机不显示桌面快捷方式,电脑桌面快捷方式不见了的解决办法
  20. Ubuntu KVM安装过程

热门文章

  1. [数据集][目标检测]塔吊数据集VOC格式2559张
  2. java实现word下载及打包成zip下载(单个文件、多个文件)
  3. CCS安装编译器的方法
  4. 区块链平台调研与分析报告.md
  5. mysql 192.168.0.%_如果mysql数据库所在的主机IP是192.168.0.1,用户名是ec,密码是123456,则用php连接这个mysql数据库的命令可以写为:...
  6. Linux驱动编程视频教程
  7. 深圳云计算学习:云计算在物联网中到底起到什么作用?
  8. CAD遇到显示驱动程序文件(.hdi)已丢失或损坏的解决办法
  9. IE浏览器按Backspace返回上一页面
  10. 汪涵夫妇被闺蜜诈骗,和政府合伙买房这事是真的 | 数据周报