import { customerFetch, ResponseDataEntity, oldBaseFetch } from '.';

export class LoginParams {
  /** 登陆标识 */
  code?: string;
  /** 账号 */
  loginAccount?: string;
  /** 密码 */
  password?: string;
}
export const appLogin = (data: LoginParams) =>
  customerFetch({
    url: '/dcxy/wechat/applet/login/',
    method: 'POST',
    data: data,
  });

export const appLogout = () =>
  customerFetch({
    url: '/dcxy/wechat/applet/login/out',
  });

export class PwdParams {
  /** 账号 */
  loginAccount: string;
  /** 密码 */
  password: string;
  /** 验证码 */
  verification: string;
}
export const changePwdByCellphone = (data: PwdParams) =>
  customerFetch({
    url: '/app/customer/forget/pwd',
    method: 'POST',
    data: data,
  });

type RegisiterPramas = {
  code: string;
  areaId: number;
  areaName: string;
  customerName: string;
  customerPhone: string;
  customerSex: string;
  password: string;
  verificationCode: string;
};
// type RegisiterReponseData = {};

export const wxUserRegister = (entity: RegisiterPramas) =>
  oldBaseFetch({
    // url: '/dcxy/wechat/applet/register/',
    url: '/dcxy/api/customer/wxmini/register',
    method: 'POST',
    data: entity,
  });

type perfectionCustomerParams = {
  birthDay?: string;
  customerHead?: string;
  customerId: number;
  customerName: string;
  customerSex: string;
  email?: string;
  entranceDate?: string;
  idCard?: string;
  studentNo?: string;
};

export const perfectionUserInfo = (entity: perfectionCustomerParams) =>
  customerFetch({
    url: '/dcxy/wechat/applet/perfection/customer',
    method: 'POST',
    data: entity,
  });

type CustomerParam = {
  areaId: number;
  areaName: string;
  customerId: number;
  customerName: string;
  customerPhone: string;
  feedbackContent: string;
};
export const fetchFeedback = (entity: CustomerParam) =>
  customerFetch({
    url: '/app/customer/feed/back',
    method: 'POST',
    data: entity,
  });

export const refreshCodeBar = (): Promise<ResponseDataEntity<string>> =>
  customerFetch({
    url: '/dcxy/wechat/applet/flush/idbar',
  });
