You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
121 lines
2.9 KiB
121 lines
2.9 KiB
12 months ago
|
<!--拍照上传-->
|
||
|
<template>
|
||
|
<view>
|
||
|
<!-- <button @click="camera">拍照</button> -->
|
||
|
<uni-file-picker ref="files" limit="3" title="最多选择3张图片" :auto-upload="false" v-model="imageValue"
|
||
|
:sizeType="sizeType" fileMediatype="image" mode="grid" file-extname="png,jpg" @select="select"
|
||
|
@delete="deleteImg" @progress="progress" @success="success"
|
||
|
:disabled="disabled" :del-icon='!disabled'
|
||
|
@fail="fail" />
|
||
|
</view>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
|
export default {
|
||
|
name: "uploadCamera",
|
||
|
data() {
|
||
|
return {
|
||
|
imageValue: [],
|
||
|
sizeType: ['compressed']
|
||
|
}
|
||
|
},
|
||
|
props: {
|
||
|
disabled: {
|
||
|
type: Boolean,
|
||
|
value: false
|
||
|
}
|
||
|
},
|
||
|
watch: {},
|
||
|
methods: {
|
||
|
// 父组件上传调用
|
||
|
upload() {
|
||
|
this.$refs.files.upload()
|
||
|
},
|
||
|
// 获取上传状态
|
||
|
select(e) {
|
||
|
console.log('选择文件:', e)
|
||
|
},
|
||
|
|
||
|
//删除
|
||
|
deleteImg(e) {
|
||
|
console.log('删除:', e)
|
||
|
},
|
||
|
|
||
|
// 获取上传进度
|
||
|
progress(e) {
|
||
|
console.log('上传进度:', e)
|
||
|
},
|
||
|
|
||
|
// 上传成功
|
||
|
success(e) {
|
||
|
console.log('上传成功')
|
||
|
},
|
||
|
|
||
|
// 上传失败
|
||
|
fail(e) {
|
||
|
console.log('上传失败:', e)
|
||
|
},
|
||
|
|
||
|
getFiles() {
|
||
|
return this.$refs.files.files;
|
||
|
},
|
||
|
setFiles(files) {
|
||
|
this.$refs.files.files = files;
|
||
|
},
|
||
|
clearFiles() {
|
||
|
this.$refs.files.files = []
|
||
|
}
|
||
|
|
||
|
|
||
|
// camera(){
|
||
|
// let that = this
|
||
|
// uni.chooseImage({
|
||
|
// count: 3, //默认9
|
||
|
// sizeType: ['original'], //原图
|
||
|
// sourceType: ['camera'], //拍照
|
||
|
// success: function (res) {
|
||
|
// console.log(res.tempFilePaths)
|
||
|
// console.log(JSON.stringify(res.tempFilePaths));
|
||
|
// that.select({
|
||
|
// tempFilePaths:[
|
||
|
// JSON.stringify(res.tempFilePaths[0])
|
||
|
// ],
|
||
|
// tempFiles:[
|
||
|
// {path: res.tempFilePaths[0]}
|
||
|
// ]})
|
||
|
// }
|
||
|
// });
|
||
|
// },
|
||
|
// camera(){
|
||
|
// // 获取摄像头管理对象 getCamera 参数 index 指定要获取摄像头的索引值,1表示主摄像头,2表示辅摄像头。如果没有设置则使用系统默认主摄像头。
|
||
|
// // 安卓不能默认打开前置摄像头 ios可以
|
||
|
// const cmr = plus.camera.getCamera()
|
||
|
// // 字符串数组,摄像头支持的拍照分辨率
|
||
|
// const res = cmr.supportedImageResolutions[0]
|
||
|
// // 字符串数组,摄像头支持的拍照文件格式
|
||
|
// const fmt = cmr.supportedImageFormats[0]
|
||
|
// // 进行拍照操作
|
||
|
// cmr.captureImage((path) => {
|
||
|
// // this.compressImage(path)
|
||
|
// // path 图片地址
|
||
|
// console.log(path)
|
||
|
// plus.gallery.save( path, function () {
|
||
|
// alert( "保存图片到相册成功" );
|
||
|
// },(error) => {
|
||
|
// alert(error);
|
||
|
// });
|
||
|
// },
|
||
|
// (error) => {
|
||
|
// console.log('Capture image failed: ' + error.message)
|
||
|
// }, {
|
||
|
// resolution: res,
|
||
|
// format: fmt,
|
||
|
// filename:''
|
||
|
// })
|
||
|
// },
|
||
|
}
|
||
|
}
|
||
|
</script>
|
||
|
<style scoped lang="scss">
|
||
|
</style>
|