-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
150 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module.exports = [ | ||
{ | ||
id: Date.now(), | ||
img: 'http:https://images2015.cnblogs.com/blog/138012/201610/138012-20161016201638030-473660627.png', | ||
title: '汉堡大王', | ||
count: 3, | ||
price: '167', | ||
commentState: 0 | ||
}, | ||
{ | ||
id: Date.now(), | ||
img: 'http:https://images2015.cnblogs.com/blog/138012/201610/138012-20161016201708124-1116595594.png', | ||
title: '麻辣香锅', | ||
count: 1, | ||
price: '188', | ||
commentState: 0 | ||
}, | ||
{ | ||
id: Date.now(), | ||
img: 'http:https://images2015.cnblogs.com/blog/138012/201610/138012-20161016201645858-1342445625.png', | ||
title: '好吃自出餐', | ||
count: 2, | ||
price: '110', | ||
commentState: 2 | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,29 @@ | ||
import React from 'react'; | ||
import React, { PureComponent } from 'react'; | ||
import './style.scss'; | ||
|
||
// 无状态组件可以直接使用函数形式创建 | ||
const Header = props => { | ||
return ( | ||
<div className="common-header"> | ||
<span className="back-icon" onClick={clickHandle}> | ||
<i className="icon-chevron-left"></i> | ||
</span> | ||
<h1>{props.title}</h1> | ||
</div> | ||
); | ||
}; | ||
|
||
const clickHandle = () => { | ||
// 返回上一页 | ||
const backRouter = this.props.backRouter; | ||
class Header extends PureComponent { | ||
render () { | ||
return ( | ||
<div className="common-header"> | ||
<span className="back-icon" onClick={this.clickHandle}> | ||
<i className="icon-chevron-left"></i> | ||
</span> | ||
<h1>{this.props.title}</h1> | ||
</div> | ||
); | ||
}; | ||
clickHandle = () => { | ||
const toHome = this.props.toHome; | ||
|
||
if (toHome) { | ||
toHome(); | ||
} else { | ||
// 返回上一页 | ||
window.history.back(); | ||
} | ||
}; | ||
|
||
if (backRouter === undefined) { | ||
this.props.toBack(backRouter); | ||
} else { | ||
window.history.back(backRouter); | ||
} | ||
}; | ||
|
||
|
||
export default Header; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import React from 'react'; | ||
import './style.scss'; | ||
|
||
// 无状态组件可以直接使用函数形式创建 | ||
const UserInfo = props => { | ||
const { cityName, username } = props.userinfo; | ||
|
||
return ( | ||
<div className="userinfo-container"> | ||
<p> | ||
<i className="icon-user"></i> | ||
<span>{username}</span> | ||
</p> | ||
<p> | ||
<i className="icon-map-marker"></i> | ||
<span>{cityName}</span> | ||
</p> | ||
</div> | ||
) | ||
}; | ||
|
||
export default UserInfo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.userinfo-container { | ||
background-color: #fff; | ||
padding: 10px; | ||
p { | ||
line-height: 1.5; | ||
color: #666; | ||
} | ||
i { | ||
margin-right: 5px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import React, { PureComponent } from 'react'; | ||
|
||
import { getOrderListData } from '~fetch/user/orderList'; | ||
|
||
class OrderList extends PureComponent { | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
data: [] | ||
} | ||
}; | ||
|
||
render() { | ||
return ( | ||
<div> | ||
13 | ||
</div> | ||
) | ||
}; | ||
|
||
componentDidMount() { | ||
const username = this.props.username; | ||
|
||
const result = getOrderListData(username); | ||
|
||
result.then(res => { | ||
if (res.status === 200) { | ||
return res.json(); | ||
} | ||
}).then(json => { | ||
const data = json; | ||
this.setState({ | ||
data: data | ||
}); | ||
}).catch(error => { | ||
console.log(error) | ||
}) | ||
}; | ||
|
||
|
||
}; | ||
|
||
export default OrderList; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import get from '../get'; | ||
|
||
export function getOrderListData(username) { | ||
const result = get(`/api/orderList/${username}`); | ||
|
||
return result; | ||
}; |