const ZB_SHOP_GLOBAL = {
    commonProperty: {
        dialogZIndex: 50000,
        attrZIndex: 1000,
        fastNavClick: false, 
        shiftDownState: false,
        ctrlDownState: false,
        copyModuleIds: [],
        imagesLoadInfo: {}, 
    },
}
const imageLoad = (url, successCallback, failCallback) => {
    let thisImgInfo = ZB_SHOP_GLOBAL.commonProperty.imagesLoadInfo[url] || null
    if (thisImgInfo) {
        typeof successCallback == 'function' &&
            successCallback(thisImgInfo.width, thisImgInfo.height, url)
    } else {
        let img = new Image()
        img.src = url
        if (img.complete) {
            ZB_SHOP_GLOBAL.commonProperty.imagesLoadInfo[url] = {
                width: img.width,
                height: img.height,
            }
            typeof successCallback == 'function' &&
                successCallback(img.width, img.height, url)
        } else {
            img.onload = function () {
                ZB_SHOP_GLOBAL.commonProperty.imagesLoadInfo[url] = {
                    width: img.width,
                    height: img.height,
                }
                typeof successCallback == 'function' &&
                    successCallback(img.width, img.height, url)
                img.onload = null
            }
            img.onerror = function () {
                typeof failCallback == 'function' && failCallback()
                img.onerror = null
            }
        }
    }
}
export default imageLoad