306132416@qq.com 3 éve%!(EXTRA string=óta)
szülő
commit
f2290dd946
2 módosított fájl, 90 hozzáadás és 24 törlés
  1. 20 14
      pages/index/activity/files.vue
  2. 70 10
      pages/index/activity/list.vue

+ 20 - 14
pages/index/activity/files.vue

@@ -4,12 +4,12 @@
 			<view class="img-container">
 				<label for="img">上传文件</label>
 				 <view class="note-image-box">
-					<view class="note-image-item" v-for="(item,index) in uploadList" :key="index">
+					<view class="note-image-item" v-for="(item,index) in uploadList" :key="item.id">
 						<!-- //右上角删除图标 -->
 						<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)">
+						<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>
@@ -65,7 +65,6 @@
 				fileIdList: [],
 				uploadList:[],
 				contentDesc:'',
-				contentLink:'',
 				type:'add',
 				isShowShareModal:false,
 			}
@@ -117,11 +116,11 @@
 					success: (res) => {
 					  if (res.data.code === 200) {
 						  let obj = res.data.data;
-						  // this.recordId = obj.id;
-						  // this.contentDesc = obj.content;
-						  // this.contentLink = obj.web_url;
-						  // this.uploadList = obj.pic_list.map((item)=>{return this.globalUrl + item.pic_url});
-						  // this.imgIdList = obj.pic_list.map((item)=>{return item.pic_id})
+						  console.log(obj)
+						  this.recordId = obj.id;
+						  this.contentDesc = obj.content;
+						  this.uploadList = obj.file_list;
+						  console.log(this.uploadList)
 					  }
 					},
 					fail: () => {
@@ -172,13 +171,17 @@
 							  icon: "none", 
 							  duration: 2500,
 							});
+							let pages = getCurrentPages(); // 获取当前页面栈的实例,以数组形式按栈的顺序给出,第一个元素为首页,最后一个元素为当前页面。
+							let nowPage = pages[pages.length - 1]; //当前页页面实例
+							let prevPage = pages[pages.length - 2]; //上一页页面实例
+							prevPage.$vm.pageShowShare('edit','files')
 							setTimeout(()=>{uni.navigateBack({})},500)
 						}else {
 							let types = 'add';
 							let pages = getCurrentPages(); // 获取当前页面栈的实例,以数组形式按栈的顺序给出,第一个元素为首页,最后一个元素为当前页面。
 							let nowPage = pages[pages.length - 1]; //当前页页面实例
 							let prevPage = pages[pages.length - 2]; //上一页页面实例
-							prevPage.$vm.pageShowShare(types,'file')
+							prevPage.$vm.pageShowShare(types,'files')
 							uni.showToast({
 							  title: "上传成功",
 							  icon: "none", 
@@ -195,26 +198,29 @@
 				});
 			},
 		 openFile(files){
-			console.log(files)
+			uni.showLoading({
+				mask:true,
+				title:'加载中...',
+				icon:'none'
+			})  
 			uni.downloadFile({
-				url: files,
+				url: getApp().globalData.shareUrl + files,
 				success: function(res) {
 					var filePath = res.tempFilePath;
 					//打开文件有效值 doc, xls, ppt, pdf, docx, xlsx, pptx
 					uni.openDocument({
 						filePath:filePath,
 						success: function(res) {
-							console.log(res)
+							uni.hideLoading();
 							//that.downloadFile_onoff = true;
 						},
 						fail(res) {
-							console.log(res)
 							uni.showToast({
 								title: '暂不支持此类型',
 								icon:'none',
 								duration: 2000
 							});
-							//uni.hideLoading();
+							uni.hideLoading();
 							//that.downloadFile_onoff = true;
 						}
 					}); 

+ 70 - 10
pages/index/activity/list.vue

@@ -60,11 +60,15 @@
 		 					</view>
 		 					<view class="active-date-comment">{{item.addtime}}</view>
 		 				</view>	
-		 				<view class="active-content-files margin-top-1">
-						     	
+		 				<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>
 						</view>
+						<view class="files-desc-box">{{item.content}}</view>
 		 				<view class="edit-icon-box-comment">
-		 					  <image src="/static/edit-icon.png" mode="aspectFit" v-if="item.edit_auth" @click="goEditPage(item.id,'comment')"></image>
+		 					  <image src="/static/edit-icon.png" mode="aspectFit" v-if="item.edit_auth" @click="goEditPage(item.id,'files')"></image>
 		 					  <image class="margin-right-0" src="/static/del-icon.png" mode="aspectFit" v-if="item.del_auth" @click="delProcess(item.id,'files')"></image>
 		 				</view>
 		 </view>
@@ -156,6 +160,7 @@ export default {
 			}  
 		  },
 		  pageShowShare(obj,tabs){
+			  console.log(obj,tabs)
 			  switch (tabs){
 				case 'record':
 				this.readActive(this.recordId)
@@ -185,27 +190,30 @@ export default {
 			 }
 		  },
 		  //打开文件
-		  openFile(files){
-		  	console.log(files)
+		  openFileFn(files){
+			uni.showLoading({
+				mask:true,
+				title:'加载中...',
+				icon:'none'
+			})  
 		  	uni.downloadFile({
-		  		url: files,
+		  		url: getApp().globalData.shareUrl + files,
 		  		success: function(res) {
 		  			var filePath = res.tempFilePath;
 		  			//打开文件有效值 doc, xls, ppt, pdf, docx, xlsx, pptx
 		  			uni.openDocument({
 		  				filePath:filePath,
 		  				success: function(res) {
-		  					console.log(res)
 		  					//that.downloadFile_onoff = true;
+							uni.hideLoading();
 		  				},
 		  				fail(res) {
-		  					console.log(res)
 		  					uni.showToast({
 		  						title: '暂不支持此类型',
 		  						icon:'none',
 		  						duration: 2000
 		  					});
-		  					//uni.hideLoading();
+		  					uni.hideLoading();
 		  					//that.downloadFile_onoff = true;
 		  				}
 		  			}); 
@@ -299,6 +307,41 @@ export default {
 				},
 			  });
 		  },
+		  delFilesRequeset(delId){
+			  let md5Sign = md5(
+				"method=" +"activity" + "&timestamp=" + getApp().globalData.globalTimestamp +
+				  "&secret=" + getApp().globalData.secret
+			  );
+			  let url = getApp().globalData.shareUrl +"api/api.php" +
+				"?method=activity&action=files_del&timestamp=" +
+				getApp().globalData.globalTimestamp + "&sign=" + md5Sign;
+			  uni.request({
+				url: url,
+				method: "POST",
+				header: {
+				  "content-type": "application/x-www-form-urlencoded",
+				},
+				data: {
+				  openid: getApp().globalData.open_id,
+				  id:delId
+				},
+				success: (res) => {
+				  if (res.data.code === 200) {
+					uni.showToast({
+					  title: "删除成功",
+					  icon: "none", 
+					  duration: 2500,
+					  success:()=>{
+						 this.getFileList(this.activeId)
+					  }
+					});
+				  }
+				},
+				fail: () => {
+				  console.log("连接失败");
+				},
+			  });
+		  },
 		  delProcess(id,type){
 		  		 let that = this;
 				 let typeTitle;
@@ -309,7 +352,7 @@ export default {
 					case 'comment':
 					 typeTitle = '确定删除此评论吗'
 						break;	
-					case 'comment':
+					case 'files':
 					 typeTitle = '确定删除此文件吗'
 						break;	
 				 }
@@ -323,6 +366,9 @@ export default {
 		  		 	    else if (type === 'comment') {
 							that.delCommentRequeset(id);
 						}
+						else if (type === 'files') {
+							that.delFilesRequeset(id);
+						}
 		  		 	} else if (res.cancel) {
 		  		 	  console.log("用户点击取消");
 		  		 	}
@@ -791,4 +837,18 @@ export default {
 			margin-right: 10rpx;	
 		} 
 	}
+	.files-class-box {
+		display: flex;
+		justify-content: flex-start;
+		margin-top: 10px;
+		width: 80%;
+	}
+	.files-desc-box {
+		text-align: center;
+		margin-top: 10px;
+	}
+    .show-file-box {
+		width: 30%;
+		margin-right: 20rpx;
+	}
 </style>