index.js
1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import Taro, {Component} from '@tarojs/taro';
import {View, Text, Navigator, Image} from '@tarojs/components';
import './index.scss'
import down from '../../assets/images/down@2x.png';
import couponModel from '../../models/coupon';
const model = new couponModel();
export default class MyCoupon extends Component {
constructor() {
super(...arguments);
this.state = {
couponList: []
};
}
config = {};
componentWillMount() {
this.getCouponList();
}
async getCouponList() {
let couponList = await model.myCouponList();
this.setState({couponList});
};
showNote = (value) => {
let {couponList} = this.state;
couponList[value].showNotes = !couponList[value].showNotes;
this.setState({
couponList
});
this.forceUpdate();
};
render() {
let {couponList} = this.state;
return (
<View className='page'>
<View className='title'>优惠券</View>
<View className='content'>
{couponList.map((value, index) => {
return <View className='item'>
<View className='ticket'>
<View className='left'>
<View className='price'>{value.coupon_value}</View>
</View>
<View className='right'>
<View className='name'>{value.coupon_name}</View>
<View className='date'>{value.coupon_validity}</View>
<View className='desc' onClick={this.showNote.bind(this, index)}>使用说明
<Image mode='aspectFit' src={down} className={value.showNotes ? 'up' : 'down'}></Image>
</View>
</View>
</View>
<View className='desc-info' style={{display: value.showNotes ? 'block' : 'none'}}>
{value.notes.map((note) => {
return <View className='p'>· {note}</View>
})}
</View>
</View>
})}
</View>
</View>
)
}
}