import React, { Component } from 'react'
import {
StyleSheet,
View,
Image,
Text,
StatusBar,
Alert,
ImageBackground,
PixelRatio,
TouchableOpacity,
ScrollView,
} from 'react-native'
import { connect } from 'react-redux'
import { createAction, NavigationActions } from '../../utils'
import Icon from '../../components/Iconfont/Iconfont'
import CodePush from 'react-native-code-push'
import Background from '../../static/images/mine-background.png'
import TX from '../../static/images/mine-TX.png'
import { ScaleUtil } from '../../utils/utils'
import MineHome_0 from '../../static/images/MineHome-0.png'
import MineHome_1 from '../../static/images/MineHome-1.png'
import MineHome_2 from '../../static/images/MineHome-2.png'
import MineHome_3 from '../../static/images/MineHome-3.png'
import MineHome_4 from '../../static/images/MineHome-4.png'
import MineHome_5 from '../../static/images/MineHome-5.png'
import { ppHOC, POC, extHOC } from './highComponent'
import { isIphoneX } from '../common/theme/config'
// @CodePush({
// checkFrequency: CodePush.CheckFrequency.ON_APP_RESUME,
// installMode: CodePush.InstallMode.ON_NEXT_RESUME
// })
@connect(({ theme, mine_header }) => ({ ...theme, ...mine_header }))
class MineHome extends Component {
constructor(props) {
super(props)
this.state = {
huanfu: '',
}
}
static navigationOptions = {
tabBarLabel: ({ tintColor }) => (
我的
),
tabBarIcon: ({ focused, tintColor }) =>
tintColor == '#333' ? (
) : (
),
}
hotDog() {
// //访问慢,不稳定
CodePush.checkForUpdate().then(update => {
if (!update) {
Alert.alert('提示', '已是最新版本--', [
{
text: 'Ok',
onPress: () => {
console.log('点了OK')
},
},
])
} else {
CodePush.sync({
// deploymentKey:
// "ODZaOd9nY_uCJ1PiwkHL-CUb23lr8504fd21-5b83-418e-89df-e737a5111208",
// updateDialog: {
// optionalIgnoreButtonLabel: "稍后",
// optionalInstallButtonLabel: "立即更新",
// optionalUpdateMessage: "有新版本了,是否更新?",
// title: "更新提示"
// },
updateDialog: true,
installMode: CodePush.InstallMode.IMMEDIATE,
})
}
})
}
codePushStatusDidChange(status) {
switch (status) {
case codePush.SyncStatus.CHECKING_FOR_UPDATE:
console.log('Checking for updates.')
break
case codePush.SyncStatus.DOWNLOADING_PACKAGE:
console.log('Downloading package.')
break
case codePush.SyncStatus.INSTALLING_UPDATE:
console.log('Installing update.')
break
case codePush.SyncStatus.UP_TO_DATE:
console.log('Up-to-date.')
break
case codePush.SyncStatus.UPDATE_INSTALLED:
console.log('Update installed.')
break
}
}
codePushDownloadDidProgress(progress) {
console.log(
progress.receivedBytes + ' of ' + progress.totalBytes + ' received.'
)
}
componentDidMount = () => {
const date = new Date().getTime()
// 信用当前可用余额
// this.RequestOthers('mine_header/CreditSaga', {
// customer: CUSTOMERINFO.id,
// })
// 费用当前可用余额
// this.RequestOthers('mine_header/CastBalSaga', {
// search_customer: CUSTOMERINFO.id,
// search_billDate_date: date,
// })
// 可用财务组织、销售组织
this.RequestOthers('mine/getCusSup', {
customerId: CUSTOMERINFO.id,
customerRankCode: CUSTOMERINFO.customerRankCode,
comeFrom: 'castBalance',
})
// 账户余额
this.RequestOthers('mine_header/MaxBalanceSaga', {
customerId: CUSTOMERINFO.id,
})
}
// 跳转
NavigateToOthers(routeName, params) {
this.props.dispatch(
NavigationActions.navigate({ routeName: routeName, params: params })
)
}
// 请求
RequestOthers(actionName, actionSearch) {
this.props.dispatch(createAction(actionName)(actionSearch))
}
skinChange = () => {
if (this.state.huanfu == 0) {
this.RequestOthers('theme/getTheme', { getColor: 'black' })
this.state.huanfu = 1
} else {
this.RequestOthers('theme/getTheme', { getColor: 'white' })
this.state.huanfu = 0
}
}
logout = () => {
this.RequestOthers('app/logout')
}
TouchList(item) {
let returnVal = [],
ImageView = []
for (let i = 0; i < item.length; i++) {
if (item[i].text == '应付对账') {
ImageView = (
)
} else if (item[i].text == '费用对账') {
ImageView = (
)
} else if (item[i].text == '基本信息') {
ImageView = (
)
} else if (item[i].text == '客户收货地址') {
ImageView = (
)
} else if (item[i].text == '客户联系人') {
ImageView = (
)
} else if (item[i].text == '我的供应商') {
ImageView = (
)
}
returnVal.push(
item[i].onTouch()}
style={{
paddingVertical: 10,
flexDirection: 'row',
justifyContent: 'space-between',
borderTopWidth: 1 / PixelRatio.get(),
borderTopColor: '#EEE',
}}
>
{/* */}
{ImageView}
{item[i].text}
)
}
return (
{returnVal}
)
}
render() {
const { appTheme, creditBalance, CastDdlData, maxBalData } = this.props
// 对账
const duizhang = [
{
text: '应付对账',
onTouch: () => this.NavigateToOthers('PayReconciliation'),
},
{
text: '费用对账',
onTouch: () => {
this.RequestOthers('mine/getOrgans', { searchMore: true })
this.RequestOthers('mine/getCusSup', {
customerId: CUSTOMERINFO.id,
customerRankCode: CUSTOMERINFO.customerRankCode,
forUse: 'CostReconciliation',
})
},
},
]
const basicInfo = [
{
text: '基本信息',
onTouch: () =>
this.RequestOthers('mine/getBasic', { customerId: CUSTOMERINFO.id }),
},
{
text: '客户收货地址',
onTouch: () =>
this.RequestOthers('mine/getCusAdd', { customerId: CUSTOMERINFO.id }),
},
{
text: '客户联系人',
onTouch: () =>
this.RequestOthers('mine/getContacts', {
customerId: CUSTOMERINFO.id,
}),
},
// {
// text: '付款单登记',
// onTouch: () => this.NavigateToOthers('PaymentRegister'),
// },
// {
// text: '支付单',
// onTouch: () => this.NavigateToOthers('RechargeHome'),
// },
]
const mySupplier = [
{
text: '我的供应商',
onTouch: () =>
this.RequestOthers('mine/getCusSup', {
customerId: CUSTOMERINFO.id,
customerRankCode: CUSTOMERINFO.customerRankCode,
comeFrom: 'supplier',
toOthers: true,
}),
},
]
return (
this.NavigateToOthers('Setting')}
/>
{/* */}
{/* {USERINFO.userName} */}
{CUSTOMERINFO.name}
{CUSTOMERINFO.customerRankCode == 1 ? (
{/* this.NavigateToOthers('Account')}
style={{
flex: 1,
paddingVertical: 8,
alignItems: 'center',
}}
>
{CURRENCY.currencySign}
{ScaleUtil(maxBalData || 0, CURRENCY.currencyAmountScale)}
账户
*/}
{/* {
this.RequestOthers('mine/getOrgans', { forUse: 'tiaozhuan' })
}}
style={{
flex: 1,
paddingVertical: 10,
alignItems: 'center',
}}
>
{CURRENCY.currencySign}
{ScaleUtil(CastDdlData, CURRENCY.currencyAmountScale)}
费用
*/}
{/* {
this.NavigateToOthers('Credit')
}}
style={{
flex: 1,
paddingVertical: 10,
alignItems: 'center',
}}
>
{CURRENCY.currencySign}
{ScaleUtil(creditBalance, CURRENCY.currencyAmountScale)}
信用
*/}
) : null}
{/* {CUSTOMERINFO.customerRankCode == 1 ? this.TouchList(duizhang) : null} */}
{this.TouchList(basicInfo)}
{this.TouchList(mySupplier)}
{/* {this.TouchList([
{ text: "换肤", onTouch: () => this.skinChange() },
{
text: "更新",
onTouch: () => this.hotDog()
}
])} */}
)
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
})
// MineHome = CodePush(MineHome);
export default MineHome