Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
软件工程实践2022年春W班
穿梭在银河的火箭队
FZUStudyRoom
提交
d6f3b251
F
FZUStudyRoom
项目概览
软件工程实践2022年春W班
/
穿梭在银河的火箭队
/
FZUStudyRoom
通知
12
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
FZUStudyRoom
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
d6f3b251
编写于
5月 10, 2022
作者:
ItbGcthate
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
304_change geolocation
上级
b9f198ba
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
71 addition
and
50 deletion
+71
-50
component/OnlineStudy/2-PlayerPKHome/index.js
component/OnlineStudy/2-PlayerPKHome/index.js
+1
-2
component/OnlineStudy/2-PlayerPKStudy/index.js
component/OnlineStudy/2-PlayerPKStudy/index.js
+1
-7
component/OnlineStudy/GlobalACID/index.js
component/OnlineStudy/GlobalACID/index.js
+0
-1
component/OnlineStudy/GlobalResourses/index.js
component/OnlineStudy/GlobalResourses/index.js
+3
-0
component/OnlineStudy/MyUtilities/index.js
component/OnlineStudy/MyUtilities/index.js
+35
-12
component/OnlineStudy/RangePKHome/index.js
component/OnlineStudy/RangePKHome/index.js
+17
-16
component/OnlineStudy/RangePKStudy/index.js
component/OnlineStudy/RangePKStudy/index.js
+14
-12
未找到文件。
component/OnlineStudy/2-PlayerPKHome/index.js
浏览文件 @
d6f3b251
...
@@ -27,9 +27,8 @@ class TwoPlayerPKHome extends Component {
...
@@ -27,9 +27,8 @@ class TwoPlayerPKHome extends Component {
const
data
=
JSON
.
parse
(
msg
.
data
);
const
data
=
JSON
.
parse
(
msg
.
data
);
console
.
log
(
data
);
console
.
log
(
data
);
if
(
false
)
{
if
(
false
)
{
const
opponent
=
null
;
//this.props.navigation.navigate('双人PK结算');
//this.props.navigation.navigate('双人PK结算');
this
.
props
.
navigation
.
navigate
(
'
双人PK中
'
,
{
opponent
:
opponent
}
);
this
.
props
.
navigation
.
navigate
(
'
双人PK中
'
);
this
.
setState
({
isStarted
:
false
,
isCanceling
:
false
,
opponent
:
null
});
this
.
setState
({
isStarted
:
false
,
isCanceling
:
false
,
opponent
:
null
});
}
}
if
(
data
.
hasOwnProperty
(
'
type
'
)
&&
data
.
type
===
'
MATCH_CANCEL_SUCCESS
'
)
{
if
(
data
.
hasOwnProperty
(
'
type
'
)
&&
data
.
type
===
'
MATCH_CANCEL_SUCCESS
'
)
{
...
...
component/OnlineStudy/2-PlayerPKStudy/index.js
浏览文件 @
d6f3b251
...
@@ -44,10 +44,7 @@ class TwoPlayerPKStudy extends Component {
...
@@ -44,10 +44,7 @@ class TwoPlayerPKStudy extends Component {
};
};
componentDidMount
()
{
componentDidMount
()
{
const
{
const
{
navigation
}
=
this
.
props
;
navigation
,
route
:
{
params
},
}
=
this
.
props
;
navigation
.
setOptions
({
navigation
.
setOptions
({
// 引入SettingButton组件至header的右边
// 引入SettingButton组件至header的右边
// 并把this.props传给SettingButton组件以实现Navigation的跳转
// 并把this.props传给SettingButton组件以实现Navigation的跳转
...
@@ -59,9 +56,6 @@ class TwoPlayerPKStudy extends Component {
...
@@ -59,9 +56,6 @@ class TwoPlayerPKStudy extends Component {
this
.
forceUpdate
();
this
.
forceUpdate
();
});
});
// 以下不是标语风格切换相关
// 以下不是标语风格切换相关
if
(
params
.
opponent
!==
undefined
&&
params
.
opponent
!==
null
)
{
this
.
setState
({
opponent
:
params
.
opponent
,
isStarted
:
true
});
}
this
.
startTimer
();
this
.
startTimer
();
}
}
...
...
component/OnlineStudy/GlobalACID/index.js
已删除
100644 → 0
浏览文件 @
b9f198ba
global
.
acID
=
1
;
// acID of range PK
component/OnlineStudy/GlobalResourses/index.js
浏览文件 @
d6f3b251
global
.
defaultRangeID
=
'
notLocated
'
;
// default value of rangeID
global
.
acID
=
-
1
;
// a acID of range PK
global
.
acID
=
-
1
;
// 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
.
websocket
=
new
WebSocket
(
'
ws://localhost:8080
'
);
// an instance of websocket
global
.
component
=
{};
component/OnlineStudy/MyUtilities/index.js
浏览文件 @
d6f3b251
...
@@ -68,6 +68,20 @@ const LocationTable = {
...
@@ -68,6 +68,20 @@ const LocationTable = {
},
},
};
};
export
const
DefaultRangeID
=
global
.
defaultRangeID
;
export
class
rangeID
{
static
get
()
{
return
global
.
rangeID
;
}
static
set
(
input
)
{
global
.
rangeID
=
input
;
}
static
setByLocation
(
longitude
,
latitude
)
{
this
.
set
(
parseLocation
(
longitude
,
latitude
));
}
}
export
class
acID
{
export
class
acID
{
static
get
()
{
static
get
()
{
return
global
.
acID
;
return
global
.
acID
;
...
@@ -77,6 +91,15 @@ export class acID {
...
@@ -77,6 +91,15 @@ export class acID {
}
}
}
}
export
class
component
{
static
get
()
{
return
global
.
component
;
}
static
set
(
input
)
{
global
.
component
=
input
;
}
}
export
class
websocket
{
export
class
websocket
{
static
get
()
{
static
get
()
{
return
global
.
websocket
;
return
global
.
websocket
;
...
@@ -196,22 +219,22 @@ export class sno {
...
@@ -196,22 +219,22 @@ export class sno {
}
}
}
}
export
function
isLegalRangeID
(
rangeID
)
{
export
function
isLegalRangeID
()
{
return
(
return
(
LocationTable
.
hasOwnProperty
(
rangeID
)
&&
LocationTable
.
hasOwnProperty
(
rangeID
.
get
()
)
&&
rangeID
!==
'
notInRange
'
&&
rangeID
.
get
()
!==
'
notInRange
'
&&
rangeID
!==
'
notLocated
'
rangeID
.
get
()
!==
'
notLocated
'
);
);
}
}
export
function
parseRangeID
(
rangeID
)
{
export
function
parseRangeID
()
{
// console.log('parseRangeID rangID: ' + rangeID)
;
let
rangeName
;
if
(
LocationTable
.
hasOwnProperty
(
rangeID
))
{
if
(
LocationTable
.
hasOwnProperty
(
rangeID
.
get
()
))
{
range
ID
=
LocationTable
[
rangeID
].
name
;
range
Name
=
LocationTable
[
rangeID
.
get
()
].
name
;
}
else
{
}
else
{
range
ID
=
'
error
'
;
range
Name
=
'
error
'
;
}
}
return
range
ID
;
return
range
Name
;
}
}
function
getRadian
(
angle
)
{
function
getRadian
(
angle
)
{
...
@@ -238,7 +261,7 @@ function getDistance(longitude1, latitude1, longitude2, latitude2) {
...
@@ -238,7 +261,7 @@ function getDistance(longitude1, latitude1, longitude2, latitude2) {
return
distance
;
return
distance
;
}
}
export
function
parseLocation
(
longitude
,
latitude
)
{
function
parseLocation
(
longitude
,
latitude
)
{
// console.log('longitude: ' + longitude + ' latitude: ' + latitude);
// console.log('longitude: ' + longitude + ' latitude: ' + latitude);
let
range
=
{
let
range
=
{
ID
:
'
notInRange
'
,
ID
:
'
notInRange
'
,
...
@@ -260,7 +283,7 @@ export function parseLocation(longitude, latitude) {
...
@@ -260,7 +283,7 @@ export function parseLocation(longitude, latitude) {
range
.
distance
=
distance
;
range
.
distance
=
distance
;
}
}
}
}
//
console.log(range.ID + ' ' + range.distance);
console
.
log
(
range
.
ID
+
'
'
+
range
.
distance
);
return
range
.
ID
;
return
range
.
ID
;
}
}
...
...
component/OnlineStudy/RangePKHome/index.js
浏览文件 @
d6f3b251
...
@@ -16,8 +16,9 @@ import Geolocation from '@react-native-community/geolocation';
...
@@ -16,8 +16,9 @@ import Geolocation from '@react-native-community/geolocation';
import
{
import
{
parseRangeID
,
parseRangeID
,
isLegalRangeID
,
isLegalRangeID
,
parseLocation
,
acID
,
acID
,
rangeID
,
DefaultRangeID
,
}
from
'
../MyUtilities
'
;
}
from
'
../MyUtilities
'
;
const
{
width
,
height
}
=
Dimensions
.
get
(
'
window
'
);
const
{
width
,
height
}
=
Dimensions
.
get
(
'
window
'
);
...
@@ -33,18 +34,22 @@ class RangePKHome extends Component {
...
@@ -33,18 +34,22 @@ class RangePKHome extends Component {
super
();
super
();
}
}
componentDidMount
()
{
rangeID
.
set
(
DefaultRangeID
);
}
componentWillUnmount
()
{
componentWillUnmount
()
{
// this.cancelLocating();
// this.cancelLocating();
// 卸载异步操作设置状态
// 卸载异步操作设置状态
this
.
setState
=
(
state
,
callback
)
=>
{
this
.
setState
=
(
state
,
callback
)
=>
{
return
;
return
;
};
};
rangeID
.
set
(
DefaultRangeID
);
}
}
state
=
{
state
=
{
isStarted
:
false
,
isStarted
:
false
,
isLocated
:
false
,
isLocated
:
false
,
rangeID
:
'
notLocated
'
,
// 初始rangeID
longitude
:
undefined
,
longitude
:
undefined
,
latitude
:
undefined
,
latitude
:
undefined
,
};
};
...
@@ -62,25 +67,21 @@ class RangePKHome extends Component {
...
@@ -62,25 +67,21 @@ class RangePKHome extends Component {
location
=>
{
location
=>
{
const
longitude
=
location
.
coords
.
longitude
;
//经度
const
longitude
=
location
.
coords
.
longitude
;
//经度
const
latitude
=
location
.
coords
.
latitude
;
//纬度
const
latitude
=
location
.
coords
.
latitude
;
//纬度
const
rangeID
=
parseLocation
(
longitude
,
latitude
);
rangeID
.
setByLocation
(
longitude
,
latitude
);
// this.setState({isStarted: false, isLocated: true, rangeID: rangID});
this
.
setState
({
this
.
setState
({
isStarted
:
false
,
isStarted
:
false
,
isLocated
:
true
,
isLocated
:
true
,
rangeID
:
rangeID
,
longitude
:
longitude
,
//经度
latitude
:
latitude
,
//纬度
});
});
},
},
error
=>
{
error
=>
{
reject
(
error
);
reject
(
error
);
this
.
setState
({
isStarted
:
false
});
this
.
setState
({
isStarted
:
false
});
if
(
error
.
code
==
2
)
{
if
(
error
.
code
==
=
2
)
{
ToastAndroid
.
show
(
ToastAndroid
.
show
(
'
定位失败,请查看手机是否开启GPS定位服务
'
,
'
定位失败,请查看手机是否开启GPS定位服务
'
,
ToastAndroid
.
SHORT
,
ToastAndroid
.
SHORT
,
);
);
}
else
if
(
error
.
code
==
3
)
{
}
else
if
(
error
.
code
==
=
3
)
{
ToastAndroid
.
show
(
ToastAndroid
.
show
(
'
定位超时,请尝试重新获取定位
'
,
'
定位超时,请尝试重新获取定位
'
,
ToastAndroid
.
SHORT
,
ToastAndroid
.
SHORT
,
...
@@ -100,12 +101,12 @@ class RangePKHome extends Component {
...
@@ -100,12 +101,12 @@ class RangePKHome extends Component {
geoLocate
=
async
()
=>
{
geoLocate
=
async
()
=>
{
if
(
Platform
.
OS
===
'
ios
'
)
{
if
(
Platform
.
OS
===
'
ios
'
)
{
await
this
.
getPositions
().
catch
(
error
=>
{}
);
await
this
.
getPositions
().
catch
();
}
else
{
}
else
{
const
permissions
=
[
PermissionsAndroid
.
PERMISSIONS
.
ACCESS_FINE_LOCATION
];
const
permissions
=
[
PermissionsAndroid
.
PERMISSIONS
.
ACCESS_FINE_LOCATION
];
const
granted
=
await
PermissionsAndroid
.
requestMultiple
(
permissions
);
const
granted
=
await
PermissionsAndroid
.
requestMultiple
(
permissions
);
if
(
granted
[
'
android.permission.ACCESS_FINE_LOCATION
'
]
===
'
granted
'
)
{
if
(
granted
[
'
android.permission.ACCESS_FINE_LOCATION
'
]
===
'
granted
'
)
{
await
this
.
getPositions
().
catch
(
error
=>
{}
);
await
this
.
getPositions
().
catch
();
}
else
{
}
else
{
ToastAndroid
.
show
(
'
定位权限被禁止
'
,
ToastAndroid
.
SHORT
);
ToastAndroid
.
show
(
'
定位权限被禁止
'
,
ToastAndroid
.
SHORT
);
}
}
...
@@ -116,7 +117,7 @@ class RangePKHome extends Component {
...
@@ -116,7 +117,7 @@ class RangePKHome extends Component {
// // eslint-disable-next-line no-undef
// // eslint-disable-next-line no-undef
// this.abortController = new AbortController();
// this.abortController = new AbortController();
this
.
setState
({
isStarted
:
true
});
this
.
setState
({
isStarted
:
true
});
this
.
geoLocate
().
then
(
r
=>
{}
);
this
.
geoLocate
().
then
();
};
};
// cancelLocating = () => {
// cancelLocating = () => {
...
@@ -129,16 +130,16 @@ class RangePKHome extends Component {
...
@@ -129,16 +130,16 @@ class RangePKHome extends Component {
startStudy
=
()
=>
{
startStudy
=
()
=>
{
//this.props.navigation.navigate('');
//this.props.navigation.navigate('');
this
.
props
.
navigation
.
navigate
(
'
区域PK中
'
,
{
rangeID
:
this
.
state
.
rangeID
}
);
this
.
props
.
navigation
.
navigate
(
'
区域PK中
'
);
};
};
render
()
{
render
()
{
const
{
isStarted
,
isLocated
,
rangeID
}
=
this
.
state
;
const
{
isStarted
,
isLocated
}
=
this
.
state
;
return
(
return
(
<
View
style
=
{
styles
.
container
}
>
<
View
style
=
{
styles
.
container
}
>
<
Image
source
=
{
isStarted
?
Locating
:
Located
}
style
=
{
styles
.
image
}
/
>
<
Image
source
=
{
isStarted
?
Locating
:
Located
}
style
=
{
styles
.
image
}
/
>
<
Text
numberOfLines
=
{
1
}
style
=
{
styles
.
text
}
>
<
Text
numberOfLines
=
{
1
}
style
=
{
styles
.
text
}
>
当前所在区域
:
{
parseRangeID
(
rangeID
)}
当前所在区域
:
{
parseRangeID
()}
<
/Text
>
<
/Text
>
{
isStarted
?
(
{
isStarted
?
(
<
MyButton
<
MyButton
...
@@ -155,7 +156,7 @@ class RangePKHome extends Component {
...
@@ -155,7 +156,7 @@ class RangePKHome extends Component {
/
>
/
>
)}
)}
<
MyButton
<
MyButton
disabled
=
{
!
isLegalRangeID
(
rangeID
)}
disabled
=
{
!
isLegalRangeID
()}
containerStyle
=
{
styles
.
myButton
.
container
}
containerStyle
=
{
styles
.
myButton
.
container
}
title
=
"
开始自习
"
title
=
"
开始自习
"
onPress
=
{
this
.
startStudy
}
onPress
=
{
this
.
startStudy
}
...
...
component/OnlineStudy/RangePKStudy/index.js
浏览文件 @
d6f3b251
...
@@ -12,7 +12,14 @@ import MyTitle from '../MyTitle';
...
@@ -12,7 +12,14 @@ import MyTitle from '../MyTitle';
import
SettingButton
from
'
../SettingButton
'
;
import
SettingButton
from
'
../SettingButton
'
;
import
MyBanner
from
'
../MyBanner
'
;
import
MyBanner
from
'
../MyBanner
'
;
import
RangePKState
from
'
../RangePKState
'
;
import
RangePKState
from
'
../RangePKState
'
;
import
{
parseMinute
,
parseRangeID
,
parseTime
,
acID
}
from
'
../MyUtilities
'
;
import
{
parseMinute
,
parseRangeID
,
parseTime
,
acID
,
rangeID
,
DefaultRangeID
,
}
from
'
../MyUtilities
'
;
const
{
width
,
height
}
=
Dimensions
.
get
(
'
window
'
);
const
{
width
,
height
}
=
Dimensions
.
get
(
'
window
'
);
/**
/**
...
@@ -34,7 +41,6 @@ class RangePKStudy extends Component {
...
@@ -34,7 +41,6 @@ class RangePKStudy extends Component {
}
}
state
=
{
state
=
{
rangeID
:
undefined
,
user
:
{
user
:
{
name
:
'
username
'
,
name
:
'
username
'
,
rank
:
'
error
'
,
rank
:
'
error
'
,
...
@@ -57,10 +63,7 @@ class RangePKStudy extends Component {
...
@@ -57,10 +63,7 @@ class RangePKStudy extends Component {
};
};
componentDidMount
()
{
componentDidMount
()
{
const
{
const
{
navigation
}
=
this
.
props
;
navigation
,
route
:
{
params
},
}
=
this
.
props
;
navigation
.
setOptions
({
navigation
.
setOptions
({
// 引入SettingButton组件至header的右边
// 引入SettingButton组件至header的右边
// 并把this.props传给SettingButton组件以实现Navigation的跳转
// 并把this.props传给SettingButton组件以实现Navigation的跳转
...
@@ -72,9 +75,6 @@ class RangePKStudy extends Component {
...
@@ -72,9 +75,6 @@ class RangePKStudy extends Component {
this
.
forceUpdate
();
this
.
forceUpdate
();
});
});
// 以下不是标语风格切换相关
// 以下不是标语风格切换相关
if
(
params
.
rangeID
!==
undefined
)
{
this
.
setState
({
rangeID
:
params
.
rangeID
});
}
this
.
startTimer
();
this
.
startTimer
();
}
}
...
@@ -140,8 +140,10 @@ class RangePKStudy extends Component {
...
@@ -140,8 +140,10 @@ class RangePKStudy extends Component {
numberTop
:
parseInt
(
this
.
state
.
timeInTheMatch
/
60
,
10
),
numberTop
:
parseInt
(
this
.
state
.
timeInTheMatch
/
60
,
10
),
numberCentre
:
999
,
numberCentre
:
999
,
numberBottom
:
9999
,
numberBottom
:
9999
,
range
:
parseRangeID
(
this
.
state
.
rangeID
),
range
:
parseRangeID
(),
});
});
rangeID
.
set
(
DefaultRangeID
);
// console.log(rangeID.get());
},
},
},
},
]);
]);
...
@@ -184,7 +186,7 @@ class RangePKStudy extends Component {
...
@@ -184,7 +186,7 @@ class RangePKStudy extends Component {
},
},
}}
}}
/
>
/
>
<
RangePKState
range
=
{
parseRangeID
(
this
.
state
.
rangeID
)}
/
>
<
RangePKState
range
=
{
parseRangeID
()}
/
>
<
MyStatistics
<
MyStatistics
containerStyle
=
{
styles
.
containerOnRight
}
containerStyle
=
{
styles
.
containerOnRight
}
insideStyle
=
{
styles
.
containerInRightColumn
}
insideStyle
=
{
styles
.
containerInRightColumn
}
...
@@ -192,7 +194,7 @@ class RangePKStudy extends Component {
...
@@ -192,7 +194,7 @@ class RangePKStudy extends Component {
onPress
=
{
this
.
openRankingList
}
onPress
=
{
this
.
openRankingList
}
text
=
{{
text
=
{{
first
:
{
first
:
{
top
:
parseRangeID
(
this
.
state
.
rangeID
)
+
'
区域
'
,
top
:
parseRangeID
()
+
'
区域
'
,
bottom
:
'
Top 3
'
,
bottom
:
'
Top 3
'
,
},
},
second
:
{
second
:
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录