From 4b9df80e147493bb17167ac73a323a1e5fe85103 Mon Sep 17 00:00:00 2001 From: lsqy Date: Sun, 8 Sep 2019 22:52:04 +0800 Subject: [PATCH] =?UTF-8?q?feat(home):=20=E6=96=B0=E5=A2=9Ebanner=E5=B1=95?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app.tsx | 3 ++- src/pages/index/index.scss | 11 ++++++++ src/pages/index/index.tsx | 53 ++++++++++++++++++++++++++++++++++---- 3 files changed, 61 insertions(+), 6 deletions(-) diff --git a/src/app.tsx b/src/app.tsx index 078ff91..02be77e 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -29,6 +29,7 @@ class App extends Component { */ config: Config = { pages: [ + 'pages/index/index', 'pages/my/index', 'pages/videoDetail/index', 'pages/search/index', @@ -39,7 +40,7 @@ class App extends Component { 'pages/searchResult/index', // 'pages/search/index', - 'pages/index/index', + 'pages/songDetail/index', 'pages/myFans/index', 'pages/myFocus/index', diff --git a/src/pages/index/index.scss b/src/pages/index/index.scss index b1b6f64..1a3ed0c 100644 --- a/src/pages/index/index.scss +++ b/src/pages/index/index.scss @@ -4,6 +4,17 @@ &.hasMusicBox { padding-bottom: 220px; } + .banner_list { + height: 375px; + margin-top: 20px; + } + .banner_list__item__img { + width: 92%; + height: 375px; + position: relative; + left: 4%; + border-radius: 20px; + } .index_header { position: fixed; top: 0; diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx index 8e99795..bf3990c 100644 --- a/src/pages/index/index.tsx +++ b/src/pages/index/index.tsx @@ -1,11 +1,12 @@ import { ComponentClass } from 'react' import Taro, { Component, Config } from '@tarojs/taro' -import { View, Image, Text } from '@tarojs/components' +import { View, Image, Text, Swiper, SwiperItem } from '@tarojs/components' import { AtTabBar } from 'taro-ui' import { connect } from '@tarojs/redux' import classnames from 'classnames' import CLoading from '../../components/CLoading' import CMusic from '../../components/CMusic' +import api from '../../services/api' import { injectPlaySong } from '../../utils/decorators' import { songType } from '../../constants/commonType' import { @@ -60,7 +61,11 @@ type PageOwnProps = {} type PageState = { current: number, - showLoading: boolean + showLoading: boolean, + bannerList: Array<{ + typeTitle: string, + pic: string + }> } type IProps = PageStateProps & PageDispatchProps & PageOwnProps @@ -113,7 +118,8 @@ class Index extends Component { super(props) this.state = { current: 0, - showLoading: true + showLoading: true, + bannerList: [] } } @@ -129,6 +135,7 @@ class Index extends Component { this.getNewsong() this.getDjprogram() this.getRecommend() + this.getBanner() } componentWillUnmount () { } @@ -176,12 +183,32 @@ class Index extends Component { this.props.getRecommend() } + getBanner() { + api.get('/banner', { + type: 2 + }).then(({ data }) => { + console.log('banner', data) + if (data.banners) { + this.setState({ + bannerList: data.banners + }) + } + }) + } + goDetail(item) { Taro.navigateTo({ url: `/pages/playListDetail/index?id=${item.id}&name=${item.name}` }) } + goDjDetail() { + Taro.showToast({ + title: '暂未实现,敬请期待', + icon: 'none' + }) + } + removeLoading() { const { recommendPlayList, recommendDj } = this.props if (recommendPlayList.length || recommendDj.length) { @@ -193,7 +220,7 @@ class Index extends Component { render () { const { recommendPlayList, recommendDj, song } = this.props - const { showLoading } = this.state + const { showLoading, bannerList } = this.state return ( { }> + + { + bannerList.map((item, index) => + + + + ) + } + 推荐歌单 @@ -233,7 +276,7 @@ class Index extends Component { { - recommendDj.map((item, index) => + recommendDj.map((item, index) =>