Commit 6e5b2e09 by niuxinyu

关门优化5

parent 4c433538
......@@ -13,7 +13,7 @@ const willCloseDoor=(data,flag=false)=>{
UTILPATH.myLogger.info("finish_task url ",url);
UTILPATH.myLogger.info("finish_task flag ",flag);
UTILPATH.myLogger.info("finish_task request ",bodyData);
console.log('datadata',data)
return async (dispatch)=>{
let success = (json)=>{
UTILPATH.myLogger.info("finish_task response ",json);
......@@ -39,7 +39,7 @@ const willCloseDoor=(data,flag=false)=>{
}).then((response)=>{
if(response.status==200&&response){
return response.json()
response.json()
}else{
var error = new Error(response.statusText)
......@@ -50,6 +50,7 @@ const willCloseDoor=(data,flag=false)=>{
}).catch(()=>{
alert('网络状态不好,请稍后重试')
})
return success(result)
} catch (err) {
......
......@@ -4,7 +4,7 @@ import Button from '../../components/CommonComponent/ButtonComponent/ButtonCompo
import PopModel from '../../components/CommonComponent/PopupComponent/PopupChildComponent'
import {sendMsg} from "../../util/socket";
require('./index.css');
let domain = ENV.domain;
export default class HomePageContainer extends React.Component{
constructor(props){
super(props);
......@@ -65,11 +65,23 @@ export default class HomePageContainer extends React.Component{
}else{
//正常调用
try {
console.log('有网络',this.props.headerInfo.taskInfo.area,this.props.headerInfo.storeInfo.id,this.props.headerInfo.taskInfo.taskId,this.props.headerInfo.taskInfo.currentTaskType,
this.props.headerInfo.userInfo.employeeId
)
this.onConnectionChange()
const { rtt, downlink, effectiveType, saveData } = navigator.connection;
if(rtt<20000){
this.axios.post(domain+'machine_pad/finish_task.action',{
area:this.props.headerInfo.taskInfo.area,
storeId:this.props.headerInfo.storeInfo.id,
taskId:this.props.headerInfo.taskInfo.taskId,
taskType:this.props.headerInfo.taskInfo.currentTaskType,
userId:this.props.headerInfo.userInfo.employeeId
}).then((res)=>{
if(res.status!=200){
var error = new Error(response.statusText)
error.response = response
throw error
}else{
this.props.willCloseDoor().then(()=>{
this.props.endCountBack();
let msg={type:'WILL_CLOSEDOOR'};
......@@ -78,13 +90,30 @@ export default class HomePageContainer extends React.Component{
// this.props.tempLogout()
console.log('有网络',this.props)
})
}else{
}
})
.catch((err)=>{
this.setState({ closeDoorStatus : 0},()=>{
alert('当前网络不佳,请稍后重试'+rtt+'/'+downlink+'/'+effectiveType)
alert('当前网络不佳,请稍后重试')
})
})
}
// this.props.willCloseDoor().then(()=>{
// this.props.endCountBack();
// let msg={type:'WILL_CLOSEDOOR'};
// sendMsg(JSON.stringify(msg));
// this.props.changeIsSend(true);
// // this.props.tempLogout()
// console.log('有网络',this.props)
// })
// }else{
// this.setState({ closeDoorStatus : 0},()=>{
// alert('当前网络不佳,请稍后重试')
// })
// }
} catch (error) {
console.log(error,'cuowu')
......@@ -178,7 +207,7 @@ export default class HomePageContainer extends React.Component{
}
}
11
HomePageContainer.propTypes = {
};
......
......@@ -8,7 +8,9 @@ import thunkMiddleware from 'redux-thunk';
require('./index.css');
import PageContainer from './containers/PageContainer/PageContainer';
const env = process.env.NODE_ENV;
import axios from 'axios'
React.Component.prototype.axios=axios
axios.defaults.withCredentials=true
function activateVendor() {
const logMiddleware = createLogger();
return (
......
......@@ -46,6 +46,7 @@
"webpack-dev-server": "^2.11.2"
},
"dependencies": {
"axios": "^0.19.0",
"cross-env": "^5.2.0",
"react": "^16.4.1",
"react-dom": "^16.4.1",
......
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