Authored by QC-L

下拉刷新添加资源位刷新 review by 黄敬囿

... ... @@ -10,9 +10,7 @@ import getPrivateKey from '../../libs/request/getPrivateKey.js'
export default class Resources extends Component {
constructor(props) {
super(props);
this.state = {
floors: []
};
}
static defaultProps = {
... ... @@ -21,21 +19,8 @@ export default class Resources extends Component {
isShow: false
}
async componentDidMount() {
const pk = await getPrivateKey();
Taro.setStorage({ key: 'verifyKey', data: pk });
commonModel.resource(this.props.code).then(res => {
if (res && res.code === 200) {
this.setState({
floors: res.data
});
}
});
}
render() {
const { floors } = this.state;
const { isShow } = this.props;
const { isShow, floors } = this.props;
return (
<View className="resources">
... ...
... ... @@ -37,7 +37,8 @@ export default class Index extends Component {
],
page: {},
productList: {},
stopLoading: {}
stopLoading: {},
floors: []
}
}
... ... @@ -51,8 +52,27 @@ export default class Index extends Component {
onPullDownRefresh() {
let filterMenu = this.props.filterMenu;
this.getProductData(filterMenu).then(isFinish => {
this.getResource().then(() => {
Taro.stopPullDownRefresh();
}).catch(error => {
Taro.stopPullDownRefresh();
})
}).catch(error => {
Taro.stopPullDownRefresh();
});
}
async getResource() {
const pk = await getPrivateKey();
Taro.setStorage({ key: 'verifyKey', data: pk });
return commonModel.resource(contentCode.index).then(res => {
if (res && res.code === 200) {
this.setState({
floors: res.data
});
}
});
}
onReachBottom() {
... ... @@ -87,6 +107,7 @@ export default class Index extends Component {
this.setState(obj, () => {
this.getProductData();
this.getResource();
});
}
... ... @@ -185,7 +206,7 @@ export default class Index extends Component {
}
render() {
let {tabs, productList} = this.state;
let {tabs, productList, isRefresh, floors} = this.state;
let {filterMenu} = this.props;
let list = productList[filterMenu.indexType] || [];
... ... @@ -203,7 +224,7 @@ export default class Index extends Component {
onScrollToLower={this.onScrollToLower}>
<Resources code={contentCode.index}></Resources>
<Resources isRefresh={isRefresh} floors={floors}></Resources>
<FilterMenu filterMenu={filterMenu} tabs={tabs} tabClass="border" fromPage="index"></FilterMenu>
{
list &&
... ...