|
@@ -3,9 +3,9 @@
|
|
|
<uni-forms ref="form" :modelValue="formData" :rules="rules" validateTrigger="bind" label-width="105px" label-align="right">
|
|
|
<uni-forms-item label="头像" name="avatar" class="f-straight">
|
|
|
<view style="display: flex;flex-wrap: wrap;">
|
|
|
- <view class="upload-img" v-if="formData?.avatar" @click="handlePreviewImage">
|
|
|
- <uni-icons size="30" type="clear" color="#fe574a" style="position: absolute;right: -11px; top: -11px; z-index: 9" @click="formData.avatar = ''"></uni-icons>
|
|
|
- <image :src="formData?.avatar" mode="contain" style="width: 200rpx;height: 200rpx;"></image>
|
|
|
+ <view class="upload-img" v-if="formData?.avatar">
|
|
|
+ <uni-icons size="35" type="clear" color="#fe574a" style="position: absolute;right: -15px; top: -15px; z-index: 9" @click="formData.avatar = ''"></uni-icons>
|
|
|
+ <image :src="formData?.avatar" mode="contain" style="width: 200rpx;height: 200rpx;" @click="handlePreviewImage"></image>
|
|
|
</view>
|
|
|
<view v-else class="upload-file" @click="uploadPhotos">
|
|
|
<uni-icons type="plusempty" size="50" color="#f1f1f1"></uni-icons>
|
|
@@ -113,6 +113,15 @@ const uploadPhotos = () => {
|
|
|
sizeType: ['original', 'compressed'],
|
|
|
sourceType: ['album', 'camera'],
|
|
|
success: function(res){
|
|
|
+ const size = res.tempFiles[0]?.size || 0
|
|
|
+ if (size >= 10485760) {
|
|
|
+ uni.showToast({
|
|
|
+ icon: 'none',
|
|
|
+ title: '头像上传大小不得超过 10MB !',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
const path = res.tempFilePaths[0]
|
|
|
uploadFile(path).then(res => {
|
|
|
formData.value.avatar = res.data
|
|
@@ -167,6 +176,7 @@ const submit = async () => {
|
|
|
|
|
|
.wrapper{
|
|
|
padding: 15px;
|
|
|
+ padding-top: 30px;
|
|
|
}
|
|
|
.upload-img{
|
|
|
position: relative;
|