Commit e739c04e by Zhang Xin

完善关门逻辑

parent 5148932b
...@@ -2,23 +2,36 @@ import fetch from 'isomorphic-fetch' ...@@ -2,23 +2,36 @@ import fetch from 'isomorphic-fetch'
import actionType from '../actiontype/error' import actionType from '../actiontype/error'
let domain = ENV.domain; let domain = ENV.domain;
const uploadError = ()=>{ var myHeaders = new Headers({
'Access-Control-Allow-Origin': '*',
// 'Content-Type': 'text/plain;charset=UTF-8',
// 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'Content-Type': 'application/json; charset=UTF-8',
});
const uploadError = (info)=>{
console.log("uploadError ",info)
let bodyData = {
warehouseId : info.storeId,
exceptionType : info.exceptionType,
taskId : info.taskId
};
return (dispatch =>{ return (dispatch =>{
// fetch(domain + '/web/pad_warehouse/getMachineData.action',{ fetch(domain + '/machine_pad/flat_warn_record',{
// credentials : 'include', credentials : 'include',
// method : 'POST', method : 'POST',
// mode : 'cors', mode : 'cors',
// body : {} headers:myHeaders,
// body : JSON.stringify(bodyData)
// }).then((response)=>response.json())
// .then(json=>{ }).then((response)=>response.json())
// console.log(json); .then(json=>{
// }).catch(e=>{console.error(e)}) console.log(json);
console.log("uploadError") }).catch(e=>{console.error(e)});
}) })
}; };
const addErrorInfo = (errMsg)=>{ const addErrorInfo = (errMsg)=>{
console.log("errMsg ,",errMsg)
return{ return{
type : actionType.ADDERRORINFO, type : actionType.ADDERRORINFO,
errMsg errMsg
......
import fetch from 'isomorphic-fetch'; import fetch from 'isomorphic-fetch';
import actionTypes from '../actiontype/user' import actionTypes from '../actiontype/user'
import {saveHeaderInfo} from './initHeader' import {saveHeaderInfo} from './initHeader'
import {addErrorInfo} from './uploadError'
const domain = ENV.domain; const domain = ENV.domain;
let json = { let json = {
...@@ -10,7 +11,7 @@ let json = { ...@@ -10,7 +11,7 @@ let json = {
"success": true "success": true
}, },
"data": { "data": {
"types":'Trouble', "types":'ER',
"employee":{ "employee":{
"id": 5, "id": 5,
"employeeName": "机器库管员", "employeeName": "机器库管员",
...@@ -50,9 +51,18 @@ const getUserinfo = (info)=>{ ...@@ -50,9 +51,18 @@ const getUserinfo = (info)=>{
}).then((response)=>response.json()) }).then((response)=>response.json())
.then(json=>{ .then(json=>{
console.log(json); console.log(json);
// if(json.meta.success && json.data){
// dispatch(saveUserinfo(json.data));
// if(!json.data.types){
// dispatch(addErrorInfo('没有任务需要处理'))
// }
// }
}).catch(e=>{console.error(e)}) }).catch(e=>{console.error(e)})
if(json.meta.success && json.data){ if(json.meta.success && json.data){
dispatch(saveUserinfo(json.data)) dispatch(saveUserinfo(json.data));
if(!json.data.types){
dispatch(addErrorInfo('没有任务需要处理'))
}
} }
} }
......
...@@ -20,7 +20,8 @@ export default class ChooseTaskContainer extends React.Component{ ...@@ -20,7 +20,8 @@ export default class ChooseTaskContainer extends React.Component{
} }
closeDoor(){ closeDoor(){
console.log("closeDoor") console.log("closeDoor");
this.props.hidePopup();
this.props.showOpenDoorPage() this.props.showOpenDoorPage()
} }
......
...@@ -12,6 +12,8 @@ export default class FinishAskContainer extends React.Component{ ...@@ -12,6 +12,8 @@ export default class FinishAskContainer extends React.Component{
} }
this.closeDoor = this.closeDoor.bind(this); this.closeDoor = this.closeDoor.bind(this);
this.selectTask = this.selectTask.bind(this); this.selectTask = this.selectTask.bind(this);
this.beginCloseDoor = this.beginCloseDoor.bind(this);
this.judgeTask = this.judgeTask.bind(this);
} }
componentWillMount(){ componentWillMount(){
...@@ -28,11 +30,44 @@ export default class FinishAskContainer extends React.Component{ ...@@ -28,11 +30,44 @@ export default class FinishAskContainer extends React.Component{
changePages(CONFIG.showPage[9]) changePages(CONFIG.showPage[9])
} }
closeDoor(){ beginCloseDoor(){
console.log("closeDoor") this.props.hidePopup()
this.props.showOpenDoorPage(); this.props.showOpenDoorPage();
} }
closeDoor(){
console.log("closeDoor");
this.props.hidePopup();
//任务完成,超时不确定
let btnDom = <Button key={"finishcloseDoorBack1"} style={{'width':'260px'}} text={"确定"} option={this.beginCloseDoor}/>
let clockDom = <Clock key={"finiscloseDoorhBack2"} totalTime={30}
style={{'width':'260px','marginLeft':'30px','borderRadius':'10px'}}
callback={this.beginCloseDoor}
/>;
this.props.showPopup({
popupText : '检测到店铺反常,请站出店铺,关闭店铺门后重新验证您的身份',
popupButtons:[btnDom,clockDom]
})
this.props.uploadErrs(2);
}
judgeTask(){
console.log("judgeTask");
this.props.hidePopup();
//任务完成,超时不确定
let btnDom = <Button key={"finishjudgeTaskBack1"} style={{'width':'260px'}} text={"确定"} option={this.beginCloseDoor}/>
let clockDom = <Clock key={"finishjudgeTaskBack2"} totalTime={30}
style={{'width':'260px','marginLeft':'30px','borderRadius':'10px'}}
callback={this.closeDoor}
/>;
this.props.showPopup({
popupText : '您的任务是否已结束',
popupButtons:[btnDom,clockDom]
});
this.props.uploadErrs(2);
}
render(){ render(){
let {userInfo,storeInfo} = this.props; let {userInfo,storeInfo} = this.props;
return( return(
...@@ -51,7 +86,7 @@ export default class FinishAskContainer extends React.Component{ ...@@ -51,7 +86,7 @@ export default class FinishAskContainer extends React.Component{
<Button text={"有"} style={{'marginTop':'120px'}} option={this.selectTask}/> <Button text={"有"} style={{'marginTop':'120px'}} option={this.selectTask}/>
<Button text={"没有"} style={{'marginTop':'40px'}} option={this.closeDoor}/> <Button text={"没有"} style={{'marginTop':'40px'}} option={this.closeDoor}/>
<Clock style={{'marginTop':'40px'}} totalTime={60} <Clock style={{'marginTop':'40px'}} totalTime={60}
callback={this.closeDoor}/> callback={this.judgeTask}/>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -39,6 +39,11 @@ const defaultPopupInfo = { ...@@ -39,6 +39,11 @@ const defaultPopupInfo = {
}; };
const initPage = showPage[7]; const initPage = showPage[7];
const errorType = {
1 : 1, //屏幕超时操作
2 : 2, //确认完成任务超时
3 : 3, //关门异常
}
class PageContainer extends React.Component { class PageContainer extends React.Component {
constructor(props) { constructor(props) {
...@@ -73,6 +78,7 @@ class PageContainer extends React.Component { ...@@ -73,6 +78,7 @@ class PageContainer extends React.Component {
this.showError = this.showError.bind(this); //展示错误信息 this.showError = this.showError.bind(this); //展示错误信息
this.hideError = this.hideError.bind(this); //隐藏错误信息 this.hideError = this.hideError.bind(this); //隐藏错误信息
this.getPageStyle = this.getPageStyle.bind(this); // this.getPageStyle = this.getPageStyle.bind(this); //
this.uploadErrs = this.uploadErrs.bind(this); //
this.maxCountBackTime = 300; this.maxCountBackTime = 300;
this.count = 1000; this.count = 1000;
...@@ -81,7 +87,7 @@ class PageContainer extends React.Component { ...@@ -81,7 +87,7 @@ class PageContainer extends React.Component {
this.taskTypeOption = { this.taskTypeOption = {
'Trouble': this.showTroublePage 'ER': this.showTroublePage
}; };
} }
...@@ -277,9 +283,18 @@ class PageContainer extends React.Component { ...@@ -277,9 +283,18 @@ class PageContainer extends React.Component {
} }
} }
uploadErrs(type){
let {dispatch,state} = this.props;
dispatch(uploadError(Object.assign({},state.headerInfo,{exceptionType:type})));
}
//弹出警告弹窗,并报警 //弹出警告弹窗,并报警
showAlarm(){ showAlarm(){
console.log("showAlarm"); console.log("showAlarm");
//屏幕超过300s无人操作
this.uploadErrs(errorType[1])
let btnDom = <Button key={"pagecountBack1"} style={{'width':'260px'}} text={"确定"} option={this.beginCloseDoor}/> let btnDom = <Button key={"pagecountBack1"} style={{'width':'260px'}} text={"确定"} option={this.beginCloseDoor}/>
let clockDom = <Clock key={"pagecountBack2"} totalTime={30} let clockDom = <Clock key={"pagecountBack2"} totalTime={30}
style={{'width':'260px','marginLeft':'30px','borderRadius':'10px'}} style={{'width':'260px','marginLeft':'30px','borderRadius':'10px'}}
...@@ -322,8 +337,7 @@ class PageContainer extends React.Component { ...@@ -322,8 +337,7 @@ class PageContainer extends React.Component {
failCloseDoor(){ failCloseDoor(){
this.playAlarmMusic(); this.playAlarmMusic();
let {dispatch} = this.props; this.uploadErrs(errorType[3]);
dispatch(uploadError());
} }
judgeDoorStatus(){ judgeDoorStatus(){
...@@ -439,6 +453,9 @@ class PageContainer extends React.Component { ...@@ -439,6 +453,9 @@ class PageContainer extends React.Component {
endCountBack={this.endCountBack} endCountBack={this.endCountBack}
changePages={(data)=>this.changePages(data)} changePages={(data)=>this.changePages(data)}
showOpenDoorPage={()=>this.showOpenDoorPage.bind(this)()} showOpenDoorPage={()=>this.showOpenDoorPage.bind(this)()}
showPopup={(info)=>this.showPopup(info)}
uploadErrs={(type)=>this.uploadErrs(type)}
hidePopup={()=>this.hidePopup()}
/>; />;
break; break;
case showPage[9]: case showPage[9]:
...@@ -446,6 +463,7 @@ class PageContainer extends React.Component { ...@@ -446,6 +463,7 @@ class PageContainer extends React.Component {
userInfo={state.userInfo} userInfo={state.userInfo}
changePages={(data)=>this.changePages(data)} changePages={(data)=>this.changePages(data)}
showOpenDoorPage={()=>this.showOpenDoorPage.bind(this)()} showOpenDoorPage={()=>this.showOpenDoorPage.bind(this)()}
hidePopup={()=>this.hidePopup()}
/>; />;
break; break;
} }
......
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