levi
levi
  • 发布:2016-03-11 11:51
  • 更新:2016-03-15 12:52
  • 阅读:1802

plus.uploader.enumerate 已上传成功的图片,也会在枚举里面读出来,默认说的枚举未上传的任务没用

分类:HTML5+

function onStateChanged(upload, status) {  
    if (upload.state == 4 && status == 200) {  
        // 上传完成  
        console.log("Upload success: " + JSON.stringify(upload));  
        plus.uploader.enumerate(function(t) {  
            console.log("还有"+t.length+"未上传")  
        })  

    }  
}  

我监听上传成功后,去枚举任务列表,全部都显示还没有上传

[LOG] : 一共有2张图片需要上传  
[LOG] : Upload success: {"__UUID__":"uploader161457667916557","url":"http://192.168.1.33:8080/api/uploadfile/uploadPicture?table_name=t_baseinfo&row_id=32&file_name=全景-01-03-02-lazyload","state":4,"options":{"method":"POST"},"uploadedSize":0,"totalSize":1993,"responseText":"","method":"POST","timeout":120,"retry":3,"retryInterval":30,"priority":1,"onCompleted":null,"eventHandlers":{"statechanged":{"type":"statechanged","handles":[null],"capture":false}},"__requestHeaders__":{},"__responseHeaders__":{"Content-Type":"application/json; charset=utf-8","Content-Length":"157","Server":"beegoServer:1.6.0","Date":"Fri, 11 Mar 2016 03:45:14 GMT"},"__noParseResponseHeader__":null,"__cacheReponseHeaders__":{}}  
[LOG] : 还有2未上传  
[LOG] : Upload success: {"__UUID__":"uploader151457667916557","url":"http://192.168.1.33:8080/api/uploadfile/uploadPicture?table_name=t_baseinfo&row_id=32&file_name=全景-01-03-02","state":4,"options":{"method":"POST"},"uploadedSize":391189,"totalSize":391189,"responseText":"","method":"POST","timeout":120,"retry":3,"retryInterval":30,"priority":1,"onCompleted":null,"eventHandlers":{"statechanged":{"type":"statechanged","handles":[null],"capture":false}},"__requestHeaders__":{},"__responseHeaders__":{"Content-Type":"application/json; charset=utf-8","Content-Length":"148","Server":"beegoServer:1.6.0","Date":"Fri, 11 Mar 2016 03:45:14 GMT"},"__noParseResponseHeader__":null,"__cacheReponseHeaders__":{}}  
[LOG] : 还有2未上传
2016-03-11 11:51 负责人:无 分享
已邀请:
DCloud_App_Array

DCloud_App_Array

上面输出的日志中state为4表示已经上传完成了,你说的全部都显示还没有上传的任务状态值是多少?

  • levi (作者)

    plus.uploader.enumerate 回调函数后面还有一个参数。文档说的,这个参数不填的话是默认返回还未上传成功的。但是他是把所有的上传任务都返回了。返回给我上传任务里面state应该都是不为4的吧。

    2016-03-16 10:33

该问题目前已经被锁定, 无法添加新回复