Commit 5d0702f2 by zhangzhi

remove socket

parent a489c232
...@@ -110,6 +110,29 @@ const fetchStoreInfo = (storeId)=>{ ...@@ -110,6 +110,29 @@ const fetchStoreInfo = (storeId)=>{
} }
}; };
//获取门店所有门信息
const fetchStoreDoorStatus = (storeId)=>{
console.log('zzzzzzzzzz1111', storeId)
return (dispatch)=>{
fetch(domain + 'machine_pad/get_all_door_status.action?storeId='+storeId,{
credentials : 'include',
method : 'GET',
mode : 'cors',
}).then((response)=>response.json())
.then(json=>{
console.log('zzzzzzz4',json)
if(json.meta.success){
emit(CONFIG.customEvent.GETDOORSTATUSREADY,json.data);
}else{
dispatch(addErrorInfo('获取门店开门信息出错'))
}
}).catch(e=>{
UTILPATH.myLogger.error(`get store door status failed ${e}`);
dispatch(fetchStoreDoorStatus(storeId));
});
}
}
//获取用户信息 //获取用户信息
const getUserinfo = (employeeId,storeId)=>{ const getUserinfo = (employeeId,storeId)=>{
...@@ -226,4 +249,4 @@ const getTaskName = (currentTaskType,childTaskNum=0)=>{ ...@@ -226,4 +249,4 @@ const getTaskName = (currentTaskType,childTaskNum=0)=>{
} }
} }
export {getStoreInfo,saveCommonInfo,getUserinfo,logout,getTaskList,getTaskName,emptyStoreInfo,fetchStoreInfo} export {getStoreInfo,saveCommonInfo,getUserinfo,logout,getTaskList,getTaskName,emptyStoreInfo,fetchStoreInfo,fetchStoreDoorStatus}
...@@ -43,7 +43,9 @@ const getStoreInfo = (data)=>{ ...@@ -43,7 +43,9 @@ const getStoreInfo = (data)=>{
} }
}; };
const listStores = ()=>{ const listStores = ()=>{
console.log('vvvvvvvvvvv1 liststores')
return (dispatch)=>{ return (dispatch)=>{
console.log('in fetch............',domain,dispatch)
fetch(domain + 'machine_pad/list_store',{ fetch(domain + 'machine_pad/list_store',{
credentials : 'include', credentials : 'include',
method : 'POST', method : 'POST',
...@@ -55,14 +57,19 @@ const listStores = ()=>{ ...@@ -55,14 +57,19 @@ const listStores = ()=>{
UTILPATH.myLogger.info("pad list stores ",json); UTILPATH.myLogger.info("pad list stores ",json);
if(json.meta.success){ if(json.meta.success){
let storeList = json.data; let storeList = json.data;
dispatch(saveStoreList(storeList)) //dispatch(saveStoreList(storeList))
emit(CONFIG.customEvent.STORELISTREADY,{}); console.log('vvvvvvv2', storeList)
emit(CONFIG.customEvent.STORELISTREADY,storeList);
}else{ }else{
//没有店铺信息 //没有店铺信息
} }
}).catch(e=>{ }).catch(e=>{
console.log('vvvvvvv999',e)
UTILPATH.myLogger.error(`pad list stores ${e}`); UTILPATH.myLogger.error(`pad list stores ${e}`);
dispatch(listStores()); dispatch(listStores());
}).catch(e1=>{
console.log('vvvvvvv101010101010101',e)
UTILPATH.myLogger.error(`pad list stores ${e1}`);
}); });
} }
} }
......
...@@ -71,6 +71,8 @@ const uploadError = (info,exceptionType,getTask=true)=>{ ...@@ -71,6 +71,8 @@ const uploadError = (info,exceptionType,getTask=true)=>{
}; };
const addErrorInfo = (errMsg)=>{ const addErrorInfo = (errMsg)=>{
console.log('in adderrorinfo', errMsg)
console.log(actionType)
return{ return{
type : actionType.ADDERRORINFO, type : actionType.ADDERRORINFO,
errMsg errMsg
......
...@@ -2,5 +2,6 @@ ...@@ -2,5 +2,6 @@
const customEvent = { const customEvent = {
STORELISTREADY: 'STORELISTREADY', STORELISTREADY: 'STORELISTREADY',
STOREINFOREADY: 'STOREINFOREADY', STOREINFOREADY: 'STOREINFOREADY',
GETDOORSTATUSREADY: 'GETDOORSTATUSREADY',
} }
module.exports = customEvent; module.exports = customEvent;
\ No newline at end of file
...@@ -15,6 +15,7 @@ export default class HomePageContainer extends React.Component{ ...@@ -15,6 +15,7 @@ export default class HomePageContainer extends React.Component{
} }
this.logout = this.logout.bind(this); this.logout = this.logout.bind(this);
this.showLogoutPopup = this.showLogoutPopup.bind(this) this.showLogoutPopup = this.showLogoutPopup.bind(this)
} }
componentWillMount(){ componentWillMount(){
...@@ -50,6 +51,9 @@ export default class HomePageContainer extends React.Component{ ...@@ -50,6 +51,9 @@ export default class HomePageContainer extends React.Component{
console.log(navigator.connection.effectiveType) console.log(navigator.connection.effectiveType)
} }
logout(){ logout(){
let props = this.props;
console.log('zzzzzzzzzzzzg',props)
let {getStoreDoorStatus, dispatch} = props;
if(this.state.closeDoorStatus === 0){ if(this.state.closeDoorStatus === 0){
this.setState({ this.setState({
closeDoorStatus : 1 closeDoorStatus : 1
...@@ -67,6 +71,7 @@ export default class HomePageContainer extends React.Component{ ...@@ -67,6 +71,7 @@ export default class HomePageContainer extends React.Component{
}) })
}else{ }else{
console.log('hihihihi herreerreherere')
//正常调用 //正常调用
...@@ -96,10 +101,11 @@ export default class HomePageContainer extends React.Component{ ...@@ -96,10 +101,11 @@ export default class HomePageContainer extends React.Component{
this.props.willCloseDoor().then(()=>{ this.props.willCloseDoor().then(()=>{
this.props.endCountBack(); this.props.endCountBack();
this.props.changeIsSend(true); this.props.changeIsSend(true);
let msg={type:'WILL_CLOSEDOOR'}; getStoreDoorStatus()
sendMsg(JSON.stringify(msg)); // let msg={type:'WILL_CLOSEDOOR'};
// this.props.tempLogout() // sendMsg(JSON.stringify(msg));
console.log('有网络',this.props) // // this.props.tempLogout()
// console.log('有网络',this.props)
}) })
} }
}) })
......
...@@ -33,7 +33,7 @@ import {getBarCodeProductInfo,saveProductInfo} from '../../actions/barcodeCommon ...@@ -33,7 +33,7 @@ import {getBarCodeProductInfo,saveProductInfo} from '../../actions/barcodeCommon
import {getTaskList, askForNextTask, emptyStoreInfo} from '../../actions/common' import {getTaskList, askForNextTask, emptyStoreInfo} from '../../actions/common'
import {submitBreakageProduct,hasNoSku} from '../../actions/breakaegContainer' import {submitBreakageProduct,hasNoSku} from '../../actions/breakaegContainer'
import {checkProductQuantity} from '../../actions/TokeStokeContainer' import {checkProductQuantity} from '../../actions/TokeStokeContainer'
import {getStoreInfo,saveCommonInfo,getUserinfo,logout,getTaskName,fetchStoreInfo} from "../../actions/common"; import {getStoreInfo,saveCommonInfo,getUserinfo,logout,getTaskName,fetchStoreInfo,fetchStoreDoorStatus} from "../../actions/common";
import {finishBoxRecovery} from "../../actions/recovery"; import {finishBoxRecovery} from "../../actions/recovery";
import replenishAction from "../../actions/replenish"; import replenishAction from "../../actions/replenish";
import {getStoreList,listStores} from "../../actions/getStore"; import {getStoreList,listStores} from "../../actions/getStore";
...@@ -244,13 +244,14 @@ class PageContainer extends React.Component { ...@@ -244,13 +244,14 @@ class PageContainer extends React.Component {
}) })
} }
}); });
on(CONFIG.customEvent.STORELISTREADY, this, ()=>{ on(CONFIG.customEvent.STORELISTREADY, this, (data)=>{
console.log('storelistready')
const that = this; const that = this;
if(!this.state.showSelectStore){ if(!this.state.showSelectStore){
this.setState({ this.setState({
showSelectStore : true showSelectStore : true
},()=>{ },()=>{
that.showStoreSelectPop(); that.showStoreSelectPop(data);
}) })
} }
}) })
...@@ -258,6 +259,38 @@ class PageContainer extends React.Component { ...@@ -258,6 +259,38 @@ class PageContainer extends React.Component {
const that = this; const that = this;
that.startWork(); that.startWork();
}) })
on(CONFIG.customEvent.GETDOORSTATUSREADY,this,(data)=>{
//门状态接收成功
console.log("door status received ",data);
console.log(data)
let area = this.props.state.commonInfo.taskInfo.area;
let storeId = this.props.state.commonInfo.storeInfo.id;
console.log('ccccccccccccc0', area)
console.log('ccccccccccc1',this.state, this.props)
console.log(setTimeout, this.handleCloseDoor, this.getStoreDoorStatus)
if(area==="A"){
console.log('hihihihihiaaaaaaaaa')
if(data.aDoor === 1){
console.log('hihihihihiaaaaaaaaaclose')
this.handleCloseDoor()
}else{
console.log('hihihihihiaaaaaaaaatimeout')
window.setTimeout(()=>{this.getStoreDoorStatus(storeId)}, 3000)
}
}else if(area==="B"){
console.log('hihihihihibbbbbbbbbb')
if(data.bDoor === 1){
console.log('hihihihihibbbbbbbbbbbbclose')
this.handleCloseDoor()
}else{
console.log('hihihihihibbbbbbbbbbtimeout')
window.setTimeout(()=>{this.getStoreDoorStatus(storeId)}, 3000)
}
}
})
on(CONFIG.socketType.STOPSTOPSERVER,this,()=>{ on(CONFIG.socketType.STOPSTOPSERVER,this,()=>{
// 接收到终止断网指令(即联网成功) // 接收到终止断网指令(即联网成功)
UTILPATH.myLogger.info("componentWillMount " ,CONFIG.socketType.STOPSTOPSERVER); UTILPATH.myLogger.info("componentWillMount " ,CONFIG.socketType.STOPSTOPSERVER);
...@@ -367,6 +400,7 @@ class PageContainer extends React.Component { ...@@ -367,6 +400,7 @@ class PageContainer extends React.Component {
},()=>{ },()=>{
this.endCountBack(); this.endCountBack();
dispatch(closeDoorSuccess(commonInfo,this.state.startStopServer)); dispatch(closeDoorSuccess(commonInfo,this.state.startStopServer));
}); });
} }
...@@ -420,6 +454,7 @@ class PageContainer extends React.Component { ...@@ -420,6 +454,7 @@ class PageContainer extends React.Component {
let nextEmployeeId = nextUserInfo.employeeId || 0; let nextEmployeeId = nextUserInfo.employeeId || 0;
let nextArea = nextTaskInfo.area || ""; let nextArea = nextTaskInfo.area || "";
let storeList = state.storeInfo && state.storeInfo.storeList ? state.storeInfo.storeList : []; let storeList = state.storeInfo && state.storeInfo.storeList ? state.storeInfo.storeList : [];
console.log('zzzzz5',nextUserInfo, nextTaskInfo)
if(nextUserInfo && nextUserInfo.taskType && nextUserInfo.id) { if(nextUserInfo && nextUserInfo.taskType && nextUserInfo.id) {
let commonInfo = this.props.state.commonInfo; let commonInfo = this.props.state.commonInfo;
let {userInfo={},taskInfo={}} = commonInfo; let {userInfo={},taskInfo={}} = commonInfo;
...@@ -488,9 +523,11 @@ class PageContainer extends React.Component { ...@@ -488,9 +523,11 @@ class PageContainer extends React.Component {
} }
componentWillUnmount(){ componentWillUnmount(){
} }
showStoreSelect(){ showStoreSelect(){
console.log('in show store select') console.log('in show store select')
let {dispatch} = this.props; let {dispatch} = this.props;
console.log(dispatch, listStores)
dispatch(listStores()) dispatch(listStores())
// let {dispatch} = this.props; // let {dispatch} = this.props;
// console.log('kkkkkkkkk') // console.log('kkkkkkkkk')
...@@ -505,6 +542,18 @@ class PageContainer extends React.Component { ...@@ -505,6 +542,18 @@ class PageContainer extends React.Component {
// } // }
// ) // )
} }
getStoreDoorStatus(storeId){
console.log("in getStoreDoorStatus")
if(!storeId){
storeId = this.props.state.commonInfo.storeInfo.id
}
console.log('storeid',storeId)
console.log(this.props)
let {dispatch} = this.props;
dispatch(fetchStoreDoorStatus(storeId))
}
showError(errMsg){ showError(errMsg){
let className = errMsg.length > 24 ? 'popupExtClass' : ''; let className = errMsg.length > 24 ? 'popupExtClass' : '';
let style = {'width':UTILPATH.getRemByPx(260)} let style = {'width':UTILPATH.getRemByPx(260)}
...@@ -520,6 +569,7 @@ class PageContainer extends React.Component { ...@@ -520,6 +569,7 @@ class PageContainer extends React.Component {
hideError(){ hideError(){
let {dispatch} = this.props; let {dispatch} = this.props;
console.log("in hideerror",this.props)
dispatch(addErrorInfo("")); dispatch(addErrorInfo(""));
this.hidePopup(); this.hidePopup();
} }
...@@ -786,9 +836,12 @@ class PageContainer extends React.Component { ...@@ -786,9 +836,12 @@ class PageContainer extends React.Component {
}) })
} }
// 选择门店拉取任务 // 选择门店拉取任务
showStoreSelectPop(){ showStoreSelectPop(data){
let {state} = this.props; let {state} = this.props;
let storeList = state.storeInfo && state.storeInfo.storeList ? state.storeInfo.storeList : []; let storeList = state.storeInfo && state.storeInfo.storeList ? state.storeInfo.storeList : [];
if(!storeList || storeList.length==0){
storeList = data
}
if(storeList && storeList.length > 0){ if(storeList && storeList.length > 0){
let storeDom = storeList.map((store,index)=>{ let storeDom = storeList.map((store,index)=>{
return <span key={"storeListPop"+index}> return <span key={"storeListPop"+index}>
...@@ -1059,6 +1112,8 @@ class PageContainer extends React.Component { ...@@ -1059,6 +1112,8 @@ class PageContainer extends React.Component {
hidePopup={()=>this.hidePopup()} hidePopup={()=>this.hidePopup()}
dispatch={dispatch} dispatch={dispatch}
showStoreSelect={()=>this.showStoreSelect()} showStoreSelect={()=>this.showStoreSelect()}
getStoreDoorStatus={()=>this.getStoreDoorStatus()}
/>; />;
break; break;
case showPage[131]: case showPage[131]:
...@@ -1072,6 +1127,8 @@ class PageContainer extends React.Component { ...@@ -1072,6 +1127,8 @@ class PageContainer extends React.Component {
changeIsSend ={this.changeIsSend.bind(this)} changeIsSend ={this.changeIsSend.bind(this)}
endCountBack={this.endCountBack} endCountBack={this.endCountBack}
startStopServer={this.state.startStopServer} startStopServer={this.state.startStopServer}
getStoreDoorStatus={()=>this.getStoreDoorStatus()}
dispatch={dispatch}
/>; />;
break; break;
case showPage[12]: case showPage[12]:
......
...@@ -2,6 +2,6 @@ ...@@ -2,6 +2,6 @@
* Created by ruibing on 16/11/2. * Created by ruibing on 16/11/2.
*/ */
module.exports = { module.exports = {
domain: 'https://test.mjitech.com/web/', domain: 'http://test.mjitech.com/web/',
uploadImg : 'https://test.mjitech.com/static/uploadTrouble' // 小程序上传图片的二维码连接(已作废) uploadImg : 'http://test.mjiteh.com/static/uploadTrouble' // 小程序上传图片的二维码连接(已作废)
} }
\ No newline at end of file
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