Commit aef9c86c by 刘珅

更新pad连接

parent 3003bbcc
...@@ -61,7 +61,7 @@ export default class HeaderComponent extends React.Component { ...@@ -61,7 +61,7 @@ export default class HeaderComponent extends React.Component {
} }
}) })
if (this.isShowVersionAndPort() && this.props.changePages) { if (this.isShowVersionAndPort() && this.props.changePages) {
this.props.changePages(CONFIG.showPage[8888]) this.props.changePages(CONFIG.showPage['DevPage'])
} }
} }
......
import { getQuery } from '../util/common';
// {}
const requestInfo = { const requestInfo = {
domainPort : '7788', domainPort : '7788',
domainIp : '192.168.10.' domainIp : '192.168.10.',
exactDomainIp: getQuery('isDev') ? '127.0.0.1' : ''
} }
module.exports = requestInfo; module.exports = requestInfo;
\ No newline at end of file
...@@ -2,6 +2,6 @@ import swiperContainers from './swiperContainer' ...@@ -2,6 +2,6 @@ import swiperContainers from './swiperContainer'
import showPage from './showPage' import showPage from './showPage'
import socketType from './socketType' import socketType from './socketType'
import taskErrorType from './taskErrorType' import taskErrorType from './taskErrorType'
import machineInfo from './machineInfo' import config from './config'
module.exports = {swiperContainers,...showPage,socketType,taskErrorType , machineInfo } module.exports = {swiperContainers,...showPage,socketType,taskErrorType , config }
\ No newline at end of file \ No newline at end of file
...@@ -18,7 +18,7 @@ const showPage = { ...@@ -18,7 +18,7 @@ const showPage = {
14 : 'Question', //二期问题反馈页面 14 : 'Question', //二期问题反馈页面
141 : 'Question1', //二期问题反馈页面 141 : 'Question1', //二期问题反馈页面
15 : 'BoxRecoverySkus', //二期回收箱回收 15 : 'BoxRecoverySkus', //二期回收箱回收
8888 : 'MachineInfo' 'DevPage' : 'DevPage'
}; };
const taskSchedule = { //任务进度序列号,后台给 const taskSchedule = { //任务进度序列号,后台给
1: showPage[5], 1: showPage[5],
......
...@@ -2,7 +2,7 @@ import React from 'react'; ...@@ -2,7 +2,7 @@ import React from 'react';
import HeaderComponent from '../../components/CommonComponent/HeaderComponent/HeaderComponent' import HeaderComponent from '../../components/CommonComponent/HeaderComponent/HeaderComponent'
import Button from '../../components/CommonComponent/ButtonComponent/ButtonComponent'; import Button from '../../components/CommonComponent/ButtonComponent/ButtonComponent';
export default class MachineInfo extends React.Component { export default class DevPage extends React.Component {
constructor(props){ constructor(props){
super(props); super(props);
this.state = { this.state = {
...@@ -19,7 +19,7 @@ export default class MachineInfo extends React.Component { ...@@ -19,7 +19,7 @@ export default class MachineInfo extends React.Component {
/> />
<div className="machineInfo" style={{textAlign:'center', marginTop:'3rem'}}> <div className="machineInfo" style={{textAlign:'center', marginTop:'3rem'}}>
<p>当前版本号 {CURVERSION}</p> <p>当前版本号 {CURVERSION}</p>
<p>当前端口号 {CONFIG.machineInfo.domainPort} </p> <p>当前端口号 {CONFIG.config.domainPort} </p>
<Button text={'首页'} btnContainer={'colfff font30'} style={{background:'#ff7860',marginLeft:'50%',transform:' translate(-50%)',marginTop:'.5rem'}} option={()=>changePages(CONFIG.showPage[13])} /> <Button text={'首页'} btnContainer={'colfff font30'} style={{background:'#ff7860',marginLeft:'50%',transform:' translate(-50%)',marginTop:'.5rem'}} option={()=>changePages(CONFIG.showPage[13])} />
</div> </div>
</div> </div>
......
...@@ -42,7 +42,7 @@ import AllClassify from '../AllClassifyContainer/AllClassifyContainer' ...@@ -42,7 +42,7 @@ import AllClassify from '../AllClassifyContainer/AllClassifyContainer'
import {willCloseDoor,closeDoorSuccess} from '../../actions/chooseTaskContainer' import {willCloseDoor,closeDoorSuccess} from '../../actions/chooseTaskContainer'
import {sendMsg} from '../../util/socket' import {sendMsg} from '../../util/socket'
import PopModel from '../../components/CommonComponent/PopupComponent/PopupChildComponent' import PopModel from '../../components/CommonComponent/PopupComponent/PopupChildComponent'
import MachineInfo from '../MachineInfo/MachineInfo' import DevPage from '../DevPage/DevPage'
/*二期引用 end*/ /*二期引用 end*/
import {on,remove} from '../../util/event'; import {on,remove} from '../../util/event';
...@@ -1095,8 +1095,8 @@ class PageContainer extends React.Component { ...@@ -1095,8 +1095,8 @@ class PageContainer extends React.Component {
willCloseDoor={async ()=>{return await dispatch(willCloseDoor(commonInfo,true))}} willCloseDoor={async ()=>{return await dispatch(willCloseDoor(commonInfo,true))}}
/>; />;
break; break;
case showPage[8888] : case showPage['DevPage'] :
pages = <MachineInfo pages = <DevPage
headerInfo = {commonInfo} headerInfo = {commonInfo}
changePages={(data)=>this.changePages(data)} changePages={(data)=>this.changePages(data)}
/> />
......
export const getQuery = (key) => {
let searchInfo = location.search.substr(1).split("&");
let searchObj = {};
searchInfo.forEach(i=>{
let obj = i.split("=");
searchObj[obj[0]] = obj[1];
});
return searchObj[key];
}
\ No newline at end of file
...@@ -2,7 +2,7 @@ import fetch from 'isomorphic-fetch'; ...@@ -2,7 +2,7 @@ import fetch from 'isomorphic-fetch';
let domain = "http://192.168.10.63:7780"; let domain = "http://192.168.10.63:7780";
const domainPort = CONFIG.machineInfo.domainPort; const domainPort = CONFIG.config.domainPort;
const myHeaders = new Headers({ const myHeaders = new Headers({
// 'Access-Control-Allow-Origin': '*', // 'Access-Control-Allow-Origin': '*',
// 'Content-Type': 'text/plain;charset=UTF-8', // 'Content-Type': 'text/plain;charset=UTF-8',
......
import {emit, on , remove} from './event' import {emit, on , remove} from './event';
import { exactDomainIp } from '../config/config';
import myLogger from './logger' import myLogger from './logger'
let domainIp = CONFIG.machineInfo.domainIp; let domainIp = CONFIG.config.domainIp;
const domainPort = CONFIG.machineInfo.domainPort; const domainPort = CONFIG.config.domainPort;
const socket = {}; const socket = {};
...@@ -60,7 +61,11 @@ socket.getIp1 = ()=>{ ...@@ -60,7 +61,11 @@ socket.getIp1 = ()=>{
if(!getIpING) { if(!getIpING) {
getIpING = true; getIpING = true;
for(let j = 0; j< 255 ; j ++){ for(let j = 0; j< 255 ; j ++){
let wsUrl = `ws://${domainIp}${j}:${domainPort}/notify?from=plant`; let connectIp = `${domainIp}${j}`;
if (exactDomainIp) {
connectIp = exactDomainIp;
}
let wsUrl = `ws://${connectIp}:${domainPort}/notify?from=plant`;
let ws1 = new WebSocket(wsUrl); let ws1 = new WebSocket(wsUrl);
ws1.onopen = function() ws1.onopen = function()
{ {
...@@ -79,6 +84,7 @@ socket.getIp1 = ()=>{ ...@@ -79,6 +84,7 @@ socket.getIp1 = ()=>{
ws1.close(); ws1.close();
if(!startStopServer){ if(!startStopServer){
//非断电断网情况就连接 //非断电断网情况就连接
console.log('=====>', info);
init(currentIpIndex,info.data,true); init(currentIpIndex,info.data,true);
} }
} }
...@@ -94,41 +100,15 @@ socket.getIp1 = ()=>{ ...@@ -94,41 +100,15 @@ socket.getIp1 = ()=>{
socket.getIp1(); socket.getIp1();
} }
} }
}
}
}
socket.getTestIp = (ip) => {
let wsUrl = `ws://${domainIp}${ip}:${domainPort}/notify?from=plant`;
let ws1 = new WebSocket(wsUrl);
ws1.onopen = function()
{
if(currentIpIndex === 255){
currentIpIndex = ip;
// ws1.close();
}else{
ws1.close();
}
}; if (exactDomainIp) {
ws1.onmessage = (evt)=>{ break;
if(currentIpIndex !== 255){
let info = JSON.parse(evt.data);
if(info.type === 'GET_STORE_ID' && info.data){
ws1.close();
if(!startStopServer){
init(currentIpIndex,info.data,true);
} }
} }
} }
};
} }
const getError = ()=>{ const getError = ()=>{
getClose(); getClose();
} }
...@@ -142,9 +122,10 @@ const getClose = ()=>{ ...@@ -142,9 +122,10 @@ const getClose = ()=>{
const init = (ip,storeid,from = false)=>{ const init = (ip,storeid,from = false)=>{
let theIp = exactDomainIp || `${domainIp}${ip}`;
let wsUrl = `ws://${domainIp}${ip}:${domainPort}/notify?from=plant&storeId=${storeid}`; let wsUrl = `ws://${theIp}:${domainPort}/notify?from=plant&storeId=${storeid}`;
if("WebSocket" in window && !ws && ip && storeid && (currentIpIndex === 255 || from)){ if("WebSocket" in window && !ws && storeid &&
(exactDomainIp || (ip && storeid && (currentIpIndex === 255 || from))) ){
ws = new WebSocket(wsUrl); ws = new WebSocket(wsUrl);
ws.onopen = function() ws.onopen = function()
...@@ -154,7 +135,7 @@ const init = (ip,storeid,from = false)=>{ ...@@ -154,7 +135,7 @@ const init = (ip,storeid,from = false)=>{
currentIpIndex = ip; currentIpIndex = ip;
storeId = storeid; storeId = storeid;
getIpING = false; getIpING = false;
myLogger.saveDomain(domainIp+ip); myLogger.saveDomain(exactDomainIp || (domainIp + ip));
if(stopTimer){ if(stopTimer){
//重连成功后,终止倒计时 //重连成功后,终止倒计时
clearTimeout(stopTimer); clearTimeout(stopTimer);
...@@ -162,7 +143,7 @@ const init = (ip,storeid,from = false)=>{ ...@@ -162,7 +143,7 @@ const init = (ip,storeid,from = false)=>{
startStopServer = false; startStopServer = false;
myLogger.info("连接成功,停止stopTimer倒计时"); myLogger.info("连接成功,停止stopTimer倒计时");
} }
emit(CONFIG.socketType.GETSTOREINFO,{ip:domainIp+ip,storeId:storeid}) emit(CONFIG.socketType.GETSTOREINFO,{ip:(exactDomainIp || (domainIp + ip)),storeId:storeid})
}; };
ws.onmessage = function (evt) ws.onmessage = function (evt)
......
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 to comment