Skip to content

Commit

Permalink
fake pay button
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankFang committed May 7, 2020
1 parent be5a257 commit c4d0529
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 59 deletions.
122 changes: 65 additions & 57 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,66 +19,74 @@ import {Pay} from './views/Pay';
import {AdminOrders} from './views/AdminOrders';

import {AdminOrder} from './views/AdminOrder';
import styled from 'styled-components';

const Wrapper = styled.div`
max-width: 500px;
margin: 0 auto;
`;

function App() {
return (
<SWRConfig value={{shouldRetryOnError: false}}>
<Router history={history}>
<Switch>
<Route exact path="/admin/shops">
<Shops/>
</Route>
<Route exact path="/admin/shops/new">
<ShopNew/>
</Route>
<Route exact path="/admin/shops/:id">
<AdminShop/>
</Route>
<Route exact path="/shops/:id">
<Shop/>
</Route>
<Route exact path="/admin/shops/:id/edit">
<AdminShopEdit/>
</Route>
<Route exact path="/admin/shops/:shopId/goods/new">
<GoodNew/>
</Route>
<Route exact path="/admin/shops/:shopId/goods/:id">
<AdminGood/>
</Route>
<Route exact path="/shops/:shopId/goods/:id">
<Good/>
</Route>
<Route exact path="/admin/shops/:shopId/goods/:id/edit">
<GoodEdit/>
</Route>
<Route exact path="/orders/new">
<OrderNew/>
</Route>
<Route exact path="/orders/:id/pay">
<Pay/>
</Route>
<Route exact path="/admin/orders">
<AdminOrders/>
</Route>
<Route exact path="/admin/orders/:id">
<AdminOrder/>
</Route>
<Route exact path="/sign_in">
<SignIn/>
</Route>
<Route exact path="/cart">
<Cart/>
</Route>
<Route exact path="/me">
<Me/>
</Route>
<Redirect exact from="/" to="/admin/shops"/>
<Route path="*">
</Route>
</Switch>
</Router>
</SWRConfig>
<Wrapper>
<SWRConfig value={{shouldRetryOnError: false}}>
<Router history={history}>
<Switch>
<Route exact path="/admin/shops">
<Shops/>
</Route>
<Route exact path="/admin/shops/new">
<ShopNew/>
</Route>
<Route exact path="/admin/shops/:id">
<AdminShop/>
</Route>
<Route exact path="/shops/:id">
<Shop/>
</Route>
<Route exact path="/admin/shops/:id/edit">
<AdminShopEdit/>
</Route>
<Route exact path="/admin/shops/:shopId/goods/new">
<GoodNew/>
</Route>
<Route exact path="/admin/shops/:shopId/goods/:id">
<AdminGood/>
</Route>
<Route exact path="/shops/:shopId/goods/:id">
<Good/>
</Route>
<Route exact path="/admin/shops/:shopId/goods/:id/edit">
<GoodEdit/>
</Route>
<Route exact path="/orders/new">
<OrderNew/>
</Route>
<Route exact path="/orders/:id/pay">
<Pay/>
</Route>
<Route exact path="/admin/orders">
<AdminOrders/>
</Route>
<Route exact path="/admin/orders/:id">
<AdminOrder/>
</Route>
<Route exact path="/sign_in">
<SignIn/>
</Route>
<Route exact path="/cart">
<Cart/>
</Route>
<Route exact path="/me">
<Me/>
</Route>
<Redirect exact from="/" to="/admin/shops"/>
<Route path="*">
</Route>
</Switch>
</Router>
</SWRConfig>
</Wrapper>
);
}

Expand Down
6 changes: 6 additions & 0 deletions src/components/VSpace.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import styled from 'styled-components';

export const VSpace = styled.span`
display:inline-block;
width: 16px;
`;
1 change: 1 addition & 0 deletions src/images/alipay.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/images/wepay.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 6 additions & 1 deletion src/views/OrderNew.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {Stretch} from '../components/Stretch';
import {MainButton} from '../components/button/MainButton';
import {defaultHttpClient} from '../lib/HttpClient';
import {history} from '../lib/history';
import {VSpace} from '../components/VSpace';

const _OrderNew: React.FC<RouteComponentProps> = (props) => {
const query = new HashQuery<{ shopId: string }>(props.location);
Expand Down Expand Up @@ -75,7 +76,11 @@ const _OrderNew: React.FC<RouteComponentProps> = (props) => {
<Space/>
购物车是空的
<Space/>
<p><Link to={`/shops/${shopId}`}><MainButton>返回购物</MainButton></Link></p>
<p>
<Link to={`/shops/${shopId}`}><MainButton>返回购物</MainButton></Link>
<VSpace/>
<Link to={`/orders`}><MainButton>查看订单</MainButton></Link>
</p>
<Space/>
</Center>
);
Expand Down
39 changes: 38 additions & 1 deletion src/views/Pay.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,47 @@
import React from 'react';
import Layout from '../components/Layout';
import {withRouter} from 'react-router-dom';
import {MainButton} from '../components/button/MainButton';
import Icon from '../components/Icon';
import wepay from 'images/wepay.svg';
import alipay from 'images/alipay.svg';
import {Img} from '../components/Img';
import styled from 'styled-components';
import {Stretch} from '../components/Stretch';
import {showAlert} from '../components/Dialog';

const Payments = styled.div`
margin-top: 32px;
img{
width: 100px;
height: 100px;
margin: 0 32px;
}
`;
const Wrapper = styled.div`
text-align:center;
padding: 16px;
`;

const pay = () => {
showAlert('抱歉,测试环境无法支付,请使用模拟支付');
};
export const _Pay: React.FC = () => {
const fakePay = () => {

};
return (
<Layout title="支付">hi</Layout>
<Layout title="支付">
<Wrapper>
<Stretch>
<MainButton onClick={fakePay}>模拟支付</MainButton>
</Stretch>
<Payments>
<Img onClick={pay} src={wepay}/>
<Img onClick={pay} src={alipay}/>
</Payments>
</Wrapper>
</Layout>
);
};

Expand Down

0 comments on commit c4d0529

Please sign in to comment.