Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
I
ios-ipad学生端
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
庄总
ios-ipad学生端
Commits
7ed0a26f
Commit
7ed0a26f
authored
Jan 20, 2022
by
zhangkaixuan11
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug
parent
7ca74f13
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
101 additions
and
58 deletions
+101
-58
src/components/Alarm.tsx
src/components/Alarm.tsx
+25
-12
src/components/Random.tsx
src/components/Random.tsx
+66
-44
src/components/rtm-adapter.ts
src/components/rtm-adapter.ts
+5
-0
src/live/Index.tsx
src/live/Index.tsx
+5
-2
No files found.
src/components/Alarm.tsx
View file @
7ed0a26f
...
...
@@ -67,12 +67,14 @@ export default class Alarm extends Component {
start
:
props
.
start
});
if
(
props
.
start
)
{
this
.
max
=
props
.
max
;
this
.
currentSec
=
this
.
max
;
this
.
djs
();
}
else
{
if
(
this
.
timer
)
{
clearTimeout
(
this
.
timer
);
}
this
.
djs
();
//
this.djs();
}
}
else
{
if
(
this
.
max
!==
props
.
max
&&
this
.
currentSec
==
this
.
max
)
{
...
...
@@ -280,11 +282,14 @@ export default class Alarm extends Component {
</
View
>
<
Text
allowFontScaling=
{
false
}
style=
{
ComponentCSS
.
alarmTimeTxt
}
>
{
this
.
state
.
sec11
}
</
Text
>
<
Text
allowFontScaling=
{
false
}
style=
{
ComponentCSS
.
alarmTimeTxt
}
>
{
this
.
state
.
sec21
}
</
Text
>
<
Animated
.
View
style=
{
[
ComponentCSS
.
topWrapper
,
this
.
getTransform
(),
{
{
this
.
state
.
showSec22
&&
<
Animated
.
View
style=
{
[
ComponentCSS
.
topWrapper
,
this
.
getTransform
(),
{
display
:
this
.
state
.
showSec22
?
'
flex
'
:
'
none
'
}]
}
>
<
Text
allowFontScaling=
{
false
}
style=
{
ComponentCSS
.
alarmTimeTxt2
}
>
{
this
.
state
.
sec22
}
</
Text
>
</
Animated
.
View
>
}
{
this
.
state
.
showSec12
&&
<
Animated
.
View
style=
{
[
ComponentCSS
.
topWrapper
,
this
.
getTransform1
(),
{
display
:
this
.
state
.
showSec12
?
'
flex
'
:
'
none
'
,
// backgroundColor: '#eee000',
...
...
@@ -292,20 +297,28 @@ export default class Alarm extends Component {
}]
}
>
<
Text
allowFontScaling=
{
false
}
style=
{
ComponentCSS
.
alarmTimeTxt2
}
>
{
this
.
state
.
sec12
}
</
Text
>
</
Animated
.
View
>
<
Animated
.
View
style=
{
[
ComponentCSS
.
topWrapper
,
this
.
getTransform2
(),
{
display
:
this
.
state
.
showMin22
?
'
flex
'
:
'
none
'
,
// backgroundColor: '#eee000',
right
:
Constants
.
unitWidth
*
120
}]
}
>
<
Text
allowFontScaling=
{
false
}
style=
{
ComponentCSS
.
alarmTimeTxt2
}
>
{
this
.
state
.
min22
}
</
Text
>
</
Animated
.
View
>
<
Animated
.
View
style=
{
[
ComponentCSS
.
topWrapper
,
this
.
getTransform3
(),
{
}
{
this
.
state
.
showMin22
&&
<
Animated
.
View
style=
{
[
ComponentCSS
.
topWrapper
,
this
.
getTransform2
(),
{
display
:
this
.
state
.
showMin22
?
'
flex
'
:
'
none
'
,
// backgroundColor: '#eee000',
right
:
Constants
.
unitWidth
*
120
}]
}
>
<
Text
allowFontScaling=
{
false
}
style=
{
ComponentCSS
.
alarmTimeTxt2
}
>
{
this
.
state
.
min22
}
</
Text
>
</
Animated
.
View
>
}
{
this
.
state
.
showMin12
&&
<
Animated
.
View
style=
{
[
ComponentCSS
.
topWrapper
,
this
.
getTransform3
(),
{
display
:
this
.
state
.
showMin12
?
'
flex
'
:
'
none
'
,
// backgroundColor: '#eee000',
right
:
Constants
.
unitWidth
*
163.5
}]
}
>
}]
}
>
<
Text
allowFontScaling=
{
false
}
style=
{
ComponentCSS
.
alarmTimeTxt2
}
>
{
this
.
state
.
min12
}
</
Text
>
</
Animated
.
View
>
</
Animated
.
View
>
}
</
ImageBackground
>
<
View
style=
{
ComponentCSS
.
centerSpearator
}
></
View
>
</
View
>
...
...
src/components/Random.tsx
View file @
7ed0a26f
...
...
@@ -34,7 +34,7 @@ export default class Random extends Component {
// names.push(item.studentName);
// });
let
names
=
[];
for
(
let
i
=
0
;
i
<
this
.
props
.
randNum
+
3
;
i
++
)
{
for
(
let
i
=
0
;
i
<
this
.
props
.
randNum
;
i
++
)
{
names
.
push
({
name
:
students
[
i
%
students
.
length
].
studentName
,
selected
:
i
===
1
?
true
:
false
...
...
@@ -43,8 +43,9 @@ export default class Random extends Component {
this
.
setState
({
students
:
students
,
names
:
names
,
randNum
:
this
.
props
.
randNum
+
this
.
state
.
selectedIndex
,
random
:
this
.
props
.
random
randNum
:
this
.
props
.
randNum
,
random
:
this
.
props
.
random
,
selectedIndex
:
this
.
props
.
selectedIndex
,
});
// console.log('names', names);
setTimeout
(
this
.
loop
,
500
);
...
...
@@ -59,14 +60,32 @@ export default class Random extends Component {
// name: students[i%students.length].studentName,
// selected: i === 1 ? true : false
// });
// }
// // }
// this.setState({
// // students: students,
// // names: names,
// randNum: nextProps.randNum,
// random: nextProps.random,
// showResult: false
// });
// setTimeout(this.loop, 500);
console
.
log
(
nextProps
)
let
students
=
nextProps
.
students
;
let
names
=
[];
for
(
let
i
=
0
;
i
<
nextProps
.
randNum
;
i
++
)
{
names
.
push
({
name
:
students
[
i
%
students
.
length
].
studentName
,
selected
:
i
===
1
?
true
:
false
});
}
this
.
setState
({
// students: students,
// names: names,
randNum
:
nextProps
.
randNum
,
names
:
names
,
randNum
:
nextProps
.
randNum
,
random
:
nextProps
.
random
,
selectedIndex
:
nextProps
.
selectedIndex
,
showResult
:
false
});
// console.log('names', names);
setTimeout
(
this
.
loop
,
500
);
}
}
...
...
@@ -97,22 +116,24 @@ export default class Random extends Component {
// }
// this.times ++;
this
.
scrollView
.
scrollTo
({
y
:
Constants
.
unitWidth
*
30
*
(
this
.
state
.
randNum
),
y
:
Constants
.
unitWidth
*
30
*
(
this
.
state
.
randNum
)
,
animated
:
true
,
});
let
names
=
this
.
state
.
names
;
for
(
let
i
=
0
;
i
<
names
.
length
;
i
++
)
{
let
selected
=
false
;
if
(
i
===
this
.
state
.
randNum
+
1
)
{
selected
=
true
;
}
names
[
i
].
selected
=
selected
;
}
this
.
setState
({
names
:
names
});
// let names = this.state.names;
// for (let i = 0; i < names.length; i ++) {
// let selected = false;
// if (i === this.state.randNum ) {
// selected = true;
// }
// names[i].selected = selected;
// }
// this.setState({
// names: names
// });
setTimeout
(()
=>
{
this
.
onMomentumScrollEnd
()
},
400
);
// Animated.parallel([
// Animated.timing(this.offsetAnim, {
// toValue: (this.state.randNum - 1) * Constants.unitWidth * (-29),
...
...
@@ -144,6 +165,29 @@ export default class Random extends Component {
// }
// }, loopPeriod)
}
onMomentumScrollEnd
=
()
=>
{
// let selectedIndex = this.state.selectedIndex;
// let index = this.state.randNum % this.state.students.length;
// this.setState({
// selectedIndex: index
// });
let
names
=
this
.
state
.
names
;
for
(
let
i
=
0
;
i
<
names
.
length
;
i
++
)
{
let
selected
=
false
;
if
(
i
===
names
.
length
-
2
)
{
selected
=
true
;
}
names
[
i
].
selected
=
selected
;
}
this
.
setState
({
names
:
names
,
showResult
:
true
});
// this.scrollView.scrollTo({
// y: Constants.unitWidth * 30 * (index),
// animated: false,
// });
}
getItems
=
()
=>
{
let
result
=
[];
...
...
@@ -169,7 +213,7 @@ export default class Random extends Component {
height
:
'
auto
'
}]
}
>
<
View
style=
{
ComponentCSS
.
alarmTitle
}
>
<
Text
allowFontScaling=
{
false
}
style=
{
ComponentCSS
.
alarmTitleTxt
}
>
答题器
</
Text
>
<
Text
allowFontScaling=
{
false
}
style=
{
ComponentCSS
.
alarmTitleTxt
}
>
随机选人
</
Text
>
</
View
>
<
View
style=
{
ComponentCSS
.
alarmSeperator
}
></
View
>
<
View
style=
{
[
ComponentCSS
.
QAWrapepr
,
PublicCSS
.
centerAll
]
}
>
...
...
@@ -191,29 +235,7 @@ export default class Random extends Component {
<
View
>
<
ScrollView
ref=
{
(
ref
)
=>
{
this
.
scrollView
=
ref
}
}
onMomentumScrollEnd=
{
()
=>
{
let
selectedIndex
=
this
.
state
.
selectedIndex
;
let
index
=
this
.
state
.
randNum
%
this
.
state
.
students
.
length
;
this
.
setState
({
selectedIndex
:
index
});
let
names
=
this
.
state
.
names
;
for
(
let
i
=
0
;
i
<
names
.
length
;
i
++
)
{
let
selected
=
false
;
if
(
i
===
index
+
1
)
{
selected
=
true
;
}
names
[
i
].
selected
=
selected
;
}
this
.
setState
({
names
:
names
,
showResult
:
true
});
this
.
scrollView
.
scrollTo
({
y
:
Constants
.
unitWidth
*
30
*
(
index
),
animated
:
false
,
});
}
}
onMomentumScrollEnd=
{
this
.
onMomentumScrollEnd
}
style=
{
{
width
:
Constants
.
unitWidth
*
240
,
height
:
Constants
.
unitWidth
*
90
,
...
...
src/components/rtm-adapter.ts
View file @
7ed0a26f
...
...
@@ -47,6 +47,11 @@ export default class RtmAdapter extends EventEmitter {
console
.
log
(
'
ChannelAttributesUpdated
'
,
evt
);
this
.
emit
(
'
attributesUpdated
'
,
evt
);
});
// this.client.addListener('ChannelMemberJoined', (evt: any) => {
// console.log('channelMemberJoined', evt);
// this.emit('channelMemberJoined', evt);
// });
}
async
login
(
uid
:
string
):
Promise
<
any
>
{
await
this
.
client
.
createClient
(
config
.
appId
);
...
...
src/live/Index.tsx
View file @
7ed0a26f
...
...
@@ -885,7 +885,6 @@ export default class Index extends Component<Props, State, HomeState, AppContext
if
(
!
value
.
pause
)
{
// 什么时候 max 需要减去 时间差?
max
-=
Math
.
round
(((
new
Date
()).
getTime
()
-
value
.
time
)
/
1000
);
}
// max ++;
if
(
max
<
0
)
{
...
...
@@ -913,7 +912,8 @@ export default class Index extends Component<Props, State, HomeState, AppContext
}
let
selectedIndex
=
0
;
if
(
value
.
rand
)
{
selectedIndex
=
(
value
.
rand
+
1
)
%
students
.
length
;
selectedIndex
=
(
value
.
rand
)
%
students
.
length
;
console
.
log
(
selectedIndex
,
'
selectedIndex
'
)
}
console
.
log
(
'
randomStuState
'
,
students
,
selectedIndex
,
value
);
this
.
setState
({
...
...
@@ -1002,6 +1002,7 @@ export default class Index extends Component<Props, State, HomeState, AppContext
});
});
this
.
context
.
client
.
on
(
'
channelMemberJoined
'
,
(
evt
:
any
)
=>
{
alert
(
1
)
const
{
uid
}
=
evt
;
let
list
=
this
.
state
.
list
;
for
(
let
i
=
0
;
i
<
this
.
state
.
students
.
length
;
i
++
)
{
...
...
@@ -1025,6 +1026,8 @@ export default class Index extends Component<Props, State, HomeState, AppContext
},
150
);
});
this
.
context
.
client
.
on
(
'
channelMemberLeft
'
,
(
evt
:
any
)
=>
{
alert
(
2
)
const
{
uid
}
=
evt
;
let
list
=
this
.
state
.
list
;
for
(
let
i
=
0
;
i
<
this
.
state
.
students
.
length
;
i
++
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment