找回密码
 立即注册
搜索

开发问题 为什么request.upload接口很慢

3
回复
1273
查看
[复制链接]

1

主题

3

帖子

20

积分

 楼主| 2019-8-1 17:35:19 显示全部楼层 |阅读模式
本帖最后由 worldpeace 于 2019-8-1 17:37 编辑 在手机选一个图片,然后用image.compressImage压缩完,都很快,,, 然后调用request.upload 上传这个压缩完的图片 要持续7,8秒才能上传完成... getPic(type){ let me = this let d = this if(type == 'pick'){ media.pickImage({ success: function(data) { compress(data.uri) }, fail: function (data, code) { console.log(`handling fail, code = ${code}`) } }) }else{ media.takePhoto({ success: function(data) { compress(data.uri) }, fail: function (data, code) { console.log(`handling fail, code = ${code}`) } }) } function compress(uri){ image.getImageInfo({ uri: uri, success: function(data) { console.log(`handling success: size = ${data.size}`) let radioNum = (data.width / 600).toFixed(1) d.debug.push(radioNum) image.compressImage({ uri: uri, quality: 90, radio: radioNum, // 变为原图的1/2大小 format: 'JPEG', success: function(compressData) { d.debug.push("压缩完成:"+ compressData.uri) me.uploadFile(compressData.uri) }, fail: function(data, code) { console.log(`handling fail, code = ${code}`) } }) }, fail: function(data, code) { console.log(`handling fail, code = ${code}`) } }) } }, uploadFile(file){ let me = this let d = this d.isShowPopSelect = false d.isLoading = true request.upload({ url: API.uploadPhotos, method: 'POST', files: [ { uri: file, filename: 'test.jpeg', } ], success: function(res) { let rd = JSON.parse(res.data) let errMsg = false d.isLoading = false let themeId = d.gender == 'female' ? 933 : 1232 if (rd.errorCode == 0 ) { router.push ({ uri: '/Detail?sid='+ rd.photoSids[0]+ '&themeId='+themeId }) }else{ d.isShowPopSelect = true } }, fail: function(data, code) { d.isLoading = false d.debug.push("data-fail") console.log(`handling fail, code = ${code}`) } }) }, 看看有什么问题吗
回复

使用道具 举报

1

主题

3

帖子

20

积分

 楼主| 2019-8-1 17:40:45 显示全部楼层
前边选完图片,压缩都很快....就是到upload里边就特别慢,,,同样的接口在小程序就很快...
回复

使用道具 举报

1

主题

3

帖子

20

积分

 楼主| 2019-8-2 10:38:48 显示全部楼层
没人遇到同样的问题吗....
回复

使用道具 举报

2019-8-6 11:13:25 显示全部楼层
我们也是调用Android系统的接口,可能跟你的网络环境有关。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册