Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
bh_face_counter
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄天晨
bh_face_counter
Commits
cbc8eed5
Commit
cbc8eed5
authored
Jul 02, 2020
by
修福龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
重力感应为零时,验证码弹窗和输入手机号码弹窗自动隐藏
parent
0acec087
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
190 additions
and
44 deletions
+190
-44
FacePage.js
src/pages/FacePage.js
+190
-44
No files found.
src/pages/FacePage.js
View file @
cbc8eed5
...
@@ -2,7 +2,9 @@ import React, {Component} from 'react';
...
@@ -2,7 +2,9 @@ import React, {Component} from 'react';
import
{
View
,
Text
,
Image
,
Dimensions
}
from
'react-native'
;
import
{
View
,
Text
,
Image
,
Dimensions
}
from
'react-native'
;
import
AsyncStorage
from
'@react-native-community/async-storage'
;
import
AsyncStorage
from
'@react-native-community/async-storage'
;
import
{
connect
}
from
'react-redux'
;
import
{
connect
}
from
'react-redux'
;
// import {RtcEngineEvents} from 'react-native-agora/lib/RtcEvents';
import
RtcEngine
from
'react-native-agora'
;
import
RtcEngine
from
'react-native-agora'
;
import
{
RtcChannel
}
from
'react-native-agora'
;
import
Touch
from
'../components/Touch'
;
import
Touch
from
'../components/Touch'
;
import
PhoneModal
from
'../components/PhoneModal'
;
import
PhoneModal
from
'../components/PhoneModal'
;
import
VerifyCodeModal
from
'../components/VerifyCodeModal'
;
import
VerifyCodeModal
from
'../components/VerifyCodeModal'
;
...
@@ -11,6 +13,7 @@ import delay from '../utils/delay';
...
@@ -11,6 +13,7 @@ import delay from '../utils/delay';
import
Speech
from
'../utils/Speech'
;
import
Speech
from
'../utils/Speech'
;
import
WxFacepay
from
'../utils/WxFacepay'
;
import
WxFacepay
from
'../utils/WxFacepay'
;
import
phone
from
'../assets/Vertical/phone.png'
;
import
phone
from
'../assets/Vertical/phone.png'
;
// import log from './engine.log';
const
{
width
}
=
Dimensions
.
get
(
'screen'
);
const
{
width
}
=
Dimensions
.
get
(
'screen'
);
...
@@ -42,6 +45,7 @@ class FacePage extends Component {
...
@@ -42,6 +45,7 @@ class FacePage extends Component {
async
componentDidMount
()
{
async
componentDidMount
()
{
this
.
listen
();
this
.
listen
();
// this.setAgoreEventListener();
}
}
onSubmit
=
async
phone
=>
{
onSubmit
=
async
phone
=>
{
...
@@ -107,48 +111,180 @@ class FacePage extends Component {
...
@@ -107,48 +111,180 @@ class FacePage extends Component {
};
};
listen
=
async
()
=>
{
listen
=
async
()
=>
{
while
(
!
window
.
socket
)
{
try
{
await
delay
(
1000
);
while
(
!
window
.
socket
)
{
}
await
delay
(
1000
);
if
(
!
window
.
socket
.
hasListeners
(
'doorLogin'
))
{
}
// 扫码验证成功
if
(
!
window
.
socket
.
hasListeners
(
'doorLogin'
))
{
window
.
socket
.
on
(
'doorLogin'
,
this
.
handleDoorLogin
);
// 扫码验证成功
}
window
.
socket
.
on
(
'doorLogin'
,
this
.
handleDoorLogin
);
if
(
!
window
.
socket
.
hasListeners
(
'scale'
))
{
}
// 重力感应变化
if
(
!
window
.
socket
.
hasListeners
(
'scale'
))
{
window
.
socket
.
on
(
'scale'
,
this
.
handleScaleChange
);
// 重力感应变化
}
window
.
socket
.
on
(
'scale'
,
this
.
handleScaleChange
);
if
(
!
window
.
socket
.
hasListeners
(
'talkCall'
))
{
}
// 语音通话中
// if (!window.socket.hasListeners('talkCall')) {
window
.
socket
.
on
(
'talkCall'
,
this
.
handleTalkCall
);
// // 语音通话中
// window.socket.on('talkCall', ({code, id, number, channel, device}) => {
// window.socket.on('talkCall', this.handleTalkCall);
// console.log(code, id, number, channel, device);
// // window.socket.on('talkCall', ({code, id, number, channel, device}) => {
// if (code === 1) {
// // console.log(code, id, number, channel, device);
// this.setState({
// // if (code === 1) {
// talkCall: 0,
// // this.setState({
// });
// // talkCall: 0,
// } else if (code === 2) {
// // });
// this.setState({
// // } else if (code === 2) {
// talkCall: 1,
// // this.setState({
// });
// // talkCall: 1,
// }
// // });
// console.warn(code, id, number, channel, device);
// // }
// // console.warn(code, id, number, channel, device);
// // });
// }
// const {data} = await this.props.dispatch({
// type: 'store/agora',
// });
// console.warn(data);
// config.appid = data.appid;
// if (!this.engine) {
// this.engine = await RtcEngine.create(config);
// }
// console.log(data);
// if (!this.engine) {
// this.engine = await RtcEngine.create(data.appid);
// }
// // await this.engine.setLogFile('/engine.log'); //设置日志文件
// // await this.engine.setLogFileSize(1024); //指定 SDK 输出日志文件的内存大小,单位为 KB
// await this.engine.disableVideo(true); // 关闭视频模块
// await this.engine.enableLocalAudio(false); //调用 enableLocalAudio(false) 关闭本地采集后,系统会走媒体音量
// await this.engine.muteAllRemoteAudioStreams(false); //停止/恢复接收所有音频流。
// await this.engine.setDefaultMuteAllRemoteAudioStreams(false); // 设置是否默认接收音频流
// await this.engine.setDefaultMuteAllRemoteVideoStreams(true); // 设置是否默认接收视频流
// await this.engine.disableVideo(); //关闭视频模块
// await this.engine.setAudioProfile(4, 3); //设置音频编码配置
// await this.engine.adjustPlaybackSignalVolume(400); //调节本地播放的所有远端用户音量
// await this.engine.adjustAudioMixingPlayoutVolume(100); //调节音乐文件的本地播放音量
// await this.engine.setDefaultAudioRoutetoSpeakerphone(true); //默认从外放(扬声器)出声
// this.engine.addListener('Warning', data => {
// console.log('Warning' + data);
// });
// });
// this.engine.addListener('Error', data => {
// console.log('Error' + data);
// });
// this.engine.addListener('JoinChannelSuccess', data => {
// console.warn('JoinChannelSuccess');
// console.warn(data);
// });
}
catch
(
e
)
{
console
.
log
(
e
);
}
}
};
};
handleTalkCall
=
async
()
=>
{
handleTalkCall
=
async
()
=>
{
// const {talkCall} = this.state;
try
{
// 加入语音通话
// const {talkCall} = this.state;
clearInterval
(
this
.
noTalkCall
);
// 加入语音通话
clearInterval
(
this
.
noTalkCall
);
const
{
data
}
=
await
this
.
props
.
dispatch
({
type
:
'store/agora'
,
});
console
.
log
(
data
);
if
(
!
this
.
engine
)
{
this
.
engine
=
await
RtcEngine
.
create
(
data
.
appid
);
// await this.engine.setLogFile('./engine.log'); //设置日志文件
// await this.engine.setLogFileSize(1024); //指定 SDK 输出日志文件的内存大小,单位为 KB
}
this
.
engine
.
createRtcChannel
(
data
.
channel
);
this
.
engine
.
addListener
(
'Warning'
,
data
=>
{
console
.
log
(
'Warning'
+
data
);
});
this
.
engine
.
addListener
(
'Error'
,
data
=>
{
console
.
log
(
'Error'
+
data
);
});
this
.
engine
.
addListener
(
'JoinChannelSuccess'
,
data
=>
{
console
.
warn
(
'JoinChannelSuccess'
);
console
.
warn
(
data
);
});
RtcChannel
.
joinChannel
(
data
.
token
,
null
,
99
,
{
autoSubscribeAudio
:
true
,
autoSubscribeVideo
:
false
,
});
//Join Channel
RtcChannel
.
enableAudio
();
// await this.engine.disableVideo(true); // 关闭视频模块
// await this.engine.enableLocalAudio(false); //调用 enableLocalAudio(false) 关闭本地采集后,系统会走媒体音量
// await this.engine.muteAllRemoteAudioStreams(false); //停止/恢复接收所有音频流。
// await this.engine.setDefaultMuteAllRemoteAudioStreams(false); // 设置是否默认接收音频流
// await this.engine.setDefaultMuteAllRemoteVideoStreams(true); // 设置是否默认接收视频流
// await this.engine.disableVideo(); //关闭视频模块
// await this.engine.setAudioProfile(4, 3); //设置音频编码配置
// await this.engine.adjustPlaybackSignalVolume(400); //调节本地播放的所有远端用户音量
// await this.engine.adjustAudioMixingPlayoutVolume(100); //调节音乐文件的本地播放音量
// await this.engine.setDefaultAudioRoutetoSpeakerphone(true); //默认从外放(扬声器)出声
//
// // await this.engine.addHandler(); //添加主回调事件
// await this.engine.enableWebSdkInteroperability(true); //打开与webSDK的互通
// await this.engine.setChannelProfile(0);
// await this.engine.setClientRole(1); //设置为主播角色
// // await this.engine.enableAudio();
// await this.engine.joinChannel(data.token, data.channel, null, 99);
// // await this.engine.setEnableSpeakerphone(true); //切换到外放
// if (!(await this.engine.isSpeakerphoneEnabled())) {
// console.warn(await this.engine.setEnableSpeakerphone(true));
// await this.engine.setEnableSpeakerphone(true); //切换到外放
// }
// console.warn(await this.engine.getCallId());
this
.
setState
({
talkCall
:
1
,
});
}
catch
(
e
)
{
console
.
log
(
e
);
}
};
//设置事件监听
// setAgoreEventListener = () => {
// RtcEngine.Warning();
// RtcEngine.Error();
// RtcEngine.ApiCallExecuted();
// RtcEngine.JoinChannelSuccess();
// RtcEngine.LeaveChannel();
// // this.engine.addListener('Error');
// // this.engine.addListener('JoinChannelSuccess', res => {
// // console.warn('JoinChannelSuccess' + res);
// // });
// //成功加入房间
// // this.engine.onJoinChannelSuccess = (channel, uid, elapsed) => {
// // console.warn(`成功加入房间,频道号:${channel}+uid+${uid}`);
// // };
// //
// // //监听是否有新用户加入
// // this.engine.onUserJoined = (uid, elapsed) => {
// // console.warn(`新用户所加入的id为:${uid}`);
// // };
// //
// // //监听用户是否离开这个房间
// // this.engine.onUserOffline = (uid, reason) => {
// // console.warn(`用户离开的id为:${uid}`);
// // };
// //
// // //监听用户是否离开这个频道
// // this.engine.onLeaveChannel = () => {
// // console.warn('用户离开');
// // };
// };
leaveC
=
async
()
=>
{
const
{
data
}
=
await
this
.
props
.
dispatch
({
const
{
data
}
=
await
this
.
props
.
dispatch
({
type
:
'store/agora'
,
type
:
'store/agora'
,
});
});
const
engine
=
await
RtcEngine
.
create
(
data
.
appid
);
if
(
!
this
.
engine
)
{
await
engine
.
joinChannel
(
data
.
token
,
data
.
channel
,
null
,
0
);
this
.
engine
=
await
RtcEngine
.
create
(
data
.
appid
);
this
.
setState
({
}
talkCall
:
1
,
// if (this.engine) {
});
console
.
warn
(
'121212'
);
await
this
.
engine
.
leaveChannel
();
// }
};
};
// device 代表当前打开的门
// device 代表当前打开的门
...
@@ -159,7 +295,15 @@ class FacePage extends Component {
...
@@ -159,7 +295,15 @@ class FacePage extends Component {
}
else
if
(
count
===
0
)
{
}
else
if
(
count
===
0
)
{
// 重力感应归零
// 重力感应归零
clearInterval
(
this
.
noTalkCall
);
clearInterval
(
this
.
noTalkCall
);
this
.
setState
({
orderDetailsModal
:
false
,
current
:
1
});
if
(
!
this
.
engine
)
{
this
.
engine
.
leaveChannel
();
}
this
.
setState
({
orderDetailsModal
:
false
,
phoneModal
:
false
,
verifyCodeModal
:
false
,
current
:
1
,
});
}
}
};
};
...
@@ -313,7 +457,7 @@ class FacePage extends Component {
...
@@ -313,7 +457,7 @@ class FacePage extends Component {
<
PhoneModal
<
PhoneModal
visible
=
{
phoneModal
}
visible
=
{
phoneModal
}
transparent
transparent
maskClosable
//
maskClosable
onClose
=
{
this
.
handleClose
}
onClose
=
{
this
.
handleClose
}
onRequestClose
=
{
this
.
handleClose
}
onRequestClose
=
{
this
.
handleClose
}
onSubmit
=
{
this
.
onSubmit
}
onSubmit
=
{
this
.
onSubmit
}
...
@@ -321,7 +465,7 @@ class FacePage extends Component {
...
@@ -321,7 +465,7 @@ class FacePage extends Component {
<
VerifyCodeModal
<
VerifyCodeModal
visible
=
{
verifyCodeModal
}
visible
=
{
verifyCodeModal
}
transparent
transparent
maskClosable
//
maskClosable
onClose
=
{
this
.
handleCodeClose
}
onClose
=
{
this
.
handleCodeClose
}
onRequestClose
=
{
this
.
handleCodeClose
}
onRequestClose
=
{
this
.
handleCodeClose
}
onSubmit
=
{
this
.
onCodeSubmit
}
onSubmit
=
{
this
.
onCodeSubmit
}
...
@@ -392,13 +536,15 @@ class FacePage extends Component {
...
@@ -392,13 +536,15 @@ class FacePage extends Component {
<
Text
style
=
{
styles
.
callText
}
>
呼叫客服
<
/Text
>
<
Text
style
=
{
styles
.
callText
}
>
呼叫客服
<
/Text
>
<
/View
>
<
/View
>
{
/*{talkCall === 1 ? (*/
}
{
/*{talkCall === 1 ? (*/
}
{
/* <View style={styles.onCall}>*/
}
{
/* <Touch onPress={this.leaveC} style={styles.footer} feedback={false}>*/
}
{
/* <Image*/
}
{
/* <View style={styles.call}>*/
}
{
/* source={require('../assets/call.gif')}*/
}
{
/* <Image*/
}
{
/* style={styles.callGif}*/
}
{
/* source={require('../assets/call.gif')}*/
}
{
/* />*/
}
{
/* style={styles.callGif}*/
}
{
/* <Text style={styles.onCallText}>正在语音通话中</Text>*/
}
{
/* />*/
}
{
/* </View>*/
}
{
/* <Text style={styles.onCallText}>正在语音通话中</Text>*/
}
{
/* </View>*/
}
{
/* </Touch>*/
}
{
/*) : talkCall === 0 ? (*/
}
{
/*) : talkCall === 0 ? (*/
}
{
/* <View style={styles.onCall}>*/
}
{
/* <View style={styles.onCall}>*/
}
{
/* <Image*/
}
{
/* <Image*/
}
...
...
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