Skip to content

Commit 583e850

Browse files
author
coderwhy
committed
完成歌手页面内容
1 parent 5fb8411 commit 583e850

File tree

15 files changed

+161
-22
lines changed

15 files changed

+161
-22
lines changed

src/App.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import HYMain from './pages/main';
88
function App() {
99
return (
1010
<Provider store={store}>
11-
<h2>哈哈哈哈</h2>
1211
<HYMain/>
1312
</Provider>
1413
);

src/pages/discover/c-pages/artist/c-cpns/artist-list/c-cpns/alpha-list/index.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,41 @@
1-
import React, { memo } from 'react';
1+
import React, { memo, useState, useEffect } from 'react';
2+
import { useSelector, shallowEqual, useDispatch } from 'react-redux';
23
import classNames from 'classnames';
34

45
import { singerAlphas } from '@/utils/handle-data';
6+
import { getArtistListAction } from '../../../../store/actionCreators';
57

68
import {
79
AlphaListWrapper
810
} from './style';
9-
import { useState } from 'react';
1011

1112
export default memo(function HYAlphaList() {
1213
const [currentAlpha, setCurrentAlpha] = useState("-1");
1314

15+
const { currentType, currentArea } = useSelector(state => ({
16+
currentType: state.getIn(["artist", "currentType"]),
17+
currentArea: state.getIn(["artist", "currentArea"])
18+
}), shallowEqual);
19+
const dispatch = useDispatch();
20+
21+
useEffect(() => {
22+
setCurrentAlpha("-1");
23+
}, [currentType, currentArea]);
24+
useEffect(() => {
25+
dispatch(getArtistListAction(currentArea, currentType.type, currentAlpha));
26+
}, [currentAlpha, currentType, currentArea, dispatch]);
27+
1428
return (
15-
<AlphaListWrapper>
29+
<AlphaListWrapper hasTop={currentArea !== -1}>
1630
{
17-
singerAlphas.map((item, index) => {
31+
currentArea !== -1 && singerAlphas.map((item, index) => {
1832
const isActive = currentAlpha === item;
1933
if (item === "0") item = "其他";
2034
if (item === "-1") item = "热门";
2135
return (
2236
<div key={item}
2337
className={classNames("item", {"active": isActive})}>
24-
<a href="/#" onClick={e => setCurrentAlpha(item)}>{item.toUpperCase()}</a>
38+
<span onClick={e => setCurrentAlpha(item)}>{item.toUpperCase()}</span>
2539
</div>
2640
)
2741
})

src/pages/discover/c-pages/artist/c-cpns/artist-list/c-cpns/alpha-list/style.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,25 @@ import styled from 'styled-components';
33
export const AlphaListWrapper = styled.div`
44
display: flex;
55
justify-content: space-between;
6-
margin-top: 20px;
6+
margin-top: ${props => props.hasTop ? "20px": 0};
77
88
.item {
99
padding: 1px 4px;
1010
border-radius: 3px;
11-
a {
11+
span {
1212
font-size: 14px;
1313
color: #333;
14+
cursor: pointer;
1415
}
1516
16-
a:hover {
17+
span:hover {
1718
text-decoration: underline;
1819
}
1920
}
2021
2122
.active {
2223
background-color: #c20c0c;
23-
a {
24+
span {
2425
color: #fff;
2526
}
2627
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import React, { memo } from 'react';
2+
3+
import { getSizeImage } from '@/utils/format-utils';
4+
5+
import { ItemWrapper } from './style';
6+
7+
export default memo(function HYArtistItemV1(props) {
8+
const { info, index } = props;
9+
10+
return (
11+
<ItemWrapper>
12+
{
13+
index < 10 && (
14+
<div className="image">
15+
<img src={getSizeImage(info.img1v1Url, 130)} alt="" />
16+
</div>
17+
)
18+
}
19+
<div className="info">
20+
<span className="name">{info.name}</span>
21+
<i className="sprite_icon2 icon"></i>
22+
</div>
23+
</ItemWrapper>
24+
)
25+
})
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import styled from 'styled-components';
2+
3+
export const ItemWrapper = styled.div`
4+
width: 130px;
5+
margin-top: 15px;
6+
7+
.image {
8+
img {
9+
width: 130px;
10+
height: 130px;
11+
}
12+
}
13+
14+
.info {
15+
margin: 10px 0;
16+
display: flex;
17+
justify-content: space-between;
18+
19+
.name {
20+
cursor: pointer;
21+
22+
&:hover {
23+
color: red;
24+
text-decoration: underline;
25+
}
26+
}
27+
28+
.icon {
29+
display: inline-block;
30+
width: 17px;
31+
height: 18px;
32+
background-position: 0 -740px;
33+
}
34+
}
35+
`

src/pages/discover/c-pages/artist/c-cpns/artist-list/index.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,29 @@ import { useSelector, shallowEqual } from 'react-redux';
44

55
import HYThemeHeaderNormal from '@/components/theme-header-normal';
66
import HYAlphaList from './c-cpns/alpha-list';
7+
import HYArtistItem from './c-cpns/artist-item';
78
import {
89
ArtistListWrapper
910
} from './style';
1011

1112
export default memo(function HYArtistList() {
12-
const { currentType } = useSelector(state => ({
13-
currentType: state.getIn(["artist", "currentType"])
13+
// redux hooks
14+
const { currentType, artistList } = useSelector(state => ({
15+
currentType: state.getIn(["artist", "currentType"]),
16+
artistList: state.getIn(["artist", "artistList"])
1417
}), shallowEqual);
1518

1619
return (
1720
<ArtistListWrapper>
1821
<HYThemeHeaderNormal title={currentType.name} />
1922
<HYAlphaList/>
23+
<div className="artist-list">
24+
{
25+
artistList.map((item, index) => {
26+
return <HYArtistItem key={item.id} index={index} info={item}/>
27+
})
28+
}
29+
</div>
2030
</ArtistListWrapper>
2131
)
2232
})

src/pages/discover/c-pages/artist/c-cpns/artist-list/style.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,12 @@ import styled from 'styled-components';
33
export const ArtistListWrapper = styled.div`
44
flex: 1;
55
padding: 40px;
6+
7+
.artist-list {
8+
display: flex;
9+
flex-wrap: wrap;
10+
justify-content: space-between;
11+
12+
padding: 5px 0 40px;
13+
}
614
`
Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
import * as actionTypes from './constants';
22

3+
import { getArtistList } from '@/services/artist';
4+
5+
const changeArtistListAction = (artistList) => ({
6+
type: actionTypes.CHANGE_ARTIST_LIST,
7+
artistList
8+
})
9+
310
export const changeCurrentAreaAction = (area) => ({
411
type: actionTypes.CHANGE_CURRENT_AREA,
512
currentArea: area
@@ -8,4 +15,13 @@ export const changeCurrentAreaAction = (area) => ({
815
export const changeCurrentTypeAction = (type) => ({
916
type: actionTypes.CHANGE_CURRENT_TYPE,
1017
currentType: type
11-
})
18+
});
19+
20+
export const getArtistListAction = (area, type, alpha) => {
21+
return dispatch => {
22+
getArtistList(area, type, alpha).then(res => {
23+
console.log(res);
24+
dispatch(changeArtistListAction(res.artists))
25+
})
26+
}
27+
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
export const CHANGE_CURRENT_AREA = "artist/CHANGE_CURRENT_AREA";
2-
export const CHANGE_CURRENT_TYPE = "artist/CHANGE_CURRENT_TYPE";
2+
export const CHANGE_CURRENT_TYPE = "artist/CHANGE_CURRENT_TYPE";
3+
4+
export const CHANGE_ARTIST_LIST = "artist/CHANGE_ARTIST_LIST";

src/pages/discover/c-pages/artist/store/reducer.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ import { Map } from 'immutable';
33
import * as actionTypes from './constants';
44

55
const defaultState = Map({
6-
currentArea: -1,
6+
currentArea: 7,
77
currentType: {
88
name: "推荐歌手",
99
type: 1
10-
}
10+
},
11+
artistList: []
1112
});
1213

1314
function reducer(state = defaultState, action) {
@@ -16,6 +17,8 @@ function reducer(state = defaultState, action) {
1617
return state.set("currentArea", action.currentArea);
1718
case actionTypes.CHANGE_CURRENT_TYPE:
1819
return state.set("currentType", action.currentType);
20+
case actionTypes.CHANGE_ARTIST_LIST:
21+
return state.set("artistList", action.artistList);
1922
default:
2023
return state;
2124
}

src/pages/discover/c-pages/recommend/c-cpns/top-banner/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ export default memo(function HYTopBanner() {
2727
}, [dispatch]);
2828

2929
const bannerChange = useCallback((from, to) => {
30-
setCurrentIndex(to);
30+
setTimeout(() => {
31+
setCurrentIndex(from);
32+
}, 0);
3133
}, []);
3234

3335
const bgImage = state.banners[currentIndex] && (state.banners[currentIndex].imageUrl + "?imageView&blur=40x20")

src/pages/player/app-play-bar/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ export default memo(function HYAppPlaybar() {
8888
const finalIndex = i - 1;
8989
if (finalIndex !== currentLyricIndex) {
9090
dispatch(changeCurrentLyricIndexAction(finalIndex));
91-
console.log(currentLyrics[finalIndex]);
9291
message.open({
9392
content: currentLyrics[finalIndex].content,
9493
key: "lyric",

src/router/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export default [
4343
path: "/discover",
4444
exact: true,
4545
render: () => (
46-
<Redirect to={"/discover/recommend"}/>
46+
<Redirect to={"/discover/artist"}/>
4747
)
4848
},
4949
{

src/services/artist.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import request from './axios';
2+
3+
export function getArtistList(area, type, initial) {
4+
let url = "/artist/list";
5+
let params = { limit: 100 }
6+
if (area === -1 && type === 1) {
7+
url = "/top/artists"
8+
} else {
9+
if (area === -1) {
10+
params = {limit: 100, cat: 5001}
11+
} else {
12+
params = {
13+
type,
14+
area,
15+
initial,
16+
limit: 100
17+
}
18+
}
19+
}
20+
21+
console.log("url:", url, "params:", params);
22+
23+
return request({
24+
url,
25+
params
26+
})
27+
}
28+

src/services/local-data.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,16 +135,13 @@ export const artistCategories = [
135135
{
136136
name: "推荐歌手",
137137
type: 1,
138-
now: false,
139138
url: "/discover/artist",
140139
id: 0
141140
},
142141
{
143142
name: "入驻歌手",
144143
type: 2,
145-
now: true,
146144
url: "/discover/artist?cat=5001",
147-
id: 5001,
148145
dataPath: "/artist/list?cat=5001"
149146
}
150147
]

0 commit comments

Comments
 (0)