import * as service from '../../services/tos';
import { message } from 'antd';
import { Link, useIntl, connect, Dispatch, history } from 'umi';

import { routerRedux } from 'dva/router'

import { printf } from '@/utils/log';

export default {
  namespace: 'Account',
  state: {
    Data: null,
    Result: null,
    DataSave: null,
    DataSaveDetail:null,
  },

  reducers: {
    returnPage(state, { Data}) {
      return { ...state, Data };
    },
    returnResult(state, { Result}) {
      return { ...state, Result};
    },
    returnDataSave(state, { DataSave }) {
      return {...state,DataSave}
    },
    returnDataSaveDetail(state, { DataSaveDetail }) {
      return {...state,DataSaveDetail}
    },
  },

  effects: {
    
    //标准请求
    *RA({ playload }, { call, put }) {
 
      const resp = yield call(service.RA, playload);
      console.log(resp)
      if (resp.code == 500||resp.error_code!="0000") {     
      }
      if (resp.error_code != "0000") {
        printf(playload, resp)
      }    
      else {      
        switch (playload.index) {
          case 41: {            
            // let Data = resp.data;          
            // yield put({ type: 'returnPage', Data });            
          } break;
          case 42: {
            history.go(-1) 
          } break;
          case 45: {
            let Data = resp;          
            yield put({ type: 'returnPage', Data });    
          } break;
        }
      }
    },

    *ResultClear({ }, { put }) {
      var tmp=null
      yield put({type: 'returnResult', tmp} )
    },

    *SA({ playload }, { call, put }) {
      var DataSave = playload
      yield put({type: 'returnDataSave', DataSave} )
    },

  },

};
