/**
 * 和用户相关的调用接口的入口类
 */

import { customHttpUtils } from "@/utils/http/customHttpUtils";
import { toolUtils } from "@/utils/toolUtils";
import { sessionStore } from "@/store/sessionStore";

export class userController {

  static httpBaseUrl = (window as any).__systemConf.admServiceUrl;

  /**
   * 登录
   * @param userName 
   * @param userPass 
   * @returns 
   */
  static async login(userName: string, userPass: string) {
    var httpUrl = toolUtils.getBaseHttpUrl(this.httpBaseUrl, 'auth/account/login');

    let requestMethod = "post";

    var loginConfig = (window as any).__systemConf.loginConfig;
    var paramObj = {
      "phone": userName,
      "passWord": userPass,
      "loginDeviceType": loginConfig.loginDeviceType,
      "loginType": loginConfig.loginType
    };

    let customHttpUtilsInstance = new customHttpUtils();

    let loginResult = await customHttpUtilsInstance.customRequest(
      httpUrl,
      null,
      paramObj,
      requestMethod
    );
    return loginResult;
  };

  static async getUserInfoById() {
    var loginConfig = (window as any).__systemConf.loginConfig;
    let userToken = sessionStore.userToken;

    var httpUrl = toolUtils.getBaseHttpUrl(this.httpBaseUrl, 'auth/login/loginInfo');

    let requestHeaders = {
      "Content-Type": "application/x-www-form-urlencoded",
      token: userToken,
      loginDeviceType: loginConfig.loginDeviceType
    };
    let requestMethod = "post";

    let customHttpUtilsInstance = new customHttpUtils();

    let loginResult = await customHttpUtilsInstance.customRequest(
      httpUrl,
      requestHeaders,
      null,
      requestMethod
    );
    return loginResult;


    return {
      result: 'success',
      content: [{
        userId: userToken,
        userName: 'adm',
        projects: [
          {
            "projectLocalName": "银泰中心",
            "projName": "银泰中心",
            "latitude": "36.5",
            "productLine": "",
            "projectCode": "",
            "detailAddress": "001号",
            "projectLocalID": "1101050031",
            "functionType": "230",
            "partitionAbbr": "银泰中心",
            "projectName": "银泰中心",
            "projectId": "Pj1101050031",
            "liveStatus": "1",
            "longitude": "102.12",
            "totalArea": null,
            "groupCode": "BR"
          },
          {
            "projectLocalName": "博锐尚格",
            "projName": "博锐尚格",
            "latitude": "36.5",
            "productLine": "1",
            "projectCode": "",
            "detailAddress": "北京市海淀区建材城中路27号金隅智造工场N2-3层",
            "projectLocalID": "1101080259",
            "functionType": "230",
            "partitionAbbr": "博锐尚格",
            "projectName": "博锐尚格",
            "projectId": "Pj1101080259",
            "liveStatus": "1",
            "longitude": "102.12",
            "totalArea": null,
            "groupCode": "BR"
          },
          {
            "projectLocalName": "禹数科技公司",
            "projName": "禹数科技公司",
            "latitude": "36.5",
            "productLine": "",
            "projectCode": null,
            "detailAddress": "金隅智造工厂N2楼3层",
            "projectLocalID": "1101101230",
            "functionType": "230",
            "partitionAbbr": "禹数科技公司",
            "projectName": "禹数科技公司",
            "projectId": "Pj1101101230",
            "liveStatus": "1",
            "longitude": "102.12",
            "totalArea": null,
            "groupCode": "BR"
          },
          {
            "projectLocalName": "北京万科半岛广场",
            "projName": "北京万科半岛广场",
            "latitude": "36.5",
            "productLine": "1",
            "projectCode": "",
            "detailAddress": "广阳新路9号院1号楼1-4层（商业部分）",
            "projectLocalID": "1101110003",
            "functionType": "230",
            "partitionAbbr": "北京万科半岛广场",
            "projectName": "北京万科半岛广场",
            "projectId": "Pj1101110003",
            "liveStatus": "1",
            "longitude": "102.12",
            "totalArea": null,
            "groupCode": "BR"
          },
          {
            "projectLocalName": "测试项目1",
            "projName": null,
            "latitude": "36.5",
            "productLine": "",
            "projectCode": "",
            "detailAddress": "",
            "projectLocalID": "1208001",
            "functionType": "200",
            "partitionAbbr": null,
            "projectName": "测试项目1",
            "projectId": "Pj1208001",
            "liveStatus": "1",
            "longitude": "102.12",
            "totalArea": null,
            "groupCode": "BR"
          },
          {
            "projectLocalName": "测试项目2",
            "projName": null,
            "latitude": "36.5",
            "productLine": "",
            "projectCode": null,
            "detailAddress": "",
            "projectLocalID": "1208002",
            "functionType": "200",
            "partitionAbbr": null,
            "projectName": "测试项目2",
            "projectId": "Pj1208002",
            "liveStatus": "0",
            "longitude": "102.12",
            "totalArea": null,
            "groupCode": "BR"
          },
          {
            "projectLocalName": "上海国际航空服务中心",
            "projName": "上海国际航空服务中心",
            "latitude": "36.5",
            "productLine": null,
            "projectCode": null,
            "detailAddress": null,
            "projectLocalID": "3101040002",
            "functionType": "230",
            "partitionAbbr": "上海国际航空服务中心",
            "projectName": "上海国际航空服务中心",
            "projectId": "Pj3101040002",
            "liveStatus": "1",
            "longitude": "102.12",
            "totalArea": null,
            "groupCode": "BR"
          },
          {
            "projectLocalName": "济南印象城",
            "projName": "济南印象城",
            "latitude": "36.5",
            "productLine": "1",
            "projectCode": null,
            "detailAddress": " 花园路136号7号楼（印象城）",
            "projectLocalID": "3701020004",
            "functionType": "230",
            "partitionAbbr": "济南印象城",
            "projectName": "济南印象城",
            "projectId": "Pj3701020004",
            "liveStatus": "1",
            "longitude": "102.12",
            "totalArea": null,
            "groupCode": "BR"
          },
          {
            "projectLocalName": "香港置地约克北郡",
            "projName": "香港置地约克北郡",
            "latitude": "36.5",
            "productLine": "1",
            "projectCode": "",
            "detailAddress": "重庆市渝北区0003项目",
            "projectLocalID": "5001120003",
            "functionType": "230",
            "partitionAbbr": "香港置地约克北郡",
            "projectName": "香港置地约克北郡",
            "projectId": "Pj5001120003",
            "liveStatus": "1",
            "longitude": "102.12",
            "totalArea": null,
            "groupCode": "BR"
          },
          {
            "projectLocalName": "不知道做什么的2",
            "projName": null,
            "latitude": "36.5",
            "productLine": "",
            "projectCode": "",
            "detailAddress": "",
            "projectLocalID": "5555567890",
            "functionType": "230",
            "partitionAbbr": null,
            "projectName": "不知道做什么的2",
            "projectId": "Pj5555567890",
            "liveStatus": "1",
            "longitude": "102.12",
            "totalArea": null,
            "groupCode": "BR"
          },
          {
            "projectLocalName": "不知道做什么的3",
            "projName": null,
            "latitude": "36.5",
            "productLine": "",
            "projectCode": null,
            "detailAddress": "",
            "projectLocalID": "6666667777",
            "functionType": "230",
            "partitionAbbr": null,
            "projectName": "不知道做什么的3",
            "projectId": "Pj6666667777",
            "liveStatus": "1",
            "longitude": "102.12",
            "totalArea": null,
            "groupCode": "BR"
          },
          {
            "projectLocalName": "龙华交付测试项目",
            "projName": "龙华模拟交付",
            "latitude": "36.5",
            "productLine": "",
            "projectCode": null,
            "detailAddress": "",
            "projectLocalID": "8888888801",
            "functionType": "230",
            "partitionAbbr": "龙华模拟交付",
            "projectName": "龙华交付测试项目",
            "projectId": "Pj8888888801",
            "liveStatus": "1",
            "longitude": "102.12",
            "totalArea": null,
            "groupCode": "BR"
          },
          {
            "projectLocalName": "京东测试项目",
            "projName": "京东测试项目",
            "latitude": "36.5",
            "productLine": "",
            "projectCode": null,
            "detailAddress": "",
            "projectLocalID": "9909990002",
            "functionType": "230",
            "partitionAbbr": "京东测试项目",
            "projectName": "京东测试项目",
            "projectId": "Pj9909990002",
            "liveStatus": "1",
            "longitude": "102.12",
            "totalArea": null,
            "groupCode": "BR"
          },
          {
            "projectLocalName": "不知道做什么的4",
            "projName": null,
            "latitude": "36.5",
            "productLine": "",
            "projectCode": "",
            "detailAddress": "",
            "projectLocalID": "9909990003",
            "functionType": "230",
            "partitionAbbr": null,
            "projectName": "不知道做什么的4",
            "projectId": "Pj9909990003",
            "liveStatus": "1",
            "longitude": "102.12",
            "totalArea": null,
            "groupCode": "BR"
          },
          {
            "projectLocalName": "京东本地测试项目",
            "projName": "京东本地测试项目",
            "latitude": "36.5",
            "productLine": "",
            "projectCode": null,
            "detailAddress": "",
            "projectLocalID": "9909990004",
            "functionType": "230",
            "partitionAbbr": "京东本地测试项目",
            "projectName": "京东本地测试项目",
            "projectId": "Pj9909990004",
            "liveStatus": "1",
            "longitude": "102.12",
            "totalArea": null,
            "groupCode": "BR"
          },
          {
            "projectLocalName": "测试003",
            "projName": null,
            "latitude": "39.93",
            "productLine": "",
            "projectCode": null,
            "detailAddress": "",
            "projectLocalID": "test003",
            "functionType": "111",
            "partitionAbbr": null,
            "projectName": "测试003",
            "projectId": "Pj129003",
            "liveStatus": "0",
            "longitude": "116.42",
            "totalArea": null,
            "groupCode": "BR"
          }
        ]
      }],
      reason: ''
    };
  };
}