1***@qq.com
1***@qq.com
  • 发布:2020-11-05 13:47
  • 更新:2020-11-05 13:47
  • 阅读:1591

【报Bug】使用uni.uploadFile上传uni.chooseVideo新拍摄的视频时,nova7手机请求超时并报错uploadFile:fail undefined。华为荣耀可苹果xr则没问题

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: win10

HBuilderX类型: 正式

HBuilderX版本号: 2.9.3

手机系统: Android

手机系统版本号: Android 10

手机厂商: 华为

手机机型: nova7

页面类型: vue

打包方式: 云端

项目创建方式: HBuilderX

App下载地址或H5⽹址: https://service.dcloud.net.cn/build/download/1e717ed0-1e9e-11eb-9f5c-5d94abfd2b96

操作步骤:
uni.chooseVideo({  
                            sourceType: ['camera', 'album'],  
                            success: (res) => {  
                                this.uploads.push(res.tempFilePath)  
                                console.log("视频的res", res)  
                                this.$emit('successVideo', res.tempFilePath)  
                            },  
                            fail: (err) => {  
                                uni.showModal({  
                                    content: JSON.stringify(err)  
                                });  
                            }  
                        });
        // 发布  
                commit(data){  
                console.log("发布数据",data)  
                    if(this.fbdata.summary==''){  
                        uni.showToast({  
                            title: '请输入发布内容',  
                            icon: 'none',  
                            duration: 500  
                        });  
                        return false  
                    }  
                    if( this.tempFilePath!=''){       
                        uni.showLoading({  
                            title: '视频正在上传',  
                            icon: 'loading,  
                            mask: true  
                        });  
                        console.log(baseApi+'/rest/common/oss/upload/video')  
                        console.log(this.tempFilePath)  
                        uni.uploadFile({  
                            url: baseApi+'/rest/common/oss/upload/video', //仅为示例,非真实的接口地址  
                            filePath: this.tempFilePath,  
                            name: 'file',  
                             formData:{  
                             },  
                            success: (res) => {   
                                console.log("上传后的地址",res)  
                            this.fbdata.videoUrl=JSON.parse(res.data).data.url  
                                uni.hideLoading();    

                                    if(this.fbdata.videoUrl==""){  
                                        uni.showToast({  
                                            title: '视频上传失败',  
                                            duration: 500  
                                        });   
                                        return false  
                                    }else{  
                                    uni.showToast({  
                                        title: '视频上传完成',  
                                        duration: 500  
                                    });   
                                }  
                                douhuoedit(data).then(res=>{  
                                    console.log("保存成功",res)  
                                    if(res.data.message="请求成功"){  
                                        uni.showToast({  
                                            title: '发布成功',  
                                            duration: 500  
                                        });  
                                        // this.fbdata={}  
                                        this.fbdata.summary='',  
                                        this.fbdata.location='',  
                                        this.fbdata.title='',  
                                        this.fbdata.productId='',  
                                        this.fbdata.videoUrl='',  
                                        this.videoList=[]  
                                        // uni.navigateTo({  
                                        //  url:'/pages/douhuo/index'  
                                        // })  
                                    }else{  
                                        uni.showToast({  
                                            title: res.data.message,  
                                            duration: 500  
                                        });  
                                    }                                 
                                })  
                            },  
                            fail:(err)=>{  
                                    uni.hideLoading();    
                                    uni.showToast({  
                                        title: "上传失败",  
                                        duration: 500  
                                    });  
                                console.log("上传失败",err)  
                            }  

                        });   

                    }else{  
                        uni.showToast({  
                            title: '请选择要上传的视频',  
                            duration: 500  
                        });  
                            return false  
                    }     

                }

预期结果:

执行uni.uploadFile成功回调

实际结果:

一直到请求超时才返回fail回调,显示什么 uni uploadFile:fail undefined

bug描述:

上传图标组件

uni.chooseVideo({  
                            sourceType: ['camera', 'album'],  
                            success: (res) => {  
                                this.uploads.push(res.tempFilePath)  
                                console.log("视频的res", res)  
                                this.$emit('successVideo', res.tempFilePath)  
                            },  
                            fail: (err) => {  
                                uni.showModal({  
                                    content: JSON.stringify(err)  
                                });  
                            }  
                        });

上传页面组件

        // 发布  
                commit(data){  
                console.log("发布数据",data)  
                    if(this.fbdata.summary==''){  
                        uni.showToast({  
                            title: '请输入发布内容',  
                            icon: 'none',  
                            duration: 500  
                        });  
                        return false  
                    }  
                    if( this.tempFilePath!=''){       
                        uni.showLoading({  
                            title: '视频正在上传',  
                            icon: 'loading,  
                            mask: true  
                        });  
                        console.log(baseApi+'/rest/common/oss/upload/video')  
                        console.log(this.tempFilePath)  
                        uni.uploadFile({  
                            url: baseApi+'/rest/common/oss/upload/video', //仅为示例,非真实的接口地址  
                            filePath: this.tempFilePath,  
                            name: 'file',  
                             formData:{  
                             },  
                            success: (res) => {   
                                console.log("上传后的地址",res)  
                            this.fbdata.videoUrl=JSON.parse(res.data).data.url  
                                uni.hideLoading();    

                                    if(this.fbdata.videoUrl==""){  
                                        uni.showToast({  
                                            title: '视频上传失败',  
                                            duration: 500  
                                        });   
                                        return false  
                                    }else{  
                                    uni.showToast({  
                                        title: '视频上传完成',  
                                        duration: 500  
                                    });   
                                }  
                                douhuoedit(data).then(res=>{  
                                    console.log("保存成功",res)  
                                    if(res.data.message="请求成功"){  
                                        uni.showToast({  
                                            title: '发布成功',  
                                            duration: 500  
                                        });  
                                        // this.fbdata={}  
                                        this.fbdata.summary='',  
                                        this.fbdata.location='',  
                                        this.fbdata.title='',  
                                        this.fbdata.productId='',  
                                        this.fbdata.videoUrl='',  
                                        this.videoList=[]  
                                        // uni.navigateTo({  
                                        //  url:'/pages/douhuo/index'  
                                        // })  
                                    }else{  
                                        uni.showToast({  
                                            title: res.data.message,  
                                            duration: 500  
                                        });  
                                    }                                 
                                })  
                            },  
                            fail:(err)=>{  
                                    uni.hideLoading();    
                                    uni.showToast({  
                                        title: "上传失败",  
                                        duration: 500  
                                    });  
                                console.log("上传失败",err)  
                            }  

                        });   

                    }else{  
                        uni.showToast({  
                            title: '请选择要上传的视频',  
                            duration: 500  
                        });  
                            return false  
                    }     

                }
2020-11-05 13:47 负责人:无 分享
已邀请:

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