import {Platform} from 'react-native';
import {useApi} from '@common/api/useApi';
import {loginSchema} from '../../api/loginSchema';

// 使用账号密码登录
// {"changeDevice":false,"enableCert":false,"gxLeader":false,"hasBindFirm":false,"hasFaceDetect":false,"hasPwd":true,"realNameStatus":0,"sessionId":"71979180-62c1-425e-a041-b3158944217c","userId":"99b00468e337456cb0005ad10d6d88da","userType":2}

const useLoginWithPassword = (phone: string, password: string) => {
  return useApi(
    '/am/v3/userCenter/account/pwdlogin',
    'POSTJSON',
    {
      phoneNum: phone,
      pwd: password,
      deviceType: Platform.select({android: '0', ios: '1'}),
    },
    loginSchema,
    {},
  );
};

export {useLoginWithPassword};
