forked from funtl/MyShopPlus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
deb98f1
commit 4db4470
Showing
12 changed files
with
352 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
...le/business-profile-feign/src/main/java/com/funtl/myshop/plus/business/dto/IconParam.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.funtl.myshop.plus.business.dto; | ||
|
||
import lombok.Data; | ||
|
||
import java.io.Serializable; | ||
|
||
/** | ||
* 修改头像参数 | ||
* <p> | ||
* Description: | ||
* </p> | ||
* | ||
* @author Lusifer | ||
* @version v1.0.0 | ||
* @date 2019-08-26 23:44:42 | ||
* @see com.funtl.myshop.plus.business.dto | ||
*/ | ||
@Data | ||
public class IconParam implements Serializable { | ||
|
||
/** | ||
* 用户名 | ||
*/ | ||
private String username; | ||
|
||
/** | ||
* 头像地址 | ||
*/ | ||
private String path; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
<template> | ||
<div :style="{zIndex:zIndex,height:height,width:width}" class="pan-item"> | ||
<div class="pan-info"> | ||
<div class="pan-info-roles-container"> | ||
<slot /> | ||
</div> | ||
</div> | ||
<!-- eslint-disable-next-line --> | ||
<div :style="{backgroundImage: `url(${image})`}" class="pan-thumb"></div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: 'PanThumb', | ||
props: { | ||
image: { | ||
type: String, | ||
required: true | ||
}, | ||
zIndex: { | ||
type: Number, | ||
default: 1 | ||
}, | ||
width: { | ||
type: String, | ||
default: '150px' | ||
}, | ||
height: { | ||
type: String, | ||
default: '150px' | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
.pan-item { | ||
width: 200px; | ||
height: 200px; | ||
border-radius: 50%; | ||
display: inline-block; | ||
position: relative; | ||
cursor: default; | ||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); | ||
} | ||
.pan-info-roles-container { | ||
padding: 20px; | ||
text-align: center; | ||
} | ||
.pan-thumb { | ||
width: 100%; | ||
height: 100%; | ||
background-position: center center; | ||
background-size: cover; | ||
border-radius: 50%; | ||
overflow: hidden; | ||
position: absolute; | ||
transform-origin: 95% 40%; | ||
transition: all 0.3s ease-in-out; | ||
} | ||
/* .pan-thumb:after { | ||
content: ''; | ||
width: 8px; | ||
height: 8px; | ||
position: absolute; | ||
border-radius: 50%; | ||
top: 40%; | ||
left: 95%; | ||
margin: -4px 0 0 -4px; | ||
background: radial-gradient(ellipse at center, rgba(14, 14, 14, 1) 0%, rgba(125, 126, 125, 1) 100%); | ||
box-shadow: 0 0 1px rgba(255, 255, 255, 0.9); | ||
} */ | ||
.pan-info { | ||
position: absolute; | ||
width: inherit; | ||
height: inherit; | ||
border-radius: 50%; | ||
overflow: hidden; | ||
box-shadow: inset 0 0 0 5px rgba(0, 0, 0, 0.05); | ||
} | ||
.pan-info h3 { | ||
color: #fff; | ||
text-transform: uppercase; | ||
position: relative; | ||
letter-spacing: 2px; | ||
font-size: 18px; | ||
margin: 0 60px; | ||
padding: 22px 0 0 0; | ||
height: 85px; | ||
font-family: 'Open Sans', Arial, sans-serif; | ||
text-shadow: 0 0 1px #fff, 0 1px 2px rgba(0, 0, 0, 0.3); | ||
} | ||
.pan-info p { | ||
color: #fff; | ||
padding: 10px 5px; | ||
font-style: italic; | ||
margin: 0 30px; | ||
font-size: 12px; | ||
border-top: 1px solid rgba(255, 255, 255, 0.5); | ||
} | ||
.pan-info p a { | ||
display: block; | ||
color: #333; | ||
width: 80px; | ||
height: 80px; | ||
background: rgba(255, 255, 255, 0.3); | ||
border-radius: 50%; | ||
color: #fff; | ||
font-style: normal; | ||
font-weight: 700; | ||
text-transform: uppercase; | ||
font-size: 9px; | ||
letter-spacing: 1px; | ||
padding-top: 24px; | ||
margin: 7px auto 0; | ||
font-family: 'Open Sans', Arial, sans-serif; | ||
opacity: 0; | ||
transition: transform 0.3s ease-in-out 0.2s, opacity 0.3s ease-in-out 0.2s, background 0.2s linear 0s; | ||
transform: translateX(60px) rotate(90deg); | ||
} | ||
.pan-info p a:hover { | ||
background: rgba(255, 255, 255, 0.5); | ||
} | ||
.pan-item:hover .pan-thumb { | ||
transform: rotate(-110deg); | ||
} | ||
.pan-item:hover .pan-info p a { | ||
opacity: 1; | ||
transform: translateX(0px) rotate(0deg); | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,3 +63,8 @@ div:focus { | |
.app-container { | ||
padding: 20px; | ||
} | ||
|
||
.components-container { | ||
margin: 30px 50px; | ||
position: relative; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
<template> | ||
<div class="components-container"> | ||
<pan-thumb :image="image" /> | ||
|
||
<el-button type="primary" icon="upload" style="position: absolute;bottom: 15px;margin-left: 40px;" @click="toggleShow"> | ||
上传头像 | ||
</el-button> | ||
|
||
<image-cropper | ||
v-model="show" | ||
field="multipartFile" | ||
:width="300" | ||
:height="300" | ||
:url="url" | ||
:params="params" | ||
:headers="headers" | ||
img-format="png" | ||
@crop-success="cropSuccess" | ||
@crop-upload-success="cropUploadSuccess" | ||
@crop-upload-fail="cropUploadFail" | ||
/> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import ImageCropper from 'vue-image-crop-upload' | ||
import PanThumb from '@/components/PanThumb' | ||
import { getToken } from '../../utils/auth' | ||
import { modifyIcon } from '@/api/profile' | ||
export default { | ||
name: 'ProfileIcon', | ||
components: { ImageCropper, PanThumb }, | ||
data() { | ||
return { | ||
url: process.env.VUE_APP_BASE_API + '/upload', | ||
show: false, | ||
params: { | ||
access_token: getToken() | ||
}, | ||
headers: { | ||
smail: '*_~' | ||
}, | ||
image: this.$store.getters.avatar | ||
} | ||
}, | ||
methods: { | ||
toggleShow() { | ||
this.show = !this.show | ||
}, | ||
/** | ||
* | ||
* @param image | ||
* @param field | ||
*/ | ||
cropSuccess(image, field) { | ||
console.log('-------- crop success --------') | ||
this.image = image | ||
}, | ||
/** | ||
* 上传成功 | ||
* @param jsonData 服务器返回数据,已进行 JSON 转码 | ||
* @param field | ||
*/ | ||
cropUploadSuccess(jsonData, field) { | ||
console.log('-------- upload success --------') | ||
console.log(jsonData) | ||
console.log('path: ', jsonData.data.path) | ||
console.log('field: ' + field) | ||
// 更新头像 | ||
modifyIcon({ | ||
username: this.$store.getters.name, | ||
path: jsonData.data.path | ||
}).then(response => { | ||
this.$message({ | ||
message: response.message, | ||
type: 'success' | ||
}) | ||
// 更新 vuex 中的头像 | ||
this.$store.dispatch('user/setAvatar', jsonData.data.path) | ||
}).catch(() => { | ||
}) | ||
}, | ||
/** | ||
* 上传失败 | ||
* @param status 服务器返回的失败状态码 | ||
* @param field | ||
*/ | ||
cropUploadFail(status, field) { | ||
console.log('-------- upload fail --------') | ||
console.log(status) | ||
console.log('field: ' + field) | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
.avatar{ | ||
width: 200px; | ||
height: 200px; | ||
border-radius: 50%; | ||
} | ||
</style> |
Oops, something went wrong.