|
@@ -1,26 +1,35 @@
|
|
|
import { Component } from 'react';
|
|
|
import Taro from '@tarojs/taro';
|
|
|
+import { connect } from 'react-redux'
|
|
|
import { View, Image } from '@tarojs/components'
|
|
|
+import { set } from '../../actions/counter'
|
|
|
import { getLiveList } from '../../utils/servers/servers'
|
|
|
import dayjs from 'dayjs';
|
|
|
|
|
|
-import ListBottomStart from '../../components/common/listBottomStart';
|
|
|
+import ListBottomStart from '../../components/common/listBottomStart';
|
|
|
|
|
|
import './index.less';
|
|
|
|
|
|
import background from '../../assets/images/background.png';
|
|
|
import NavBar from "../../components/NavBar";
|
|
|
|
|
|
+@connect(({ counter }) => ({
|
|
|
+ counter
|
|
|
+}), (dispatch) => ({
|
|
|
+ set(value) {
|
|
|
+ dispatch(set(value))
|
|
|
+ }
|
|
|
+}))
|
|
|
class LiveList extends Component {
|
|
|
|
|
|
constructor(props) {
|
|
|
super(props);
|
|
|
- this.state={
|
|
|
+ this.state = {
|
|
|
list: [],
|
|
|
pageNo: 0,
|
|
|
listState: 'LOADING',
|
|
|
}
|
|
|
- this.getLiveList= this.getLiveList.bind(this);
|
|
|
+ this.getLiveList = this.getLiveList.bind(this);
|
|
|
}
|
|
|
|
|
|
async componentDidShow() {
|
|
@@ -31,15 +40,15 @@ class LiveList extends Component {
|
|
|
await this.getLiveList();
|
|
|
}
|
|
|
|
|
|
- onPullDownRefresh(){
|
|
|
+ onPullDownRefresh() {
|
|
|
this.getLiveList();
|
|
|
}
|
|
|
|
|
|
- onReachBottom(){
|
|
|
- this.getLiveList(this.state.pageNo+1);
|
|
|
+ onReachBottom() {
|
|
|
+ this.getLiveList(this.state.pageNo + 1);
|
|
|
}
|
|
|
|
|
|
- async getLiveList (pageNo = 1){
|
|
|
+ async getLiveList(pageNo = 1) {
|
|
|
this.setState({
|
|
|
listState: 'LOADING'
|
|
|
})
|
|
@@ -47,30 +56,30 @@ class LiveList extends Component {
|
|
|
pageNo: pageNo,
|
|
|
pageSize: 10,
|
|
|
});
|
|
|
- if(msg.error.length === 0){
|
|
|
- if(msg.data.totalCount === 0){
|
|
|
+ if (msg.error.length === 0) {
|
|
|
+ if (msg.data.totalCount === 0) {
|
|
|
this.setState({
|
|
|
listState: 'NO_DATA'
|
|
|
})
|
|
|
- }else if(msg.data.totalCount === this.state.list.length && pageNo !== 1){
|
|
|
- Taro.showToast({title:'没有更多数据了',icon:'none'});
|
|
|
+ } else if (msg.data.totalCount === this.state.list.length && pageNo !== 1) {
|
|
|
+ Taro.showToast({ title: '没有更多数据了', icon: 'none' });
|
|
|
this.setState({
|
|
|
listState: 'NO_MORE_DATA'
|
|
|
})
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
this.setState({
|
|
|
- list:pageNo === 1 ? msg.data.list : this.state.list.concat(msg.data.list),
|
|
|
+ list: pageNo === 1 ? msg.data.list : this.state.list.concat(msg.data.list),
|
|
|
pageNo: msg.data.pageNo
|
|
|
- },()=>{
|
|
|
- if(msg.data.totalCount === this.state.list.length){
|
|
|
+ }, () => {
|
|
|
+ if (msg.data.totalCount === this.state.list.length) {
|
|
|
this.setState({
|
|
|
listState: 'NO_MORE_DATA'
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
- }else{
|
|
|
- Taro.showToast({title:msg.error[0].message,icon:'none'});
|
|
|
+ } else {
|
|
|
+ Taro.showToast({ title: msg.error[0].message, icon: 'none' });
|
|
|
this.setState({
|
|
|
listState: msg.error[0].field === '403' ? 'NO_DATA' : 'RELOAD'
|
|
|
})
|
|
@@ -78,23 +87,23 @@ class LiveList extends Component {
|
|
|
Taro.stopPullDownRefresh();
|
|
|
}
|
|
|
|
|
|
- render () {
|
|
|
+ render() {
|
|
|
return (
|
|
|
<View className='livePlayerPage'>
|
|
|
<NavBar
|
|
|
extClass='NavBar'
|
|
|
title='直播'
|
|
|
background='#7ac7ff'
|
|
|
- onHome={()=>{}}
|
|
|
+ onHome={() => { }}
|
|
|
/>
|
|
|
- <Image src={background} className='background'/>
|
|
|
+ <Image src={background} className='background' />
|
|
|
<View className='title'>推荐</View>
|
|
|
<View className='list'>
|
|
|
{
|
|
|
- this.state.list.map((v,k)=>(
|
|
|
- <View key={k} className='item' onClick={()=>{
|
|
|
+ this.state.list.map((v, k) => (
|
|
|
+ <View key={k} className='item' onClick={() => {
|
|
|
let customParams = encodeURIComponent(JSON.stringify({ path: 'pages/liveRoom/index', pid: 1 }));
|
|
|
- let url = 'plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id='+v.roomid+'&custom_params='+customParams;
|
|
|
+ let url = 'plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=' + v.roomid + '&custom_params=' + customParams;
|
|
|
Taro.navigateTo({
|
|
|
url
|
|
|
})
|
|
@@ -115,15 +124,15 @@ class LiveList extends Component {
|
|
|
{dayjs.unix(v.start_time).format('YYYY-MM-DD HH:mm:ss')}
|
|
|
</View>
|
|
|
</View>
|
|
|
- <Image className='thumbnailUrl' src={v.feeds_img} resizeMode='center'/>
|
|
|
+ <Image className='thumbnailUrl' src={v.feeds_img} resizeMode='center' />
|
|
|
</View>
|
|
|
))
|
|
|
}
|
|
|
<ListBottomStart
|
|
|
state={this.state.listState}
|
|
|
- reload={()=>{
|
|
|
- this.getLiveList(this.state.pageNo+1);
|
|
|
- }}/>
|
|
|
+ reload={() => {
|
|
|
+ this.getLiveList(this.state.pageNo + 1);
|
|
|
+ }} />
|
|
|
</View>
|
|
|
</View>
|
|
|
)
|