uniapp 小程序 拍照 uni.chooseImage

// 拍摄照片

toTakePicture: function() {
    
    
	let _this = this;
	// 项目实战中使用
	uni.chooseImage({
    
    
		count: 1,  // 图片数量
		sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
		sourceType: ['album', 'camera'], //从相册选择或者拍照
		success: (res) => {
    
    
			const tempFilePaths = res.tempFilePaths;
			console.log(tempFilePaths[0])
			_this.logo_list = tempFilePaths[0]
			uni.uploadFile({
    
    
				url: 'https://xx.com/center/group/icon', //上传图片api
				filePath: tempFilePaths[0],
				name: 'groupicon',
				header:{
    
    
					"Authorization": userinfo.token
				},
				success: (res) => {
    
    
					let group =  JSON.parse(res.data) 
					uni.showToast({
    
    
						title:"上传成功",
						icon:"success"
					})
				}
			});
		}
	});
},

猜你喜欢

转载自blog.csdn.net/maoge_666/article/details/131082131