import {
    request
} from '@/untils/AxiosUtils.js';
import {
    decryptJson
} from '@/untils/authService.js'
import website from "@/config/website";

const authUrl = '/api/jobslink-api/user/user/auth/auth'

// export const findAuth = () => request({
//     url: '/api/jobslink-api/user/user/find',
//     method: 'get'
// });

export const findAuth = async () => {
    try {
        const encrypted = await request({
            url: '/api/jobslink-api/user/user/find',
            method: 'get',
            responseType: 'text', // 接收纯文本密文
        });
        const decryptedStr = decryptJson(encrypted.data);
        return {
            data: JSON.parse(decryptedStr),
        };
    } catch (error) {
        console.error('请求或解密过程中出错:', error);
        return null;
    }
};

export const cheakValue = () => request({
    url: authUrl,
    method: 'post',
    data: {
        cheakvalue: 1,
        bakvalue: 0
    }
});

export const realName = (realName, idNumber) => request({
    url: authUrl,
    method: 'post',
    data: {
        cheakvalue: 2,
        realName,
        idNumber
    }
});

export const bank = (bankName, realName, cardNumber, def, id) => request({
    url: authUrl,
    method: 'post',
    data: {
        cheakvalue: 3,
        bankName,
        cardNumber,
        realName,
        def,
        id
    }
});

export const insure = (bakvalue) => request({
    url: authUrl,
    method: 'post',
    data: {
        cheakvalue: 4,
        bakvalue
    }
});
// 判断当前用户是否采集签名
export const isGather = () => request({
    url: "/api/jobslink-api/doc/docUserSeal/isGather",
    method: 'get',
});
// 个人端签名采集
export const signGather = (signSrcUrl, password, confirmPassword) => request({
    url: "/api/jobslink-api/doc/docUserSeal/signGather",
    method: 'post',
    data: {
        signSrcUrl,
        password,
        confirmPassword
    }
});
// 获取短信接口
export const sendValidate = (mobile) => request({
    url: "/api/jobslink-api/doc/docUserCert/resetPass/sendValidate",
    method: 'get',
    data: {
        mobile
    }
});
// 密码重置接口
export const resetPass = (mobile, code, password) => request({
    url: "/api/jobslink-api/doc/docUserCert/resetPass",
    method: 'post',
    headers: {
        'SCaptcha-Key': mobile,
        'SCaptcha-Code': code,
        'password': password
    }
});
// 我的合同
export const contractList = (params) => request({
    url: "/api/jobslink-api/doc/contract/personal/contractList",
    method: 'get',
    data: params
});
// 签名密码  /jobslink-api/doc/docUserCert/checkPass
export const checkPass = (params) => request({
    url: "/api/jobslink-api/doc/docUserCert/checkPass",
    method: 'get',
    data: params
});
// 返回的是base64格式的pdf
export const viewContract = (params) => request({
    url: "/api/jobslink-api/doc/contract/viewContract",
    method: 'get',
    data: params
});

//新实名认证api
export const newCertification = (bakvalue, realName, idNumber, cardNumber, bankCode, def, bankName) => request({
    url: '/api/jobslink-api/user/user/auth/authNew',
    method: 'post',
    data: {
        bakvalue,
        realName,
        idNumber,
        cardNumber,
        bankCode,
        def,
        bankName
    }
});
// 电话联系
export const getPhoneCountNumber = (params) => request({
    url: "/api/jobslink-api/serve/phone",
    method: 'get',
    data: params
});