613d2a9c
Andy
add icon
|
1
|
<template>
|
c0534536
Andy
add 个人资料 前端页面
|
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
<div class="">
<!--卡片-->
<el-row :gutter="16" class="">
<el-col :span="8">
<el-card class="box-card">
<el-upload
class="avatar-uploader text-center"
action="https://jsonplaceholder.typicode.com/posts/"
:show-file-list="false"
:on-success="handleAvatarSuccess"
:on-remove="handleRemove"
:before-upload="beforeAvatarUpload">
<img v-if="imageUrl" :src="imageUrl" class="avatar">
<i v-else class="el-icon-plus avatar-uploader-icon"></i>
</el-upload>
<!--<el-button class="text-center" size="small" type="primary">点击上传</el-button>-->
<!--<div slot="tip" class="el-upload__tip"></div>-->
<div class="common-color text-center" style="line-height: 30px">15143234323</div>
|
613d2a9c
Andy
add icon
|
20
|
|
c0534536
Andy
add 个人资料 前端页面
|
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
<div class="font-size12 text-center" style="line-height: 30px">支持JPG格式且小于5MB</div>
<div class="font-size12 text-center" style="height: 146px"> </div>
</el-card>
</el-col>
<el-col :span="16">
<el-card class="box-card">
<!-- <div slot="header" class="clearfix" style="line-height: 32px;">
<span>个人资料</span>
</div>-->
<el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="80px">
<el-form-item label="姓名" class="margin-bottom30" prop="username">
<el-input v-model="ruleForm.username" style="width: 300px"></el-input>
</el-form-item>
<el-form-item label="性别" class="margin-bottom30" prop="sex">
<el-select v-model="ruleForm.sex" style="width: 300px">
<el-option label="男" value="1"/>
<el-option label="女" value="2"/>
</el-select>
</el-form-item>
<el-form-item label="生日" class="margin-bottom30" prop="birthday">
<el-date-picker
v-model="ruleForm.birthday"
type="date"
placeholder="选择日期" style="width: 300px">
</el-date-picker>
</el-form-item>
<el-form-item label="年龄" class="margin-bottom30" prop="num">
<el-input-number v-model="ruleForm.num" @change="handleChange" :min="1" :max="150" style="width: 300px"></el-input-number>
</el-form-item>
<el-form-item label="位置" class="margin-bottom30" prop="address">
<el-input type="text" v-model="ruleForm.address" style="width: 300px"></el-input>
</el-form-item>
|
613d2a9c
Andy
add icon
|
53
|
|
c0534536
Andy
add 个人资料 前端页面
|
54
55
56
57
58
59
60
61
|
<el-form-item>
<el-button type="primary" @click="submitForm('ruleForm')">提交</el-button>
<el-button @click="resetForm('ruleForm')">取消</el-button>
</el-form-item>
</el-form>
</el-card>
</el-col>
</el-row>
|
613d2a9c
Andy
add icon
|
62
63
64
65
66
|
</div>
</template>
<script>
export default {
|
613d2a9c
Andy
add icon
|
67
68
|
data() {
return {
|
c0534536
Andy
add 个人资料 前端页面
|
69
70
71
72
73
74
|
imageUrl: '',
ruleForm: {
username: '万八',
num: '23',
sex:'男',
birthday: '2019-08-17',
|
7efbb9fb
Andy
add 个人资料 前端页面
|
75
|
address: '北京海淀区上地五街1003号'
|
c0534536
Andy
add 个人资料 前端页面
|
76
77
78
79
|
},
rules: {
username: [
{ required: true, message: '请输入活动名称', trigger: 'blur' },
|
7efbb9fb
Andy
add 个人资料 前端页面
|
80
|
{ min: 1, max: 10, message: '长度在 3 到 10 个字符', trigger: 'blur' }
|
c0534536
Andy
add 个人资料 前端页面
|
81
|
],
|
c0534536
Andy
add 个人资料 前端页面
|
82
|
birthday: [
|
7efbb9fb
Andy
add 个人资料 前端页面
|
83
84
|
{ required: true, message: '请输入日期', trigger: 'blur' },
{ type: 'email', message: '请输入正确的日期', trigger: ['blur', 'change'] }
|
c0534536
Andy
add 个人资料 前端页面
|
85
|
],
|
c0534536
Andy
add 个人资料 前端页面
|
86
87
|
address: [
{ required: true, message: '请输入活动名称', trigger: 'blur' },
|
7efbb9fb
Andy
add 个人资料 前端页面
|
88
|
{ min: 1, max: 30, message: '长度在 1 到 30 个字符', trigger: 'blur' }
|
c0534536
Andy
add 个人资料 前端页面
|
89
|
],
|
613d2a9c
Andy
add icon
|
90
|
}
|
c0534536
Andy
add 个人资料 前端页面
|
91
|
};
|
613d2a9c
Andy
add icon
|
92
|
},
|
613d2a9c
Andy
add icon
|
93
|
methods: {
|
c0534536
Andy
add 个人资料 前端页面
|
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
handleRemove(res, file) {
console.log(res, file);
},
handleAvatarSuccess(res, file) {
this.imageUrl = URL.createObjectURL(file.raw);
},
beforeAvatarUpload(file) {
const isJPG = file.type === 'image/jpeg';
const isLt5M = file.size / 1024 / 1024 < 5;
if (!isJPG) {
this.$message.error('上传头像图片只能是 JPG 格式!');
}
if (!isLt5M) {
this.$message.error('上传头像图片大小不能超过 5MB!');
}
return isJPG && isLt5M;
|
7efbb9fb
Andy
add 个人资料 前端页面
|
111
112
113
|
},
resetForm(formName) {
this.$refs[formName].resetFields();
|
613d2a9c
Andy
add icon
|
114
115
116
117
|
}
}
}
</script>
|
c0534536
Andy
add 个人资料 前端页面
|
118
119
120
121
|
<style lang="scss" >
.avatar-uploader .el-upload {
border: 1px dashed #d9d9d9;
|
7efbb9fb
Andy
add 个人资料 前端页面
|
122
|
border-radius: 50%;
|
c0534536
Andy
add 个人资料 前端页面
|
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
cursor: pointer;
position: relative;
overflow: hidden;
}
.avatar-uploader .el-upload:hover {
border-color: #409EFF;
}
.avatar-uploader-icon {
font-size: 28px;
color: #8c939d;
width: 178px;
height: 178px;
line-height: 178px;
text-align: center;
}
.avatar {
width: 178px;
height: 178px;
display: block;
}
.margin-bottom30{
margin-bottom: 30px;
}
</style>
|
613d2a9c
Andy
add icon
|
|
|