logwire-wms-ui-test
Version:
运匠科技wms-PDA基础组件库
55 lines (45 loc) • 1.16 kB
JavaScript
/**
@name: 获取图片展示路径
@description: 获取图片展示路径
@author 张文
@date: 2022-01-19
*/
import {imgSrc} from "../api/common/GetImgSrc";
/**
* 获取图片展示路径
* @author 张文
* @date 2022-01-19
* @param {String} strUrl 图片路径集合
* @return {Promise} 返回异步函数,结果为获取到的图片路径
* */
export const GetImgSrc = {
asyncGet(strUrl) {
return new Promise((pres, perr) => {
if (!strUrl) {
pres([])
return
}
const imgArr = strUrl.split('|')
let ossName=[]
for (let i = 0; i <imgArr.length; i++) {
const arr = imgArr[i].split('=')
if (arr[1]){
ossName.push(arr[1])
}
}
Promise.all(
ossName.map(item => {
return imgSrc.get({
objectName: item,
contentType: 'image/' + item.split('.').reverse()[0]
})
})
).then(res => {
let imgUrl = res.map(item => item.downloadSignedUrl)
pres(imgUrl)
}).catch(err => {
perr(err)
})
})
}
}