Commit adc98325 by wufan

feat:完善axios

parent 3742cffc
/* /*
* @Author: 吴文洁 * @Author: 吴文洁
* @Date: 2020-08-31 09:34:31 * @Date: 2020-08-31 09:34:31
* @LastEditors: 吴文洁 * @LastEditors: wufan
* @LastEditTime: 2020-08-31 09:35:36 * @LastEditTime: 2020-12-01 15:25:04
* @Description: * @Description:
* @Copyright: 杭州杰竞科技有限公司 版权所有 * @Copyright: 杭州杰竞科技有限公司 版权所有
*/ */
...@@ -32,28 +32,19 @@ class Axios { ...@@ -32,28 +32,19 @@ class Axios {
params: any, params: any,
options: FetchOptions = { requestType: 'json' } options: FetchOptions = { requestType: 'json' }
): Promise<any> { ): Promise<any> {
const _url = `${url}?p=w&v=v${VERSION}&userType=${USER_TYPE}&token=${User.getToken()}&uid=${User.getUid()}&tid=${User.getTid()}&aid=${User.getAid()}`; const _url = `${url}?storeId=${USER_TYPE}&token=${User.getToken()}&storeUserId=${User.getStoreUserId()}&userId=${User.getUserId()}}`;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const { NewVersion = "5.0", currentUserInstInfo } = window;
// const { instId } = currentUserInstInfo;
const instance: AxiosInstance = axios.create({ const instance: AxiosInstance = axios.create({
timeout: TIME_OUT, timeout: TIME_OUT,
responseType: 'json', responseType: 'json',
headers: { headers: {
instId: '123', storeId: User.getStoreId(),
p: 'w', storeUserId: User.getStoreUserId(),
v: 'VERSION', userId: User.getUserId(),
vn: `v${VERSION}`,
project: PROJECT,
userType: USER_TYPE,
cid: User.getCid(),
uid: User.getUid(),
tid: User.getTid(),
token: User.getToken(), token: User.getToken(),
bizAccountId: User.getAid(), product: "xmCloudClass",
xmVersion: NewVersion ? '5.0' : '4.0', 'Content-Type': options.requestType === 'form' ? 'application/x-www-form-urlencoded' : 'application/json; charset=UTF-8',
'Content-Type': options.requestType === 'json' ? 'application/json; charset=UTF-8' : 'application/x-www-form-urlencoded',
} }
}); });
......
/* /*
* @Author: 吴文洁 * @Author: 吴文洁
* @Date: 2020-08-31 09:34:51 * @Date: 2020-08-31 09:34:51
* @LastEditors: 吴文洁 * @LastEditors: wufan
* @LastEditTime: 2020-08-31 09:35:25 * @LastEditTime: 2020-12-01 15:25:58
* @Description: * @Description:
* @Copyright: 杭州杰竞科技有限公司 版权所有 * @Copyright: 杭州杰竞科技有限公司 版权所有
*/ */
...@@ -19,23 +19,21 @@ class Service { ...@@ -19,23 +19,21 @@ class Service {
return Axios.post('POST', `apollo/${url}`, params, option); return Axios.post('POST', `apollo/${url}`, params, option);
} }
static Hades(url: string, params: any, option?: any) {
return Axios.post('POST', `hades/${url}`, params, option);
}
static Sales(url: string, params: any, option: any) { static Sales(url: string, params: any, option: any) {
return Axios.post('POST', `sales/${url}`, params, option); return Axios.post('POST', `sales/${url}`, params, option);
} }
static post(url: string, params: any, option: any) { static postJSON(url: string, params: any, option: any) {
return Axios.post('POST', url, params, option); return Axios.post('POST', url, params, option);
} }
static MFS(url: string, params: any, option: any) { static MFS(url: string, params: any, option: any) {
return Axios.post('POST', `mfs/${url}`, params, option); return Axios.post('POST', `mfs/${url}`, params, option);
} }
static postJSON(url: string, params: any, option: any) {
option = option || {};
option.contentType = 'application/json; charset=UTF-8';
return Axios.post('post', url, JSON.stringify(params), option);
}
} }
export default Service; export default Service;
\ No newline at end of file
/* /*
* @Author: 吴文洁 * @Author: 吴文洁
* @Date: 2020-08-31 09:34:25 * @Date: 2020-08-31 09:34:25
* @LastEditors: 吴文洁 * @LastEditors: wufan
* @LastEditTime: 2020-08-31 09:54:34 * @LastEditTime: 2020-12-01 10:36:59
* @Description: * @Description:
* @Copyright: 杭州杰竞科技有限公司 版权所有 * @Copyright: 杭州杰竞科技有限公司 版权所有
*/ */
...@@ -12,20 +12,16 @@ import { PREFIX } from '@/domains/basic-domain/constants'; ...@@ -12,20 +12,16 @@ import { PREFIX } from '@/domains/basic-domain/constants';
class User { class User {
getUid() { getStoreId(){
return Storage.get(`${PREFIX}_uid`) || '1115167164014264433'; return Storage.get(`${PREFIX}_storeId`)
} }
getAid() { getStoreUserId(){
return Storage.get(`${PREFIX}_aid`) || '1298172751712686082'; return Storage.get(`${PREFIX}_storeUserId`)
} }
getTid() { getUserId(){
return Storage.get(`${PREFIX}_tid`) || '1298172751712686082'; return Storage.get(`${PREFIX}_userId`)
}
getCid() {
return Storage.get(`${PREFIX}_cid`);
} }
getToken() { getToken() {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: wufan * @Author: wufan
* @Date: 2020-11-25 18:25:02 * @Date: 2020-11-25 18:25:02
* @LastEditors: wufan * @LastEditors: wufan
* @LastEditTime: 2020-11-30 17:17:17 * @LastEditTime: 2020-12-01 15:26:12
* @Description: Description * @Description: Description
* @@Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有 * @@Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/ */
......
/* /*
* @Author: 陈剑宇 * @Author: 陈剑宇
* @Date: 2020-05-07 14:43:01 * @Date: 2020-05-07 14:43:01
* @LastEditTime: 2020-11-09 09:52:03 * @LastEditTime: 2020-12-01 11:03:11
* @LastEditors: 吴文洁 * @LastEditors: wufan
* @Description: * @Description:
* @FilePath: /wheat-web-demo/src/domains/basic-domain/constants.ts * @FilePath: /wheat-web-demo/src/domains/basic-domain/constants.ts
*/ */
...@@ -24,6 +24,6 @@ export const TIME_OUT: number = 20000; ...@@ -24,6 +24,6 @@ export const TIME_OUT: number = 20000;
export const USER_TYPE: string = 'B'; export const USER_TYPE: string = 'B';
export const PROJECT = 'xmzj-web-b'; export const PROJECT = 'xmzj-web-b';
export const VERSION = '5.4.8'; export const VERSION = '5.4.8';
export const PREFIX = 'xiaomai'; export const PREFIX = 'cloud-class';
// host // host
export const BASIC_HOST: string = BASIC_HOST_MAP[ENV]; export const BASIC_HOST: string = BASIC_HOST_MAP[ENV];
\ No newline at end of file
...@@ -2,22 +2,23 @@ ...@@ -2,22 +2,23 @@
* @Author: 吴文洁 * @Author: 吴文洁
* @Date: 2020-04-27 20:35:34 * @Date: 2020-04-27 20:35:34
* @LastEditors: wufan * @LastEditors: wufan
* @LastEditTime: 2020-11-30 11:02:00 * @LastEditTime: 2020-12-01 15:23:22
* @Description: * @Description:
*/ */
import React from 'react'; import React, { useEffect, useState } from "react";
import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom';
import { HashRouter } from 'react-router-dom'; import { HashRouter } from 'react-router-dom';
import { ConfigProvider } from 'antd'; import { ConfigProvider } from 'antd';
import { createHashHistory } from 'history'; import { createHashHistory } from 'history';
import zh_CN from 'antd/es/locale/zh_CN'; import zh_CN from 'antd/es/locale/zh_CN';
import _ from 'underscore'; import _ from 'underscore';
import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse, AxiosPromise } from 'axios';
import { RootRouter } from './routes/index'; import { RootRouter } from './routes/index';
import 'antd/dist/antd.less'; import 'antd/dist/antd.less';
import '@/common/less/index.less'; import '@/common/less/index.less';
import '@/core/function' import '@/core/function';
import User from '@/common/js/user';
import '@/common/less/index.less'; import '@/common/less/index.less';
const history = createHashHistory(); const history = createHashHistory();
...@@ -39,6 +40,21 @@ window.RCHistory = _.extend({}, history, { ...@@ -39,6 +40,21 @@ window.RCHistory = _.extend({}, history, {
} }
}); });
export async function mount() { export async function mount() {
// useEffect(()=>{
// fetchUserInsts();
// })
// function fetchUserInsts(){
// const userId = User.getUserId();
// axios.post("hades/public/store/getUserStore",{ userId })
// .then((res: any) => {
// const { storeGroupVOS, storeVOS } = res.result;
// })
// }
ReactDOM.render( ReactDOM.render(
<RootRouter/>, <RootRouter/>,
document.getElementById('root')); document.getElementById('root'));
......
...@@ -57,7 +57,7 @@ function EmployeesManagePage() { ...@@ -57,7 +57,7 @@ function EmployeesManagePage() {
const [choosedItem, setChooseItem] = useState({}); const [choosedItem, setChooseItem] = useState({});
useEffect(() => { useEffect(() => {
// getEmployeeList(); getEmployeeList();
}, [query]); }, [query]);
function getEmployeeList() { function getEmployeeList() {
......
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