Commit 5b54c38f by zhanghaozhe

exchange-coupons

parent bbff4327
...@@ -34,11 +34,27 @@ $bg_type2: #E0B97B; ...@@ -34,11 +34,27 @@ $bg_type2: #E0B97B;
&.coupon-type1 { &.coupon-type1 {
background: $bg_type1; background: $bg_type1;
} }
&.coupon-type2 { &.coupon-type2 {
background: $E0B97B; background: $E0B97B;
} }
& > .iconfont {
$size: 22px;
position: absolute;
top: 50%;
right: 20px;
transform: translateY(-50%);
width: $size;
height: $size;
display: none;
}
.check {
display: block;
}
ul { ul {
position: absolute; position: absolute;
bottom: 0; bottom: 0;
...@@ -76,8 +92,8 @@ $bg_type2: #E0B97B; ...@@ -76,8 +92,8 @@ $bg_type2: #E0B97B;
padding: 3px 8px; padding: 3px 8px;
font-size: $font_12; font-size: $font_12;
color: $border_f31; color: $border_f31;
border:1px solid $border_f31; border: 1px solid $border_f31;
border-radius:10px; border-radius: 10px;
background: transparent; background: transparent;
-webkit-appearance: none; -webkit-appearance: none;
} }
......
...@@ -3,13 +3,19 @@ import './coupon.scss' ...@@ -3,13 +3,19 @@ import './coupon.scss'
import classnames from 'classnames' import classnames from 'classnames'
const Coupon = ({type, couponName, denomination, expire_time, limit, onClick}) => { const Coupon = ({type, couponName, denomination, expire_time, limit, onClick, showUseButton, selected}) => {
let style = {
visibility: showUseButton ? 'visible' : 'hidden'
}
return ( return (
<li className='coupon'> <li className='coupon'>
<div className={classnames('coupon-info', `coupon-type${type}`)}> <div className={classnames('coupon-info', `coupon-type${type}`)}>
<p className='type'>{couponName}</p> <p className='type'>{couponName}</p>
<p className='denomination'>{denomination} <span></span></p> <p className='denomination'>{denomination} <span></span></p>
<p className='expire'>有效期至:{expire_time}</p> <p className='expire'>有效期至:{expire_time}</p>
<i className={classnames('iconfont icondanseshixintubiao-5', {
check: selected
})}></i>
<ul> <ul>
{ {
new Array(19).fill('a').map((item, index) => { new Array(19).fill('a').map((item, index) => {
...@@ -20,7 +26,11 @@ const Coupon = ({type, couponName, denomination, expire_time, limit, onClick}) = ...@@ -20,7 +26,11 @@ const Coupon = ({type, couponName, denomination, expire_time, limit, onClick}) =
</div> </div>
<div className="coupon-des"> <div className="coupon-des">
<span className='limit'>{limit}</span> <span className='limit'>{limit}</span>
<button className='use' onClick={onClick}>立即使用</button> <button
className='use'
onClick={onClick}
style={style}
>立即使用</button>
</div> </div>
</li> </li>
); );
......
.exchange-bar {
display: flex;
justify-content: space-between;
width: 100%;
padding: 10px 12px;
border-bottom: 1px solid $border_e7eaf1;
button {
display: inline-block;
width: 84px;
height: 36px;
line-height: 36px;
font-size: $font_16;
color: $white;
background-color: $bg_ccc;
border: none;
-webkit-appearance: none;
&.active {
background-color: $active;
}
}
}
\ No newline at end of file
import React, { Component } from 'react';
import './exchange-bar.scss'
import Input from '../Input'
import classnames from 'classnames'
class ExchangeBar extends Component {
constructor(props) {
super(props)
this.state = {}
}
render() {
const {onChange, exchangeNum} = this.props
return (
<div className="exchange-bar">
<Input
placeholder={'请输入优惠码'}
onChange={onChange}
type={'number'}
/>
<button className={classnames({
active: exchangeNum.length > 0
})}>兑换
</button>
</div>
);
}
}
export default ExchangeBar;
\ No newline at end of file
...@@ -3,9 +3,8 @@ import './coupons.scss' ...@@ -3,9 +3,8 @@ import './coupons.scss'
// import { Toast } from "antd-mobile"; // import { Toast } from "antd-mobile";
import Input from "./Input" import Coupon from '../common/Coupon'
import classnames from 'classnames' import ExchangeBar from '../common/ExchangeBar'
import Coupon from './Coupon'
const mockData = [ const mockData = [
...@@ -26,7 +25,7 @@ const mockData = [ ...@@ -26,7 +25,7 @@ const mockData = [
] ]
class Coupons extends Component { class ExchangeCoupons extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
this.state = { this.state = {
...@@ -49,18 +48,15 @@ class Coupons extends Component { ...@@ -49,18 +48,15 @@ class Coupons extends Component {
render() { render() {
return ( return (
<div id='coupons'> <div id='coupons'>
<div className="exchange"> <ExchangeBar
<Input onChange={this.onChange}
placeholder={'请输入优惠码'} exchangeNum={this.state.exchangeNum}
onChange={this.onChange} />
type={'number'} <Content
/> coupons={mockData}
<button className={classnames({ onClick={this.useCoupon}
active: this.state.exchangeNum.length > 0 showUseButton={true}
})}>兑换 />
</button>
</div>
<Content coupons={mockData} onClick={this.useCoupon}/>
</div> </div>
); );
} }
...@@ -77,7 +73,7 @@ function Empty() { ...@@ -77,7 +73,7 @@ function Empty() {
) )
} }
function Content({coupons,onClick}) { function Content({coupons, onClick, ...rest}) {
if (coupons.length === 0) { if (coupons.length === 0) {
return <Empty/> return <Empty/>
} }
...@@ -85,7 +81,11 @@ function Content({coupons,onClick}) { ...@@ -85,7 +81,11 @@ function Content({coupons,onClick}) {
<ul className='coupon-list'> <ul className='coupon-list'>
{ {
mockData.map((item, index) => { mockData.map((item, index) => {
return <Coupon {...item} key={index} onClick={onClick}/> return <Coupon
{...item}
key={index}
onClick={onClick}
{...rest}/>
}) })
} }
</ul> </ul>
...@@ -96,4 +96,4 @@ function Content({coupons,onClick}) { ...@@ -96,4 +96,4 @@ function Content({coupons,onClick}) {
return Toast.info(text, 1) return Toast.info(text, 1)
}*/ }*/
export default Coupons; export default ExchangeCoupons;
\ No newline at end of file \ No newline at end of file
...@@ -8,7 +8,7 @@ import Study from './components/study'; ...@@ -8,7 +8,7 @@ import Study from './components/study';
import My from './components/my'; import My from './components/my';
import CourseList from './components/classify/courselist'; import CourseList from './components/classify/courselist';
import Examination from './components/examination' import Examination from './components/examination'
import Coupons from './components/coupons' import ExchangeCoupons from './components/coupons/exchange-coupons'
const router = () => ( const router = () => (
...@@ -21,7 +21,7 @@ const router = () => ( ...@@ -21,7 +21,7 @@ const router = () => (
<Route path='/my' component={My}></Route> <Route path='/my' component={My}></Route>
<Route path='/courselist' component={CourseList}></Route> <Route path='/courselist' component={CourseList}></Route>
<Route path='/examination' component={Examination}></Route> <Route path='/examination' component={Examination}></Route>
<Route path='/coupons' component={Coupons}></Route> <Route path='/exchange-coupons' component={ExchangeCoupons}></Route>
</Switch> </Switch>
<Menu/> <Menu/>
</Router> </Router>
......
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