import Taro, { Component } from '@tarojs/taro'
import { View, Input, Picker, ScrollView, Button } from '@tarojs/components'
import { Loading } from '@components'
import { connect } from '@tarojs/redux'
import * as actions from '@actions/list'
import ItemList from './itemlist'
import { getWindowHeight } from '@utils/style'
import './list.scss'
@connect(state => state.home, { ...actions, })
class List extends Component {
config = {
navigationBarTitleText: '报告列表'
}
state = {
loading: false,
lastItemId: 0,
hasMore: true,
selectorChecked: { id: 0, key: "按报告类型", value: 'title' },
selector: [
{ id: 0, key: "按报告类型", value: 'title' },
{ id: 1, key: "按企业名称", value: 'companyName' },
{ id: 2, key: "按项目名称", value: 'reportName' },
{ id: 3, key: "按关键词", value: 'keyword' },],
keyword: "",
dataList: [],
}
componentDidMount() {
this.getData()
}
page = 1
getData = () => {
let payload = {}
this.setState({ loading: true })
if (!this.state.keyword) {
payload = {
page: this.page
}
} else {
payload = {
page: this.page,
field: this.state.selectorChecked.value,
keyword: this.state.keyword,
}
}
this.props.getList(payload).then((data) => {
this.setState({
loading: false,
dataList: this.page === 1 ? data.reports : this.state.dataList.concat(data.reports),
})
page = data.reports.length === 0 ? this.page : this.page++
}).catch(() => {
this.setState({ loading: false })
})
}
onChange = e => {
this.setState({
selectorChecked: this.state.selector[e.detail.value],
})
}
onInput = e => {
this.setState({
keyword: e.detail.value
})
}
render() {
// if (this.state.loaded) {
// return
// }
return (
{this.state.selectorChecked.key} ▼
{
this.page = 1
this.getData()
}}
>搜索
)
}
}
export default List