Defined in: src/doc/doc.js:1589
Module: dpzeus

方法

cancelUploadImage

cancelUploadImage
(
  • opt
)
Object

Defined in src/doc/doc.js:1725

取消上传,适用于上传未完成时用户尝试退出当前页面。

参数:

opt Object
opt.success Function

调用成功执行的回调

参数名类型标识描述
opt Object
参数名类型标识描述
success Function

调用成功执行的回调

Returns:

[Object]

Base

Example:

<html>
    <h1>取消上传,适用于上传未完成时用户尝试退出当前页面。</h1>
</html>
<script>
DPZeus.cancelUploadImage({
    success: function(data){
        // 取消上传图片
        alert(JSON.stringify(data));
    },
    error: function(error) {
        alert(JSON.stringify(error));
    }
});
</script>

chooseImage

chooseImage
(
  • opts
)
Object

Defined in src/doc/doc.js:1796

Available since 2.0.0

选择图片
NOTE: 暂时没有实现,后续迭代

参数:

opts Object
opts.type String

图片类型:'gallery'相册, 'camera'相机, ''呼出相机和相册组合

[opts.count=9] Number optional

可选,表示可以选择图片的最大数量,当type:camera时此参数无效。

[opts.ensureUpright=false] Boolean optional

可选,true表示需要在返回前调整图片朝向为正立。

[opts.returnType] String optional

可选,指定返回类型, localId返回本地URL对应的具体图片。 base64:返回base64编码,返回值以data;image/jpeg;base64开头。default: localId

[opts.width] Number optional

可选,表示裁减到指定的宽度

[opts.maxWidth] Number optional

可选,表示裁减到指定的宽度

[opts.height] Number optional

可选,表示裁减到指定的宽度

[opts.maxHeight] Number optional

可选,表示裁减到指定的宽度

[opts.quality] Number optional

可选,指定图片的压缩质量,范围从0~100. 0表示质量最差,100表示原图

opts.success Function

成功回调

参数名类型标识描述
opts Object
参数名类型标识描述
type String

图片类型:'gallery'相册, 'camera'相机, ''呼出相机和相册组合

[count=9] Number optional

可选,表示可以选择图片的最大数量,当type:camera时此参数无效。

[ensureUpright=false] Boolean optional

可选,true表示需要在返回前调整图片朝向为正立。

[returnType] String optional

可选,指定返回类型, localId返回本地URL对应的具体图片。 base64:返回base64编码,返回值以data;image/jpeg;base64开头。default: localId

[width] Number optional

可选,表示裁减到指定的宽度

[maxWidth] Number optional

可选,表示裁减到指定的宽度

[height] Number optional

可选,表示裁减到指定的宽度

[maxHeight] Number optional

可选,表示裁减到指定的宽度

[quality] Number optional

可选,指定图片的压缩质量,范围从0~100. 0表示质量最差,100表示原图

success Function

成功回调

Returns:

[Object]
{
 photoInfos: <Array>// { localId: <String> }
}

Example:

<html>
    <h1>选择图片</h1>
</html>
<script>
DPZeus.chooseImage({
    type: 'gallery', //图片类型:'gallery'相册, 'camera'相机, ''呼出相机和相册组合
    count: 6, //可选,表示可以选择图片的最大数量,当type:camera时此参数无效。default: 9
    ensureUpright: false, // 可选,true表示需要在返回前调整图片朝向为正立。default: false
    returnType: 'localId', //可选,指定返回类型, localId返回本地URL对应的具体图片。 base64:返回base64编码,返回值以data;image/jpeg;base64开头。default: localId
    width: 300, //可选,表示裁减到指定的宽度
    maxWidth: 300, //可选,指定最大宽度,如果原始宽度大于给定数值,则裁减为给定数值
    height: 300, //可选,表示裁减到指定的高度
    maxHeight:300, //可选,指定最大高度,如果原始高度大于给定数值,则裁减为给定数值
    quality: 100, //可选,指定图片的压缩质量,范围从0~100. 0表示质量最差,100表示原图
    success: function(result){
        /*var photos = result.photoInfos // photoInfos是一个对象数组,每个对象包括以下内容
        photos.forEach(function(photo){
            var resource = photo.localId; //返回本地资源id
        });*/
        alert(JSON.stringify(result));
    },
    handle: function (data) {
        alert(JSON.stringify(data));
    },
    fail: function(error){
        alert(JSON.stringify(error));
    }
});
</script>

downloadImage

downloadImage
(
  • opts
)
Object

Defined in src/doc/doc.js:1776

下载图片,下载完成后,图片会出现在用户设备的资源库中

参数:

opts Object
opts.type Integer

0或1,若为1则下载到相册,为0则返回imageData(base64)

opts.imageUrl String

图片地址

opts.success Function
参数名类型标识描述
opts Object
参数名类型标识描述
type Integer

0或1,若为1则下载到相册,为0则返回imageData(base64)

imageUrl String

图片地址

success Function

Returns:

[Object]
{
 imageData: <String>,
}

Example:

<html>
    <h1>下载图片,下载完成后,图片会出现在用户设备的资源库中</h1>
</html>
<script>
DPZeus.downloadImage({
    type: 1,
    imageUrl: "http://p0.meituan.net/ugcpic/399fdac2b46a80ef85315a906504a3d0%40700w_700h_1e_1l%7Cwatermark%3D1%26%26r%3D1%26p%3D9%26x%3D2%26y%3D2%26relative%3D1%26o%3D20",
    success: function(result){
        // log("下载到相册", result);
        alert(JSON.stringify(result));
    },
    fail: function(error){
        alert(JSON.stringify(error));
    }
});
DPZeus.downloadImage({
    type: 0,
    imageUrl: "http://pic18.nipic.com/20111221/8277927_142720680000_2.jpg",
    success: function(result){
//        log(result.imageData);
        alert(JSON.stringify(result));
    },
    fail: function(error){
        alert(JSON.stringify(error));
    }
});
</script>

editPhoto

editPhoto
(
  • opt
  • opt
)
Object

Defined in src/doc/doc.js:1754

更改(删除)图片
注意:点评管家特有的实现
IOS需要特殊参数,可以在相册管理项目里测试

参数:

opt Object
opt Object
opt. Array

图片列表

opt.name String

图片名称

opt.url String

图片地址

opt. Integer

当前所在页,从0开始

opt. Function

调用成功执行的回调

参数名类型标识描述
opt Object
opt Object
参数名类型标识描述
Array

图片列表

name String

图片名称

url String

图片地址

Integer

当前所在页,从0开始

Function

调用成功执行的回调

Returns:

[Object]

Base

Example:

<html>
    <h1>更改(删除)图片</h1>
</html>
<script>
DPZeus.editPhoto({
    albumId: 115963,
    albumType: 1,
    picId: 99629614,
    shopId: 1794790,
//    index: 0,
//    imageList : [
//        {
//            "name" : "url",
//            "url" : "http://pic18.nipic.com/20111221/8277927_142720680000_2.jpg"
//        },
//        {
//            "name" : "url",
//            "url" : "http://p0.meituan.net/ugcpic/399fdac2b46a80ef85315a906504a3d0%40700w_700h_1e_1l%7Cwatermark%3D1%26%26r%3D1%26p%3D9%26x%3D2%26y%3D2%26relative%3D1%26o%3D20"
//        }
//    ],
    success: function(result){
        alert(JSON.stringify(result));
    },
    fail: function(error){
        alert(JSON.stringify(error));
    }
});
</script>

playVoice

playVoice
(
  • opts
)
Object

Defined in src/doc/doc.js:1842

播放本地音频

参数:

opts Object
opts.localId String

本地音频资源Id (必填)

opts.success Function

成功回调

opts.fail Function

失败回调

参数名类型标识描述
opts Object
参数名类型标识描述
localId String

本地音频资源Id (必填)

success Function

成功回调

fail Function

失败回调

Returns:

[Object]

Base

Example:

<html>
<h1>播放本地音频</h1>
</html>
<script>
DPZeus.playVoice({
    localId: '',
    success: function(data){
        alert(JSON.stringify(data));
    },
    fail: function(error){
        alert(JSON.stringify(error));
    }
});
</script>

previewImage

previewImage
(
  • opts
)
Object

Defined in src/doc/doc.js:1825

Available since 2.0.0

预览图片

参数:

opts Object
opts.current String

默认展示的图片

opts.urls Array

相册列表url

opts.success Function

成功回调

参数名类型标识描述
opts Object
参数名类型标识描述
current String

默认展示的图片

urls Array

相册列表url

success Function

成功回调

Returns:

[Object]

Base

Example:

<html>
    <h1>预览图片</h1>
</html>
<script>
DPZeus.previewImage({
    current: 'http://qcloud.dpfile.com/pc/dtd2J85NF5XA9N05fApQev7ClauEcDEfc_zawxZH0SqQWrpyuEjOfC4q9CE3ZmEVF7VyRb1efu_m19nXPmKITg.jpg', //默认展示的图片
    urls: [
        'http://qcloud.dpfile.com/pc/A3mS4yOpuaixLkXLfbLV0w9z6ryEy8Z9GX7n5AY4dNRFTa-JmkT1RTt3v_DleNRIF7VyRb1efu_m19nXPmKITg.jpg',
        'http://qcloud.dpfile.com/pc/kwV_XIl6MXHbzcqzPyH2e0z7WJjAoYApPFzIFJ4p834BUn-Uub6f6-g23P-tPTEbF7VyRb1efu_m19nXPmKITg.jpg' // 相册列表url
    ],
    success: function(data){
        alert(JSON.stringify(data));
    },
    fail: function(error){
        alert(JSON.stringify(error));
    }
});
</script>

reuploadImage

reuploadImage
(
  • opts
)
Object

Defined in src/doc/doc.js:1739

Available since 0.4.6

重新上传图片

参数:

opts Object
opts.originalFileName
opts.originalData
opts.callback Function

callback回调

参数名类型标识描述
opts Object
参数名类型标识描述
originalFileName
originalData
callback Function

callback回调

Returns:

[Object]

Base

showImages

showImages
(
  • opt
)
Object

Defined in src/doc/doc.js:1645

Available since 0.4.7

调用native的图片查看功能展示图片列表

参数:

opt Object
opt.imageList Array

图片列表

opt.imageList.name String 图片名称
opt.imageList.url String 图片地址
opt.editable Boolean

是否可编辑

opt.index Int

当前所在页,从0开始

opt.success Function

删除成功的回调

opt.fail Function

删除失败的回调

参数名类型标识描述
opt Object
参数名类型标识描述
imageList Array

图片列表

参数名类型标识描述
name String
图片名称
url String
图片地址
editable Boolean

是否可编辑

index Int

当前所在页,从0开始

success Function

删除成功的回调

fail Function

删除失败的回调

Returns:

[Object]
{
 name: <String>,
 action: <String>,
}

删除图片时的回调参数属性

Example:

<html>
    <h1>TODO showPhoto 需要合并过来
调用native的图片查看功能展示图片列表</h1>
</html>
<script>
DPZeus.showImages({
    editable : true,
    index : 0,
    imageList : [
        {
            "name" : "url",
            "url" : "http://pic18.nipic.com/20111221/8277927_142720680000_2.jpg"
        },
        {
            "name" : "url",
            "url" : "http://p0.meituan.net/ugcpic/399fdac2b46a80ef85315a906504a3d0%40700w_700h_1e_1l%7Cwatermark%3D1%26%26r%3D1%26p%3D9%26x%3D2%26y%3D2%26relative%3D1%26o%3D20"
        }
    ],
    success: function(result){
        alert(JSON.stringify(result));
    },
    fail: function(error){
        alert(JSON.stringify(error));
    }
});
</script>

showPhoto

showPhoto
(
  • opt
)
Object deprecated

Defined in src/doc/doc.js:1618

Available since 0.2.9

调用native的图片查看功能展示图片
从2.0.0开始转到showImages

参数:

opt Object
opt.name String

图片名称

opt.url String

图片地址

opt.editable Boolean

是否可编辑

opt.success Function
opt.fail Function
参数名类型标识描述
opt Object
参数名类型标识描述
name String

图片名称

url String

图片地址

editable Boolean

是否可编辑

success Function
fail Function

Returns:

[Object]
{
 name: <String>,
 action: <String>,
}

删除图片时的回调参数属性

Example:

<html>
    <h1>调用native的图片查看功能展示图片</h1>
</html>
<script>
DPZeus.showPhoto({
    name:'I am a photo',
    url: "http://p0.meituan.net/ugcpic/399fdac2b46a80ef85315a906504a3d0%40700w_700h_1e_1l%7Cwatermark%3D1%26%26r%3D1%26p%3D9%26x%3D2%26y%3D2%26relative%3D1%26o%3D20",
    editable: true,
    success: function(result){
        alert(JSON.stringify(result));
    },
    fail: function(error){
        alert(JSON.stringify(error));
    }
});
</script>

stopMusic

stopMusic
(
  • opt
)
Object

Defined in src/doc/doc.js:1604

停止音乐播放

参数:

opt Object
opt.success Function

调用成功执行的回调

参数名类型标识描述
opt Object
参数名类型标识描述
success Function

调用成功执行的回调

Returns:

[Object]

Base

Example:

<html>
    <h1>停止音乐播放</h1>
</html>
<script>
DPZeus.stopMusic({
    success: function(data){
        alert(JSON.stringify(data));
    },
    fail: function(error){
        alert(JSON.stringify(error));
    }
});
</script>

uploadImage

uploadImage
(
  • opts
)
Object

Defined in src/doc/doc.js:1673

Available since 0.2.9

选择上传图片
注意: 2.0.0 之后有些新变化, 场景一:选择后立即上传,参数为maxNum,uploadUrl;
场景二:2.0.0 之后支持传入localIds上传选定的资源。
native 端已经兼容两种写法,2.0.0 版本不需要修改。如果需要使用场景二,推荐使用 上传图片

参数:

opts Object
opts.maxNum Number

最大选取的图片数

opts.bucket String

桶名

opts.signatureURL String

签名URL

opts.clientId String

mt上传至指定bucket下时。默认为shaitu

opts.localIds Array

待上传图片的本地资源位置id

opts.success Function

调用成功回调

opts.handle Function

上传成功的回调

opts.fail Function

调用失败回调

参数名类型标识描述
opts Object
参数名类型标识描述
maxNum Number

最大选取的图片数

bucket String

桶名

signatureURL String

签名URL

clientId String

mt上传至指定bucket下时。默认为shaitu

localIds Array

待上传图片的本地资源位置id

success Function

调用成功回调

handle Function

上传成功的回调

fail Function

调用失败回调

Returns:

[Object]
{
 progress: <String>,
}

Example:

<html>
    <h1>选择上传图片</h1>
    <b style="color:red;">注意: 2.0.0 之后有些新变化,
        场景一:选择后立即上传,参数为maxNum,uploadUrl;<br/>
        场景二:2.0.0 之后支持传入localIds上传选定的资源。<br/>
        native 端已经兼容两种写法,2.0.0 版本不需要修改。如果需要使用场景二,推荐使用 <a href='#method_uploadPhoto'>上传图片</a>
    </b>
</html>
<script>
DPZeus.uploadImage({
    maxNum: '5',
    uploadUrl: 'https://apollo.51ping.com/app-visit/attach/upload',
    /*bucket: 'shaitu',
    signatureURL: '',
    clientId: 'shaitu',
    localIds: ['localId1', 'localId2'],*/
    success: function(data){
        alert(JSON.stringify(data));
    },
    handle: function(data){
        if(data && data.progress == 'success'){
            // TODO
        }
        if(data&&data.progress=='start'){
            // TODO
        }
        if(data&&data.progress=='uploading'){
            // TODO
        }
        alert(JSON.stringify(data));
    },
    fail: function(err){
        alert(JSON.stringify(err));
    }
});
</script>

uploadPhoto

uploadPhoto
(
  • opts
)
Object

Defined in src/doc/doc.js:1704

Available since 2.0.0

上传图片
NOTE: 暂时没有实现,后续迭代

参数:

opts Object
opts.bucket String

桶名

opts.signatureURL String

签名URL

opts.localIds Array

待上传图片的本地资源位置id

opts.success Function

调用成功回调

opts.handle Function

上传成功的回调

opts.fail Function

调用失败回调

参数名类型标识描述
opts Object
参数名类型标识描述
bucket String

桶名

signatureURL String

签名URL

localIds Array

待上传图片的本地资源位置id

success Function

调用成功回调

handle Function

上传成功的回调

fail Function

调用失败回调

Returns:

[Object]

Base

Example:

<html>
    <h1>选择上传图片</h1>
    <b>注意: 2.0.0 按照KNB最新的接口实现</b>
</html>
<script>
DPZeus.uploadPhoto({
    bucket: 'shaitu',
    signatureURL: '',
    clientId: 'shaitu',
    localIds: ['localId1', 'localId2'],
    success: function(data){
        alert(JSON.stringify(data));
    },
    handle: function(data){
        if(data && data.progress == 'success'){
            // TODO
        }
        if(data&&data.progress=='start'){
            // TODO
        }
        if(data&&data.progress=='uploading'){
            // TODO
        }
        alert(JSON.stringify(data));
    },
    fail: function(err){
        alert(JSON.stringify(err));
    }
});
</script>