You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
639 B
28 lines
639 B
|
3 years ago
|
function _getServiceAddress () {
|
||
|
|
return window.location.protocol + '//' + window.location.host
|
||
|
|
}
|
||
|
|
|
||
|
|
export function getImageInfo ({
|
||
|
|
src
|
||
|
|
}, callbackId) {
|
||
|
|
const {
|
||
|
|
invokeCallbackHandler: invoke
|
||
|
|
} = UniServiceJSBridge
|
||
|
|
const img = new Image()
|
||
|
|
const realPath = src
|
||
|
|
img.onload = function () {
|
||
|
|
invoke(callbackId, {
|
||
|
|
errMsg: 'getImageInfo:ok',
|
||
|
|
width: img.naturalWidth,
|
||
|
|
height: img.naturalHeight,
|
||
|
|
path: realPath.indexOf('/') === 0 ? _getServiceAddress() + realPath : realPath
|
||
|
|
})
|
||
|
|
}
|
||
|
|
img.onerror = function (e) {
|
||
|
|
invoke(callbackId, {
|
||
|
|
errMsg: 'getImageInfo:fail'
|
||
|
|
})
|
||
|
|
}
|
||
|
|
img.src = src
|
||
|
|
}
|