ChooseGoods.js 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. import React, { Component } from 'react'
  2. import {
  3. StyleSheet,
  4. View,
  5. Image,
  6. StatusBar,
  7. Dimensions,
  8. TouchableOpacity,
  9. PixelRatio,
  10. Text,
  11. FlatList,
  12. } from 'react-native'
  13. import { connect } from 'react-redux'
  14. import { Button } from '../../components'
  15. import Icon from '../../components/Iconfont/Iconfont'
  16. import { NavigationActions, createAction } from '../../utils'
  17. import Input from '../../components/input/index'
  18. import Checkbox from '../../components/checkbox/index'
  19. import Grid from '../../components/Grid'
  20. import Collapsible from 'react-native-collapsible'
  21. import SearchModal from './SearchResults'
  22. const { width, height } = Dimensions.get('window')
  23. const data1 = [
  24. { a: 'aaa', id: 'a1' },
  25. { a: 'aaa', id: 'a2' },
  26. { a: 'aaa', id: 'a3' },
  27. ]
  28. const data2 = [
  29. { a: 'bbb', id: 'b1' },
  30. { a: 'bbb', id: 'b2' },
  31. { a: 'bbb', id: 'b3' },
  32. ]
  33. @connect(({ theme, home }) => ({ ...theme, ...home }))
  34. class ChooseGoods extends Component {
  35. constructor(props) {
  36. super()
  37. this.state = {
  38. allProDatas: [],
  39. priceCompany: false,
  40. listRowBool: true,
  41. filterIndex1: 0,
  42. filterIndex2: 0,
  43. collapsed: true,
  44. collapsed1: false,
  45. collapsed2: false,
  46. gridStyle: {
  47. viewWid: {
  48. width: width,
  49. height: width * 0.4 + 1,
  50. borderBottomColor: '#F5F5F5',
  51. borderBottomWidth: 1 / PixelRatio.get(),
  52. },
  53. imgWid: {
  54. width: width * 0.4,
  55. height: width * 0.4,
  56. },
  57. },
  58. }
  59. }
  60. componentWillMount() {
  61. this.setState({ allProDatas: this.props.allProDatas })
  62. }
  63. gotoDetail = () => {
  64. this.props.dispatch(NavigationActions.navigate({ routeName: 'Detail' }))
  65. }
  66. toggleExpanded(e) {
  67. if (!this.state.collapsed1 && !this.state.collapsed2) {
  68. e == '1'
  69. ? this.setState({
  70. collapsed: !this.state.collapsed,
  71. collapsed1: !this.state.collapsed1,
  72. })
  73. : this.setState({
  74. collapsed: !this.state.collapsed,
  75. collapsed2: !this.state.collapsed2,
  76. })
  77. } else {
  78. this.state.collapsed1
  79. ? e == '1'
  80. ? this.setState({
  81. collapsed: !this.state.collapsed,
  82. collapsed1: !this.state.collapsed1,
  83. })
  84. : this.setState({
  85. collapsed1: !this.state.collapsed1,
  86. collapsed2: !this.state.collapsed2,
  87. })
  88. : e == '1'
  89. ? this.setState({
  90. collapsed1: !this.state.collapsed1,
  91. collapsed2: !this.state.collapsed2,
  92. })
  93. : this.setState({
  94. collapsed: !this.state.collapsed,
  95. collapsed2: !this.state.collapsed2,
  96. })
  97. }
  98. }
  99. filterIndexfun(index, selnum) {
  100. selnum == '1'
  101. ? this.setState({
  102. filterIndex1: index,
  103. collapsed: !this.state.collapsed,
  104. collapsed1: !this.state.collapsed1,
  105. })
  106. : this.setState({
  107. filterIndex2: index,
  108. collapsed: !this.state.collapsed,
  109. collapsed2: !this.state.collapsed2,
  110. })
  111. }
  112. filterRender(item) {
  113. if (this.state.collapsed1 && !this.state.collapsed2) {
  114. return (
  115. <TouchableOpacity
  116. key={item.item.id}
  117. style={{
  118. marginBottom: 10,
  119. }}
  120. onPress={() => this.filterIndexfun(item.index, '1')}
  121. >
  122. {this.state.filterIndex1 == item.index ? (
  123. <View
  124. style={{
  125. flexDirection: 'row',
  126. justifyContent: 'space-between',
  127. }}
  128. >
  129. <Text style={{ color: 'red' }}>{item.item.a}</Text>
  130. <Icon name="icon-icon-duigou" size={16} color={'red'} />
  131. </View>
  132. ) : (
  133. <Text>{item.item.a}</Text>
  134. )}
  135. </TouchableOpacity>
  136. )
  137. } else {
  138. return (
  139. <TouchableOpacity
  140. key={item.item.id}
  141. style={{
  142. marginBottom: 10,
  143. }}
  144. onPress={() => this.filterIndexfun(item.index, '2')}
  145. >
  146. {this.state.filterIndex2 == item.index ? (
  147. <View
  148. style={{
  149. flexDirection: 'row',
  150. justifyContent: 'space-between',
  151. }}
  152. >
  153. <Text style={{ color: 'red' }}>{item.item.a}</Text>
  154. <Icon name="icon-icon-duigou" size={16} color={'red'} />
  155. </View>
  156. ) : (
  157. <Text>{item.item.a}</Text>
  158. )}
  159. </TouchableOpacity>
  160. )
  161. }
  162. }
  163. checkClick(bool, checkname) {
  164. switch (checkname) {
  165. case 'newpro':
  166. console.log('newpro>>>>>' + bool)
  167. break
  168. case 'inventory':
  169. console.log('inventory>>>>' + bool)
  170. break
  171. case 'hotsale':
  172. console.log('hotsale>>>>>' + bool)
  173. break
  174. }
  175. }
  176. listRowCol() {
  177. if (this.state.listRowBool) {
  178. this.setState({
  179. listRowBool: !this.state.listRowBool,
  180. gridStyle: {
  181. viewWid: {
  182. borderRightColor: '#F5F5F5',
  183. borderRightWidth: 1 / PixelRatio.get(),
  184. borderBottomColor: '#F5F5F5',
  185. borderBottomWidth: 1 / PixelRatio.get(),
  186. width: width / 2,
  187. height: width / 2 + 110,
  188. },
  189. imgWid: {
  190. width: width / 2 - 1,
  191. height: width / 2,
  192. },
  193. },
  194. })
  195. } else {
  196. this.setState({
  197. listRowBool: !this.state.listRowBool,
  198. gridStyle: {
  199. viewWid: {
  200. width: width,
  201. height: width * 0.4 + 1,
  202. borderBottomColor: '#F5F5F5',
  203. borderBottomWidth: 1 / PixelRatio.get(),
  204. },
  205. imgWid: {
  206. width: width * 0.4,
  207. height: width * 0.4,
  208. },
  209. },
  210. })
  211. }
  212. }
  213. render() {
  214. const { appTheme } = this.props
  215. return (
  216. <View
  217. style={[
  218. styles.container,
  219. { backgroundColor: appTheme.backgroundColor },
  220. ]}
  221. >
  222. <StatusBar
  223. animated={true}
  224. barStyle={appTheme.barStyle}
  225. backgroundColor={'transparent'}
  226. translucent={true}
  227. />
  228. <View
  229. style={{
  230. width: width,
  231. // height: 68,
  232. height: HEADERSTYLE.height + 8,
  233. backgroundColor: '#FFF',
  234. flexDirection: 'row',
  235. justifyContent: 'space-between',
  236. paddingHorizontal: 10,
  237. paddingBottom: 7,
  238. borderBottomColor: '#DDD',
  239. borderBottomWidth: 1 / PixelRatio.get(),
  240. }}
  241. >
  242. <TouchableOpacity
  243. style={{ alignSelf: 'flex-end' }}
  244. onPress={() => this.props.dispatch(NavigationActions.back())}
  245. >
  246. <Icon
  247. name="icon-icon-xiala"
  248. style={{ transform: [{ rotate: '90deg' }] }}
  249. size={28}
  250. color={'#666'}
  251. />
  252. </TouchableOpacity>
  253. <View style={{ flexDirection: 'row' }}>
  254. <Input
  255. touchBool={true}
  256. touchInput={() => this.mdl._openModal()}
  257. style={{
  258. height: 30,
  259. width: width / 1.36,
  260. borderRadius: width / 2,
  261. alignSelf: 'flex-end',
  262. paddingLeft: 14,
  263. }}
  264. placeholder={'商品名称/编码'}
  265. textInputBacg={'#EEE'}
  266. iconColor={'#999'}
  267. placeholderTextColor={'#999'}
  268. // onchangeFn={e => {
  269. // console.log(e);
  270. // }}
  271. />
  272. <View
  273. style={{ alignSelf: 'flex-end', marginLeft: 8, marginBottom: 3 }}
  274. >
  275. <Icon
  276. name="icon-icon-shangpin"
  277. size={20}
  278. color={'#666'}
  279. onPress={() => this.listRowCol()}
  280. />
  281. </View>
  282. </View>
  283. </View>
  284. <SearchModal
  285. // cb={data => {
  286. // this._refreshPlist(data);
  287. // }}
  288. ref={mdl => (this.mdl = mdl)}
  289. // fuleipro={this.state.footerdata}
  290. dispatch={this.props.dispatch}
  291. comFrom={'ChooseGoods'}
  292. />
  293. </View>
  294. )
  295. }
  296. }
  297. const styles = StyleSheet.create({
  298. container: {
  299. flex: 1,
  300. },
  301. icon: {
  302. width: 32,
  303. height: 32,
  304. },
  305. })
  306. export default ChooseGoods