File tree Expand file tree Collapse file tree 2 files changed +116
-3
lines changed
src/views/account/settings Expand file tree Collapse file tree 2 files changed +116
-3
lines changed Original file line number Diff line number Diff line change
1
+ <template >
2
+ <a-modal :visible =" visible" title =" 修改头像" :maskClosable =" false" :confirmLoading =" confirmLoading" :width =" 800" >
3
+ <a-row >
4
+ <a-col :span =" 12" :style =" {height: '350px'}" >
5
+ <vue-cropper
6
+ ref =" cropper"
7
+ :img =" options.img"
8
+ :info =" true"
9
+ :autoCrop =" options.autoCrop"
10
+ :autoCropWidth =" options.autoCropWidth"
11
+ :autoCropHeight =" options.autoCropHeight"
12
+ :fixedBox =" options.fixedBox"
13
+ @realTime =" realTime"
14
+ >
15
+ </vue-cropper >
16
+ </a-col >
17
+ <a-col :span =" 12" :style =" {height: '350px'}" >
18
+ <div class =" avatar-upload-preview" >
19
+ <img :src =" previews.url" :style =" previews.img" />
20
+ </div >
21
+ </a-col >
22
+ </a-row >
23
+
24
+ <template slot="footer">
25
+ <a-button key =" back" @click =" cancelHandel" >取消</a-button >
26
+ <a-button key =" submit" type =" primary" :loading =" confirmLoading" @click =" okHandel" >保存</a-button >
27
+ </template >
28
+ </a-modal >
29
+ </template >
30
+ <script >
31
+ import VueCropper from ' vue-cropper'
32
+
33
+ export default {
34
+ components: {
35
+ VueCropper
36
+ },
37
+ data () {
38
+ return {
39
+ visible: false ,
40
+ id: null ,
41
+ confirmLoading: false ,
42
+
43
+ options: {
44
+ img: ' http://ofyaji162.bkt.clouddn.com/bg1.jpg' ,
45
+ autoCrop: true ,
46
+ autoCropWidth: 200 ,
47
+ autoCropHeight: 200 ,
48
+ fixedBox: true
49
+ },
50
+ previews: {},
51
+ };
52
+ },
53
+ watch: {
54
+
55
+ },
56
+ methods: {
57
+ edit (id ) {
58
+ this .visible = true ;
59
+ this .id = id;
60
+ /* 获取原始头像 */
61
+
62
+ },
63
+ close () {
64
+ this .id = null ;
65
+ this .visible = false ;
66
+ },
67
+ cancelHandel () {
68
+ this .close ();
69
+ },
70
+ okHandel () {
71
+ const vm = this
72
+
73
+ vm .confirmLoading = true
74
+ setTimeout (() => {
75
+ vm .confirmLoading = false
76
+ vm .close ()
77
+ vm .$message .success (' 上传头像成功' );
78
+ }, 2000 )
79
+
80
+ },
81
+
82
+ realTime (data ) {
83
+ this .previews = data
84
+ }
85
+ }
86
+ };
87
+ </script >
88
+
89
+ <style lang="scss" scoped>
90
+
91
+ .avatar-upload-preview {
92
+ position : absolute ;
93
+ top : 50% ;
94
+ transform : translate (50% , -50% );
95
+ width : 180px ;
96
+ height : 180px ;
97
+ border-radius : 50% ;
98
+ box-shadow : 0 0 4px #ccc ;
99
+ overflow : hidden ;
100
+
101
+ img {
102
+ width : 100% ;
103
+ height : 100% ;
104
+ }
105
+ }
106
+ </style >
Original file line number Diff line number Diff line change 52
52
53
53
</a-col >
54
54
<a-col :md =" 24" :lg =" 8" :style =" { minHeight: '180px' }" >
55
- <div class =" ant-upload-preview" >
55
+ <div class =" ant-upload-preview" @click = " $refs.modal.edit(1) " >
56
56
<a-icon type =" cloud-upload-o" class =" upload-icon" />
57
57
<div class =" mask" >
58
58
<a-icon type =" plus" />
62
62
</a-col >
63
63
64
64
</a-row >
65
+
66
+ <avatar-modal ref =" modal" >
67
+
68
+ </avatar-modal >
65
69
</div >
66
70
</template >
67
71
68
72
<script >
69
- import VueCropper from " vue-cropper/example/src/vue-cropper/vue-cropper "
73
+ import AvatarModal from ' ./AvatarModal '
70
74
71
75
export default {
72
76
components: {
73
- VueCropper
77
+ AvatarModal
74
78
},
75
79
data () {
76
80
return {
92
96
fixedNumber: [1 , 1 ]
93
97
}
94
98
}
99
+ },
100
+ methods: {
101
+
95
102
}
96
103
}
97
104
</script >
You can’t perform that action at this time.
0 commit comments