瀏覽代碼

update pc_chat

luke 6 年之前
父節點
當前提交
a9004d0571
共有 2 個文件被更改,包括 31 次插入6 次删除
  1. 30 5
      pc_chat/src/components/leaveMsg.vue
  2. 1 1
      pc_chat/src/components/ledgeBase.vue

+ 30 - 5
pc_chat/src/components/leaveMsg.vue

@@ -62,14 +62,15 @@
 						<!-- :on-preview="handlePictureCardPreview"  :on-remove="handleRemove" -->
 						<el-upload style="margin-top:14px;"
 								   action="/api/index/upload/uploadImg"
-								   :before-upload="beforeAvatarUpload"
+								   ref="upload"
+								   :file-list="fileList"
 								   :on-change='uploadChange'
+								   :before-upload="beforeAvatarUpload"
 								   :on-success='uploadSuccess'
 								   :on-error="uploadError"
 								   :on-remove="handleRemove"
 								   :auto-upload="false"
 								   list-type="picture-card"
-								   ref="upload"
 								   :limit="4"
 								   :on-exceed="handleExceed"
 						>
@@ -107,6 +108,8 @@
 				WX: '',
 				uploadImg: [],//上传图片的数据集合
 				imgUrl:'',
+				fileList: [],
+				isUpImg:false,
 			}
 		},
 		methods: {
@@ -122,12 +125,13 @@
 					this.$message.error('请填写留言信息!');
 				} else {
 					// 手动上传
+					this.isUpImg = true;
 					this.$refs.upload.submit();
 					let _this = this;
 					let uid = localStorage.getItem('uid');
 
 					setTimeout(function () {
-						// console.log(this.imgUrl,"上传的图片")
+						console.log(this.imgUrl,"上传的图片")
 						let params = {
 							'nick_name': _this.call,
 							'email': _this.eMail,
@@ -142,6 +146,8 @@
 							if (res.data.code == 1) {
 								_this.$message.success('留言成功')
 								_this.$emit('value', 10);
+								this.$refs.upload.clearFiles();
+								this.fileList =[];
 							}
 						})
 					}, 1500)
@@ -185,8 +191,7 @@
 				if (!isLt1M) {
 					this.$message.error('上传文件大小不能超过 2MB!');
 				}
-
-				return isJPG && isLt1M;
+				return isJPG && isLt1M
 			},
 			// 上传成功时的回调
 			uploadSuccess(res, file) {
@@ -209,6 +214,26 @@
 			// 每次改变图片状态返回的回调
 			uploadChange(file, fileList) {
 				// console.log('每次改变图片状态返回的回调', fileList)
+				const isJPG = file.raw.type == 'image/jpeg' || 'image/jpg' || 'image/png' || 'image/svg';
+				const isLt1M = file.size / 1024 / 1024 < 0.5;
+				if (!isJPG) {
+					this.$message.error('上传只能是图片格式!');
+					fileList.pop();
+					this.fileList = fileList;
+					return false
+				}
+				if (!isLt1M) {
+					this.$message.error('上传图片大小单张不能超过0.5MB!');
+					fileList.pop()
+					this.fileList = fileList;
+					return false
+				}
+				this.$refs.upload.clearFiles();
+				if(!this.isUpImg){
+					this.fileList.push(file)
+				}else{
+					this.fileList = fileList
+				}
 			},
 		}
 	}

+ 1 - 1
pc_chat/src/components/ledgeBase.vue

@@ -220,7 +220,7 @@
 	.title {
 		float: left;
 		width: 300px;
-		overflow-y: hidden;
+		overflow: hidden;
 		word-break: keep-all;
 		white-space: nowrap;
 		text-overflow: ellipsis;