...
|
...
|
@@ -42,8 +42,32 @@ export default class Index extends Component { |
|
|
}
|
|
|
|
|
|
config = {
|
|
|
navigationBarTitleText: 'UFO'
|
|
|
};
|
|
|
navigationBarTitleText: 'UFO',
|
|
|
enablePullDownRefresh: true,
|
|
|
backgroundTextStyle: "dark",
|
|
|
onReachBottomDistance: 50
|
|
|
};
|
|
|
|
|
|
onPullDownRefresh() {
|
|
|
let filterMenu = this.props.filterMenu;
|
|
|
this.getProductData(filterMenu).then(isFinish => {
|
|
|
Taro.stopPullDownRefresh();
|
|
|
});
|
|
|
}
|
|
|
|
|
|
onReachBottom() {
|
|
|
let { filterMenu } = this.props;
|
|
|
let { page } = this.state;
|
|
|
let type = filterMenu.indexType;
|
|
|
|
|
|
console.log('onReachBottom: ', type);
|
|
|
|
|
|
if (!this.state.stopLoading[type]) {
|
|
|
this.setState({ page: Object.assign(page, { [type]: page[type] + 1 }) }, () => {
|
|
|
this.getProductData();
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
componentDidMount() {
|
|
|
let obj = {
|
...
|
...
|
@@ -66,13 +90,15 @@ export default class Index extends Component { |
|
|
});
|
|
|
}
|
|
|
|
|
|
componentWillReceiveProps(nextProps) {
|
|
|
componentWillReceiveProps(nextProps, oldProps) {
|
|
|
let curType = nextProps.filterMenu.indexType;
|
|
|
let oldCurType = oldProps && oldProps.filterMenu && oldProps.filterMenu.indexType;
|
|
|
let { productList } = this.state;
|
|
|
|
|
|
console.log(curType);
|
|
|
if (productList[curType].length === 0) {
|
|
|
this.getProductData(nextProps.filterMenu);
|
|
|
if (curType !== oldCurType) {
|
|
|
if (productList[curType].length === 0) {
|
|
|
this.getProductData(nextProps.filterMenu);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -90,10 +116,9 @@ export default class Index extends Component { |
|
|
type: type,
|
|
|
page: page[type]
|
|
|
}).then(ret => {
|
|
|
console.log(ret);
|
|
|
if (ret && ret.code === 200) {
|
|
|
let list = ret.data && ret.data.product_list || [];
|
|
|
|
|
|
|
|
|
if (list.length === 0) {
|
|
|
this.setState({
|
|
|
stopLoading: Object.assign(stopLoading, { [type]: true })
|
...
|
...
|
@@ -104,7 +129,10 @@ export default class Index extends Component { |
|
|
});
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
return true;
|
|
|
}).catch(error => {
|
|
|
return false;
|
|
|
});
|
|
|
}
|
|
|
|
|
|
onScrollToLower() {
|
...
|
...
|
@@ -121,6 +149,8 @@ export default class Index extends Component { |
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// gotoNative() {
|
|
|
// Taro.navigateTo({
|
|
|
// url: '/pages/nativeTest/nativeTest'
|
...
|
...
|
@@ -160,7 +190,7 @@ export default class Index extends Component { |
|
|
let list = productList[filterMenu.indexType] || [];
|
|
|
|
|
|
return (
|
|
|
<ScrollView
|
|
|
<View
|
|
|
className='index-page'
|
|
|
scrollY
|
|
|
scrollWithAnimation
|
...
|
...
|
@@ -181,7 +211,7 @@ export default class Index extends Component { |
|
|
}
|
|
|
|
|
|
<Image className="goYohoBuy" onClick={this.goYohoBuyMinApp.bind(this)} src={goYohoBuy} mode="aspectFill" />
|
|
|
</ScrollView>
|
|
|
</View>
|
|
|
)
|
|
|
}
|
|
|
}
|
...
|
...
|
|