This repository was archived by the owner on May 11, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +35
-2
lines changed
components/parts-recom-item Expand file tree Collapse file tree 2 files changed +35
-2
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ export function getRecommendItem (recommendId) {
4646 }
4747 }
4848
49+ // 在没有 header 验证的情况下直接使用 jsonp 请求 url,否则使用后端 ajax 代理
4950 // return jsonp(RECOMMEND_ITEM_URL, data, {
5051 // ...options,
5152 // // https://github.com/webmodules/jsonp/blob/master/index.js#L50
Original file line number Diff line number Diff line change 33 <PartsMusicList
44 :bgImage =" itemBgImage"
55 :title =" itemTitle"
6+ :songs =" itemSongs"
67 />
78 </transition >
89</template >
1112import PartsMusicList from ' components/parts-music-list/parts-music-list'
1213import { mapGetters } from ' vuex'
1314import { getRecommendItem } from ' api/the-recommend'
14- // import { ERR_OK } from 'api/config'
15+ import { ERR_OK } from ' api/config'
16+ import { createSong } from ' common/js/normalize-song'
1517
1618export default {
1719 methods: {
1820 _getRecommendItem (id ) {
19- getRecommendItem (id).then (res => console .log (res))
21+ if (! this .recommendItem .dissid ) { // 在 recommend 详情页刷新时,跳转至首页
22+ this .$router .push ({ path: ' /recommend' })
23+ return
24+ }
25+
26+ getRecommendItem (id).then (res => {
27+ if (res .code === ERR_OK ) {
28+ this .itemSongs = this ._normalizeSongs (res .cdlist [0 ].songlist )
29+ console .info (' %c Loading recommend songs' , ' color: dodgerblue' )
30+ }
31+ })
32+ },
33+
34+ _normalizeSongs (list ) {
35+ let ret = []
36+ list .forEach (musicData => {
37+ if (musicData .songmid && musicData .albummid ) {
38+ ret .push (createSong (musicData))
39+ }
40+ })
41+ return ret
2042 }
2143 },
44+
2245 computed: {
2346 itemTitle () {
47+ if (! this .recommendItem .dissid ) { // 在 recommend 详情页刷新时
48+ return
49+ }
2450 return this .recommendItem .creator .name
2551 },
2652
@@ -37,6 +63,12 @@ export default {
3763 this ._getRecommendItem (this .recommendItem .dissid )
3864 },
3965
66+ data () {
67+ return {
68+ itemSongs: []
69+ }
70+ },
71+
4072 components: {
4173 PartsMusicList
4274 }
You can’t perform that action at this time.
0 commit comments