import md5 from 'js-md5';
export default function useCode(){
    return new Promise((resolve,reject) => {
        const authCallback = (params) => {
            console.log('authCallback-use',params);
            const {code} = params
            resolve(code)
        }
        const getNewAuthorization = () => {
            let appId = import.meta.env.VITE_YCNC_APPID; 
            let time = Date.now().toString();
            let secret = import.meta.env.VITE_YCNC_SECRET; 
            let signBefore = appId + time + secret;
            let sign = md5(signBefore);//普通md5
            let param = {
                appId: appId,
                sign: sign,
                time: time,
                tran_code: "157",
                fn: "authCallback",
                needBind: ""
            };
            console.log('auth-param157-use',param);
            Fw.device.api.getNewAuthorization(param)
        };
        window.authCallback = authCallback;
        getNewAuthorization()
    })
}