<template>
<view>
<image-cropper :src="imgurl" @confirm="doUpload" @cancel="cancel"></image-cropper>
</view>
</template>
<script>
import { mapState, mapMutations } from 'vuex'
import ImageCropper from "@/components/invinbg-image-cropper/invinbg-image-cropper.vue"
export default {
components: {ImageCropper},
data() {
return {
imgurl: ''
}
},
computed: {
...mapState(['userAvatar'])
},
onLoad() {
let vm = this;
uni.chooseImage({
count: 1, //默认9
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
sourceType: ['album'], //从相册选择
success: (res) => {
vm.imgurl = res.tempFilePaths[0];
console.log(res, vm.imgurl);
},
fail: (err) => {
uni.navigateBack()
}
})
},
methods: {
...mapMutations(['updateAvatar']),
doUpload(e) {
this.updateAvatar(e.detail.tempFilePath);
uni.navigateBack();
},
cancel() {
uni.navigateBack()
}
}
}
</script>
<style>
</style>
重复
- 发布:2019-10-09 23:17
- 更新:2019-10-10 22:09
- 阅读:1280