提交者
Gitee
!604 修复小屏幕上修改头像界面布局错位的问题
Merge pull request !604 from 也曾为你、像超人/master
正在显示
2 个修改的文件
包含
23 行增加
和
9 行删除
| @@ -250,9 +250,10 @@ | @@ -250,9 +250,10 @@ | ||
| 250 | } | 250 | } |
| 251 | 251 | ||
| 252 | .avatar-upload-preview { | 252 | .avatar-upload-preview { |
| 253 | - position: absolute; | 253 | + position: relative; |
| 254 | top: 50%; | 254 | top: 50%; |
| 255 | - transform: translate(50%, -50%); | 255 | + left: 50%; |
| 256 | + transform: translate(-50%, -50%); | ||
| 256 | width: 200px; | 257 | width: 200px; |
| 257 | height: 200px; | 258 | height: 200px; |
| 258 | border-radius: 50%; | 259 | border-radius: 50%; |
| @@ -24,7 +24,7 @@ | @@ -24,7 +24,7 @@ | ||
| 24 | </el-row> | 24 | </el-row> |
| 25 | <br /> | 25 | <br /> |
| 26 | <el-row> | 26 | <el-row> |
| 27 | - <el-col :lg="2" :md="2"> | 27 | + <el-col :lg="2" :sm="3" :xs="3"> |
| 28 | <el-upload action="#" :http-request="requestUpload" :show-file-list="false" :before-upload="beforeUpload"> | 28 | <el-upload action="#" :http-request="requestUpload" :show-file-list="false" :before-upload="beforeUpload"> |
| 29 | <el-button size="small"> | 29 | <el-button size="small"> |
| 30 | 选择 | 30 | 选择 |
| @@ -32,19 +32,19 @@ | @@ -32,19 +32,19 @@ | ||
| 32 | </el-button> | 32 | </el-button> |
| 33 | </el-upload> | 33 | </el-upload> |
| 34 | </el-col> | 34 | </el-col> |
| 35 | - <el-col :lg="{span: 1, offset: 2}" :md="2"> | 35 | + <el-col :lg="{span: 1, offset: 2}" :sm="2" :xs="2"> |
| 36 | <el-button icon="el-icon-plus" size="small" @click="changeScale(1)"></el-button> | 36 | <el-button icon="el-icon-plus" size="small" @click="changeScale(1)"></el-button> |
| 37 | </el-col> | 37 | </el-col> |
| 38 | - <el-col :lg="{span: 1, offset: 1}" :md="2"> | 38 | + <el-col :lg="{span: 1, offset: 1}" :sm="2" :xs="2"> |
| 39 | <el-button icon="el-icon-minus" size="small" @click="changeScale(-1)"></el-button> | 39 | <el-button icon="el-icon-minus" size="small" @click="changeScale(-1)"></el-button> |
| 40 | </el-col> | 40 | </el-col> |
| 41 | - <el-col :lg="{span: 1, offset: 1}" :md="2"> | 41 | + <el-col :lg="{span: 1, offset: 1}" :sm="2" :xs="2"> |
| 42 | <el-button icon="el-icon-refresh-left" size="small" @click="rotateLeft()"></el-button> | 42 | <el-button icon="el-icon-refresh-left" size="small" @click="rotateLeft()"></el-button> |
| 43 | </el-col> | 43 | </el-col> |
| 44 | - <el-col :lg="{span: 1, offset: 1}" :md="2"> | 44 | + <el-col :lg="{span: 1, offset: 1}" :sm="2" :xs="2"> |
| 45 | <el-button icon="el-icon-refresh-right" size="small" @click="rotateRight()"></el-button> | 45 | <el-button icon="el-icon-refresh-right" size="small" @click="rotateRight()"></el-button> |
| 46 | </el-col> | 46 | </el-col> |
| 47 | - <el-col :lg="{span: 2, offset: 6}" :md="2"> | 47 | + <el-col :lg="{span: 2, offset: 6}" :sm="2" :xs="2"> |
| 48 | <el-button type="primary" size="small" @click="uploadImg()">提 交</el-button> | 48 | <el-button type="primary" size="small" @click="uploadImg()">提 交</el-button> |
| 49 | </el-col> | 49 | </el-col> |
| 50 | </el-row> | 50 | </el-row> |
| @@ -56,6 +56,7 @@ | @@ -56,6 +56,7 @@ | ||
| 56 | import store from "@/store"; | 56 | import store from "@/store"; |
| 57 | import { VueCropper } from "vue-cropper"; | 57 | import { VueCropper } from "vue-cropper"; |
| 58 | import { uploadAvatar } from "@/api/system/user"; | 58 | import { uploadAvatar } from "@/api/system/user"; |
| 59 | +import { debounce } from '@/utils' | ||
| 59 | 60 | ||
| 60 | export default { | 61 | export default { |
| 61 | components: { VueCropper }, | 62 | components: { VueCropper }, |
| @@ -79,7 +80,8 @@ export default { | @@ -79,7 +80,8 @@ export default { | ||
| 79 | autoCropHeight: 200, // 默认生成截图框高度 | 80 | autoCropHeight: 200, // 默认生成截图框高度 |
| 80 | fixedBox: true // 固定截图框大小 不允许改变 | 81 | fixedBox: true // 固定截图框大小 不允许改变 |
| 81 | }, | 82 | }, |
| 82 | - previews: {} | 83 | + previews: {}, |
| 84 | + resizeHandler: null | ||
| 83 | }; | 85 | }; |
| 84 | }, | 86 | }, |
| 85 | methods: { | 87 | methods: { |
| @@ -90,6 +92,16 @@ export default { | @@ -90,6 +92,16 @@ export default { | ||
| 90 | // 打开弹出层结束时的回调 | 92 | // 打开弹出层结束时的回调 |
| 91 | modalOpened() { | 93 | modalOpened() { |
| 92 | this.visible = true; | 94 | this.visible = true; |
| 95 | + if (!this.resizeHandler) { | ||
| 96 | + this.resizeHandler = debounce(() => { | ||
| 97 | + this.refresh() | ||
| 98 | + }, 100) | ||
| 99 | + } | ||
| 100 | + window.addEventListener("resize", this.resizeHandler) | ||
| 101 | + }, | ||
| 102 | + // 刷新组件 | ||
| 103 | + refresh() { | ||
| 104 | + this.$refs.cropper.refresh(); | ||
| 93 | }, | 105 | }, |
| 94 | // 覆盖默认的上传行为 | 106 | // 覆盖默认的上传行为 |
| 95 | requestUpload() { | 107 | requestUpload() { |
| @@ -141,6 +153,7 @@ export default { | @@ -141,6 +153,7 @@ export default { | ||
| 141 | closeDialog() { | 153 | closeDialog() { |
| 142 | this.options.img = store.getters.avatar | 154 | this.options.img = store.getters.avatar |
| 143 | this.visible = false; | 155 | this.visible = false; |
| 156 | + window.removeEventListener("resize", this.resizeHandler) | ||
| 144 | } | 157 | } |
| 145 | } | 158 | } |
| 146 | }; | 159 | }; |
-
请 注册 或 登录 后发表评论