takePhoto: function() {\n var that = this;\n wx.chooseMedia({\n count: 3,\n mediaType: ['image'],\n sourceType: ['camera'],\n success: function(res) {\n var tempFilePaths = res.tempFiles.map(function(file) {\n return file.tempFilePath;\n });\n \n // Get the current date\n var date = new Date();\n var year = date.getFullYear();\n var month = date.getMonth() + 1;\n var day = date.getDate();\n \n // Create the file name using the current date\n var fileName = year + "-" + month + "-" + day + ".jpg";\n \n // Upload the images to cloud storage\n var images = that.data.images;\n images.push(...tempFilePaths);\n that.setData({\n images: images\n });\n \n // Upload the images to cloud storage\n wx.cloud.uploadFile({\n cloudPath: fileName,\n filePath: tempFilePaths[0], // Assuming only one image is selected\n success: function(res) {\n console.log('Upload successful: ', res.fileID);\n },\n fail: function(err) {\n console.error('Upload failed: ', err);\n }\n });\n }\n });\n }


原文地址: https://www.cveoy.top/t/topic/pwG7 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录