hookehuyr

fix(AddProfile): 修复头像显示问题并调整图片大小限制

将头像显示逻辑简化为使用默认头像当未设置时
调整图片上传大小限制从10MB降至5MB
......@@ -3,8 +3,7 @@
<!-- Avatar -->
<view class="flex flex-col items-center py-8" @click="changeAvatar">
<view class="w-24 h-24 rounded-full bg-gray-100 flex items-center justify-center mb-2 overflow-hidden">
<image v-if="formData.avatar_url" :src="formData.avatar_url" class="w-full h-full" mode="aspectFill" />
<My size="40" color="#888" v-else />
<image :src="formData.avatar_url || defaultAvatar" class="w-full h-full" mode="aspectFill" />
</view>
<text class="text-gray-500 text-sm">上传头像</text>
</view>
......@@ -85,8 +84,10 @@
<script setup>
import { ref, reactive, onMounted, computed } from 'vue';
import Taro from '@tarojs/taro';
import { My, Date as DateIcon, Right } from '@nutui/icons-vue-taro';
import { Date as DateIcon, Right } from '@nutui/icons-vue-taro';
import BASE_URL from '@/utils/config';
// 默认头像
const defaultAvatar = 'https://cdn.ipadbiz.cn/mlaj/images/icon_1.jpeg'
/**
* @description 表单数据
......@@ -180,9 +181,9 @@ const changeAvatar = () => {
sourceType: ['album', 'camera'],
success: (res) => {
const tempFile = res.tempFiles[0];
if (tempFile.size > 10 * 1024 * 1024) {
if (tempFile.size > 5 * 1024 * 1024) {
Taro.showToast({
title: '图片大小不能超过10MB',
title: '图片大小不能超过5MB',
icon: 'none',
});
return;
......