kdxcxs
4 years ago
6 changed files with 123 additions and 11 deletions
@ -0,0 +1,35 @@ |
|||
import React, {Component} from 'react'; |
|||
import {ToastAndroid} from 'react-native'; |
|||
import YooSplashUI from '../ui/YooSplashUI'; |
|||
import {post} from '../api/HTTP'; |
|||
import CookieManager from '@react-native-community/cookies'; |
|||
|
|||
export default class YooSplash extends Component { |
|||
componentDidMount() { |
|||
post('http://eol.ctbu.edu.cn/meol/loginCheck.do', { |
|||
headers: { |
|||
'Cache-Control': 'max-age=0', |
|||
'Upgrade-Insecure-Requests': '1', |
|||
Origin: 'http://eol.ctbu.edu.cn', |
|||
'Content-Type': 'application/x-www-form-urlencoded', |
|||
'User-Agent': 'YooMooc', |
|||
Referer: |
|||
'http://eol.ctbu.edu.cn/meol/common/security/login.jsp?enterLid=46445', |
|||
'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8,en-US;q=0.7', |
|||
}, |
|||
}) |
|||
.then((response) => { |
|||
if (/<title>(.|\n)*用户登录(.|\n)*<\/title>/.test(response)) { |
|||
this.props.gotoLogin(); |
|||
CookieManager.clearAll(); |
|||
} else if (/<title>(.|\n)*网络课程(.|\n)*<\/title>/.test(response)) { |
|||
this.props.gotoForum(); |
|||
} |
|||
}) |
|||
.catch(() => ToastAndroid.show('无法连接到服务器', ToastAndroid.SHORT)); |
|||
} |
|||
|
|||
render() { |
|||
return <YooSplashUI />; |
|||
} |
|||
} |
@ -1,5 +1,6 @@ |
|||
import YooLogin from './YooLogin'; |
|||
import YooForum from './YooForum'; |
|||
import YooBackground from '../ui/YooBackground'; |
|||
import YooSplash from './YooSplash'; |
|||
|
|||
export {YooLogin, YooForum, YooBackground}; |
|||
export {YooLogin, YooForum, YooBackground, YooSplash}; |
|||
|
@ -0,0 +1,38 @@ |
|||
import React, {Component} from 'react'; |
|||
import {View, StyleSheet, Image, Text, ActivityIndicator} from 'react-native'; |
|||
|
|||
const styles = StyleSheet.create({ |
|||
container: { |
|||
flex: 1, |
|||
alignItems: 'center', |
|||
}, |
|||
logo: { |
|||
marginTop: 120, |
|||
width: 200, |
|||
height: 200, |
|||
marginBottom: 16, |
|||
}, |
|||
text: { |
|||
fontSize: 24, |
|||
fontWeight: 'bold', |
|||
}, |
|||
indicator: { |
|||
marginTop: 64, |
|||
}, |
|||
}); |
|||
|
|||
export default class YooSplashUI extends Component { |
|||
render() { |
|||
return ( |
|||
<View style={styles.container}> |
|||
<Image source={require('../../assets/icon.png')} style={styles.logo} /> |
|||
<Text style={styles.text}>正在检查网络,请稍后</Text> |
|||
<ActivityIndicator |
|||
size="large" |
|||
color="#0000ff" |
|||
style={styles.indicator} |
|||
/> |
|||
</View> |
|||
); |
|||
} |
|||
} |
Loading…
Reference in new issue