已解决
ios 小程序调用wx.uploadvideo 遇到的问题?描述 上传视频文件的时候 在微信开发者工具上传视频没有问题, 但是下列真机测试时: ios端调用wx.uploadvideo时 1 上传已有视频时 上传失败 2 上传拍摄视频时 上传成功 android 没有问题 以下为代码片段 简易demo index.js [代码]//index.js[代码][代码]var[代码] [代码]app = getApp()[代码][代码]var[代码] [代码]count = 0;[代码][代码]Page({[代码][代码] [代码][代码]data: {[代码][代码] [代码][代码]chooesVideo: [代码][代码]''[代码][代码], [代码][代码]//上传视频地址[代码][代码] [代码][代码]tipHide: [代码][代码]false[代码][代码],[代码][代码] [代码][代码]chooseTypeHide: [代码][代码]true[代码][代码],[代码][代码] [代码][代码]},[代码] [代码] [代码][代码]/**[代码][代码] [代码][代码]* 生命周期函数--监听页面加载[代码][代码] [代码][代码]*/[代码][代码] [代码][代码]onLoad: [代码][代码]function[代码] [代码](options) {[代码][代码] [代码][代码]console.log(options.status)[代码][代码] [代码][代码]},[代码][代码] [代码][代码]/**[代码][代码] [代码][代码]* 生命周期函数--监听页面初次渲染完成[代码][代码] [代码][代码]*/[代码][代码] [代码][代码]onReady: [代码][代码]function[代码] [代码](res) {[代码][代码] [代码][代码]this[代码][代码].videoContext = wx.createVideoContext([代码][代码]'prew_video'[代码][代码]);[代码][代码] [代码][代码]},[代码][代码]/**[代码][代码] [代码][代码]* 上传图片[代码][代码] [代码][代码]*/[代码][代码] [代码][代码]chooseImg: [代码][代码]function[代码] [代码]() {[代码][代码] [代码][代码]let that = [代码][代码]this[代码][代码] [代码][代码]wx.chooseImage({[代码][代码] [代码][代码]count: 1, [代码][代码]// 默认9[代码][代码] [代码][代码]sizeType: [[代码][代码]'original'[代码][代码], [代码][代码]'compressed'[代码][代码]], [代码][代码]// 可以指定是原图还是压缩图,默认二者都有[代码][代码] [代码][代码]sourceType: [[代码][代码]'album'[代码][代码], [代码][代码]'camera'[代码][代码]], [代码][代码]// 可以指定来源是相册还是相机,默认二者都有[代码][代码] [代码][代码]success: [代码][代码]function[代码] [代码](res) {[代码][代码] [代码][代码]console.log(res)[代码][代码] [代码][代码]var[代码] [代码]tempFilePaths = res.tempFilePaths[代码][代码] [代码][代码]that.data.images = tempFilePaths[代码][代码] [代码][代码]// 多图片[代码][代码] [代码][代码]// that.data.urls = that.data.urls.concat(tempFilePaths)[代码][代码] [代码][代码]// 单图片[代码][代码] [代码][代码]that.data.urls = tempFilePaths[0][代码][代码] [代码][代码]that.setData({[代码][代码] [代码][代码]images: tempFilePaths[0],[代码][代码] [代码][代码]urls: that.data.urls[代码][代码] [代码][代码]})[代码] [代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]},[代码] [代码] [代码][代码]/**[代码][代码] [代码][代码]* 上传视频[代码][代码] [代码][代码]*/[代码][代码] [代码][代码]chooseVideo: [代码][代码]function[代码] [代码]() {[代码][代码] [代码][代码]let that = [代码][代码]this[代码][代码] [代码][代码]wx.chooseVideo({[代码][代码] [代码][代码]sourceType: [[代码][代码]'album'[代码][代码], [代码][代码]'camera'[代码][代码]],[代码][代码] [代码][代码]maxDuration: 60,[代码][代码] [代码][代码]camera: [代码][代码]'back'[代码][代码],[代码][代码] [代码][代码]success: [代码][代码]function[代码] [代码](res) {[代码][代码] [代码][代码]console.log(res.tempFilePath),[代码][代码] [代码][代码]that.setData({[代码][代码] [代码][代码]chooesVideo: res.tempFilePath[代码][代码] [代码][代码]})[代码][代码] [代码] [代码] [代码][代码]var[代码] [代码]src = that.data.chooesVideo;[代码][代码] [代码][代码]wx.uploadFile({[代码][代码] [代码][代码]url: [代码][代码]''[代码][代码],//服务器接口[代码][代码] [代码][代码]method: [代码][代码]'POST'[代码][代码],[代码][代码]//这句话好像可以不用[代码][代码] [代码][代码]filePath: src,[代码][代码] [代码][代码]header: {[代码][代码] [代码][代码]'content-type'[代码][代码]: [代码][代码]'multipart/form-data'[代码][代码] [代码][代码]},[代码][代码] [代码][代码]name: [代码][代码]'file'[代码][代码],[代码][代码]//服务器定义的Key值[代码][代码] [代码][代码]success: [代码][代码]function[代码] [代码](res) {[代码][代码] [代码][代码]console.log(res)[代码][代码] [代码][代码]},[代码][代码] [代码][代码]fail: [代码][代码]function[代码] [代码]() {[代码][代码] [代码][代码]console.log([代码][代码]'接口调用失败'[代码][代码])[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码] [代码] [代码][代码]},[代码][代码] [代码] [代码] [代码][代码]/**[代码][代码] [代码][代码]* 全屏改变[代码][代码] [代码][代码]*/[代码][代码] [代码][代码]bindVideoScreenChange: [代码][代码]function[代码] [代码](e) {[代码][代码] [代码][代码]var[代码] [代码]status = e.detail.fullScreen;[代码][代码] [代码][代码]var[代码] [代码]play = {[代码][代码] [代码][代码]playVideo: [代码][代码]false[代码][代码] [代码][代码]}[代码][代码] [代码][代码]if[代码] [代码](status) {[代码][代码] [代码][代码]play.playVideo = [代码][代码]true[代码][代码];[代码][代码] [代码][代码]} [代码][代码]else[代码] [代码]{[代码][代码] [代码][代码]this[代码][代码].videoContext.pause();[代码][代码] [代码][代码]}[代码][代码] [代码][代码]this[代码][代码].setData(play);[代码][代码] [代码][代码]}[代码] [代码]})[代码]index.wxml [代码]<!-- 图片预览 -->[代码][代码]<[代码][代码]view[代码] [代码]class[代码][代码]=[代码][代码]'preview-warp'[代码] [代码]wx:if[代码][代码]=[代码][代码]"{{urls}}"[代码][代码]>[代码][代码] [代码][代码]<[代码][代码]image[代码] [代码]src[代码][代码]=[代码][代码]'{{urls}}'[代码] [代码]/>[代码][代码]</[代码][代码]view[代码][代码]>[代码][代码]<[代码][代码]view[代码] [代码]class[代码][代码]=[代码][代码]"prew_video"[代码] [代码]hidden[代码][代码]=[代码][代码]"{{chooesVideo==''}}"[代码][代码]>[代码][代码] [代码][代码]<[代码][代码]video[代码] [代码]bindfullscreenchange[代码][代码]=[代码][代码]"bindVideoScreenChange"[代码] [代码]src[代码][代码]=[代码][代码]"{{chooesVideo}}"[代码] [代码]></[代码][代码]video[代码][代码]>[代码][代码]</[代码][代码]view[代码][代码]>[代码] [代码]<!-- 按钮组 -->[代码][代码]<[代码][代码]view[代码] [代码]class[代码][代码]=[代码][代码]'upimg'[代码] [代码]bindtap[代码][代码]=[代码][代码]'chooseImg'[代码][代码]>上传图片</[代码][代码]view[代码][代码]>[代码][代码]<[代码][代码]view[代码] [代码]class[代码][代码]=[代码][代码]'upvideo'[代码] [代码]bindtap[代码][代码]=[代码][代码]'chooseVideo'[代码][代码]>上传视频</[代码][代码]view[代码][代码]>[代码]index.wcss [代码]/* 预览 */[代码][代码].preview-warp{[代码][代码] [代码][代码]display[代码][代码]: flex;[代码][代码] [代码][代码]align-items: [代码][代码]center[代码][代码]; [代码][代码]/*垂直居中*/[代码][代码] [代码][代码]justify-[代码][代码]content[代码][代码]: [代码][代码]center[代码][代码]; [代码][代码]/*居中对齐*/[代码][代码] [代码][代码]position[代码][代码]: [代码][代码]relative[代码][代码];[代码][代码] [代码][代码]background-color[代码][代码]: [代码][代码]#fff[代码][代码];[代码][代码]}[代码][代码].prew_video{[代码][代码] [代码][代码]display[代码][代码]: flex;[代码][代码] [代码][代码]align-items: [代码][代码]center[代码][代码]; [代码][代码]/*垂直居中*/[代码][代码] [代码][代码]justify-[代码][代码]content[代码][代码]: [代码][代码]center[代码][代码]; [代码][代码]/*居中对齐*/[代码][代码] [代码][代码]position[代码][代码]: [代码][代码]relative[代码][代码];[代码][代码] [代码][代码]background-color[代码][代码]: [代码][代码]#fff[代码][代码];[代码][代码]}[代码][代码].prew_video[[代码][代码]hidden[代码][代码]]{[代码][代码] [代码][代码]display[代码][代码]: [代码][代码]none[代码][代码];[代码][代码]}[代码][代码].prew_video .play{[代码][代码] [代码][代码]width[代码][代码]: [代码][代码]48[代码][代码]rpx;[代码][代码] [代码][代码]height[代码][代码]: [代码][代码]48[代码][代码]rpx;[代码][代码]}[代码] [代码]/* 上传按钮组 */[代码][代码].upimg{[代码][代码] [代码][代码]width[代码][代码]: [代码][代码]49%[代码][代码];[代码][代码] [代码][代码]height[代码][代码]: [代码][代码]80[代码][代码]rpx;[代码][代码] [代码][代码]line-height[代码][代码]: [代码][代码]80[代码][代码]rpx;[代码][代码] [代码][代码]font-size[代码][代码]: [代码][代码]30[代码][代码]rpx;[代码][代码] [代码][代码]float[代码][代码]: [代码][代码]left[代码][代码];[代码][代码] [代码][代码]background[代码][代码]: [代码][代码]#41C7DB[代码][代码];[代码][代码] [代码][代码]text-align[代码][代码]: [代码][代码]center[代码][代码];[代码][代码] [代码][代码]border[代码][代码]: [代码][代码]1px[代码] [代码]solid[代码] [代码]#000[代码][代码];[代码][代码] [代码][代码]/* border-left: 1px solid #000; */[代码][代码]}[代码][代码].upvideo{[代码][代码] [代码][代码]width[代码][代码]: [代码][代码]49.5%[代码][代码];[代码][代码] [代码][代码]height[代码][代码]: [代码][代码]80[代码][代码]rpx;[代码][代码] [代码][代码]line-height[代码][代码]: [代码][代码]80[代码][代码]rpx;[代码][代码] [代码][代码]font-size[代码][代码]: [代码][代码]30[代码][代码]rpx;[代码][代码] [代码][代码]float[代码][代码]: [代码][代码]left[代码][代码];[代码][代码] [代码][代码]text-align[代码][代码]: [代码][代码]center[代码][代码];[代码][代码] [代码][代码]border[代码][代码]: [代码][代码]1px[代码] [代码]solid[代码] [代码]#000[代码][代码];[代码][代码] [代码][代码]background[代码][代码]: [代码][代码]#fff[代码][代码]}[代码] 求助
2019-12-13已解决
ios 小程序调用wx.uploadvideo 遇到的问题描述 上传视频文件的时候 在微信开发者工具上传视频没有问题, 但是下列真机测试时: ios端调用wx.uploadvideo时 1 上传已有视频时 上传失败 2 上传拍摄视频时 上传成功 android 没有问题
2019-12-13