import React, { Component } from 'react' import { StyleSheet, View, Dimensions, TouchableOpacity, Text, FlatList, } from 'react-native' import Toast from 'react-native-root-toast' import { connect } from 'react-redux' import { createAction } from '../../../utils' import Input from '../../../components/input' import * as authService from '../../../services/auth' const { width, height } = Dimensions.get('window') // @connect(({ optional }) => ({ ...optional })) class GoodsFlatList extends Component { constructor(props) { super(props) this.state = { goodsList: [], kw: '', checkList: [] } } async componentDidMount() { this.getGoodsByKW('', true) } //颜色卡片列表 _goodsList( item, index,goodsList) { return( { goodsList.forEach(e => {e.isChecked = false}) item.isChecked = true goodsList.splice(goodsList.findIndex(e => e.code == item.code),1,item) this.setState({goodsList}) if (item.basePrice) { this.props.addGoods && this.props.addGoods(item) } else { Toast.show("未获取该商品价格,请选择其他商品",{position : toastHeight}); } }} > {item.name} 编码:{item.code} 型号:{item.specification} 规格:{item.model} 价格:¥ {item.basePrice || "--"} ) } //根据色卡号查询调色 async getGoodsByKW(kw,init) { if (!kw && !init) { Toast.show("请输入商品信息",{position : toastHeight}); return } const search = { page: 0, size: 10, search_EQ_isEnable: 1, search_keywords: kw, search_customerId: CUSTOMERINFO.id, search_customerRankCode: CUSTOMERINFO.customerRankCode } const goodsData = await authService.searchCommodityList(search) console.log('goodsData=================>', goodsData) // const goodsData = {} if (goodsData.status == 200) { this.setState({goodsList: goodsData.data.content}) } else { Toast.show("未搜索到商品信息",{position : toastHeight}); return } } render() { return ( { this.getGoodsByKW(e) }} /> 商品列表 index} style={{height:280}} data={this.state.goodsList} renderItem={({ item, key}) => this._goodsList(item, key,this.state.goodsList)} numColumns= {1} /> ) } } const styles = StyleSheet.create({ titleText: { fontSize: 14, lineHeight: 20, color: '#999', }, contentText: { flex: 1, fontSize: 13, lineHeight: 18, color: '#333', }, }) export default GoodsFlatList