var jd = "104.41361653448905";
var wd = "31.127827898122767";
var address = "德阳市公安局";
var appVersion = "1.1.3";
//NFC回调
function setCardInfoByNFC(info, base64) {
    console.log(base64)
    if (info) {
        info = JSON.parse(info)
        info.data.zp = base64;
        window.postMessage({
            data: info,
            type: 'NFC'
        }, '*')
    }
}

// 拍照
function setimage_base64(pzid, base64) {
    if (base64) {
        window.postMessage({
            data: base64,
            type: 'PHOTO'
        }, '*')
    }
}


//存
function setStorage(key, value) {
    try {
        bridge.putString(key, value)
    } catch (error) {
        window.localStorage.setItem(key, value)
    }
}

//取
function getStorage(key) {
    try {
        return bridge.getString(key)
    } catch (error) {
        return window.localStorage.getItem(key)
    }
}

//删
function delteteStorage(key) {
    try {
        bridge.delString(key)
    } catch (error) {
        window.localStorage.removeItem(key)
    }
}

//车牌OCR回调
function setcphm(cphm) {
    window.postMessage({
        data: cphm,
        type: 'cphm'
    }, '*')
}

//车牌颜色OCR回调
function setcpcolor(color) {
    if (color != "蓝") {
        let dm = color == "绿" ? '52' : '01'
        window.postMessage({
            data: dm,
            color: color,
            type: 'color'
        }, '*')

    } else {
        window.postMessage({
            data: '02',
            color: color,
            type: 'color'
        }, '*')
    }
}

//身份证OCR回调
function setCardInfoByOCR(info, base64) {
    window.postMessage({
        data: info,
        type: 'sfzh'
    }, '*')
}

//视频上传成功ID
function setVideoId(id) {
    window.postMessage({
        data: id,
        type: 'videoId'
    }, '*')
}

//获取经纬度
function getLocation() {
    var pgis = {};
    try {
        pgis = JSON.parse(bridge.getLocation()); //手机端
    } catch (error) {
        pgis = {
            lng: jd,
            lat: wd,
            zbly: 1,
        };
    }
    return pgis;
}