提交 8c29166c authored 作者: 徐立's avatar 徐立
......@@ -8,11 +8,12 @@ import { isJSON } from '../utils/utils';
let ws = null;
/**
* props 定义
* url: 二维码url
* show: 是否显示二维码Modal
* wxSocketGateWay: webscoket 链接地址
* mockServer: 接口地址前缀 用于获取sessionid;
* props{
* url: 二维码url
* show: 是否显示二维码Modal
* wxSocketGateWay: webscoket 链接地址
* mockServer: 接口地址前缀 用于获取sessionid;
* }
* */
export default class LoginWithQrCode extends Component {
constructor(props) {
......@@ -20,10 +21,10 @@ export default class LoginWithQrCode extends Component {
const { wxSocketGateWay, mockServer } = this.props;
this.wxSocketGateWay = wxSocketGateWay;
this.mockServer = mockServer;
if(!wxSocketGateWay){
if (!wxSocketGateWay) {
this.wxSocketGateWay = config.wxSocketGateWay;
}
if(!mockServer){
if (!mockServer) {
this.mockServer = config.mockServer;
}
this.state = {
......@@ -40,7 +41,7 @@ export default class LoginWithQrCode extends Component {
};
componentWillUnmount(){
componentWillUnmount() {
this.initWs(); // 组件不加载的时候 注销websocket
}
......@@ -73,7 +74,7 @@ export default class LoginWithQrCode extends Component {
// that.getAppId();
that.setState({
showRefresh: true,
})
});
};
ws.onmessage = (evt) => {
if (typeof evt.data === String) {
......@@ -144,11 +145,11 @@ export default class LoginWithQrCode extends Component {
connectTimes: 0,
showRefresh: false,
connectStatus: false,
})
});
};
render() {
const { sessionId, connectStatus,showRefresh, loading } = this.state;
const { sessionId, connectStatus, showRefresh, loading } = this.state;
const { url, show } = this.props;
if (this.props.show && !connectStatus) {
this.startConnect();
......@@ -160,9 +161,10 @@ export default class LoginWithQrCode extends Component {
margin: '0 auto',
}}>
{
this.props.show && !connectStatus ? <Spin size="large" style={{
this.props.show && !connectStatus ? <Spin size="large" style={{
height: '200px',
paddingTop: '100px',}}/>:
paddingTop: '100px',
}}/> :
<QRCode
bgColor="white"
fgColor='black'
......@@ -177,7 +179,7 @@ export default class LoginWithQrCode extends Component {
marginTop: '10px',
borderTop: '1px solid #eee',
}}>
<Icon type="info-circle" style={{color: '#E36968'}}/>
<Icon type="info-circle" style={{ color: '#E36968' }}/>
<span style={{
fontWeight: 'blod',
}}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论