|
@@ -27,10 +27,13 @@
|
|
|
<div class="form-el-upload">
|
|
|
<el-upload
|
|
|
class="avatar-uploader"
|
|
|
- action="https://jsonplaceholder.typicode.com/posts/"
|
|
|
+ accept="image/jpeg,image/gif,image/png"
|
|
|
+ action="https://www-b.caimei365.com/register/imageUpload.action"
|
|
|
:show-file-list="false"
|
|
|
:on-success="handleAvatarSuccess"
|
|
|
:before-upload="beforeAvatarUpload"
|
|
|
+ :multiple="false"
|
|
|
+ :limit= '1'
|
|
|
>
|
|
|
<img v-if="form.imageUrl" :src="form.imageUrl" class="avatar">
|
|
|
<i v-else class="el-icon-plus avatar-uploader-icon" />
|
|
@@ -42,6 +45,7 @@
|
|
|
<div class="form-el-upload">
|
|
|
<el-upload
|
|
|
class="avatar-uploader"
|
|
|
+ accept="image/jpeg,image/gif,image/png,image/jpg"
|
|
|
action="https://jsonplaceholder.typicode.com/posts/"
|
|
|
:show-file-list="false"
|
|
|
:on-success="handleDoorwaySuccess"
|
|
@@ -72,6 +76,7 @@
|
|
|
<script>
|
|
|
// 引入省市区组件,公共组件所在的路径
|
|
|
import City from '@/components/Ctiy'
|
|
|
+import { addNewClub } from '@/api/club'
|
|
|
export default {
|
|
|
components: { City },
|
|
|
data() {
|
|
@@ -121,7 +126,9 @@ export default {
|
|
|
this.addList.area = data.area
|
|
|
},
|
|
|
handleAvatarSuccess(res, file) {
|
|
|
- console.log(res)
|
|
|
+ this.getBase64(file.raw).then(res => {
|
|
|
+ console.log(res)
|
|
|
+ });
|
|
|
const fileName = file.name
|
|
|
const regex = /(.jpg|.jpeg|.gif|.png|.bmp)$/
|
|
|
if (regex.test(fileName.toLowerCase())) {
|
|
@@ -138,7 +145,9 @@ export default {
|
|
|
return isLt5M
|
|
|
},
|
|
|
handleDoorwaySuccess(res, file) {
|
|
|
- console.log(res)
|
|
|
+ this.getBase64(file.raw).then(res => {
|
|
|
+ console.log(res)
|
|
|
+ });
|
|
|
const fileName = file.name
|
|
|
const regex = /(.jpg|.jpeg|.gif|.png|.bmp)$/
|
|
|
if (regex.test(fileName.toLowerCase())) {
|
|
@@ -148,11 +157,30 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
beforeDoorwayUpload(file) {
|
|
|
+ this.getBase64(file.raw).then(res => {
|
|
|
+ console.log(res)
|
|
|
+ });
|
|
|
const isLt5M = file.size / 1024 / 1024 < 5
|
|
|
if (!isLt5M) {
|
|
|
this.$message.error('上传头像图片大小不能超过 5MB!')
|
|
|
}
|
|
|
return isLt5M
|
|
|
+ },
|
|
|
+ getBase64(file) {
|
|
|
+ return new Promise(function(resolve, reject) {
|
|
|
+ let reader = new FileReader();
|
|
|
+ let imgResult = "";
|
|
|
+ reader.readAsDataURL(file);
|
|
|
+ reader.onload = function() {
|
|
|
+ imgResult = reader.result;
|
|
|
+ };
|
|
|
+ reader.onerror = function(error) {
|
|
|
+ reject(error);
|
|
|
+ };
|
|
|
+ reader.onloadend = function() {
|
|
|
+ resolve(imgResult);
|
|
|
+ };
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
}
|