/** * Sample React Native App * https://github.com/facebook/react-native * * @format * @flow */ import React, { Component } from 'react'; import { Platform, StyleSheet, Text, View, Image, TouchableOpacity, StatusBar, ImageBackground, Button, DeviceEventEmitter } from 'react-native'; import BasePage from './BasePage'; import commonutil from './utils/commonutil'; import http_user from './services/user'; type Props = {}; export default class SchoolAge extends BasePage { state = {}; render() { return ( 请选择孩子所在的学龄段 ); } componentWillMount() {} pres() { //PRESCHOOL("学前") this.updateUserInfo('PRESCHOOL'); } primary() { // PRIMARY_SCHOOL("小学") this.updateUserInfo('PRIMARY_SCHOOL'); } middle() { this.updateUserInfo('MIDDLE_SCHOOL'); } async updateUserInfo(group) { if (global.userInfo.isVisitor) { console.log('游客登录'); //是访客登录 global.userInfo.ageGroup = group; this.clearPageToNext('MainPage'); commonutil.saveUserInfo(); return true; } else { console.log('正常登录'); let opts = { method: 'PUT', //请求方法 body: { ageGroup: group } //请求体 }; await http_user.update_UserInfo(opts).then((res) => { global.userInfo.ageGroup = group; commonutil.saveUserInfo(); this.clearPageToNext('MainPage'); }); } } } const styles = StyleSheet.create({ title_text: { justifyContent: 'center', alignItems: 'center', color: 'black', fontSize: 20, fontWeight: '300', textAlign: 'center' }, view_flex: { flex: 0.1 }, touchable_item: { flex: 1, width: '90%', justifyContent: 'center', alignItems: 'center' }, image_item: { width: '100%', height: '95%', resizeMode: 'contain' } });