306132416@qq.com 3 years ago
parent
commit
c77d28493c

+ 45 - 6
pages/index/activity/files.vue

@@ -9,9 +9,9 @@
 						<view class="close-icon" @click="delFile(index)">
 							<uni-icons type="closeempty" size="18" color="#fff"></uni-icons>
 						</view>
-						<view class="image-box display-around-column" @click="()=>openFile(item.url)">
-							<image src="../../../static/file.png" mode="aspectFill" style="width: 90rpx;height: 70rpx;"></image>
-							<view class="margin-top-3">{{item.name}}</view>
+						<view class="image-box display-evenly-column" @click="()=>openFile(item.url)">
+							<image :src=" fileType[item.type] ||'../../../static/file.png'" mode="aspectFill" style="width: 70rpx;height: 70rpx;"></image>
+							<view class="file-font-box">{{item.name}}</view>
 						</view>
 					</view>
 					<view v-if="uploadList.length < 3" class="note-image-item" @click="chooseFile()">
@@ -67,6 +67,14 @@
 				contentDesc:'',
 				type:'add',
 				isShowShareModal:false,
+				fileType:{
+				  'docx':'../../../static/files-icon/word.png',
+				  'doc':'../../../static/files-icon/word.png',
+				  'pdf':'../../../static/files-icon/pdf.png',
+				  'xlsx':'../../../static/files-icon/excel.png',
+				  'xls':'../../../static/files-icon/excel.png',
+				  'ppt':'../../../static/files-icon/ppt.png',
+				}
 			}
 		},
 		onLoad(option) {
@@ -96,6 +104,13 @@
 				});
 				setTimeout(()=>{uni.navigateBack({})},500)
 			},
+			splitFileNameList(fileList){
+				  let arr = fileList;
+				  arr.forEach((item,index)=>{
+					item.type = item.name.split('.').pop().toLowerCase();
+				  })
+				  return arr;
+			},
 			getInfos(id){
 				let md5Sign = md5(
 					"method=" +"activity" + "&timestamp=" + getApp().globalData.globalTimestamp +
@@ -116,10 +131,14 @@
 					success: (res) => {
 					  if (res.data.code === 200) {
 						  let obj = res.data.data;
-						  console.log(obj)
 						  this.recordId = obj.id;
 						  this.contentDesc = obj.content;
-						  this.uploadList = obj.file_list;
+						   obj.file_list.forEach((item)=>{
+							  this.fileIdList.push(item.id)
+						  })
+						  let fileArr = obj.file_list;
+						  console.log(fileArr)
+						  this.uploadList = this.splitFileNameList(fileArr);
 						  console.log(this.uploadList)
 					  }
 					},
@@ -230,6 +249,11 @@
 		  chooseFile(){
 		  	//chooseMessageFile
 		  	let that = this;
+			uni.showLoading({
+				mask:true,
+				title:'上传中...',
+				icon:'none'
+			})  
 		  	uni.chooseMessageFile({
 		  	  count: 3,
 		  	  type: 'file',
@@ -244,6 +268,11 @@
 		  	})
 		  	console.log('文件上传')
 		  },
+		  splitFileName(param){
+		  	  let obj = param;
+			  obj.type = param.name.split('.').pop().toLowerCase();
+		  	  return obj;
+		  },
 		  uploadFileRequest(fileVal){
 		  	let that = this;
 			let md5Sign = md5(
@@ -264,10 +293,11 @@
 		  		},
 		  		success: res => {
 					 this.fileObj = JSON.parse(res.data);
-					 console.log(this.fileObj.data)
+					 this.fileObj.data = this.splitFileName(this.fileObj.data);
 					 this.fileObj.data.url = getApp().globalData.shareUrl + this.fileObj.data.url;
 					 this.uploadList.push(this.fileObj.data);
 					 this.fileIdList.push(this.fileObj.data.id);
+					 uni.hideLoading();
 		  		},
 		  		fail:res=>{
 		  			console.log("上传请求失败");
@@ -278,6 +308,7 @@
 			delFile(idx) {
 			  this.uploadList.splice(idx, 1);
 			  this.fileIdList.splice(idx, 1);
+			  console.log(this.fileIdList)
 			},
 		}
 	}
@@ -584,4 +615,12 @@
 			}
 		}
 	}
+	.file-font-box {
+		margin-top: 10rpx;
+		width: 60%;
+		white-space: nowrap;
+		overflow: hidden;
+		text-overflow: ellipsis;
+		font-size: 24rpx;
+	}
 </style>

+ 30 - 5
pages/index/activity/list.vue

@@ -61,9 +61,9 @@
 		 					<view class="active-date-comment">{{item.addtime}}</view>
 		 				</view>	
 		 				<view class="active-content-files files-class-box">
-						     	<view class="show-file-box" v-for="(file,index) in item.file_list" :key="file.id" @click="()=>openFileFn(file.url)">
-						     		<image src="../../../static/file.png" mode="aspectFill" style="width: 90rpx;height: 70rpx;"></image>
-						     		<view class="margin-top-3" style="font-size: 24rpx;">{{file.name}}</view>
+						     	<view class="show-file-box display-evenly-column .items-center" v-for="(file,index) in item.file_list" :key="file.id" @click="()=>openFileFn(file.url)">
+						     		<image :src="fileType[file.type] || '../../../static/file.png'" mode="aspectFill" style="width: 70rpx;height: 70rpx;"></image>
+						     		<view class="margin-top-3 file-font-box">{{file.name}}</view>
 						     	</view>
 						</view>
 						<view class="files-desc-box">{{item.content}}</view>
@@ -122,6 +122,14 @@ export default {
 	  isShowShareModal:false,
 	  items:['记录','文件','评论'],
 	  current:0,
+	  fileType:{
+		  'docx':'../../../static/files-icon/word.png',
+		  'doc':'../../../static/files-icon/word.png',
+		  'pdf':'../../../static/files-icon/pdf.png',
+		  'xlsx':'../../../static/files-icon/excel.png',
+		  'xls':'../../../static/files-icon/excel.png',
+		  'ppt':'../../../static/files-icon/ppt.png',
+	  }
     };
   },
   onLoad(option) {
@@ -434,6 +442,15 @@ export default {
 				},
 			  });
 		  },
+		  splitFileName(fileList){
+			  let arr = fileList;
+			  arr.forEach((item,index)=>{
+				  item.file_list.forEach((child,childIndex)=>{
+					  child.type = child.name.split('.').pop().toLowerCase();
+				  })
+			  })
+			  return arr;
+		  },
 		  getFileList(id){
 			  let md5Sign = md5(
 				"method=" +"activity" + "&timestamp=" + getApp().globalData.globalTimestamp +
@@ -454,8 +471,9 @@ export default {
 				},
 				success: (res) => {
 				  if (res.data.code === 200) {
-					  console.log(res.data.data)
-					  this.fileList = res.data.data.list;
+					  let fileArr = res.data.data.list;
+					  this.fileList = this.splitFileName(fileArr);
+					  console.log(this.fileList)
 				  }
 				},
 				fail: () => {
@@ -851,4 +869,11 @@ export default {
 		width: 30%;
 		margin-right: 20rpx;
 	}
+	.file-font-box {
+		width: 60%;
+		white-space: nowrap;
+		overflow: hidden;
+		text-overflow: ellipsis;
+		font-size: 24rpx;
+	}
 </style>

BIN
static/files-icon/excel.png


BIN
static/files-icon/pdf.png


BIN
static/files-icon/ppt.png


BIN
static/files-icon/word.png