|
@@ -1,24 +1,29 @@
|
1
|
1
|
import Taro, { Component } from '@tarojs/taro';
|
2
|
|
-import { getWindowHeight } from '@utils/style'
|
3
|
2
|
import './index.scss'
|
4
|
|
-
|
|
3
|
+import { transferImage } from '@utils/tools'
|
5
|
4
|
import ready from '@utils/ready'
|
6
|
5
|
import { connect } from '@tarojs/redux'
|
7
|
6
|
import * as actions from '@actions/shop'
|
8
|
|
-import dayjs from 'dayjs'
|
|
7
|
+import { View } from '@tarojs/components';
|
|
8
|
+import { queryUserInfo, doUserSignin } from '@services/user'
|
|
9
|
+const ruleBg = require('@assets/rulebg.png')
|
|
10
|
+
|
|
11
|
+@connect(state => ({ ...state.shop, ...state.user, ...state.city, }), { ...actions })
|
9
|
12
|
|
10
|
|
-@connect(state => ({ ...state.shop, ...state.user }), { ...actions })
|
11
|
13
|
export default class Shop extends Component {
|
12
|
14
|
config = {
|
13
|
15
|
navigationBarTitleText: '积分规则'
|
14
|
16
|
}
|
15
|
17
|
|
16
|
18
|
state = {
|
17
|
|
- pointRule: []
|
|
19
|
+ pointRule: [],
|
|
20
|
+ user: {},
|
18
|
21
|
}
|
19
|
22
|
|
20
|
23
|
componentWillMount() {
|
|
24
|
+ this.loadUserInfo()
|
21
|
25
|
this.loadRecords()
|
|
26
|
+
|
22
|
27
|
}
|
23
|
28
|
|
24
|
29
|
loadRecords() {
|
|
@@ -29,6 +34,85 @@ export default class Shop extends Component {
|
29
|
34
|
})
|
30
|
35
|
Taro.hideLoading()
|
31
|
36
|
})
|
|
37
|
+
|
|
38
|
+ }
|
|
39
|
+ loadUserInfo() {
|
|
40
|
+ queryUserInfo().then(user => {
|
|
41
|
+ this.setState({
|
|
42
|
+ user,
|
|
43
|
+ })
|
|
44
|
+ })
|
|
45
|
+ }
|
|
46
|
+ getBtnName(code) {
|
|
47
|
+ const { user: { havaSigned } } = this.state
|
|
48
|
+ switch (code) {
|
|
49
|
+ case 'checkin':
|
|
50
|
+ return havaSigned ? '已签到' : '签到'
|
|
51
|
+ case 'share-poster':
|
|
52
|
+ return '去分享'
|
|
53
|
+ case 'recommend-customer':
|
|
54
|
+ return '去推荐'
|
|
55
|
+ case 'signup-agent':
|
|
56
|
+ return '去授权'
|
|
57
|
+ case 'document_verify':
|
|
58
|
+ return '去提交'
|
|
59
|
+ default:
|
|
60
|
+ return '立即参与'
|
|
61
|
+ }
|
|
62
|
+ }
|
|
63
|
+ // 签到
|
|
64
|
+ doSign(pointsAmount) {
|
|
65
|
+ const { user: { id, havaSigned } } = this.state
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+ if (havaSigned) {
|
|
69
|
+ return
|
|
70
|
+ }
|
|
71
|
+ doUserSignin({ id }).then(res => {
|
|
72
|
+ Taro.showToast({
|
|
73
|
+ title: `签到成功,获取${pointsAmount}积分`,
|
|
74
|
+ icon: 'none'
|
|
75
|
+ })
|
|
76
|
+ this.loadUserInfo()
|
|
77
|
+
|
|
78
|
+ })
|
|
79
|
+ }
|
|
80
|
+ handleItemClick(item) {
|
|
81
|
+ switch (item.code) {
|
|
82
|
+ case 'checkin':
|
|
83
|
+ this.doSign(item.pointsAmount)
|
|
84
|
+ return
|
|
85
|
+ case 'share-poster':
|
|
86
|
+ Taro.switchTab({
|
|
87
|
+ url: '/pages/project/index'
|
|
88
|
+ })
|
|
89
|
+ return
|
|
90
|
+ case 'recommend-customer':
|
|
91
|
+ Taro.navigateTo({
|
|
92
|
+ url: `/pages/agent/recommend/index?type=index&cityId=` + this.props.curCity.id
|
|
93
|
+ })
|
|
94
|
+ return
|
|
95
|
+ case 'signup-agent':
|
|
96
|
+ Taro.navigateTo({
|
|
97
|
+ url: '/pages/person/personDetail/index'
|
|
98
|
+ })
|
|
99
|
+ return
|
|
100
|
+ case 'document_verify':
|
|
101
|
+ Taro.navigateTo({
|
|
102
|
+ url: '/pages/person/profile/index'
|
|
103
|
+ })
|
|
104
|
+ return
|
|
105
|
+ default:
|
|
106
|
+ Taro.getApp().props.projectIndex = 2
|
|
107
|
+ Taro.switchTab({
|
|
108
|
+ url: `/pages/activity/activity`,
|
|
109
|
+ fail: res => {
|
|
110
|
+ Taro.getApp().props.projectIndex = 0
|
|
111
|
+ }
|
|
112
|
+ })
|
|
113
|
+ return
|
|
114
|
+ }
|
|
115
|
+
|
32
|
116
|
}
|
33
|
117
|
|
34
|
118
|
render() {
|
|
@@ -36,28 +120,24 @@ export default class Shop extends Component {
|
36
|
120
|
const { pointRule } = this.state
|
37
|
121
|
|
38
|
122
|
return (
|
39
|
|
- <View className="page">
|
40
|
|
- <View className='rule_title'>
|
41
|
|
- <Text>积分项</Text>
|
42
|
|
- <Text>奖励积分</Text>
|
43
|
|
- <Text>说明</Text>
|
44
|
|
- </View>
|
|
123
|
+ // <View className="page" style={`background: url(${transferImage(buildBg)}) no-repeat center;background-size: 100% 100%;`}>
|
|
124
|
+ <View className="page" >
|
|
125
|
+ <Image className="bg-img" src={transferImage(ruleBg)} mode='widthFix'></Image>
|
45
|
126
|
<ScrollView
|
46
|
127
|
scrollY
|
47
|
128
|
scroll-with-animation
|
48
|
129
|
enable-back-to-top
|
49
|
130
|
className="list"
|
50
|
131
|
style={{
|
51
|
|
- height: '65vh'
|
|
132
|
+ maxHeight: '78vh'
|
52
|
133
|
}}>
|
53
|
134
|
{
|
54
|
135
|
pointRule.length === 0 ? '' : (
|
55
|
136
|
pointRule.map(item => (
|
56
|
137
|
<View className='rule_item' key={item.ruleId}>
|
57
|
|
- <Text>{item.ruleName}</Text>
|
58
|
|
- <Text>+{item.pointsAmount}</Text>
|
59
|
|
- <Text>{item.remark}</Text>
|
60
|
|
- {/* <Text>{dayjs(item.updateDate).format('YYYY-MM-DD HH:mm:ss')}</Text> */}
|
|
138
|
+ <View className="item-name">{item.ruleName}<Text className="item-num">+{item.pointsAmount}</Text><Text className="jifen">积分</Text></View>
|
|
139
|
+ <View className="item-rule">{item.remark}</View>
|
|
140
|
+ <View className={this.getBtnName(item.code)=='已签到'?'yiqiandao':"item-btn"} onClick={this.handleItemClick.bind(this, item)}>{this.getBtnName(item.code)}</View>
|
61
|
141
|
</View>
|
62
|
142
|
))
|
63
|
143
|
)
|