Skip to content

Commit

Permalink
'解决数据请求出错问题'
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengdechang committed May 13, 2021
1 parent d5a079e commit 4cba6e8
Show file tree
Hide file tree
Showing 16 changed files with 55 additions and 41 deletions.
11 changes: 11 additions & 0 deletions reportermap/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "reportermap",
"version": "0.1.0",
"private": true,
"devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-router": "~4.5.0",
"@vue/cli-plugin-vuex": "~4.5.0",
"@vue/cli-service": "~4.5.0"
}
}
8 changes: 4 additions & 4 deletions src/components/common/Comment.vue
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ export default {
},
//评论msg处理
msgHandler (res) {
if (res.code !== 200) {
return this.$message.error('数据请求失败')
}
// if (res.code !== 200) {
// return this.$message.error('评论msg处理数据请求失败')
// }
this.hotComments = res.hotComments || []
this.hotComments.map(item => {
item.isHot = true
Expand All @@ -195,7 +195,7 @@ export default {
}
comment(params).then(res =>{
if (res.code !== 200) {
return this.$message.error('数据请求失败')
return this.$message.error('评论数据请求失败')
}
this.msg = ''
this.getComment()
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/songlist.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default {
getPlayList (params) {
playList(params).then(res =>{
if (res.code !== 200) {
return this.$message.error('数据请求失败')
return this.$message.error('获取歌曲列表数据请求失败')
}
this.list = this.params.offset !== 0 ? [...this.list, ...res.playlists] : res.playlists
this.pageList = this.list.slice(0,(this.page+1)*20)
Expand Down
2 changes: 1 addition & 1 deletion src/networks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const likeSongofName =(keywords) => get(`/cloudsearch?keywords= ${keyword


//id相对应的歌词
export const songLyric =(id) => get(`/lyric?id=${id}`);
export const songLyric =(sid) => get(`/lyric?id=${sid}`);
//根据keywords相应的id获取音乐url
export const songUrl =(id) => get(`/song/url?id=${id}`);

Expand Down
6 changes: 3 additions & 3 deletions src/views/album/Album.vue
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export default {
getAlbum (params) {
album(params).then(res =>{
if (res.code !== 200) {
return this.$message.error('数据请求失败')
return this.$message.error('歌单推荐数据请求失败')
}
this.artist_id = res.album.artists[0].id;
this.details = res.album;
Expand All @@ -141,7 +141,7 @@ export default {
getAlbumDynamic (params) {
albumDynamic(params).then(res =>{
if (res.code !== 200) {
return this.$message.error('数据请求失败')
return this.$message.error('专辑动态数据请求失败')
}
this.dynamic = res
})
Expand All @@ -150,7 +150,7 @@ export default {
getArtistAlbum (id) {
artistAlbum({ id: id, limit: 5,offset:0}).then(res =>{
if (res.code !== 200) {
return this.$message.error('数据请求失败')
return this.$message.error('歌手专辑数据请求失败')
}
this.hotAlbums = res.hotAlbums
})
Expand Down
10 changes: 5 additions & 5 deletions src/views/home/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
getHotTags () {
hotList().then(res =>{
if (res.code !== 200) {
return this.$message.error('数据请求失败')
return this.$message.error('歌单分类数据请求失败')
}
res.tags.unshift({ name: '为您推荐' })
this.playlist_tags = res.tags.splice(0, 6)
Expand All @@ -134,7 +134,7 @@
getPlayList (params) {
playLists(params).then(res =>{
if (res.code !== 200) {
return this.$message.error('数据请求失败')
return this.$message.error('分类歌单数据请求失败')
}
this.playlist_list = res.playlists
})
Expand All @@ -149,7 +149,7 @@
getAlbum (params) {
topAlbum(params).then(res =>{
if (res.code !== 200) {
return this.$message.error('数据请求失败')
return this.$message.error('新碟上架数据请求失败')
}
if(res.monthData.length == []){
this.album_list = res.weekData.slice(0, 9)
Expand All @@ -168,7 +168,7 @@
getMv (params) {
getNewMv(params).then(res =>{
if (res.code !== 200) {
return this.$message.error('数据请求失败')
return this.$message.error('最新MV数据请求失败')
}
this.mv_list = res.data;
})
Expand All @@ -183,7 +183,7 @@
getArtists (params) {
topArtists(params).then(res =>{
if (res.code !== 200) {
return this.$message.error('数据请求失败')
return this.$message.error('热门歌手数据请求失败')
}
this.artists_list = res.artists
})
Expand Down
6 changes: 4 additions & 2 deletions src/views/lyric/SongShowLyric.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export default {
}
},
mounted () {
console.log(this.sId);
this.getLyrics(this.sId)
},
// 监听属性 类似于data概念
Expand All @@ -60,8 +61,9 @@ export default {
},
// 方法集合
methods: {
async getLyrics (id) {
songLyric(id).then(res =>{
getLyrics (sid) {
songLyric(sid).then(res =>{
console.log(res.lrc);
this.lyric = this.parseLyric(res.lrc.lyric)
}).catch(err => {
console.log(err);
Expand Down
8 changes: 4 additions & 4 deletions src/views/mv/MvDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export default {
getMvUrl (r) {
mvUrl({ id: this.$route.query.id, r }).then(res =>{
if (res.code !== 200) {
return this.$message.error('数据请求失败')
return this.$message.error('获取mv地址数据请求失败')
}
const src =res.data.url
this.$set(this.videoOptions.sources, 0, {
Expand All @@ -149,7 +149,7 @@ export default {
getSimiMv(){
simiMv( {id:this.$route.query.id} ).then(res =>{
if (res.code !== 200) {
return this.$message.error('数据请求失败')
return this.$message.error('获取相似Mv数据请求失败')
}
this.simiMv = res.mvs
})
Expand All @@ -158,7 +158,7 @@ export default {
this.currentTime = 0
mvDetail({ id: this.$route.query.id}).then(res =>{
if (res.code !== 200) {
return this.$message.error('数据请求失败')
return this.$message.error('mv详情数据请求失败')
}
this.mvDetail = res.data
this.videoOptions.qualityList = res.data.brs
Expand All @@ -167,7 +167,7 @@ export default {
mvUrl({ id:this.$route.query.id}).then(res =>{
const src = res.url
if (res.code !== 200) {
return this.$message.error('数据请求失败')
return this.$message.error('mv地址数据请求失败')
}
this.$set(this.videoOptions.sources, 0, {
type: 'video/mp4',
Expand Down
2 changes: 1 addition & 1 deletion src/views/mv/MvPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export default {
getMv (params) {
mv(params).then(res =>{
if (res.code !== 200) {
return this.$message.error('数据请求失败')
return this.$message.error('获取数据请求失败')
}
this.list = this.params.offset !== 0 ? [...this.list, ...res.data] : res.data
this.pageList = this.list.slice(0,(this.page+1)*20)
Expand Down
4 changes: 2 additions & 2 deletions src/views/rank/Rank.vue
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export default {
getTopListDetail () {
topListDetail().then(res =>{
if (res.code !== 200) {
return this.$message.error('数据请求失败')
return this.$message.error('获取排行榜详情数据请求失败')
}
// 云音乐TOP榜
Expand All @@ -175,7 +175,7 @@ export default {
this.isLoading = true
listDetail({ id: this.rId, s: -1 }).then(res =>{
if (res.code !== 200) {
return this.$message.error('数据请求失败')
return this.$message.error('获取排行榜单详情数据请求失败')
}
this.rankInfo = res.playlist
Expand Down
4 changes: 2 additions & 2 deletions src/views/search/Search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export default {
getSearchSuggest () {
searchSuggest({ keywords: this.keyVal }).then(res =>{
if (res.code !== 200) {
return this.$message.error('数据请求失败')
return this.$message.error('获取搜索建议数据请求失败')
}
this.suggestInfo = res.result
Expand All @@ -160,7 +160,7 @@ export default {
getSearchMatch () {
cloudsearch({ keywords: this.keyVal, type: this.type, limit: this.limit, offset: this.offset }).then(res =>{
if (res.code !== 200) {
return this.$msg.error('数据请求失败')
return this.$msg.error('热门搜索数据请求失败')
}
if (this.type === '1') {
Expand Down
8 changes: 4 additions & 4 deletions src/views/singer/Artist.vue
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
getArtistDesc () {
artistDesc({ id: this.sUid, timestamp: new Date().valueOf() }).then(res =>{
if (res.code !== 200) {
return this.$message.error('数据请求失败')
return this.$message.error('获取歌手描述数据请求失败')
}
this.introduction = res.introduction
})
Expand All @@ -173,7 +173,7 @@
this.isLoading = true
artists({ id: this.sUid, timestamp: new Date().valueOf() }).then(res =>{
if (res.code !== 200) {
return this.$message.error('数据请求失败')
return this.$message.error('获取歌手数据请求失败')
}
this.artist = res.artist
Expand Down Expand Up @@ -233,7 +233,7 @@
this.isLoading = true
artistAlbum({ id: this.sUid, offset: this.offset }).then(res =>{
if (res.code !== 200) {
return this.$message.error('数据请求失败')
return this.$message.error('获取歌手专辑数据请求失败')
}
this.total = res.artist.albumSize
Expand All @@ -250,7 +250,7 @@
this.isLoadMv = false
artistMv({ id: this.sUid, offset: this.offset }).then(res =>{
if (res.code !== 200) {
return this.$message.error('数据请求失败')
return this.$message.error('获取歌手专辑数据请求失败')
}
this.hasMoreMvs = res.hasMore
this.hotMvs = [...this.hotMvs, ...res.mvs]
Expand Down
2 changes: 1 addition & 1 deletion src/views/singer/Singer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
getArtist (params) {
artistList(params).then(res =>{
if (res.code !== 200) {
return this.$message.error('数据请求失败')
return this.$message.error('获取歌手列表数据请求失败')
}
this.list = this.params.offset !== 0 ? [...this.list, ...res.artists] : res.artists
this.pageList = this.list.slice(0,(this.page+1)*30)
Expand Down
3 changes: 2 additions & 1 deletion src/views/songlist/SongList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
moreTxt: {},
allList: {},
params: {
order: 'hot',
order: 'hot',
cat: '',
limit: 50,
Expand All @@ -73,7 +74,7 @@
this.sub = res.sub
if (res.code !== 200) {
return this.$message.error('数据请求失败')
return this.$message.error('获取所点击类型的歌单数据请求失败')
}
for (const k in res.categories) {
Expand Down
8 changes: 4 additions & 4 deletions src/views/songlist/detail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ export default {
this.isLoading = true
playlistdetail(params).then(res => {
if (res.code !== 200) {
return this.$message.error('数据请求失败')
return this.$message.error('获取歌单中歌曲的列表数据请求失败')
}
this.details = res.playlist
Expand Down Expand Up @@ -266,7 +266,7 @@ export default {
getCollect(params) {
playlistSCollect(params).then(res => {
if (res.code !== 200) {
return this.$message.error('数据请求失败')
return this.$message.error('订阅该歌单的用户列表数据请求失败')
}
this.collects = res.subscribers
})
Expand All @@ -276,7 +276,7 @@ export default {
getRecom(params) {
playlistRelated(params).then(res => {
if (res.code !== 200) {
return this.$message.error('数据请求失败')
return this.$message.error('相关歌单推荐数据请求失败')
}
this.playlists = res.playlists
})
Expand All @@ -285,7 +285,7 @@ export default {
getComment(params) {
playlistComment(params).then(res => {
if (res.code !== 200) {
return this.$message.error('数据请求失败')
return this.$message.error('歌单精彩评论数据请求失败')
}
this.comments = res.comments
})
Expand Down
12 changes: 6 additions & 6 deletions src/views/songs/Song.vue
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ export default {
//获取歌曲详情
getSongDetail () {
songDetail({ ids: this.sId,timestamp: new Date().valueOf() }).then(res =>{
if (res.code !== 200) {
return this.$message.error('数据请求失败')
}
// if (res.code !== 200) {
// return this.$message.error('数据请求失败')
// }
// 是否有版权播放
// res.songs[0].license = !res.privileges[0].cp
this.info = res.songs[0];
Expand All @@ -158,9 +158,9 @@ export default {
// 获取相似音乐
getSimiSong () {
simiSong({ id: this.sId }).then(res =>{
if (res.code !== 200) {
return this.$message.error('数据请求失败')
}
// if (res.code !== 200) {
// return this.$message.error('获取相似音乐数据请求失败')
// }
this.simiSong = res.songs
})
Expand Down

0 comments on commit 4cba6e8

Please sign in to comment.