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
| var app = new Vue({ el:"#player", data:{ query:"", musicList:[], musicUrl:"", pause:"iconfont icon-play", playing:"music__list__item", musicName:"...", artist:"...", picUrl:"", play:"", musicIndex:0, totalTime:"00:00" }, methods:{ searchMusic:function(){ var that=this; axios.get("https://autumnfish.cn/search?keywords="+this.query) .then(function(response){ that.musicList=response.data.result.songs; console.log(response) },function(err){}) }, playMusic:function(musicId,musicname,artist,index){ this.play="play"; this.musicIndex=index;
var that=this; axios.get("https://autumnfish.cn/song/url?id="+musicId) .then(function(response){ that.musicUrl=response.data.data[0].url; that.pause="iconfont icon-pause"; that.playing="music__list__item play"; that.musicName=musicname; that.artist=artist; console.log(response) },function(err){})
totalMinute = parseInt(this.$refs.audio.duration / 60) < 10 ? "0" + parseInt(this.$refs.audio.duration / 60) : parseInt(this.$refs.audio.duration / 60); totalSecond = parseInt(this.$refs.audio.duration % 60) < 10 ? "0" + parseInt(this.$refs.audio.duration % 60) : parseInt(this.$refs.audio.duration % 60); this.totalTime = totalMinute +":"+ totalSecond; console.log(this.totalTime)
axios.get("https://autumnfish.cn/song/detail?ids="+musicId) .then(function(response){ console.log(response.data.songs[0].al.picUrl) that.picUrl=response.data.songs[0].al.picUrl; },function(err){}) }, musiccl:function(){ if(this.pause=="iconfont icon-pause"){ this.$refs.audio.pause(); this.pause="iconfont icon-play"; this.play="" }else{ this.$refs.audio.play(); this.pause="iconfont icon-pause"; this.play="play" } }, musicChange:function(changeid){ index=this.musicIndex; if( index>=0 && index<=this.musicList.length){ if(changeid=="pre" && index>0){ musicId=this.musicList[index-1].id; musicname=this.musicList[index-1].name; artist=this.musicList[index-1].artists[0].name; this.playMusic(musicId,musicname,artist,index-1); } if(changeid=="next" && index<this.musicList.length){ musicId=this.musicList[index+1].id; musicname=this.musicList[index+1].name; artist=this.musicList[index+1].artists[0].name; this.playMusic(musicId,musicname,artist,index+1); } } } } })
|