小程序有两个页面,都有使用到wx.uploadFile这个api,其中一个是使用wx.chooseMedia获取图片,这个是正常的;但是另一个页面使用CameraContentxt.tekaPhoto获取的图片,在开发工具是正常上传,在真机调试的时候就无法上传了,success,fail,complete这三个函数也没有回调,就像没有使用过wx.uploadFile一样;已经确定图片是存在的,就是没有任何回调,三个回调函数都有写上(在另一个wx.chooseMedia页面上传是正常的,所以代码和配置应该没问题),体验版也上传了,安卓ios都不可用,请问有大神帮解答一下吗?
这个没执行?
takePhoto() {
let _this = this
const ctx = wx.createCameraContext()
const listener = ctx.onCameraFrame(() => {
})
ctx.takePhoto({
quality: 'high',
success: (res) => {
_this.getImgo(res.tempImagePath)
listener.stop({
success: (res) => {
console.log(res)
},
fail: (err) => {
console.log(err)
}
})
},
fail: (err) => {
console.log(err)
}
})
},
路径保存到this.data中,点击下载之后保存本地+上传服务器,触发提问贴出来的代码,已经确定图片路径存在
savePhoto() {
let _this = this
_this.upLoadImgFun(_this.data.filepath)
wx.saveFile({
tempFilePath: _this.data.filepath,
success: function (res) {
//返回保存时的临时路径 res.savedFilePath
const savedFilePath = res.savedFilePath
// 保存到本地相册
wx.saveImageToPhotosAlbum({
filePath: savedFilePath,
success(res) {
wx.showToast({
title: '成功',
icon: 'success',
duration: 2000//持续的时间
})
wx.redirectTo({
url: '/pages/index/success/success',
})
}
})
},
fail:function (info) {//缓存文件达到上限,清理内存
wx.showToast({
title: '网络较忙,请稍后~',
icon: 'none',
duration: 1000
})
wx.getFileSystemManager().getSavedFileList({
success:function (res) {
res.fileList.forEach((val,key)=>{
wx.getFileSystemManager().removeSavedFile({
filePath:val.filePath
})
setTimeout(function () {
_this.photographAagain()
},1500)
})
}
})
}
})
},