Commit 5d0702f2 by zhangzhi

remove socket

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