import React, { Component } from 'react'
import {
StyleSheet,
ScrollView,
View,
Text,
Image,
Dimensions,
StatusBar,
TouchableOpacity,
PixelRatio,
FlatList,
} from 'react-native'
import { connect } from 'react-redux'
import png from '../../../static/images/defaultimg.jpg'
import Icon from '../../../components/Iconfont/Iconfont'
import { NavigationActions, createAction } from '../../../utils'
import Checkbox from '../../../components/checkbox/index'
import CountNum from '../../../components/CountNum'
import Collapsible from 'react-native-collapsible'
import { ImageBaseUrl } from '../../../utils/fetch/Fetchx'
import dataModel from '../../common/datamodel/dataModel'
import { accSub } from '../../../utils/utils'
import Setting from '../../mine/Setting'
const { width, height } = Dimensions.get('window')
@connect(({ theme, attention, orderlist }) => ({
...theme,
...attention,
...orderlist,
}))
class Unpaid extends Component {
constructor(props) {
super(props)
this.state = {
topNavIndex: 2,
listIndex: true,
selectAll: false,
}
}
// 头部
header() {
return (
this.props.dispatch(NavigationActions.back())}
>
返回
关注
{/* this.setState({ listIndex: !this.state.listIndex })}
>
{this.state.listIndex ? "展开" : "收起"}
*/}
)
}
componentDidMount() {
let date = new Date().getTime()
this.props.dispatch(createAction('attention/getAttentionList')())
this.props.dispatch(
createAction('orderlist/getOrderList')({
listData: [],
pageInfo: { page: 0, size: 20 },
touchCode: 0,
searchInfo: {
search_IN_saleModel: '01,03',
search_GTE_orderDate_date: date - 7 * 24 * 3600 * 1000,
search_LT_orderDate_date: date,
},
})
)
}
replenList(item, index) {
return (
{/* {this.state.topNavIndex == 1 ? null : (
{
item.isChecked = bool;
if (
this.props.attentData &&
this.props.attentData.every(
item => item.isChecked == true
)
) {
this.setState({ selectAll: true });
} else {
this.setState({ selectAll: false });
}
}}
/>
)} */}
{item.goodsDisplayName}
编码:{item.goodsCode}
{/*
库存:{item.stock || 0} {item.mainNumUnitName}
*/}
{
this.props.dispatch(
createAction('attention/delAttention')(item.id)
)
}}
>
{
let postData = dataModel(
item,
CUSTOMERINFO.id,
CUSTOMERINFO.customerRankCode
)
this.props.dispatch(
createAction('shoppingcart/addShop')(postData)
)
}}
>
{/*
console.log(nv)}
/>
主数量:20
金额:
{CURRENCY.currencySign}72000.00
*/}
{/*
{this.state.topNavIndex !== 1
? `建议补货数量:100`
: `2018-12-12 已订购100件`}
{this.state.topNavIndex !== 1 ? (
在途量:15件
) : null}
{this.state.topNavIndex !== 1
? `安全库存天数:100件`
: `建议补货数量:100`}
{this.state.topNavIndex !== 1
? `日均销量:100件`
: `在途量:15件`}
*/}
)
}
selectAll(bool) {
for (let item of this.props.attentData) {
if (item && !item.isChecked) {
item.isChecked = bool
} else {
item.isChecked = bool
}
}
this.props.dispatch(
createAction('attention/updateAttention')({
attentData: this.props.attentData,
})
)
this.setState({ selectAll: bool })
}
render() {
const { appTheme, attentData, listData } = this.props
const { topNavIndex } = this.state
let newListData = []
if (
listData &&
listData.length > 0 &&
listData[1] &&
Object.keys(listData[1]).length > 0
) {
listData.sort((a, b) => b.orderDate - a.orderDate)
newListData = listData.slice(0, 20)
}
let FlatData = [],
mapObj = {}
if (topNavIndex == 1) {
if (newListData && newListData.length > 0) {
newListData.map(data => {
if (data.reqOrderItems && data.reqOrderItems.length > 0) {
data.reqOrderItems.map(item => {
item.saleOrgName = data.saleOrgName
item.saleOrgCode = data.saleOrgCode
item.saleOrgId = data.saleOrgId
mapObj[item.goodsId] = item
})
}
})
for (let objdata in mapObj) {
FlatData.push(mapObj[objdata])
}
} else {
FlatData = []
}
} else if (topNavIndex == 2) {
FlatData = attentData
}
return (
{/* 头部导航 */}
{this.header()}
{/* 二级导航 */}
{/* this.setState({ topNavIndex: 0, data: data1 })}
style={{
flex: 1,
alignItems: "center"
}}
>
快速补货(99+)
*/}
this.setState({ topNavIndex: 1, selectAll: false })}
style={{ flex: 1, alignItems: 'center' }}
>
最近购买
{
attentData.map(data => (data.isChecked = false))
this.setState({ topNavIndex: 2, selectAll: false })
}}
style={{ flex: 1, alignItems: 'center' }}
>
关注商品
{/* 列表 */}
index}
data={FlatData}
extraData={this.state}
renderItem={({ item, index }) => this.replenList(item, index)}
/>
{/* 底部加入购物车 */}
{/*
{this.state.topNavIndex == 1 ? null : (
this.selectAll(bool)}
label={
全选
}
labelStyle={{
fontSize: 14,
lineHeight: 20,
color: "#333",
alignSelf: "center"
}}
/>
)}
合计:
{CURRENCY.currencySign}72000.00
加入购物车
*/}
)
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
})
export default Unpaid