import React, { Component } from 'react'
import {
StyleSheet,
View,
StatusBar,
Dimensions,
ScrollView,
FlatList,
PixelRatio,
TouchableOpacity,
Text,
} from 'react-native'
import { connect } from 'react-redux'
import { NavigationActions, createAction, Storage } from '../../utils'
import Input from '../../components/input/index'
import Icon from '../../components/Iconfont/Iconfont'
import ModalEcx from '../../components/Modal'
const { width, height } = Dimensions.get('window')
// @connect(({ theme }) => ({ ...theme }))
class SearchResults extends Component {
constructor(props) {
super(props)
this.state = {
data: [],
rowPrice: 0,
autoFocusBool: true,
isShow: '请输入商品名称或商品编码',
defaultValue: '',
}
}
componentDidMount() {
this.storageOperate()
}
async storageOperate(e) {
let searchVals = []
let SearchData = await Storage.get('queryCondition', false)
if (SearchData) {
searchVals = searchVals.concat(SearchData)
}
if (e && e.replace(/(^s*)|(s*$)/g, ' ') != ' ') {
searchVals = searchVals.concat(e.replace(/(^\s*)|(\s*$)/g, ''))
Storage.set('queryCondition', searchVals)
}
searchVals = Array.from(new Set(searchVals))
this.setState({ data: searchVals })
}
_closeModal() {
this.mdl._setModalVisible(false)
}
_openModal = va => {
this.mdl._setModalVisible(true)
// if (va) {
this.setState({ defaultValue: va })
// }
}
recentRender(item, index) {
return (
{
if (this.props.comFrom && this.props.comFrom == 'CommodityShowbase') {
this.props.cb(item.item)
} else {
this.props.dispatch(
NavigationActions.navigate({
routeName: 'CommodityShowbase',
params: { searchval: item.item },
})
)
}
this._closeModal()
this.storageOperate(item.item)
}}
style={{
paddingHorizontal: 16,
paddingVertical: 4,
backgroundColor: '#EEE',
borderRadius: 100,
marginRight: 10,
marginTop: 13,
}}
>
{item.item}
)
}
_renderModalContent() {
return (
{
if (
this.props.comFrom &&
this.props.comFrom == 'CommodityShowbase'
) {
this.props.cb(e)
} else {
this.props.dispatch(
NavigationActions.navigate({
routeName: 'CommodityShowbase',
params: { searchval: e },
// params: { searchval: e ? e : this.state.defaultValue }
})
)
}
this._closeModal()
this.storageOperate(e)
}}
/>
{
this._closeModal()
}}
>
取消
最近搜索
index}
renderItem={(item, index) => this.recentRender(item, index)}
columnWrapperStyle={{ flexWrap: 'wrap' }}
numColumns={4}
/>
{
Storage.set('queryCondition', false)
this.storageOperate()
}}
style={{
marginTop: 60,
alignSelf: 'center',
justifyContent: 'center',
flexDirection: 'row',
}}
>
清空历史记录
)
}
render() {
return (
(this.mdl = mdl)}
content={this._renderModalContent()}
/>
)
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
icon: {
width: 32,
height: 32,
},
})
export default SearchResults