概要

实现网络图片的本地缓存,支持单个缓存、批量缓存;支持保存本地图片、远程图片到相册。

1.setImageWithURL

功能

缓存单张网络图片

定义

IpuMobile.setImageWithURL(imgUrl, refresh, err);

参数

参数名 参数类型 参数描述 参数备注
imgUrl string 远程图片绝对路径 必传
refresh boolean 是否强制下载,为true时不管有没有缓存都从远程下载 选传
err function 执行失败后的回调函数 选传

范例

IpuMobile.setImageWithURL('http://cafe.smallpay.com/xd/media/goods/m_1003/g_940/20151112202854_844.png');
IpuMobile.setImageWithURL('http://cafe.smallpay.com/xd/media/goods/m_1003/g_940/20151112202854_844.png', true);

备注

refresh不传时,默认为不强制下载,有缓存则不从远程下载。

2.setImageWithURLs

功能

批量缓存网络图片

定义

IpuMobile.setImageWithURLs(imgUrls, refresh, err);

参数

参数名 参数类型 参数描述 参数备注
imgUrls array 远程图片数组,元素为远程图片绝对路径 必传
refresh boolean 是否强制下载,为true时不管有没有缓存都从远程下载 选传
err function 执行失败后的回调函数 选传

范例

IpuMobile.setImageWithURLs(['http://cafe.smallpay.com/xd/media/goods/m_1003/g_940/20151112202854_844.png', 'http://cafe.smallpay.com/xd/media/goods/m_1003/g_940/20151112202854_844.png']);
IpuMobile.setImageWithURLs(['http://cafe.smallpay.com/xd/media/goods/m_1003/g_940/20151112202854_844.png', 'http://cafe.smallpay.com/xd/media/goods/m_1003/g_940/20151112202854_844.png'], true);

备注

refresh不传时,默认为不强制下载,有缓存则不从远程下载。

3.clearImageCache

功能

清空本地缓存图片

定义

IpuMobile.clearImageCache();

参数

范例

IpuMobile.clearImageCache()

备注

4.saveImageToAlbum

功能

保存远程图片或本地图片到手机相册

定义

IpuMobile.saveImageToAlbum(imgUrl, err);

参数

参数名 参数类型 参数描述 参数备注
imgUrl string 本地缓存图片路径或远程图片路径 必传
err function 执行失败后的回调函数 选传

范例

IpuMobile.saveImageToAlbum('http://cafe.smallpay.com/xd/media/goods/m_1003/g_940/20151112202854_844.png')
IpuMobile.saveImageToAlbum('file://user/........aaa.png')

备注

远程图片以http://或https://协议开头,本地缓存图片以file://协议开头

Copyright © aiipu.com 2017 all right reserved,powered by Gitbook该文件修订时间: 2020-09-01 15:11:34

results matching ""

    No results matching ""