/**
 * long description for the file
 *
 * @summary 登录
 * @author wu <308822989@qq.com>
 *
 * Created at     : 2018-08-27 14:56:41
 * Last modified  : 2018-08-29 08:51:35
 */

import axios from '@/config/axios.js';
import { setCookie, getCookie, dgTree } from '@/utils/util.js';
import moment from 'moment';
import { proPath, cookieUserId, cookieUserName, cookieTime } from '@/config/config.js';

const actions = {
  //  登录
  login ({ commit, state }, oParam) {
    let res = axios.post(proPath + 'auth/login', oParam, {
      headers: {
        'Content-Type': 'application/x-www-form-urlencoded'
      }
    });
    res.then(res => {
      setCookie(cookieUserId, res.data.user.userCode, cookieTime, '/');
      // 保存用户姓名到cookie
      setCookie(cookieUserName, res.data.user.userName, cookieTime, '/');
    });
    return res;
  }
}

//
export default {
  namespaced: true,
  actions
}
