actionCreators.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import * as constants from './constants';
  2. import { fromJS } from 'immutable';
  3. import * as config from '../../../common/config.js';
  4. import axios from '../../../common/axios_auth.js';
  5. import qs from 'qs';
  6. //获得公司详情
  7. export const getCompanyDetail = (key,error) => {
  8. return (dispatch) => {
  9. axios.get(config.CLD2API + '/contact/companyDetail/'+key).then((res) => {
  10. const data = res.data;
  11. if (data.code === 200) {
  12. dispatch({
  13. type: constants.CHANGE_COMPANY_DETAIL,
  14. data: data.data,
  15. });
  16. } else {
  17. error('公司详情请求失败');
  18. }
  19. }).catch((e) => {
  20. error('公司详情请求失败');
  21. })
  22. }
  23. };
  24. //loading
  25. export const changeLoading = () => {
  26. return (dispatch) => {
  27. dispatch({
  28. type: constants.CHANGE_COMPANYDETAIL_LOADING,
  29. data: true,
  30. });
  31. }
  32. }
  33. //
  34. export const modifyCompany = (name,value,title,error) => {
  35. return (dispatch) => {
  36. let data = {
  37. 'field':name,
  38. 'value': value,
  39. };
  40. axios.post(config.CLD2API + '/contact/modifyCompany', qs.stringify(data)).then((res) => {
  41. const data = res.data;
  42. if (data.code === 200) {
  43. // dispatch({
  44. // type: constants.CHANGE_COMPANY_DETAIL,
  45. // data: data.data,
  46. // });
  47. } else {
  48. error(`更新${title}失败`);
  49. }
  50. }).catch((e) => {
  51. error(`更新${title}失败`);
  52. })
  53. }
  54. }