Commit adc98325 by wufan

feat:完善axios

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