fix: update page
This commit is contained in:
@@ -48,9 +48,15 @@
|
|||||||
</view>
|
</view>
|
||||||
<scroll-view scroll-x class="avatar-scroll" show-scrollbar="false">
|
<scroll-view scroll-x class="avatar-scroll" show-scrollbar="false">
|
||||||
<view class="avatar-list">
|
<view class="avatar-list">
|
||||||
<view class="avatar-card upload-card" @tap="useWeChatAvatar">
|
<view class="avatar-card upload-card">
|
||||||
|
<button
|
||||||
|
class="wechat-avatar-btn"
|
||||||
|
open-type="chooseAvatar"
|
||||||
|
@chooseavatar="onChooseAvatar"
|
||||||
|
>
|
||||||
<view class="upload-icon">📷</view>
|
<view class="upload-icon">📷</view>
|
||||||
<text class="upload-text">微信头像</text>
|
<text class="upload-text">微信头像</text>
|
||||||
|
</button>
|
||||||
</view>
|
</view>
|
||||||
<view
|
<view
|
||||||
v-for="(item, i) in systemAvatars"
|
v-for="(item, i) in systemAvatars"
|
||||||
@@ -465,6 +471,25 @@ const handleLogind = async () => {
|
|||||||
// Logic after successful login if needed
|
// Logic after successful login if needed
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onChooseAvatar = async (e) => {
|
||||||
|
const avatarUrl = e.detail.avatarUrl;
|
||||||
|
if (!avatarUrl) return;
|
||||||
|
|
||||||
|
uni.showLoading({ title: "上传中...", mask: true });
|
||||||
|
try {
|
||||||
|
const imageUrl = await uploadImage(avatarUrl);
|
||||||
|
currentAvatar.value = {
|
||||||
|
id: "wechat_" + Date.now(),
|
||||||
|
imageUrl: imageUrl,
|
||||||
|
};
|
||||||
|
uni.hideLoading();
|
||||||
|
} catch (e) {
|
||||||
|
uni.hideLoading();
|
||||||
|
uni.showToast({ title: "上传失败", icon: "none" });
|
||||||
|
console.error("Upload avatar error", e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const useWeChatAvatar = () => {
|
const useWeChatAvatar = () => {
|
||||||
if (!isLoggedIn.value) {
|
if (!isLoggedIn.value) {
|
||||||
loginPopupRef.value.open();
|
loginPopupRef.value.open();
|
||||||
@@ -832,29 +857,50 @@ const loadImage = (url) => {
|
|||||||
position: relative;
|
position: relative;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
box-shadow: 0 6rpx 16rpx rgba(0, 0, 0, 0.06);
|
box-shadow: 0 6rpx 16rpx rgba(0, 0, 0, 0.06);
|
||||||
}
|
|
||||||
.avatar-card.active {
|
&.active {
|
||||||
outline: 4rpx solid #ff3b30;
|
outline: 4rpx solid #ff3b30;
|
||||||
}
|
}
|
||||||
|
|
||||||
.upload-card {
|
&.upload-card {
|
||||||
|
background: #fff5f5;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
background: #fff5f5;
|
|
||||||
border: 2rpx dashed #ffccc7;
|
border: 2rpx dashed #ffccc7;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
|
||||||
|
.wechat-avatar-btn {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
background: transparent;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
line-height: normal;
|
||||||
|
border: none;
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
border: none;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.upload-icon {
|
.upload-icon {
|
||||||
font-size: 48rpx;
|
font-size: 48rpx;
|
||||||
margin-bottom: 8rpx;
|
margin-bottom: 8rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.upload-text {
|
.upload-text {
|
||||||
font-size: 22rpx;
|
font-size: 22rpx;
|
||||||
color: #ff3b30;
|
color: #ff3b30;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.avatar-thumb {
|
.avatar-thumb {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|||||||
Reference in New Issue
Block a user