Commit fe082724 by Denglingling

统一封装接口错误提示

parent fa026b12
import { PostRequest,GetRequest } from '../network/RequestUtils';
import { show, getUrlParams } from '../utils/Utils';
import { show, getUrlParams, showWarnErrorMessage, showErrorMessage } from '../utils/Utils';
import {
DEVICE_INFORMATION_UPDATE_DOING,
DEVICE_INFORMATION_UPDATE_SUCCESS,
......@@ -14,22 +14,27 @@ export function updateDeviceStatus({access_token, ...params}) {
let {global_domain_config} = getState().login
PostRequest(global_domain_config, getUrlParams('/hardware_control/door_control', {access_token: access_token}), params)
.then(res => {
console.log('门禁管理-修改状态 res=====', res);
if(res.error_code == 0) {
show(`${params.data.message}`);
dispatch(requestUpdateSuccess());
} else if(res.error_code === 41006) {
show('登录过期,请重新登录');
dispatch(exitLoginStatus());
} else {
let error_msg = res.error_msg || res.message
show(error_msg);
dispatch(requestUpdateFail());
}else {
showWarnErrorMessage(dispatch, res, exitLoginStatus, requestUpdateFail)
}
// else if(res.error_code === 41006) {
// show('登录过期,请重新登录');
// dispatch(exitLoginStatus());
// } else {
// let error_msg = res.error_msg || res.message
// show(error_msg);
// dispatch(requestUpdateFail());
// }
})
.catch(err => {
console.log('------err--====updateDeviceStatus----', Object.keys(err), err)
show(err.error);
dispatch(requestUpdateFail());
showErrorMessage(dispatch, err, requestUpdateFail, '门禁管理-修改状态')
// console.log('------err--====updateDeviceStatus----', Object.keys(err), err)
// show(err.error);
// dispatch(requestUpdateFail());
})
}
}
......
import { PostRequest, GetRequest, UploadRequest } from '../network/RequestUtils';
import { show, getUrlParams } from '../utils/Utils';
import { show, getUrlParams, showWarnErrorMessage, showErrorMessage } from '../utils/Utils';
import { exitLoginStatus } from './LoginAction';
import {
EQUIP_CONSU_LIST_DOING,
......@@ -25,23 +25,31 @@ export function requestEquipOrganizations(params) {
if(res.error_code == 0) {
let { data: { organizations } } = res
dispatch(requestListDataSuccess(organizations));
} else if(res.error_code === 41006) {
show('登录过期,请重新登录');
dispatch(exitLoginStatus());
} else {
let error_msg = res.error_msg || res.message
show(error_msg);
dispatch(requestListDataFail());
}
}else {
showWarnErrorMessage(dispatch, res, exitLoginStatus, requestListDataFail)
}
// else if(res.error_code === 41006) {
// show('登录过期,请重新登录');
// dispatch(exitLoginStatus());
// } else {
// let error_msg = res.error_msg || res.message
// show(error_msg);
// dispatch(requestListDataFail());
// }
})
.catch(err => {
console.log('------err--====requestEquipOrganizations----', Object.keys(err), err)
show(err.error);
dispatch(requestListDataFail());
showErrorMessage(dispatch, err, requestListDataFail, '获取组织')
// console.log('------err--====requestEquipOrganizations----', Object.keys(err), err)
// show(err.error);
// dispatch(requestListDataFail());
})
}
}
export const reqEquipOrganizations = async (global_domain_config, params) => {
return await GetRequest(global_domain_config, getUrlParams('/authorized_inventory/search', params))
}
// 获取客户名称 params={access_token:'', org_code:'', seller_code:''}
export function requestEquipSurgeryHospital(params) {
return (dispatch, getState) => {
......@@ -53,19 +61,23 @@ export function requestEquipSurgeryHospital(params) {
if(res.error_code == 0) {
let { data: { customers } } = res
dispatch(requestListDataSuccess(customers));
} else if(res.error_code === 41006) {
show('登录过期,请重新登录');
dispatch(exitLoginStatus());
} else {
let error_msg = res.error_msg || res.message
show(error_msg);
dispatch(requestListDataFail());
}
}else {
showWarnErrorMessage(dispatch, res, exitLoginStatus, requestListDataFail)
}
// else if(res.error_code === 41006) {
// show('登录过期,请重新登录');
// dispatch(exitLoginStatus());
// } else {
// let error_msg = res.error_msg || res.message
// show(error_msg);
// dispatch(requestListDataFail());
// }
})
.catch(err => {
console.log('------err--====requestEquipSurgeryHospital----', Object.keys(err), err)
show(err.error);
dispatch(requestListDataFail());
showErrorMessage(dispatch, err, requestListDataFail, '获取客户名称')
// console.log('------err--====requestEquipSurgeryHospital----', Object.keys(err), err)
// show(err.error);
// dispatch(requestListDataFail());
})
}
}
......@@ -84,20 +96,27 @@ export function requestEquipOrderInfo(params) {
console.log('获取订单信息 res=====', res)
if(res.error_code == 0) {
let { data: { surgery_collect_headers } } = res
dispatch(requestListDataSuccess(surgery_collect_headers));
} else if(res.error_code === 41006) {
show('登录过期,请重新登录');
dispatch(exitLoginStatus());
} else {
let error_msg = res.error_msg || res.message
show(error_msg);
dispatch(requestListDataFail());
if(surgery_collect_headers && surgery_collect_headers.length > 0){
surgery_collect_headers.sort((obj_1, obj_2) => obj_2.collect_number === obj_1.collect_number ? 0 : (obj_2.collect_number > obj_1.collect_number ? 1 : -1))
}
dispatch(requestListDataSuccess(surgery_collect_headers));
}else {
showWarnErrorMessage(dispatch, res, exitLoginStatus, requestListDataFail)
}
// else if(res.error_code === 41006) {
// show('登录过期,请重新登录');
// dispatch(exitLoginStatus());
// } else {
// let error_msg = res.error_msg || res.message
// show(error_msg);
// dispatch(requestListDataFail());
// }
})
.catch(err => {
console.log('------err--====requestEquipOrderInfo----', Object.keys(err), err)
show(err.error);
dispatch(requestListDataFail());
showErrorMessage(dispatch, err, requestListDataFail, '获取订单信息')
// console.log('------err--====requestEquipOrderInfo----', Object.keys(err), err)
// show(err.error);
// dispatch(requestListDataFail());
})
}
}
......@@ -162,19 +181,23 @@ export function requestEquipSumbit({access_token, ...params}) {
console.log('提交数据 res=====', res)
if(res.error_code == 0) {
dispatch(requestSubmitSuccess(res));
} else if(res.error_code === 41006) {
show('登录过期,请重新登录');
dispatch(exitLoginStatus());
} else {
let error_msg = res.error_msg || res.message
show(error_msg);
dispatch(requestSubmitFail());
}
}else {
showWarnErrorMessage(dispatch, res, exitLoginStatus, requestSubmitFail)
}
// else if(res.error_code === 41006) {
// show('登录过期,请重新登录');
// dispatch(exitLoginStatus());
// } else {
// let error_msg = res.error_msg || res.message
// show(error_msg);
// dispatch(requestSubmitFail());
// }
})
.catch(err => {
console.log('------err--====requestEquipSumbit----', Object.keys(err), err)
show(err.error);
dispatch(requestSubmitFail());
showErrorMessage(dispatch, err, requestSubmitFail, '提交数据')
// console.log('------err--====requestEquipSumbit----', Object.keys(err), err)
// show(err.error);
// dispatch(requestSubmitFail());
})
}
}
......
import { PostRequest,GetRequest } from '../network/RequestUtils';
import { show, getUrlParams } from '../utils/Utils';
import { show, getUrlParams, showWarnErrorMessage, showErrorMessage } from '../utils/Utils';
import {
HISTOR_ORDER_SEARCH_DOING,
HISTOR_ORDER_SEARCH_SUCCESS,
......@@ -44,22 +44,30 @@ export function requestGetAllBorrow(params) {
let {global_domain_config} = getState().login
GetRequest(global_domain_config, getUrlParams('/surgery/collect_order/search', params))
.then(res => {
console.log('借货订单查询 res=====', res)
if(res.error_code == 0) {
let { data: { surgery_collect_headers } } = res
if(surgery_collect_headers && surgery_collect_headers.length > 0){
surgery_collect_headers.sort((obj_1, obj_2) => obj_2.collect_number === obj_1.collect_number ? 0 : (obj_2.collect_number > obj_1.collect_number ? 1 : -1))
}
dispatch(requestSearchSuccess(surgery_collect_headers));
} else if(res.error_code === 41006) {
show('登录过期,请重新登录');
dispatch(exitLoginStatus());
} else {
let error_msg = res.error_msg || res.message
show(error_msg);
dispatch(requestSearchFail());
}else {
showWarnErrorMessage(dispatch, res, exitLoginStatus, requestSearchFail)
}
// else if(res.error_code === 41006) {
// show('登录过期,请重新登录');
// dispatch(exitLoginStatus());
// } else {
// let error_msg = res.error_msg || res.message
// show(error_msg);
// dispatch(requestSearchFail());
// }
})
.catch(err => {
console.log('------err--====requestGetAllBorrow----', Object.keys(err), err)
show(err.error);
dispatch(requestSearchFail());
showErrorMessage(dispatch, err, requestSearchFail, '借货订单查询')
// console.log('------err--====requestGetAllBorrow----', Object.keys(err), err)
// show(err.error);
// dispatch(requestSearchFail());
})
}
}
......@@ -76,22 +84,27 @@ export function requestGetAllConsume(params) {
let {global_domain_config} = getState().login
GetRequest(global_domain_config, getUrlParams('/surgery/consume_header/search', params))
.then(res => {
console.log('消耗订单查询 res=====', res)
if(res.error_code == 0) {
let { data: { sur_consume_headers } } = res
dispatch(requestSearchSuccess(sur_consume_headers));
} else if(res.error_code === 41006) {
show('登录过期,请重新登录');
dispatch(exitLoginStatus());
} else {
let error_msg = res.error_msg || res.message
show(error_msg);
dispatch(requestSearchFail());
}else {
showWarnErrorMessage(dispatch, res, exitLoginStatus, requestSearchFail)
}
// else if(res.error_code === 41006) {
// show('登录过期,请重新登录');
// dispatch(exitLoginStatus());
// } else {
// let error_msg = res.error_msg || res.message
// show(error_msg);
// dispatch(requestSearchFail());
// }
})
.catch(err => {
console.log('------err--====requestGetAllConsume----', Object.keys(err), err)
show(err.error);
dispatch(requestSearchFail());
showErrorMessage(dispatch, err, requestSearchFail, '消耗订单查询')
// console.log('------err--====requestGetAllConsume----', Object.keys(err), err)
// show(err.error);
// dispatch(requestSearchFail());
})
}
}
......@@ -108,23 +121,28 @@ export function requestGetAllTrans(params) {
let {global_domain_config} = getState().login
GetRequest(global_domain_config, getUrlParams('/surgery/trans_header/search', params))
.then(res => {
console.log('转单订单查询 res=====', res)
if(res.error_code == 0) {
let { data: { sur_order_transfer_head_chs_v } } = res
let transData = getDuplicateIncreCount(sur_order_transfer_head_chs_v, 'order_number')
dispatch(requestSearchSuccess(transData));
} else if(res.error_code === 41006) {
show('登录过期,请重新登录');
dispatch(exitLoginStatus());
} else {
let error_msg = res.error_msg || res.message
show(error_msg);
dispatch(requestSearchFail());
}else {
showWarnErrorMessage(dispatch, res, exitLoginStatus, requestSearchFail)
}
// else if(res.error_code === 41006) {
// show('登录过期,请重新登录');
// dispatch(exitLoginStatus());
// } else {
// let error_msg = res.error_msg || res.message
// show(error_msg);
// dispatch(requestSearchFail());
// }
})
.catch(err => {
console.log('------err--====requestGetAllTrans----', Object.keys(err), err)
show(err.error);
dispatch(requestSearchFail());
showErrorMessage(dispatch, err, requestSearchFail, '转单订单查询')
// console.log('------err--====requestGetAllTrans----', Object.keys(err), err)
// show(err.error);
// dispatch(requestSearchFail());
})
}
}
......
......@@ -5,10 +5,11 @@ import {
EXIT_LOGIN,
AUTO_LOGIN_SUCCESS,
AUTO_LOGIN_FAILURE,
SET_DOMAIN_CONFIGURATE
SET_DOMAIN_CONFIGURATE,
SET_VERSION_APK
} from '../base/ActionTypes';
import { GetRequest, PostRequest } from '../network/RequestUtils';
import { getUrlParams, show } from '../utils/Utils';
import { getUrlParams, show, showWarnErrorMessage, showErrorMessage } from '../utils/Utils';
export function requestLogin(params) {
return (dispatch, getState) => {
......@@ -24,8 +25,6 @@ export function requestLogin(params) {
show(`当前用户没有菜单权限,\n请联系管理员配置!`)
dispatch(loginFailure())
}
// show('登录成功');
// dispatch(loginSuccess(res, params.data.user_name, params.data.user_password));
}else {
let error_msg = res.error_msg || res.message
if(res.error_code == -3) {
......@@ -35,10 +34,11 @@ export function requestLogin(params) {
dispatch(loginFailure())
}
}).catch((err) => {
let error_msg = err.error || '请求接口错误,请联系管理员'
show(error_msg);
dispatch(loginFailure())
console.error(err)
// let error_msg = err.error || '请求接口错误,请联系管理员'
// show(error_msg);
// dispatch(loginFailure())
// console.error(err)
showErrorMessage(dispatch, err, loginFailure, '登录')
})
}
}
......@@ -95,16 +95,16 @@ export function autoLogin(params) {
show(`当前用户没有菜单权限,\n请联系管理员配置!`)
dispatch(autoLoginFailure())
}
// dispatch(autoLoginSuccess(res))
}else {
console.log(res.error_msg);
show(res.error_msg);
let error_msg = res.error_msg || res.message
show(error_msg);
dispatch(autoLoginFailure())
}
}).catch((err) => {
show(err.error);
dispatch(autoLoginFailure())
console.error(err)
// show(err.error);
// dispatch(autoLoginFailure())
// console.error(err)
showErrorMessage(dispatch, err, autoLoginFailure, '自动登录')
})
}
}
......@@ -125,3 +125,26 @@ export const requestSysProfile = async (global_domain_config, params) => {
export const requestSysValueSet = async (global_domain_config, params) => {
return await GetRequest(global_domain_config, getUrlParams('/system/value_set/search', params))
}
//安卓请求版本信息
export const requestLatestVersion = async (global_domain_config, params) => {
return await GetRequest(global_domain_config, getUrlParams('/getLatestVersion', params))
}
//IOS请求版本信息
export const requestIOSLatestVersion = async () => {
return fetch('https://itunes.apple.com/lookup?bundleId=com.wuji.bonehouse')
.then((response) => response.json())
.then((data) => data)
.catch((error) => {
console.error(error);
return {error_code: -3, error_msg:'请求异常,请重试'}
});
}
export function setVersionApk(versionApk) {
return {
type: SET_VERSION_APK,
local_version_apk: versionApk
}
}
import { PostRequest, GetRequest, UploadRequest } from '../network/RequestUtils';
import { show, getUrlParams } from '../utils/Utils';
import { show, getUrlParams, showWarnErrorMessage, showErrorMessage } from '../utils/Utils';
import { exitLoginStatus } from './LoginAction';
import {
TRANS_ORDER_LIST_DOING,
......@@ -19,26 +19,35 @@ export function requestTransOrganizations(params) {
let { global_domain_config } = getState().login
GetRequest(global_domain_config, getUrlParams('/authorized_inventory/search', params))
.then(res => {
console.log('获取组织 res=====', res);
if(res.error_code == 0) {
let { data: { organizations } } = res
dispatch(requestListDataSuccess(organizations));
} else if(res.error_code === 41006) {
show('登录过期,请重新登录');
dispatch(exitLoginStatus());
} else {
let error_msg = res.error_msg || res.message
show(error_msg);
dispatch(requestListDataFail());
}
}else {
showWarnErrorMessage(dispatch, res, exitLoginStatus, requestListDataFail)
}
// else if(res.error_code === 41006) {
// show('登录过期,请重新登录');
// dispatch(exitLoginStatus());
// } else {
// let error_msg = res.error_msg || res.message
// show(error_msg);
// dispatch(requestListDataFail());
// }
})
.catch(err => {
console.log('------err--====requestTransOrganizations----', Object.keys(err), err)
show(err.error);
dispatch(requestListDataFail());
showErrorMessage(dispatch, err, requestListDataFail, '获取组织')
// console.log('------err--====requestTransOrganizations----', Object.keys(err), err)
// show(err.error);
// dispatch(requestListDataFail());
})
}
}
export const reqTransOrganizations = async (global_domain_config, params) => {
return await GetRequest(global_domain_config, getUrlParams('/authorized_inventory/search', params))
}
// 获取客户名称 params={access_token:'', org_code:'', seller_code:''}
export function requestTransSurgeryHospital(params) {
return (dispatch, getState) => {
......@@ -46,22 +55,27 @@ export function requestTransSurgeryHospital(params) {
let { global_domain_config } = getState().login
GetRequest(global_domain_config, getUrlParams('/sale/seller_customer/search', params))
.then(res => {
console.log('获取客户名称 res=====', res);
if(res.error_code == 0) {
let { data: { customers } } = res
dispatch(requestListDataSuccess(customers));
} else if(res.error_code === 41006) {
show('登录过期,请重新登录');
dispatch(exitLoginStatus());
} else {
let error_msg = res.error_msg || res.message
show(error_msg);
dispatch(requestListDataFail());
}
}else {
showWarnErrorMessage(dispatch, res, exitLoginStatus, requestListDataFail)
}
// else if(res.error_code === 41006) {
// show('登录过期,请重新登录');
// dispatch(exitLoginStatus());
// } else {
// let error_msg = res.error_msg || res.message
// show(error_msg);
// dispatch(requestListDataFail());
// }
})
.catch(err => {
console.log('------err--====requestTransSurgeryHospital----', Object.keys(err), err)
show(err.error);
dispatch(requestListDataFail());
showErrorMessage(dispatch, err, requestListDataFail, '获取客户名称')
// console.log('------err--====requestTransSurgeryHospital----', Object.keys(err), err)
// show(err.error);
// dispatch(requestListDataFail());
})
}
}
......@@ -77,30 +91,34 @@ export function requestTransTargetOrderInfo(params) {
let { global_domain_config } = getState().login
GetRequest(global_domain_config, getUrlParams('/surgery/collect_order/search', params))
.then(res => {
console.log('获取目标订单信息 res=====', res);
if(res.error_code == 0) {
let { data: { surgery_collect_headers } } = res
dispatch(requestListDataSuccess(surgery_collect_headers));
} else if(res.error_code === 41006) {
show('登录过期,请重新登录');
dispatch(exitLoginStatus());
} else {
let error_msg = res.error_msg || res.message
show(error_msg);
dispatch(requestListDataFail());
if(surgery_collect_headers && surgery_collect_headers.length > 0){
surgery_collect_headers.sort((obj_1, obj_2) => obj_2.collect_number === obj_1.collect_number ? 0 : (obj_2.collect_number > obj_1.collect_number ? 1 : -1))
}
dispatch(requestListDataSuccess(surgery_collect_headers));
}else {
showWarnErrorMessage(dispatch, res, exitLoginStatus, requestListDataFail)
}
// else if(res.error_code === 41006) {
// show('登录过期,请重新登录');
// dispatch(exitLoginStatus());
// } else {
// let error_msg = res.error_msg || res.message
// show(error_msg);
// dispatch(requestListDataFail());
// }
})
.catch(err => {
console.log('------err--====requestTransTargetOrderInfo----', Object.keys(err), err)
show(err.error);
dispatch(requestListDataFail());
showErrorMessage(dispatch, err, requestListDataFail, '获取目标订单信息')
// console.log('------err--====requestTransTargetOrderInfo----', Object.keys(err), err)
// show(err.error);
// dispatch(requestListDataFail());
})
}
}
export const reqTransTargetOrderInfo = async (global_domain_config, params) => {
return await GetRequest(global_domain_config, getUrlParams('/surgery/collect_order/search', params))
}
function requestListDataing() {
return {
type: TRANS_ORDER_LIST_DOING
......@@ -170,22 +188,26 @@ export function requestTransSumbit({access_token, ...params}) {
console.log('params--------', params)
PostRequest(global_domain_config, getUrlParams('/transferSurOrder/sur_order_transfer/create', {access_token: access_token}), params)
.then(res => {
console.log('requestTransSumbit === res--------', res)
console.log('提交数据 res=====', res)
if(res.error_code == 0) {
dispatch(requestSubmitSuccess(res));
} else if(res.error_code === 41006) {
show('登录过期,请重新登录');
dispatch(exitLoginStatus());
} else {
let error_msg = res.error_msg || res.message
show(error_msg);
dispatch(requestSubmitFail());
}
}else {
showWarnErrorMessage(dispatch, res, exitLoginStatus, requestSubmitFail)
}
// else if(res.error_code === 41006) {
// show('登录过期,请重新登录');
// dispatch(exitLoginStatus());
// } else {
// let error_msg = res.error_msg || res.message
// show(error_msg);
// dispatch(requestSubmitFail());
// }
})
.catch(err => {
console.log('------err--====requestTransSumbit----', Object.keys(err), err)
show(err.error);
dispatch(requestSubmitFail());
showErrorMessage(dispatch, err, requestSubmitFail, '获取目标订单信息')
// console.log('------err--====requestTransSumbit----', Object.keys(err), err)
// show(err.error);
// dispatch(requestSubmitFail());
})
}
}
......
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 sign in to comment