uploadFilePromise(file) {
				console.log(file);
				let _this = this
				return new Promise((resolve, reject) => {
					uni.uploadFile({
						url: BASE_URL_API + 'app/upload/file',
						filePath: file.url,//临时路径
						name: 'file', //对应后台接口参数名
						method: 'POST',
						header: {
							'token': _this.$config.getToke()
						},
						formData: {
							//要上传的文件
							file: file
						},
						success(res) {
							console.log(res);
							if (res.path) {
								that.imageUrls = res.path;
								console.log(that.imageUrls);
							}
						},
						fail(res) {
							console.log(res);
							uni.showToast({
								icon: 'error',
								title: '图片上传失败!'
							})
						}
					})


				})
			},

Logo

北京人形旗下天工造物具身智能开源社区,聚焦具身天工与慧思开物两大平台

更多推荐