import React, { Component } from 'react'; import { SnackbarHOC, getImageUrl, WordsBtn } from 'educoder'; import { Form, Button, Input ,Modal } from 'antd' import Modals from "../../modals/Modals"; import '../../courses/css/Courses.css' import './common.css' import axios from 'axios' class AccountSecure extends Component { constructor (props) { super(props) this.state = { Modalstype:false, list:[{ en_type: "wechat", id: null, nickname: "", },{ en_type: "qq", id: null, nickname: "", } ] } } IsPC=()=>{ var userAgentInfo = navigator.userAgent; var Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"]; var flag = true; for (var v = 0; v < Agents.length; v++) { if (userAgentInfo.indexOf(Agents[v]) > 0) { flag = false; break; } } return flag; } componentDidMount() { let {basicInfo}=this.props; let {list}=this.state; let newlist=list; if(basicInfo===undefined||JSON.stringify(basicInfo) == "{}"||basicInfo&&basicInfo.open_users.length===0){ }else{ basicInfo&&basicInfo.open_users.map((item,key)=>{ newlist.map((items,keys)=>{ if(item.en_type===items.en_type){ items.id=item.id; items.nickname=item.nickname; } }) }) } this.setState({ list:newlist }) } showModal=()=>{ this.setState({ visible: true, }); }; handleOk=(e)=> { this.setState({ visible: false, }); }; handleCancel=()=>{ this.setState({ visible: false, }); }; Cancelundologins=()=>{ this.setState({ Modalstype:false, ModalCancel:this.Cancelundologin, ModalSave:this.Saveundologin, }) } Saveundologin=(id)=>{ let {basicInfo}=this.props; let url=`/users/accounts/${basicInfo.id}/open_users/${id}.json`; axios.delete(url).then((result)=>{ if(result.data.status===0){ this.props.showNotification('解绑成功'); this.Cancelundologins() this.props.getBasicInfo() } }).catch((error)=>{ console.log(error) }) } undologin=(type,id)=>{ this.setState({ Modalstype:true, Modalstopval:type==="wechat"?"是否确定解绑微信账号?":"是否确定解绑QQ账号?", ModalCancel:this.Cancelundologins, ModalSave:()=>this.Saveundologin(id), }) } openqqlogin=()=>{ window.location.href=`https://graph.qq.com/oauth2.0/show?which=Login&display=pc&client_id=101508858&redirect_uri=https%3a%2f%2f${window.location.host}%2fotherloginqq&response_type=code` } openphoneqqlogin=()=>{ window.open( `https://xui.ptlogin2.qq.com/cgi-bin/xlogin?appid=716027609&pt_3rd_aid=101508858&daid=383&pt_skey_valid=0&style=35&s_url=http%3A%2F%2Fconnect.qq.com&refer_cgi=authorize&which=&client_id=101508858&response_type=code&scope=get_user_info&redirect_uri=https%3a%2f%2ftest-newweb.educoder.net%2fotherloginqq&response_type=code` ) } render() { let flag = this.IsPC(); //true为PC端,false为手机端 let {list}=this.state; return (
{/*提示*/}
绑定登录账号
{list.map((item,key)=>{ return(
{item.en_type!="qq"?:} {item.en_type!="qq"?微信:QQ}
{item.nickname}
{item.en_type!="qq"? this.showModal("wechat"):() => this.undologin("wechat",item.id) } >{item.id===null?"绑定":"解绑"}: this.openphoneqqlogin():() => this.openqqlogin():() => this.undologin("qq",item.id) } >{item.id===null?"绑定":"解绑"}}
) }) }

this.handleCancel()}>取消

* 我们确保你所提供的信息均处于严格保密状态,不会泄露
); } } const WrappedAccountSecure = Form.create({ name: 'AccountSecure' })(AccountSecure); export default WrappedAccountSecure;