个人信息页面内部跳转,review by Redding
Showing
6 changed files
with
213 additions
and
13 deletions
@@ -8,6 +8,7 @@ import { | @@ -8,6 +8,7 @@ import { | ||
8 | View, | 8 | View, |
9 | Text, | 9 | Text, |
10 | Image, | 10 | Image, |
11 | + TouchableOpacity, | ||
11 | } from 'react-native'; | 12 | } from 'react-native'; |
12 | 13 | ||
13 | import {Map} from 'immutable'; | 14 | import {Map} from 'immutable'; |
@@ -29,12 +30,27 @@ export default class PersonalInfo extends Component { | @@ -29,12 +30,27 @@ export default class PersonalInfo extends Component { | ||
29 | if (dataSource.get('id') == 'portrait' && dataSource.get('url') == '') { | 30 | if (dataSource.get('id') == 'portrait' && dataSource.get('url') == '') { |
30 | imageUrl = require('../image/avatar_icon.png'); | 31 | imageUrl = require('../image/avatar_icon.png'); |
31 | } else if (dataSource.get('id') == 'VIPLevel') { | 32 | } else if (dataSource.get('id') == 'VIPLevel') { |
32 | - imageUrl = require('../image/VIP1.png'); | 33 | + switch (dataSource.get('content')) { |
34 | + case '1': | ||
35 | + imageUrl = require('../image/VIP1.png'); | ||
36 | + break; | ||
37 | + case '2': | ||
38 | + imageUrl = require('../image/VIP2.png'); | ||
39 | + break; | ||
40 | + case '3': | ||
41 | + imageUrl = require('../image/VIP3.png'); | ||
42 | + break; | ||
43 | + default: | ||
44 | + imageUrl = ''; | ||
45 | + } | ||
33 | } else if (dataSource.get('id') == 'mineQRCode') { | 46 | } else if (dataSource.get('id') == 'mineQRCode') { |
34 | imageUrl = require('../image/mine_qr.png'); | 47 | imageUrl = require('../image/mine_qr.png'); |
35 | } | 48 | } |
36 | let url = YH_Image.getSlicedUrl(dataSource.get('url'), 40, 40, 2); // 商品缩略图 | 49 | let url = YH_Image.getSlicedUrl(dataSource.get('url'), 40, 40, 2); // 商品缩略图 |
37 | return ( | 50 | return ( |
51 | + <TouchableOpacity activeOpacity={1.0} onPress={() => { | ||
52 | + this.props.onPressInfoCell && this.props.onPressInfoCell(dataSource); | ||
53 | + }}> | ||
38 | <View style={[styles.container,{height: cellHeight + (withoutBottomLine?0.0:0.5)}]}> | 54 | <View style={[styles.container,{height: cellHeight + (withoutBottomLine?0.0:0.5)}]}> |
39 | <View style={[styles.contentContainer,{height: cellHeight}]}> | 55 | <View style={[styles.contentContainer,{height: cellHeight}]}> |
40 | 56 | ||
@@ -42,10 +58,12 @@ export default class PersonalInfo extends Component { | @@ -42,10 +58,12 @@ export default class PersonalInfo extends Component { | ||
42 | {dataSource.get('title')} | 58 | {dataSource.get('title')} |
43 | </Text> | 59 | </Text> |
44 | <View style={styles.contentContainer}> | 60 | <View style={styles.contentContainer}> |
45 | - | ||
46 | - <Text style={styles.content}> | ||
47 | - {dataSource.get('content')} | ||
48 | - </Text> | 61 | + {dataSource.get('id') == 'VIPLevel'? |
62 | + null | ||
63 | + :<Text style={styles.content}> | ||
64 | + {dataSource.get('content')} | ||
65 | + </Text> | ||
66 | + } | ||
49 | {dataSource.get('id') == 'portrait' && dataSource.get('url') != '' ? | 67 | {dataSource.get('id') == 'portrait' && dataSource.get('url') != '' ? |
50 | <YH_Image url={url} style={styles.userImage} /> | 68 | <YH_Image url={url} style={styles.userImage} /> |
51 | :null | 69 | :null |
@@ -63,6 +81,7 @@ export default class PersonalInfo extends Component { | @@ -63,6 +81,7 @@ export default class PersonalInfo extends Component { | ||
63 | <View style={{width: width,height: 0.5,backgroundColor: '#e5e5e5',}}/> | 81 | <View style={{width: width,height: 0.5,backgroundColor: '#e5e5e5',}}/> |
64 | } | 82 | } |
65 | </View> | 83 | </View> |
84 | + </TouchableOpacity> | ||
66 | ); | 85 | ); |
67 | } | 86 | } |
68 | } | 87 | } |
@@ -34,13 +34,13 @@ export default class PersonalInfo extends Component { | @@ -34,13 +34,13 @@ export default class PersonalInfo extends Component { | ||
34 | return( | 34 | return( |
35 | <InfoCell | 35 | <InfoCell |
36 | dataSource={rowData} | 36 | dataSource={rowData} |
37 | + onPressInfoCell={this.props.onPressInfoCell} | ||
37 | /> | 38 | /> |
38 | ); | 39 | ); |
39 | } | 40 | } |
40 | 41 | ||
41 | render() { | 42 | render() { |
42 | let {dataSource} = this.props; | 43 | let {dataSource} = this.props; |
43 | - let dataList = [0,1,2]; | ||
44 | return ( | 44 | return ( |
45 | <View style={styles.container}> | 45 | <View style={styles.container}> |
46 | <ListView | 46 | <ListView |
@@ -46,13 +46,21 @@ function mapDispatchToProps(dispatch) { | @@ -46,13 +46,21 @@ function mapDispatchToProps(dispatch) { | ||
46 | class PersonalInfoContainer extends Component { | 46 | class PersonalInfoContainer extends Component { |
47 | constructor(props) { | 47 | constructor(props) { |
48 | super(props); | 48 | super(props); |
49 | + this._onPressInfoCell = this._onPressInfoCell.bind(this); | ||
50 | + } | ||
49 | 51 | ||
52 | + _onPressInfoCell(cellInfo) { | ||
53 | + this.props.actions.onPressInfoCell(cellInfo); | ||
50 | } | 54 | } |
51 | 55 | ||
52 | componentDidMount() { | 56 | componentDidMount() { |
53 | this.props.actions.fetchPersonalInfo(); | 57 | this.props.actions.fetchPersonalInfo(); |
54 | } | 58 | } |
55 | 59 | ||
60 | + componentWillUnmount() { | ||
61 | + this.props.actions.modifyUserBaseInfo(); | ||
62 | + } | ||
63 | + | ||
56 | render() { | 64 | render() { |
57 | let {personalInfo} = this.props; | 65 | let {personalInfo} = this.props; |
58 | let {pageCellList} = personalInfo; | 66 | let {pageCellList} = personalInfo; |
@@ -60,6 +68,7 @@ class PersonalInfoContainer extends Component { | @@ -60,6 +68,7 @@ class PersonalInfoContainer extends Component { | ||
60 | <View style={styles.container}> | 68 | <View style={styles.container}> |
61 | <PersonalInfo | 69 | <PersonalInfo |
62 | dataSource={pageCellList} | 70 | dataSource={pageCellList} |
71 | + onPressInfoCell={this._onPressInfoCell} | ||
63 | /> | 72 | /> |
64 | </View> | 73 | </View> |
65 | ); | 74 | ); |
@@ -84,7 +84,7 @@ function processProfile(profile){ | @@ -84,7 +84,7 @@ function processProfile(profile){ | ||
84 | case 'portrait': | 84 | case 'portrait': |
85 | cellItem.url = profile.head_ico; | 85 | cellItem.url = profile.head_ico; |
86 | break; | 86 | break; |
87 | - case 'nickname': | 87 | + case 'nick_name': |
88 | cellItem.content = profile.nickname; | 88 | cellItem.content = profile.nickname; |
89 | break; | 89 | break; |
90 | case 'gender':{ | 90 | case 'gender':{ |
@@ -95,7 +95,7 @@ function processProfile(profile){ | @@ -95,7 +95,7 @@ function processProfile(profile){ | ||
95 | } | 95 | } |
96 | } | 96 | } |
97 | break; | 97 | break; |
98 | - case 'birthDay': | 98 | + case 'birthday': |
99 | cellItem.content = profile.birthday; | 99 | cellItem.content = profile.birthday; |
100 | break; | 100 | break; |
101 | case 'VIPLevel':{ | 101 | case 'VIPLevel':{ |
@@ -117,3 +117,143 @@ function processProfile(profile){ | @@ -117,3 +117,143 @@ function processProfile(profile){ | ||
117 | dispatch(updatePageCellList(pageCellList)); | 117 | dispatch(updatePageCellList(pageCellList)); |
118 | } | 118 | } |
119 | } | 119 | } |
120 | + | ||
121 | +export function modifyUserBaseInfo(cellList) { | ||
122 | + return (dispatch, getState) => { | ||
123 | + let {app, personalInfo} = getState(); | ||
124 | + let {pageCellList} = personalInfo; | ||
125 | + if (!cellList) { | ||
126 | + cellList = pageCellList.toJS(); | ||
127 | + } | ||
128 | + let params = {}; | ||
129 | + cellList.map((cellItem, i) => { | ||
130 | + if (cellItem.id == 'gender') { | ||
131 | + let gender = 0; | ||
132 | + if (cellItem.content == 'BOY') { | ||
133 | + gender = 1; | ||
134 | + } else if (cellItem.content == 'GIRL') { | ||
135 | + gender = 2; | ||
136 | + } | ||
137 | + params.gender = gender; | ||
138 | + }else { | ||
139 | + if (cellItem.baseUpload) { | ||
140 | + params[cellItem.id] = cellItem.content; | ||
141 | + } | ||
142 | + } | ||
143 | + }) | ||
144 | + return new PersonalInfoService(app.host).modifyUserBaseInfo(params) | ||
145 | + .then(json => { | ||
146 | + | ||
147 | + console.log('-----更新信息'); | ||
148 | + console.log(json); | ||
149 | + }) | ||
150 | + .catch(error => { | ||
151 | + console.log('-----更新信息'); | ||
152 | + console.log(error); | ||
153 | + }) | ||
154 | + } | ||
155 | +} | ||
156 | + | ||
157 | +export function onPressInfoCell(cellInfo) { | ||
158 | + return (dispatch, getState) => { | ||
159 | + let {app, personalInfo} = getState(); | ||
160 | + let {pageCellList} = personalInfo; | ||
161 | + pageCellList = pageCellList.toJS(); | ||
162 | + switch (cellInfo.get('id')) { | ||
163 | + case 'portrait':{ | ||
164 | + ReactNative.NativeModules.YH_PersonalInfoHelper.selectAvatarAction() | ||
165 | + .then(data => { | ||
166 | + if (data && data != '') { | ||
167 | + pageCellList[0].url = data; | ||
168 | + } | ||
169 | + dispatch(updatePageCellList(pageCellList)); | ||
170 | + }) | ||
171 | + .catch(error => { | ||
172 | + console.log('-----imageUrl error'); | ||
173 | + console.log(error); | ||
174 | + }); | ||
175 | + } | ||
176 | + break; | ||
177 | + case 'nick_name': { | ||
178 | + ReactNative.NativeModules.YH_PersonalInfoHelper.gotoEditNickName(cellInfo.get('content')) | ||
179 | + .then(data => { | ||
180 | + pageCellList[cellInfo.get('index')].content = data; | ||
181 | + dispatch(updatePageCellList(pageCellList)); | ||
182 | + dispatch(modifyUserBaseInfo(pageCellList)); | ||
183 | + }) | ||
184 | + .catch(error => { | ||
185 | + console.log('-----nickname error'); | ||
186 | + console.log(error); | ||
187 | + }); | ||
188 | + } | ||
189 | + break; | ||
190 | + case 'gender':{ | ||
191 | + ReactNative.NativeModules.YH_PersonalInfoHelper.selectGenderAction() | ||
192 | + .then(data => { | ||
193 | + console.log('-----gender'); | ||
194 | + console.log(data); | ||
195 | + pageCellList[cellInfo.get('index')].content = data; | ||
196 | + dispatch(updatePageCellList(pageCellList)); | ||
197 | + }) | ||
198 | + .catch(error => { | ||
199 | + console.log('-----nickname error'); | ||
200 | + console.log(error); | ||
201 | + }); | ||
202 | + } | ||
203 | + break; | ||
204 | + case 'birthday':{ | ||
205 | + ReactNative.NativeModules.YH_PersonalInfoHelper.selectBirthdayAction() | ||
206 | + .then(data => { | ||
207 | + console.log('-----gender'); | ||
208 | + console.log(data); | ||
209 | + pageCellList[cellInfo.get('index')].content = data; | ||
210 | + dispatch(updatePageCellList(pageCellList)); | ||
211 | + }) | ||
212 | + .catch(error => { | ||
213 | + console.log('-----nickname error'); | ||
214 | + console.log(error); | ||
215 | + }); | ||
216 | + } | ||
217 | + break; | ||
218 | + case 'VIPLevel':{ | ||
219 | + ReactNative.NativeModules.YH_PersonalInfoHelper.gotoVIPLevelVC(); | ||
220 | + } | ||
221 | + break; | ||
222 | + case 'mineQRCode':{ | ||
223 | + ReactNative.NativeModules.YH_PersonalInfoHelper.gotoMineQRCode(); | ||
224 | + } | ||
225 | + break; | ||
226 | + case 'height': | ||
227 | + case 'weight':{ | ||
228 | + ReactNative.NativeModules.YH_PersonalInfoHelper.selectHeightWeightAction() | ||
229 | + .then(data => { | ||
230 | + console.log('-----height & weight'); | ||
231 | + console.log(data); | ||
232 | + if (cellInfo.get('id') == 'height') { | ||
233 | + pageCellList[cellInfo.get('index')].content = data.height; | ||
234 | + pageCellList[cellInfo.get('index') + 1].content = data.weight; | ||
235 | + } else if (cellInfo.get('id') == 'weight') { | ||
236 | + pageCellList[cellInfo.get('index')].content = data.weight; | ||
237 | + pageCellList[cellInfo.get('index') - 1].content = data.height; | ||
238 | + } | ||
239 | + dispatch(updatePageCellList(pageCellList)); | ||
240 | + }) | ||
241 | + .catch(error => { | ||
242 | + console.log('-----nickname error'); | ||
243 | + console.log(error); | ||
244 | + }); | ||
245 | + } | ||
246 | + break; | ||
247 | + case 'addressManage':{ | ||
248 | + ReactNative.NativeModules.YH_PersonalInfoHelper.gotoManagerAddressVC(); | ||
249 | + } | ||
250 | + break; | ||
251 | + case 'accountBind':{ | ||
252 | + ReactNative.NativeModules.YH_PersonalInfoHelper.gotoAccountBindVC(); | ||
253 | + } | ||
254 | + break; | ||
255 | + default: | ||
256 | + | ||
257 | + } | ||
258 | + } | ||
259 | +} |
@@ -6,50 +6,66 @@ let personalInfoCelllist = [ | @@ -6,50 +6,66 @@ let personalInfoCelllist = [ | ||
6 | id: 'portrait', | 6 | id: 'portrait', |
7 | title: '头像', | 7 | title: '头像', |
8 | url: '', | 8 | url: '', |
9 | + index: 0, | ||
9 | },{ | 10 | },{ |
10 | - id: 'nickname', | 11 | + id: 'nick_name', |
11 | title: '昵称', | 12 | title: '昵称', |
12 | content: '', | 13 | content: '', |
14 | + index: 1, | ||
15 | + baseUpload: true, | ||
13 | },{ | 16 | },{ |
14 | id: 'gender', | 17 | id: 'gender', |
15 | title: '性别', | 18 | title: '性别', |
16 | - content: '', | 19 | + content: '选择性别', |
20 | + index: 2, | ||
21 | + baseUpload: true, | ||
17 | },{ | 22 | },{ |
18 | - id: 'birthDay', | 23 | + id: 'birthday', |
19 | title: '生日', | 24 | title: '生日', |
20 | content: '', | 25 | content: '', |
26 | + index: 3, | ||
27 | + baseUpload: true, | ||
21 | },{ | 28 | },{ |
22 | id: 'VIPLevel', | 29 | id: 'VIPLevel', |
23 | title: '会员等级', | 30 | title: '会员等级', |
24 | content: '', | 31 | content: '', |
32 | + index: 4, | ||
25 | },{ | 33 | },{ |
26 | id: 'mineQRCode', | 34 | id: 'mineQRCode', |
27 | title: '我的二维码', | 35 | title: '我的二维码', |
28 | content: '', | 36 | content: '', |
29 | withoutBottomLine: true, | 37 | withoutBottomLine: true, |
38 | + index: 5, | ||
30 | },{ | 39 | },{ |
31 | id: 'separate', | 40 | id: 'separate', |
41 | + index: 6, | ||
32 | },{ | 42 | },{ |
33 | id: 'height', | 43 | id: 'height', |
34 | title: '身高', | 44 | title: '身高', |
35 | content: '', | 45 | content: '', |
46 | + index: 7, | ||
47 | + baseUpload: true, | ||
36 | },{ | 48 | },{ |
37 | id: 'weight', | 49 | id: 'weight', |
38 | title: '体重', | 50 | title: '体重', |
39 | content: '', | 51 | content: '', |
40 | withoutBottomLine: true, | 52 | withoutBottomLine: true, |
53 | + index: 8, | ||
54 | + baseUpload: true, | ||
41 | },{ | 55 | },{ |
42 | id: 'separate', | 56 | id: 'separate', |
57 | + index: 9, | ||
43 | },{ | 58 | },{ |
44 | id: 'addressManage', | 59 | id: 'addressManage', |
45 | title: '地址管理', | 60 | title: '地址管理', |
46 | content: '', | 61 | content: '', |
62 | + index: 10, | ||
47 | },{ | 63 | },{ |
48 | id: 'accountBind', | 64 | id: 'accountBind', |
49 | title: '账号绑定', | 65 | title: '账号绑定', |
50 | content: '', | 66 | content: '', |
51 | withoutBottomLine: true, | 67 | withoutBottomLine: true, |
52 | - | 68 | + index: 11, |
53 | } | 69 | } |
54 | ] | 70 | ] |
55 | 71 | ||
@@ -58,7 +74,7 @@ let InitialState = Record({ | @@ -58,7 +74,7 @@ let InitialState = Record({ | ||
58 | userProfile: new (Record({ | 74 | userProfile: new (Record({ |
59 | isFetching: false, | 75 | isFetching: false, |
60 | profile: Map(), | 76 | profile: Map(), |
61 | - })) | 77 | + })), |
62 | }); | 78 | }); |
63 | 79 | ||
64 | export default InitialState; | 80 | export default InitialState; |
@@ -27,4 +27,20 @@ export default class MineGuangService { | @@ -27,4 +27,20 @@ export default class MineGuangService { | ||
27 | throw(error); | 27 | throw(error); |
28 | }); | 28 | }); |
29 | } | 29 | } |
30 | + | ||
31 | + async modifyUserBaseInfo(params) { | ||
32 | + return await this.api.get({ | ||
33 | + url: '', | ||
34 | + body: { | ||
35 | + method: 'app.passport.modifyBase', | ||
36 | + ...params, | ||
37 | + } | ||
38 | + }) | ||
39 | + .then((json) => { | ||
40 | + return json; | ||
41 | + }) | ||
42 | + .catch((error) => { | ||
43 | + throw(error); | ||
44 | + }); | ||
45 | + } | ||
30 | } | 46 | } |
-
Please register or login to post a comment