import { getImgUrl } from '/@/api/dataAdmin/assembly';
import { img } from '/@/api/resource/plat';




//获取图片
function reqGetImg(i, d) {
    if (i) {
        var arr = i.split(',')
        arr.length > 1 && getImgUrl(arr[0], arr[1]).then(r => d.src = r)
    }
}


function setHtmlImg(j, n) {
    img(j.SERVICEID).then(r => {
        if (r && r.length) {
            var i = r[0];
            var dom = document.getElementById(`${i.serviceid}${n}`)
            if (i.thumbnail.indexOf(",") > -1) {
                if (i.thumbnail.indexOf("base64") > -1) {
                    dom.src = i.thumbnail ? i.thumbnail : './static/img/default-dr3.jpg';
                } else {
                    reqGetImg(i.thumbnail, dom)
                }
            } else {
                var uri = "http://192.168.119.143:8080/onemapV5.0/";
                dom.src = i.thumbnail ? (uri + i.thumbnail) : './static/img/default-dr3.jpg';
            }
        }
    })
}



export {
    reqGetImg,
    setHtmlImg,
}