12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046 |
- /**
- * Sample React Native App
- * https://github.com/facebook/react-native
- *
- * @format
- * @flow
- */
- import React, { Component } from 'react';
- import {
- StyleSheet,
- Text,
- View,
- Image,
- TouchableOpacity,
- ImageBackground,
- ToastAndroid,
- BackHandler,
- StatusBar,
- DeviceEventEmitter
- } from 'react-native';
- import BasePage from './BasePage';
- import CourseTitle from '../pages/components/CourseTitle';
- import ChosePhoto from '../pages/components/ChosePhoto';
- import RegionModal from '../pages/components/RegionModal';
- import BirthdayModal from '../pages/components/BirthdayModal';
- import GradeSelectionModal from '../pages/components/GradeSelectionModal';
- import PersonalInfoDialog from '../pages/components/PersonalInfoDialog';
- import http_user from './services/user';
- import wechat from './utils/wechat';
- import commonutil from './utils/commonutil';
- type Props = {};
- export default class PersonalInfo extends BasePage {
- state = {
- ready: false,
- file_user_data: new Map(),
- user_nickName: '未设置',
- schoolName: '未设置',
- provinceName: '未设置',
- citys: '',
- grade_text: '七年级',
- grade_index: 6,
- birthday_year: 0,
- birthday_month: 0,
- birthday_day: 0,
- birthday_time: 0,
- photo_uri: require('./images/userInfo/default_photo.png'),
- phone: '',
- phone_bind_result: false,
- phone_bind_type: 1, //1是绑定,2是修改
- phone_bind_color: 'red',
- wechat_nickName: '',
- wechat_bind_color: 'red',
- show_bind_phone: false
- };
- render() {
- if (!this.state.ready) {
- return null;
- }
- return (
- <View style={{ backgroundColor: '#F0F1F5', flex: 1 }}>
- <View style={{ width: '100%', height: this.getWindowHeight() }}>
- <PersonalInfoDialog
- ref={(view) => (this.dialog = view)}
- style={{ height: 10000 }}
- updateParentState={this.updateState.bind(this)}
- />
- <ChosePhoto ref={(view) => (this.chosephoto = view)} photoback={this.photoback.bind(this)} />
- <RegionModal
- ref={(view) => (this.regionmodal = view)}
- cityscommit={this.cityscommit.bind(this)}
- provinceName={this.state.provinceName}
- citys={this.state.citys}
- />
- <GradeSelectionModal
- ref={(view) => (this.gradeselectionModal = view)}
- commitGrade={this.commitGrade.bind(this)}
- grade_index={this.state.grade_index}
- />
- <BirthdayModal
- ref={(view) => (this.birthdaymodal = view)}
- birthdaycommit={this.birthdaycommit.bind(this)}
- year={this.state.birthday_year}
- month={this.state.birthday_month}
- day={this.state.birthday_day}
- />
- <StatusBar backgroundColor={'transparent'} translucent={true} />
- <View
- style={{
- flex: 1,
- flexDirection: 'column'
- }}
- >
- <ImageBackground
- source={require('./images/userInfo/top.png')}
- style={{
- flex: 3,
- width: '100%',
- backgroundColor: '#F0F1F5',
- height: '75%'
- }}
- imageStyle={{ resizeMode: 'cover' }}
- >
- <View
- style={{
- flex: 1,
- alignItems: 'center',
- justifyContent: 'center',
- flexDirection: 'column'
- }}
- >
- <CourseTitle
- style={{ flex: 5 }}
- width={this.getWindowWidth()}
- title="个人信息"
- lefttype={2}
- righttype={0}
- textcolor={'white'}
- backPress={this.personinfoback.bind(this)}
- />
- <TouchableOpacity
- style={{
- flex: 1.3,
- backgroundColor: 'white',
- width: '90%',
- bottom: 0,
- alignItems: 'center',
- justifyContent: 'flex-end',
- bottom: -30,
- borderRadius: 10,
- overflow: 'hidden'
- }}
- activeOpacity={1}
- onPress={() => this.arrowpress(0)}
- >
- <View
- style={{
- flex: 1,
- borderRadius: 20,
- overflow: 'hidden',
- alignItems: 'center',
- justifyContent: 'center',
- flexDirection: 'row'
- }}
- >
- <View style={{ flex: 0.5 }} />
- <View
- style={{
- flex: 3,
- height: '100%',
- alignItems: 'center',
- justifyContent: 'center'
- }}
- >
- <Image
- style={{
- borderRadius: 50,
- width: '80%',
- height: '70%'
- // borderWidth: 3
- // borderColor: "red"
- }}
- source={this.state.photo_uri}
- />
- </View>
- <View
- style={{
- flex: 9,
- backgroundColor: 'white',
- height: '100%',
- justifyContent: 'center'
- }}
- >
- <Text style={{ left: 10, color: 'black', fontSize: 16 }}>修改头像</Text>
- </View>
- <View
- style={{
- flex: 1.5,
- height: '65%',
- alignItems: 'center',
- justifyContent: 'center'
- }}
- >
- {this.getArraowImg(0)}
- </View>
- </View>
- </TouchableOpacity>
- <View style={{ flex: 0.5 }} />
- </View>
- </ImageBackground>
- <View style={{ flex: 0.2 }} />
- <View
- style={{
- width: '100%',
- flex: 3.3,
- alignItems: 'center',
- backgroundColor: '#F0F1F5'
- }}
- >
- <View
- style={{
- backgroundColor: 'rgb(242, 242, 242)',
- width: '90%',
- alignItems: 'center',
- justifyContent: 'center',
- height: '100%',
- overflow: 'hidden',
- borderRadius: 10
- }}
- >
- <View
- style={{
- width: '100%',
- alignItems: 'center',
- justifyContent: 'center',
- height: '100%'
- }}
- >
- <TouchableOpacity
- style={{
- flex: 1,
- marginVertical: 1,
- width: '100%',
- flexDirection: 'row',
- backgroundColor: 'white'
- }}
- activeOpacity={1}
- onPress={() => this.arrowpress(1)}
- >
- <View
- style={{
- flex: 2,
- alignItems: 'center',
- justifyContent: 'center'
- }}
- >
- {this.choseheadericon(1)}
- </View>
- <Text style={styles.item_text}>昵称</Text>
- <View
- style={{
- flex: 5,
- alignItems: 'flex-end'
- }}
- >
- <Text
- style={{
- flex: 1,
- fontSize: 15,
- textAlignVertical: 'center'
- }}
- numberOfLines={1}
- ellipsizeMode={'tail'}
- >
- {this.state.user_nickName}
- </Text>
- </View>
- <View
- style={{
- flex: 1.1,
- alignItems: 'center',
- justifyContent: 'center'
- }}
- >
- {this.getArraowImg(1)}
- </View>
- </TouchableOpacity>
- <TouchableOpacity
- style={{
- flex: 1,
- width: '100%',
- flexDirection: 'row',
- backgroundColor: 'white',
- marginVertical: 1
- }}
- activeOpacity={1}
- onPress={() => this.arrowpress(2)}
- >
- <View
- style={{
- flex: 2,
- alignItems: 'center',
- justifyContent: 'center'
- }}
- >
- {this.choseheadericon(2)}
- </View>
- <Text style={styles.item_text}>生日</Text>
- <View
- style={{
- flex: 5,
- alignItems: 'flex-end'
- }}
- >
- <Text
- style={{
- flex: 1,
- fontSize: 15,
- textAlignVertical: 'center'
- }}
- numberOfLines={1}
- ellipsizeMode={'tail'}
- >
- {this.state.birthday_time}
- </Text>
- </View>
- <View
- style={{
- flex: 1.1,
- alignItems: 'center',
- justifyContent: 'center'
- }}
- >
- {this.getArraowImg(2)}
- </View>
- </TouchableOpacity>
- <TouchableOpacity
- style={{
- flex: 1,
- width: '100%',
- flexDirection: 'row',
- backgroundColor: 'white',
- marginVertical: 1
- }}
- activeOpacity={1}
- onPress={() => this.arrowpress(3)}
- >
- <View
- style={{
- flex: 2,
- alignItems: 'center',
- justifyContent: 'center'
- }}
- >
- {this.choseheadericon(3)}
- </View>
- <Text style={styles.item_text}>所在地区</Text>
- <View
- style={{
- flex: 5,
- alignItems: 'flex-end'
- }}
- >
- <Text
- style={{
- flex: 1,
- fontSize: 15,
- textAlignVertical: 'center'
- }}
- numberOfLines={1}
- ellipsizeMode={'tail'}
- >
- {this.state.provinceName}-{this.state.citys}
- </Text>
- </View>
- <View
- style={{
- flex: 1.1,
- alignItems: 'center',
- justifyContent: 'center'
- }}
- >
- {this.getArraowImg(3)}
- </View>
- </TouchableOpacity>
- <TouchableOpacity
- style={{
- flex: 1,
- width: '100%',
- flexDirection: 'row',
- backgroundColor: 'white',
- marginVertical: 1
- }}
- activeOpacity={1}
- onPress={() => this.arrowpress(4)}
- >
- <View
- style={{
- flex: 2,
- alignItems: 'center',
- justifyContent: 'center'
- }}
- >
- {this.choseheadericon(4)}
- </View>
- <Text style={styles.item_text}>我的学校</Text>
- <View
- style={{
- flex: 5,
- alignItems: 'flex-end'
- }}
- >
- <Text
- style={{
- flex: 1,
- fontSize: 15,
- textAlignVertical: 'center'
- }}
- numberOfLines={1}
- ellipsizeMode={'tail'}
- >
- {this.state.schoolName}
- </Text>
- </View>
- <View
- style={{
- flex: 1.1,
- alignItems: 'center',
- justifyContent: 'center'
- }}
- >
- {this.getArraowImg(4)}
- </View>
- </TouchableOpacity>
- {/* <TouchableOpacity
- style={{
- flex: 1,
- marginTop: 1,
- width: '100%',
- flexDirection: 'row',
- backgroundColor: 'white',
- marginVertical: 1
- }}
- activeOpacity={1}
- onPress={() => this.arrowpress(5)}
- >
- <View
- style={{
- flex: 2,
- alignItems: 'center',
- justifyContent: 'center'
- }}
- >
- {this.choseheadericon(5)}
- </View>
- <Text style={styles.item_text}>我的年级</Text>
- <View
- style={{
- flex: 5,
- alignItems: 'flex-end'
- }}
- >
- <Text
- style={{
- flex: 1.1,
- fontSize: 15,
- textAlignVertical: 'center'
- }}
- numberOfLines={1}
- ellipsizeMode={'tail'}
- >
- {this.state.grade_text}
- </Text>
- </View>
- <View
- style={{
- flex: 1.1,
- alignItems: 'center',
- justifyContent: 'center'
- }}
- >
- {this.getArraowImg(5)}
- </View>
- </TouchableOpacity> */}
- </View>
- </View>
- </View>
- <View style={{ flex: 0.3, backgroundColor: '#F0F1F5' }} />
- <View
- style={{
- flex: 1.5,
- backgroundColor: '#F0F1F5',
- alignItems: 'center',
- justifyContent: 'center'
- }}
- >
- <View
- style={{
- width: '90%',
- alignItems: 'center',
- justifyContent: 'center',
- height: '100%',
- overflow: 'hidden',
- borderRadius: 10
- }}
- >
- <TouchableOpacity
- style={{
- flex: 1,
- width: '100%',
- flexDirection: 'row',
- backgroundColor: 'white',
- marginVertical: 1
- }}
- activeOpacity={1}
- onPress={() => this.arrowpress(6)}
- >
- <View
- style={{
- flex: 2,
- alignItems: 'center',
- justifyContent: 'center'
- }}
- >
- {this.choseheadericon(6)}
- </View>
- <Text style={styles.item_text}>我的手机号</Text>
- <View
- style={{
- flex: 5,
- alignItems: 'flex-end'
- }}
- >
- <Text
- style={{
- flex: 1,
- fontSize: 15,
- textAlignVertical: 'center',
- color: this.state.phone_bind_color
- }}
- numberOfLines={1}
- ellipsizeMode={'tail'}
- >
- {this.state.phone}
- </Text>
- </View>
- <View
- style={{
- flex: 1.1,
- alignItems: 'center',
- justifyContent: 'center'
- }}
- >
- {this.getArraowImg(6)}
- </View>
- </TouchableOpacity>
- <TouchableOpacity
- style={{
- flex: 1,
- width: '100%',
- flexDirection: 'row',
- backgroundColor: 'white',
- marginVertical: 1
- }}
- activeOpacity={1}
- onPress={() => this.arrowpress(7)}
- >
- <View
- style={{
- flex: 2,
- alignItems: 'center',
- justifyContent: 'center'
- }}
- >
- {this.choseheadericon(7)}
- </View>
- <Text style={styles.item_text}>我的微信</Text>
- <View
- style={{
- flex: 5,
- alignItems: 'flex-end'
- }}
- >
- <Text
- style={{
- flex: 1,
- fontSize: 15,
- textAlignVertical: 'center',
- color: this.state.wechat_bind_color
- }}
- numberOfLines={1}
- ellipsizeMode={'tail'}
- >
- {this.state.wechat_nickName}
- </Text>
- </View>
- <View
- style={{
- flex: 1.1,
- alignItems: 'center',
- justifyContent: 'center'
- }}
- >
- {this.getArraowImg(4)}
- </View>
- </TouchableOpacity>
- </View>
- </View>
- <View
- style={{
- width: '100%',
- flex: 2.7,
- backgroundColor: '#F0F1F5',
- flexDirection: 'column'
- }}
- >
- <View
- style={{
- flex: 1,
- flexDirection: 'row',
- alignItems: 'center',
- justifyContent: 'center'
- }}
- >
- <View
- style={{
- alignItems: 'center',
- width: '100%',
- height: '100%',
- backgroundColor: '#F0F1F5',
- justifyContent: 'center'
- }}
- >
- <View
- style={{
- flex: 3
- }}
- />
- <TouchableOpacity
- activeOpacity={1}
- style={{
- flex: 2,
- width: '100%',
- alignItems: 'center',
- justifyContent: 'center',
- height: '100%'
- }}
- onPress={() => this.logout()}
- >
- <ImageBackground
- source={require('./images/userInfo/logoutbg.png')}
- style={{
- flex: 1,
- width: '100%',
- alignItems: 'center',
- justifyContent: 'center',
- height: '100%'
- }}
- imageStyle={{ resizeMode: 'contain' }}
- >
- <Text
- style={{
- fontSize: 22,
- color: 'white',
- width: '100%',
- textAlign: 'center'
- }}
- >
- 退出登录
- </Text>
- </ImageBackground>
- </TouchableOpacity>
- <View
- style={{
- flex: 1.5
- }}
- />
- </View>
- </View>
- </View>
- </View>
- </View>
- {/* <BindPhoneSuccess show={this.state.show_bind_phone} /> */}
- </View>
- );
- }
- componentWillMount() {
- //获取用户信息
- this.getUserInfo();
- BackHandler.addEventListener('hardwareBackPress', this.onBackAndroid);
- }
- componentWillUnmount() {
- BackHandler.removeEventListener('hardwareBackPress', this.onBackAndroid);
- }
- async getUserInfo() {
- let userinfo = await global.storage
- .load({
- key: 'userInfo'
- })
- .then((result) => {
- this.state.file_user_data = commonutil.jsonToMap(result);
- var time = this.formaterDate(this.state.file_user_data.get('birthday'));
- this.setState({
- schoolName:
- this.state.file_user_data.get('school') === ''
- ? '未设置'
- : this.state.file_user_data.get('school'),
- provinceName:
- this.state.file_user_data.get('province') === ''
- ? '未设置'
- : this.state.file_user_data.get('province'),
- citys: this.state.file_user_data.get('city') === '' ? '未设置' : this.state.file_user_data.get('city'),
- phone: this.state.file_user_data.get('mobile'),
- wechat_nickName: this.state.file_user_data.get('wechat_nickName'),
- user_nickName: this.state.file_user_data.get('nickName'),
- birthday_time: time
- });
- if (this.state.file_user_data.get('avatar').length > 0) {
- this.setState({
- photo_uri: {
- uri: this.state.file_user_data.get('avatar')
- }
- });
- }
- if (this.state.phone == null || this.state.phone === '') {
- this.setState({
- phone_bind_color: 'red',
- phone_bind_type: 1,
- phone: '未绑定'
- });
- } else {
- this.setState({
- phone_bind_color: 'rgba(113, 113, 113, 1)',
- phone_bind_type: 2
- });
- }
- if (this.state.wechat_nickName == null || this.state.wechat_nickName === '') {
- this.setState({
- wechat_bind_color: 'red',
- wechat_nickName: '未绑定'
- });
- } else {
- this.setState({
- wechat_bind_color: 'rgba(113, 113, 113, 1)'
- });
- }
- this.setState({
- ready: true
- });
- })
- .catch((err) => {
- console.log('PersonalInfo:ERROR' + err.message);
- });
- }
- onBackAndroid = () => {
- if (this.state.show_bind_phone) {
- this.setState({
- show_bind_phone: false
- });
- } else {
- this.goBack();
- }
- return true;
- };
- getArraowImg(type) {
- return (
- <View
- style={{
- width: '100%',
- height: '100%',
- alignItems: 'center',
- resizeMode: 'contain',
- justifyContent: 'center'
- }}
- //onPress={() => this.arrowpress(type)}
- >
- <Image
- source={require('./images/userInfo/arrow.png')}
- style={{
- width: '20%',
- height: '30%'
- }}
- />
- </View>
- );
- }
- choseheadericon(type) {
- let headerpath;
- switch (type) {
- case 0:
- headerpath = require('./images/userInfo/headportrait.png');
- break;
- case 1:
- headerpath = require('./images/userInfo/nickname.png');
- break;
- case 2:
- headerpath = require('./images/userInfo/birthday.png');
- break;
- case 3:
- headerpath = require('./images/userInfo/location.png');
- break;
- case 4:
- headerpath = require('./images/userInfo/school.png');
- break;
- case 5:
- headerpath = require('./images/userInfo/grade.png');
- break;
- case 6:
- headerpath = require('./images/userInfo/phone.png');
- break;
- case 7:
- headerpath = require('./images/userInfo/wechat.png');
- break;
- }
- // alert(headerpath);
- return (
- <Image
- source={headerpath}
- style={{
- width: '60%',
- height: '60%',
- resizeMode: 'contain'
- }}
- />
- );
- }
- arrowpress(type) {
- switch (type) {
- case 0:
- this.chosephoto.setModalVisible(true);
- break;
- case 1:
- this.dialog.setInfo('修改昵称', '昵称');
- this.dialog.setModalVisible(true, 1);
- break;
- case 2:
- // alert("生日");
- this.birthdaymodal.setModalVisible(true);
- break;
- case 3:
- this.regionmodal.setModalVisible(true);
- break;
- case 4:
- this.dialog.setInfo('我的学校', '学校名称');
- this.dialog.setModalVisible(true, 2);
- break;
- case 5:
- this.gradeselectionModal.setModalVisible(true);
- break;
- //手机号
- case 6:
- if (this.state.phone === '未绑定') {
- this.props.navigation.navigate('PhoneBind', {
- type: this.state.phone_bind_type,
- bind_phone_back: this.bind_phone_back.bind(this)
- });
- }
- break;
- //微信
- case 7:
- wechat.wechatLogin((result) => {
- let opts = {
- method: 'PUT',
- body: {
- openId: result['openid'],
- unionId: result['unionid'],
- avatar: '',
- sex: result['sex'],
- nickName: result['nickname']
- }
- };
- http_user.bind_wechat(opts).then((res) => {
- if (res.code == 200) {
- this.setState({
- wechat_nickName: res['nickname'],
- wechat_bind_color: 'rgba(113, 113, 113, 1)'
- });
- } else {
- this.Toast(res.message);
- }
- });
- });
- break;
- }
- }
- logout() {
- //清空存储的用户信息
- http_user.LoginOut().then((res) => {
- console.log('====================================');
- console.log('res', res);
- console.log('====================================');
- global.storage.remove({ key: 'userInfo' });
- this.clearPageToNext('Login');
- });
- }
- updateState(input_text, type) {
- if (type == 1) {
- this.setState({ user_nickName: input_text });
- this.updateUserInfo({ nickName: input_text });
- } else if (type == 2) {
- this.setState({ schoolName: input_text });
- this.updateUserInfo({ school: input_text });
- }
- }
- cityscommit(provinces_name, citys_name) {
- this.setState({
- provinceName: provinces_name,
- citys: citys_name
- });
- this.updateUserInfo({ province: provinces_name, city: citys_name });
- }
- commitGrade(text, index) {
- this.setState({
- grade_text: text,
- grade_index: index
- });
- this.updateUserInfo({ grade: index + 1 });
- }
- birthdaycommit(year, month, day) {
- this.setState({
- birthday_time: year + '年' + month + '月' + day + '日'
- });
- var date = new Date(year + '-' + month + '-' + day);
- this.updateUserInfo({ birthday: date });
- }
- photoback(photo_uri) {
- if (photo_uri == undefined || photo_uri === '' || photo_uri == null) {
- return;
- }
- this.upload_head(photo_uri);
- }
- updateUserInfo(object) {
- let opts = {
- method: 'PUT', //请求方法
- body: object //请求体
- };
- http_user.update_UserInfo(opts).then((res) => {
- this.update_file_userinfo(this.state.file_user_data, res);
- this.saveUserInfo(commonutil.mapToJson(this.state.file_user_data));
- });
- }
- bind_phone_back(phone_num, result) {
- if (result == true) {
- this.Toast('修改手机号成功');
- this.setState({
- phone: phone_num,
- phone_bind_result: result,
- show_bind_phone: true
- });
- } else {
- this.Toast('修改手机号失败');
- }
- }
- personinfoback() {
- // this.props.navigation.state.params.infoback();
- DeviceEventEmitter.emit('infoback');
- this.props.navigation.goBack();
- }
- formaterDate(date) {
- var date = new Date(date);
- var Y = date.getFullYear() + '';
- var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '';
- var D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' ';
- this.setState({
- birthday_year: Y,
- birthday_month: M,
- birthday_day: D
- });
- return Y + '-' + M + '-' + D;
- }
- upload_head(file_path) {
- //上传成功但是没拿到数据
- http_user.uploadImage(file_path).then((res) => {
- //请求成功
- if (res.code == 200) {
- this.setState({
- photo_uri: { uri: res.data }
- });
- this.updateUserInfo({ avatar: res.data });
- } else {
- this.Toast('上传失败:' + res.message);
- }
- });
- }
- update_file_userinfo(map, res) {
- map.set('ageGroup', res.data.ageGroup);
- map.set('avatar', res.data.avatar);
- map.set('birthday', res.data.birthday);
- map.set('channel', res.data.channel);
- map.set('city', res.data.city);
- map.set('country', res.data.country);
- map.set('eid', res.data.eid);
- map.set('gmtCreated', res.data.gmtCreated);
- map.set('gmtModified', res.data.gmtModified);
- map.set('mobile', res.data.mobile);
- map.set('nickName', res.data.nickName);
- map.set('province', res.data.province);
- map.set('school', res.data.school);
- map.set('sex', res.data.sex);
- map.set('status', res.data.status);
- map.set('uid', res.data.uid);
- }
- }
- class BindPhoneSuccess extends BasePage {
- render() {
- if (this.props.show) {
- return (
- <View
- style={{
- position: 'absolute',
- width: '100%',
- height: '100%',
- backgroundColor: 'rgba(0, 0, 0, 0.5)'
- }}
- />
- );
- } else {
- return null;
- }
- }
- }
- const styles = StyleSheet.create({
- item: {
- flex: 1,
- width: '100%',
- flexDirection: 'row',
- backgroundColor: 'white',
- marginTop: 1,
- backgroundColor: 'red'
- },
- item_text: {
- flex: 3,
- textAlignVertical: 'center',
- color: 'black',
- fontSize: 16
- }
- });
|