hookehuyr

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

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