123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- import { Component } from 'react';
- import Taro from '@tarojs/taro';
- import { View } from '@tarojs/components'
- import { getPublicReleaseList } from '../../utils/servers/servers';
- import { AtTabs, AtTabsPane } from 'taro-ui';
- import ListBottomStart from '../../components/common/listBottomStart';
- import './index.less';
- import 'taro-ui/dist/style/components/tabs.scss';
- import MyList from './myList';
- class Examine extends Component {
- constructor(props) {
- super(props);
- this.state={
- current:0,
- list: [],
- pageNo: 1,
- listState: 'LOADING',
- examinelist: [],
- examinePageNo: 1,
- examineListState: 'LOADING',
- }
- this.getPublicReleaseList= this.getPublicReleaseList.bind(this);
- this.getMyList= this.getMyList.bind(this);
- this.getExamineList= this.getExamineList.bind(this);
- }
- componentDidShow() {
- }
- async componentDidMount() {
- await this.getPublicReleaseList();
- }
- onPullDownRefresh(){
- this.getPublicReleaseList();
- }
- onReachBottom(){
- this.getPublicReleaseList(true);
- }
- async getPublicReleaseList (lv){
- if(this.state.current === 0){
- await this.getMyList(lv ? this.state.pageNo + 1 : 1)
- } else if(this.state.current === 1){
- await this.getExamineList(lv ? this.state.examinePageNo + 1 : 1)
- }
- }
- async getMyList(pageNo){
- this.setState({
- listState: 'LOADING'
- })
- let msg = await getPublicReleaseList({
- pageNo: pageNo,
- pageSize: 10,
- type: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'});
- this.setState({
- listState: 'NO_MORE_DATA'
- })
- }else{
- this.setState({
- 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){
- this.setState({
- listState: 'NO_MORE_DATA'
- })
- }
- })
- }
- }else{
- Taro.showToast({title:msg.error[0].message,icon:'none'});
- this.setState({
- listState: msg.error[0].field === '403' ? 'NO_DATA' : 'RELOAD'
- })
- }
- Taro.stopPullDownRefresh();
- }
- async getExamineList(pageNo){
- this.setState({
- examineListState: 'LOADING'
- })
- let msg = await getPublicReleaseList({
- pageNo: pageNo,
- pageSize: 10,
- type:1,
- });
- if(msg.error.length === 0){
- if(msg.data.totalCount === 0){
- this.setState({
- examineListState: 'NO_DATA'
- })
- }else if(msg.data.totalCount === this.state.examinelist.length && pageNo !== 1){
- Taro.showToast({title:'没有更多数据了',icon:'none'});
- this.setState({
- examineListState: 'NO_MORE_DATA'
- })
- }else{
- this.setState({
- examinelist:pageNo === 1 ? msg.data.list : this.state.examinelist.concat(msg.data.list),
- examinePageNo: msg.data.pageNo
- },()=>{
- if(msg.data.totalCount === this.state.examinelist.length){
- this.setState({
- examineListState: 'NO_MORE_DATA'
- })
- }
- })
- }
- }else{
- Taro.showToast({title:msg.error[0].message,icon:'none'});
- this.setState({
- examineListState: msg.error[0].field === '403' ? 'NO_DATA' : 'RELOAD'
- })
- }
- Taro.stopPullDownRefresh();
- }
- render () {
- return (
- <View className='indexPage'>
- <AtTabs current={this.state.current || 0} tabList={[{ title: '我的' }, { title: '审核' }]} onClick={(current)=>{
- this.setState({
- current
- },()=>{
- if((current === 0 && this.state.pageNo === 1) || (current === 1 && this.state.examinePageNo === 1)){
- this.getPublicReleaseList();
- }
- })
- }}>
- <AtTabsPane current={this.state.current} index={0} >
- <MyList
- type={0}
- list={this.state.list}
- listState={this.state.listState}
- onRefresh={()=>{
- this.getPublicReleaseList(true);
- }}/>
- </AtTabsPane>
- <AtTabsPane current={this.state.current} index={1}>
- <MyList
- type={1}
- list={this.state.examinelist}
- listState={this.state.examineListState}
- onRefresh={()=>{
- this.getPublicReleaseList(true);
- }}/>
- </AtTabsPane>
- </AtTabs>
- </View>
- )
- }
- }
- export default Examine
|