Commit 826d0c41 by MissYasiky

把登录按钮的响应方法从 html 中提取出来

parent 0bd8b394
......@@ -110,6 +110,60 @@ export default class PolyvLogin extends Component {
}
}
myPress() {
if (this.state.pressed == true) {
console.log("处理中,请稍后")
return
}
this.state.pressed = true
if (this.state.tabIndex == 1) {//回放
this.state.loginInfo = PolyvViewManager.refCollection['PlayBackLogin'].state.playbackInfo
} else {
this.state.loginInfo = PolyvViewManager.refCollection['LiveLogin'].state.liveInfo
}
var loginInfo = this.state.loginInfo
if (!loginInfo) {
alert("input login info")
this.state.pressed = false
return
}
if(this.checkInputIlleage()){
if(this.state.tabIndex == 0){ // 直播登录
PolyvCloudClassModule.liveLogin(findNodeHandle(this), loginInfo.userId,
loginInfo.channelId, loginInfo.appId, loginInfo.appScrect)
.then(ret => {
this.state.pressed = false
if (ret.code != 0) {
var str = "登录失败 errCode=" + ret.code + " errMsg=" + ret.message;
console.log(str);
alert(str);
} else {
console.log("登录成功");
}
})
} else { // 回放登录
PolyvCloudClassModule.playbackLogin(findNodeHandle(this), loginInfo.userId,
loginInfo.channelId, loginInfo.vid, loginInfo.appId, loginInfo.appScrect)
.then(ret => {
this.state.pressed = false
if (ret.code != 0) {
var str = "登录失败 errCode=" + ret.code + " errMsg=" + ret.message;
console.log(str);
alert(str);
} else {
console.log("登录成功");
}
})
}
} else {
this.state.pressed = false
}
}
render() {
let title = this.state.showTitleText ?
<Text>POLYV&#160;&#160;云课堂</Text> :
......@@ -120,59 +174,7 @@ export default class PolyvLogin extends Component {
<AppContainer style={styles.tab} onNavigationStateChange={this.handleNavigationChange} ref={'tab'} />
<View style={styles.center}>
<Text style={styles.text}
onPress={() => {
if (this.state.pressed == true) {
console.log("处理中,请稍后")
return
}
this.state.pressed = true
if (this.state.tabIndex == 1) {//回放
this.state.loginInfo = PolyvViewManager.refCollection['PlayBackLogin'].state.playbackInfo
} else {
this.state.loginInfo = PolyvViewManager.refCollection['LiveLogin'].state.liveInfo
}
var loginInfo = this.state.loginInfo
if (!loginInfo) {
alert("input login info")
this.state.pressed = false
return
}
if(this.checkInputIlleage()){
if(this.state.tabIndex == 0){ // 直播登录
PolyvCloudClassModule.liveLogin(findNodeHandle(this), loginInfo.userId,
loginInfo.channelId, loginInfo.appId, loginInfo.appScrect)
.then(ret => {
this.state.pressed = false
if (ret.code != 0) {
var str = "登录失败 errCode=" + ret.code + " errMsg=" + ret.message;
console.log(str);
alert(str);
} else {
console.log("登录成功");
}
})
} else { // 回放登录
PolyvCloudClassModule.playbackLogin(findNodeHandle(this), loginInfo.userId,
loginInfo.channelId, loginInfo.vid, loginInfo.appId, loginInfo.appScrect)
.then(ret => {
this.state.pressed = false
if (ret.code != 0) {
var str = "登录失败 errCode=" + ret.code + " errMsg=" + ret.message;
console.log(str);
alert(str);
} else {
console.log("登录成功");
}
})
}
} else {
this.state.pressed = false
}
}}>登录</Text>
onPress={() => {this.myPress()}}>登录</Text>
</View>
</View>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment