Procházet zdrojové kódy

头像上传大小不得超过 10MB !

lifanagju_citu před 6 měsíci
rodič
revize
b4ba059466
2 změnil soubory, kde provedl 15 přidání a 5 odebrání
  1. 2 2
      pages/index/my.vue
  2. 13 3
      pagesA/resumeOnline/baseInfoEdit.vue

+ 2 - 2
pages/index/my.vue

@@ -259,8 +259,8 @@ const handleLogoutConfirm = () => {
 	.vipIcon {
 		position: absolute;
 		width: 45px;
-		height: 45px;
-		bottom: 24px;
+		height: 24px;
+		bottom: 34px;
 		left: 50%;
 	}
 }

+ 13 - 3
pagesA/resumeOnline/baseInfoEdit.vue

@@ -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;