Commit 2c44e827 by 姜雷

修改首页样式以及豆展示问题

parent 33942358
...@@ -78,7 +78,6 @@ ...@@ -78,7 +78,6 @@
.Home-UserBox-Bean { .Home-UserBox-Bean {
padding: 32px 40px 70px; padding: 32px 40px 70px;
display: flex; display: flex;
justify-content: space-around;
flex-flow: wrap; flex-flow: wrap;
font-size: 24px; font-size: 24px;
color: #666; color: #666;
...@@ -86,6 +85,7 @@ ...@@ -86,6 +85,7 @@
width: 40%; width: 40%;
display: flex; display: flex;
align-items: center; align-items: center;
margin: 0 5%;
} }
.Home-UserBox-BeanIcon { .Home-UserBox-BeanIcon {
width: 24px; width: 24px;
......
...@@ -44,6 +44,7 @@ import MenuIconBlock from '@/components/MenuIcon/block/MenuIconBlock'; ...@@ -44,6 +44,7 @@ import MenuIconBlock from '@/components/MenuIcon/block/MenuIconBlock';
import MenuIconBig from '@/components/MenuIcon/big/MenuIconBig'; import MenuIconBig from '@/components/MenuIcon/big/MenuIconBig';
enum BeanType { enum BeanType {
aimi = 'aimi',
shower = 'shower', shower = 'shower',
hairDryer = 'hairDryer', hairDryer = 'hairDryer',
water = 'water', water = 'water',
...@@ -130,13 +131,17 @@ class Home extends Component { ...@@ -130,13 +131,17 @@ class Home extends Component {
type: ServiceTypeParams.wechatAppV, type: ServiceTypeParams.wechatAppV,
}).then(res => { }).then(res => {
console.log(res); console.log(res);
this.setState({ this.setState(
serviceList: res.data, {
}); serviceList: res.data,
const { beanAccount } = this.state; },
if (beanAccount && beanAccount.length) { () => {
this.getFilterBeanList(); const { beanAccount } = this.state;
} if (beanAccount && beanAccount.length) {
this.getFilterBeanList();
}
},
);
}); });
} }
} }
...@@ -151,13 +156,17 @@ class Home extends Component { ...@@ -151,13 +156,17 @@ class Home extends Component {
}) })
.then(res => { .then(res => {
const data = res.data; const data = res.data;
this.setState({ this.setState(
beanAccount: data, {
}); beanAccount: data,
const { serviceList } = this.state; },
if (serviceList && serviceList.length) { () => {
this.getFilterBeanList(); const { serviceList } = this.state;
} if (serviceList && serviceList.length) {
this.getFilterBeanList();
}
},
);
}) })
.catch(console.error); .catch(console.error);
} }
...@@ -182,11 +191,7 @@ class Home extends Component { ...@@ -182,11 +191,7 @@ class Home extends Component {
getFilterBeanList() { getFilterBeanList() {
const { beanAccount, serviceList } = this.state; const { beanAccount, serviceList } = this.state;
let beanMap = { let aimiItem = beanAccount.find(item => item.serviceId === '0');
[BeanType.water]: 0,
[BeanType.shower]: 0,
[BeanType.hairDryer]: 0,
};
let cfItem = beanAccount.find( let cfItem = beanAccount.find(
item => item.serviceId === '4' || item.serviceId === '12', item => item.serviceId === '4' || item.serviceId === '12',
); );
...@@ -199,6 +204,9 @@ class Home extends Component { ...@@ -199,6 +204,9 @@ class Home extends Component {
item.serviceId === '11' || item.serviceId === '11' ||
item.serviceId === '9', item.serviceId === '9',
); );
let beanMap = {
[BeanType.aimi]: aimiItem ? aimiItem.money : 0,
};
for (let index = 0; index < serviceList.length; index++) { for (let index = 0; index < serviceList.length; index++) {
const service = serviceList[index]; const service = serviceList[index];
if ( if (
...@@ -210,7 +218,7 @@ class Home extends Component { ...@@ -210,7 +218,7 @@ class Home extends Component {
} else if (service.serviceId === 4 || service.serviceId === 12) { } else if (service.serviceId === 4 || service.serviceId === 12) {
beanMap[BeanType.hairDryer] = cfItem ? cfItem.money : 0; beanMap[BeanType.hairDryer] = cfItem ? cfItem.money : 0;
} else if (service.serviceId === 5 || service.serviceId === 10) { } else if (service.serviceId === 5 || service.serviceId === 10) {
beanMap[BeanType.hairDryer] = xyItem ? xyItem.money : 0; beanMap[BeanType.shower] = xyItem ? xyItem.money : 0;
} }
} }
let arr: BeanAccount[] = Object.keys(beanMap).map(k => ({ let arr: BeanAccount[] = Object.keys(beanMap).map(k => ({
...@@ -293,13 +301,11 @@ class Home extends Component { ...@@ -293,13 +301,11 @@ class Home extends Component {
render() { render() {
const { userinfo } = this.props; const { userinfo } = this.props;
const { const {
beanAccount,
annItem, annItem,
barMenuVisiable, barMenuVisiable,
serviceList, serviceList,
filterBeanList, filterBeanList,
} = this.state; } = this.state;
let aimiItem = beanAccount.find(item => item.serviceId === '0');
return ( return (
<View className='Home'> <View className='Home'>
{barMenuVisiable ? ( {barMenuVisiable ? (
...@@ -347,19 +353,18 @@ class Home extends Component { ...@@ -347,19 +353,18 @@ class Home extends Component {
</View> </View>
<View className='Home-UserBox-line' /> <View className='Home-UserBox-line' />
<View className='Home-UserBox-Bean'> <View className='Home-UserBox-Bean'>
{aimiItem && (
<View className='Home-UserBox-BeanItem'>
<Image className='Home-UserBox-BeanIcon' src={AimiIcon} />
<Text>艾米豆:</Text>
<Text className='Home-UserBox-BeanCount'>
{aimiItem ? aimiItem.money.toFixed(2) : '0.00'}
</Text>
</View>
)}
{filterBeanList && {filterBeanList &&
filterBeanList.length && filterBeanList.length &&
filterBeanList.map(beanItem => filterBeanList.map(beanItem =>
beanItem.serviceId === BeanType.water ? ( beanItem.serviceId === BeanType.aimi ? (
<View className='Home-UserBox-BeanItem'>
<Image className='Home-UserBox-BeanIcon' src={AimiIcon} />
<Text>艾米豆:</Text>
<Text className='Home-UserBox-BeanCount'>
{beanItem.money ? beanItem.money.toFixed(2) : '0.00'}
</Text>
</View>
) : beanItem.serviceId === BeanType.water ? (
<View <View
key={beanItem.serviceId} key={beanItem.serviceId}
className='Home-UserBox-BeanItem'> className='Home-UserBox-BeanItem'>
...@@ -391,9 +396,6 @@ class Home extends Component { ...@@ -391,9 +396,6 @@ class Home extends Component {
</View> </View>
) : null, ) : null,
)} )}
{serviceList && serviceList.length % 2 ? null : (
<View className='Home-UserBox-BeanItem' />
)}
</View> </View>
<View className='Home-UserBox-Order'> <View className='Home-UserBox-Order'>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment