diff --git a/component/OnlineStudy/2-PlayerPKHome/index.js b/component/OnlineStudy/2-PlayerPKHome/index.js index 62cd7e19b260828e34209d2393d9f62b6270fdd2..22bad50d5c4ecc4692f13c997f810b1f5c072c2e 100644 --- a/component/OnlineStudy/2-PlayerPKHome/index.js +++ b/component/OnlineStudy/2-PlayerPKHome/index.js @@ -42,6 +42,7 @@ class TwoPlayerPKHome extends Component { state = {isStarted: false, isCanceling: false}; resolveMessage = msg => { + console.log(msg); const data = JSON.parse(msg.data); console.log(data); if (data.hasOwnProperty('type')) { diff --git a/component/OnlineStudy/GlobalResourses/index.js b/component/OnlineStudy/GlobalResourses/index.js index dc0f2b547ff4455f45f63429cf7f44b6486b74e3..e85469c60ccf4de29a5c092985920797f5a47cd4 100644 --- a/component/OnlineStudy/GlobalResourses/index.js +++ b/component/OnlineStudy/GlobalResourses/index.js @@ -3,3 +3,4 @@ global.defaultACID = 'notLocated'; // default value of acID global.acID = global.defaultACID; // a acID of range PK global.rangeID = global.defaultRangeID; // rangeID for school buildings global.websocket = new WebSocket('ws://localhost:8080'); // an instance of websocket +global.sno=''; diff --git a/component/OnlineStudy/GlobalUserTest/index.js b/component/OnlineStudy/GlobalUserTest/index.js deleted file mode 100644 index c3f52fb17513683b7cca01595c0a46c9c36dc761..0000000000000000000000000000000000000000 --- a/component/OnlineStudy/GlobalUserTest/index.js +++ /dev/null @@ -1,20 +0,0 @@ -global.sno = '221900330'; -global.password = '123'; - -export class sno { - static get() { - return global.sno; - } - static set(input) { - global.sno = input; - } -} - -export class password { - static get() { - return global.password; - } - static set(input) { - global.password = input; - } -} diff --git a/component/OnlineStudy/MyTest/index.js b/component/OnlineStudy/MyTest/index.js deleted file mode 100644 index ea1509f7d3cbe90820903b41627baea7935aac73..0000000000000000000000000000000000000000 --- a/component/OnlineStudy/MyTest/index.js +++ /dev/null @@ -1,49 +0,0 @@ -import {sno, password} from '../GlobalUserTest'; -import {post, get} from '../MyUtilities'; -// import {get, post} from '../../../utils/http'; - -const URL_LOGIN = 'http://www.tdms.xyz:8000/FZUStudy/login'; -const URL_LOGOUT = 'http://www.tdms.xyz:8000/FZUStudy/logout'; -const URL_2PLAYER_PK_MATCH = 'ws://www.tdms.xyz:8000/FZUStudy/websocket/pk/'; // + '{sno}' - -// export function login() { -// const data = { -// sno: sno.get(), -// password: password.get(), -// }; -// const resolveData = r => { -// console.log(r); -// }; -// // console.log('[Login] sno: ' + data.sno + ' password: ' + data.password); -// post(URL_LOGIN, data).then(resolveData).catch(); -// } - -// export function logout() { -// const resolveData = data => { -// console.log(data); -// }; -// // console.log('[Logout]'); -// get(URL_LOGOUT, {}).then(resolveData).catch(); -// } - -// export function connect() { -// const socketUrl = URL_2PLAYER_PK_MATCH + sno.get(); -// let socket = new WebSocket(socketUrl); -// //打开事件 -// socket.onopen = function () { -// console.log('websocket 已打开'); -// }; -// //获得消息事件 -// socket.onmessage = function (msg) { -// const serverMsg = '收到服务端信息: ' + msg.data; -// console.log(serverMsg); -// }; -// //关闭事件 -// socket.onclose = function () { -// console.log('websocket 已关闭'); -// }; -// //发生了错误事件 -// socket.onerror = function () { -// console.log('websocket 发生了错误'); -// }; -// } diff --git a/component/OnlineStudy/MyUtilities/index.js b/component/OnlineStudy/MyUtilities/index.js index 667ffdec88897fe972686a121436b0bd8f3bd1c1..8367e8b553f44562264124b223e450c3a937fc61 100644 --- a/component/OnlineStudy/MyUtilities/index.js +++ b/component/OnlineStudy/MyUtilities/index.js @@ -1,14 +1,14 @@ import '../GlobalResourses'; // 用户 sno -import '../GlobalUserTest'; import CookieManager from '@react-native-cookies/cookies'; import {ToastAndroid} from 'react-native'; - +import {connect} from "react-redux"; +import {Component} from "react"; /** * class sno 的 get() 和 set() 需要修改以指向“全局变量”中的“学号” */ const EARTH_RADIUS = 6371393; // metre -const DEFAULT_DISTANCE = 100; // metre +const DEFAULT_DISTANCE = 200; // metre const URL_SHORT = 'http://www.tdms.xyz:8000/FZUStudy'; const URL_AREA_GET_ID = 'http://www.tdms.xyz:8000/FZUStudy/study/areaGetID'; const URL_AREA_MATCH = 'http://www.tdms.xyz:8000/FZUStudy/study/areamatch'; @@ -315,13 +315,20 @@ export class websocket { } } +const mapStateToProps = state => { + const {user} = state; + return {user}; +}; + + // 用户 sno -export class sno { +export class sno{ + static get() { return global.sno; } - static set(input) { - global.sno = input; + static set(sno) { + global.sno=sno; } } @@ -368,7 +375,7 @@ function getDistance(longitude1, latitude1, longitude2, latitude2) { } function parseLocation(longitude, latitude) { - // console.log('longitude: ' + longitude + ' latitude: ' + latitude); + console.log('longitude: ' + longitude + ' latitude: ' + latitude); let range = { ID: 'notInRange', distance: DEFAULT_DISTANCE, diff --git a/component/OnlineStudy/RangePKHome/index.js b/component/OnlineStudy/RangePKHome/index.js index 85c685ecada2607e48c875a4495c586ac1517ae9..708a1700b949b18beb3f714148475efbacadcd84 100644 --- a/component/OnlineStudy/RangePKHome/index.js +++ b/component/OnlineStudy/RangePKHome/index.js @@ -63,6 +63,8 @@ class RangePKHome extends Component { location => { const longitude = location.coords.longitude; //经度 const latitude = location.coords.latitude; //纬度 + // console.log('longitude:',longitude) + // console.log('latitude:',latitude) rangeID.setByLocation(longitude, latitude); this.setState({ isStarted: false, diff --git a/component/OnlineStudy/RangePKStudy/index.js b/component/OnlineStudy/RangePKStudy/index.js index 1bfcd0d504e74b7db3b3ff961160e82bf276a54e..d15320a00075479cd887a3a463be076c96aebf71 100644 --- a/component/OnlineStudy/RangePKStudy/index.js +++ b/component/OnlineStudy/RangePKStudy/index.js @@ -252,6 +252,9 @@ class RangePKStudy extends Component { let top = 'ERROR'; let bottom = 'ERROR'; console.log('[QUIT_SUCCESS]', params); + if(params.hasOwnProperty('duration')){ + top=params.duration + } if ( params.hasOwnProperty('start_time') && params.hasOwnProperty('end_time') diff --git a/page/Login/index.js b/page/Login/index.js index cfb7b11dd852a86ec61009fa68f7134cf781ade7..91db2b05bd221c6c8c1cc9348edf0f5f88d1b3ac 100644 --- a/page/Login/index.js +++ b/page/Login/index.js @@ -16,7 +16,7 @@ import {SafeAreaProvider} from 'react-native-safe-area-context'; import {connect} from 'react-redux'; import {bindActionCreators} from 'redux'; import {updateUserDetail} from '../../store/action/user-actions'; - +import {sno as globalSno} from '../../component/OnlineStudy/MyUtilities' class Login extends Component { static navigationOptions = { title: '登录', @@ -54,7 +54,7 @@ class Login extends Component { }); // alert('登录成功!'); ToastAndroid.show('登录成功!', 500); //提示 - global.sno=sno; + globalSno.set(sno) this.props.navigation.navigate('Home'); }) .catch(err => { diff --git a/page/Login/register.js b/page/Login/register.js index 26b80f60abcdba72b2b8cef524921749850fd2b3..8c4e9d7f8ac0f6addc5460f73e47d15a9408a072 100644 --- a/page/Login/register.js +++ b/page/Login/register.js @@ -12,7 +12,7 @@ import {Button, CheckBox, Icon, Input} from 'react-native-elements'; import {connect} from 'react-redux'; import {bindActionCreators} from 'redux'; import {updateUserDetail} from '../../store/action/user-actions'; - +import {sno as globalSno} from '../../component/OnlineStudy/MyUtilities' const {width, height} = Dimensions.get('window'); class register extends Component { @@ -49,7 +49,7 @@ class register extends Component { ToastAndroid.show('注册成功!', 500); //提示 http('post', '/login', {sno, password}).then(res => { console.log('res', res); - global.sno=sno; + globalSno.set(sno); this.props.updateUserDetail(res.data); this.props.navigation.navigate('Home'); });