index.jsx 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. import { Component } from 'react';
  2. import Taro from '@tarojs/taro';
  3. import { View } from '@tarojs/components'
  4. import { getPublicReleaseList } from '../../utils/servers/servers';
  5. import { AtTabs, AtTabsPane } from 'taro-ui';
  6. import ListBottomStart from '../../components/common/listBottomStart';
  7. import './index.less';
  8. import 'taro-ui/dist/style/components/tabs.scss';
  9. import MyList from './myList';
  10. class Examine extends Component {
  11. constructor(props) {
  12. super(props);
  13. this.state={
  14. current:0,
  15. list: [],
  16. pageNo: 1,
  17. listState: 'LOADING',
  18. examinelist: [],
  19. examinePageNo: 1,
  20. examineListState: 'LOADING',
  21. }
  22. this.getPublicReleaseList= this.getPublicReleaseList.bind(this);
  23. this.getMyList= this.getMyList.bind(this);
  24. this.getExamineList= this.getExamineList.bind(this);
  25. }
  26. componentDidShow() {
  27. }
  28. async componentDidMount() {
  29. await this.getPublicReleaseList();
  30. }
  31. onPullDownRefresh(){
  32. this.getPublicReleaseList();
  33. }
  34. onReachBottom(){
  35. this.getPublicReleaseList(true);
  36. }
  37. async getPublicReleaseList (lv){
  38. if(this.state.current === 0){
  39. await this.getMyList(lv ? this.state.pageNo + 1 : 1)
  40. } else if(this.state.current === 1){
  41. await this.getExamineList(lv ? this.state.examinePageNo + 1 : 1)
  42. }
  43. }
  44. async getMyList(pageNo){
  45. this.setState({
  46. listState: 'LOADING'
  47. })
  48. let msg = await getPublicReleaseList({
  49. pageNo: pageNo,
  50. pageSize: 10,
  51. type:0,
  52. });
  53. if(msg.error.length === 0){
  54. if(msg.data.totalCount === 0){
  55. this.setState({
  56. listState: 'NO_DATA'
  57. })
  58. }else if(msg.data.totalCount === this.state.list.length && pageNo !== 1){
  59. Taro.showToast({title:'没有更多数据了',icon:'none'});
  60. this.setState({
  61. listState: 'NO_MORE_DATA'
  62. })
  63. }else{
  64. this.setState({
  65. list:pageNo === 1 ? msg.data.list : this.state.list.concat(msg.data.list),
  66. pageNo: msg.data.pageNo
  67. },()=>{
  68. if(msg.data.totalCount === this.state.list.length){
  69. this.setState({
  70. listState: 'NO_MORE_DATA'
  71. })
  72. }
  73. })
  74. }
  75. }else{
  76. Taro.showToast({title:msg.error[0].message,icon:'none'});
  77. this.setState({
  78. listState: msg.error[0].field === '403' ? 'NO_DATA' : 'RELOAD'
  79. })
  80. }
  81. Taro.stopPullDownRefresh();
  82. }
  83. async getExamineList(pageNo){
  84. this.setState({
  85. examineListState: 'LOADING'
  86. })
  87. let msg = await getPublicReleaseList({
  88. pageNo: pageNo,
  89. pageSize: 10,
  90. type:1,
  91. });
  92. if(msg.error.length === 0){
  93. if(msg.data.totalCount === 0){
  94. this.setState({
  95. examineListState: 'NO_DATA'
  96. })
  97. }else if(msg.data.totalCount === this.state.examinelist.length && pageNo !== 1){
  98. Taro.showToast({title:'没有更多数据了',icon:'none'});
  99. this.setState({
  100. examineListState: 'NO_MORE_DATA'
  101. })
  102. }else{
  103. this.setState({
  104. examinelist:pageNo === 1 ? msg.data.list : this.state.examinelist.concat(msg.data.list),
  105. examinePageNo: msg.data.pageNo
  106. },()=>{
  107. if(msg.data.totalCount === this.state.examinelist.length){
  108. this.setState({
  109. examineListState: 'NO_MORE_DATA'
  110. })
  111. }
  112. })
  113. }
  114. }else{
  115. Taro.showToast({title:msg.error[0].message,icon:'none'});
  116. this.setState({
  117. examineListState: msg.error[0].field === '403' ? 'NO_DATA' : 'RELOAD'
  118. })
  119. }
  120. Taro.stopPullDownRefresh();
  121. }
  122. render () {
  123. return (
  124. <View className='indexPage'>
  125. <AtTabs current={this.state.current || 0} tabList={[{ title: '我的' }, { title: '审核' }]} onClick={(current)=>{
  126. this.setState({
  127. current
  128. },()=>{
  129. if((current === 0 && this.state.pageNo === 1) || (current === 1 && this.state.examinePageNo === 1)){
  130. this.getPublicReleaseList();
  131. }
  132. })
  133. }}>
  134. <AtTabsPane current={this.state.current} index={0} >
  135. <MyList
  136. type={0}
  137. list={this.state.list}
  138. listState={this.state.listState}
  139. onRefresh={()=>{
  140. this.getPublicReleaseList(true);
  141. }}/>
  142. </AtTabsPane>
  143. <AtTabsPane current={this.state.current} index={1}>
  144. <MyList
  145. type={1}
  146. list={this.state.examinelist}
  147. listState={this.state.examineListState}
  148. onRefresh={()=>{
  149. this.getPublicReleaseList(true);
  150. }}/>
  151. </AtTabsPane>
  152. </AtTabs>
  153. </View>
  154. )
  155. }
  156. }
  157. export default Examine