zizhong.wang 3 년 전
부모
커밋
2db7642688
2개의 변경된 파일94개의 추가작업 그리고 79개의 파일을 삭제
  1. 89 5
      components/artical-deatil/index.vue
  2. 5 74
      pages/notice/notice_deatil.vue

+ 89 - 5
components/artical-deatil/index.vue

@@ -13,6 +13,15 @@
 		<u-parse :content="model.artical"  @navigate="navigateUrl" />
       </view>
     </view>
+	
+	<view style="margin-bottom: 12%;">
+		<view class="closure-font" v-if="enClosureList.length">附件:</view>
+		<view class="enClosure-box" v-for="(item,index) in enClosureList" :key="item.id">
+			<view @click="showEnclosure(item.url)">{{index + 1}}.{{item.name}}</view>
+		</view>
+	</view>
+	
+	
     <view class="footer">
       <view style="width: 100%">
         <footer-share
@@ -40,13 +49,26 @@ export default {
       type: String,
       default: "",
     },
-  },
-  components: {
-    FooterShare,
-	uParse
-  },
+	enclosureIds: {
+	  type: String,
+	  default: "",
+	},
+	},
+    components: {
+		FooterShare,
+		uParse
+	},
+	watch:{
+		enclosureIds:function(val){
+	        if(val){
+				this.getEnclosure(val)
+			}
+		},
+	},
   data() {
     return {
+		enClosureList:[],
+		shareUrl:getApp().globalData.shareUrl
       // model: {
       //   title: " 线上直播课程 | 《精准识人 - 人才面试评估分享会》",
       //   // way: "区人力资源局",
@@ -67,6 +89,53 @@ export default {
 	  		}
 	  	  });
 	  },
+	showEnclosure(url){
+		uni.showLoading({
+			title:'加载中...'
+		})
+		let urls = this.shareUrl + url;
+		uni.downloadFile({
+		  url: urls,
+		  success: function (res) {
+			var filePath = res.tempFilePath;
+			uni.openDocument({
+			  filePath: filePath,
+			  showMenu: true,
+			  success: function (res) {
+				uni.hideLoading();
+			  }
+			});
+		  }
+		});
+	},
+	getEnclosure(athId){
+		let md5Sign = md5(
+		  "method=" +"common" +"&timestamp=" + getApp().globalData.globalTimestamp +"&secret=" +getApp().globalData.secret
+		);
+		let url =
+		  getApp().globalData.shareUrl + "api/api.php" +"?method=common&action=attach_ids&timestamp=" +
+		  getApp().globalData.globalTimestamp + "&sign=" + md5Sign;
+		let postData = {
+		  attach_ids: athId,
+		};
+		//获取文章
+		uni.request({
+		  url: url,
+		  method: "POST",
+		  header: {
+		    "content-type": "application/x-www-form-urlencoded",
+		  },
+		  data: postData,
+		  success: (res) => {
+		    if (res.data.code === 200) {
+				this.enClosureList = res.data.data;
+		    }
+		  },
+		  fail: () => {
+		    console.log("连接失败");
+		  },
+		});
+	},  
     sharePage() {
     let that = this;
     console.log('点击分享');
@@ -158,5 +227,20 @@ export default {
       padding: 30rpx;
     }
   }
+  .closure-font {
+  	font-size: 28rpx;
+  	padding-left: 40rpx;
+  	margin-bottom: 20rpx;
+  }
+  .enClosure-box {
+  	width: 100%;
+  	display: flex;
+  	flex-direction: column;
+  	font-size: 28rpx;
+  	color: cornflowerblue;
+  	cursor: pointer;
+  	margin-bottom: 20rpx;
+	text-indent: 50rpx;
+  }
 }
 </style>

+ 5 - 74
pages/notice/notice_deatil.vue

@@ -1,12 +1,6 @@
 <template>
   <view>
-    <artical-deatil :model="model"></artical-deatil>
-	<view style="margin-bottom: 12%;">
-		<view class="closure-font" v-if="enClosureList.length">附件:</view>
-		<view class="enClosure-box" v-for="(item,index) in enClosureList" :key="item.id">
-			<view @click="showEnclosure(item.url)">{{index + 1}}.{{item.name}}</view>
-		</view>
-	</view>
+    <artical-deatil :model="model" :enclosureIds="enclosureId"></artical-deatil>
   </view>
 </template>
 
@@ -23,8 +17,7 @@ export default {
         artical: "",
         id: "",
       },
-	  enClosureList:[],
-	  shareUrl:getApp().globalData.shareUrl
+	  enclosureId:'',
     };
   },
   components: {
@@ -67,15 +60,14 @@ export default {
             let data = res.data.data;
             this.model.title = data.title;
             this.model.way = data.sponsor;
+			this.enclosureId = data.attach_ids;
+			console.log(this.enclosureId)
             let time = this.$options.filters["globalTime"](data.publish_time);
             let timeSecond = this.$options.filters["globalTimeSecond"](
               data.publish_time
             );
             this.model.time = time + " " + timeSecond;
             this.getRich();
-			if(data.attach_ids){
-				this.getEnclosure(data.attach_ids)
-			}
           }
         },
         fail: () => {
@@ -83,53 +75,6 @@ export default {
         },
       });
     },
-	showEnclosure(url){
-		uni.showLoading({
-			title:'加载中...'
-		})
-		let urls = this.shareUrl + url;
-		uni.downloadFile({
-		  url: urls,
-		  success: function (res) {
-			var filePath = res.tempFilePath;
-			uni.openDocument({
-			  filePath: filePath,
-			  showMenu: true,
-			  success: function (res) {
-				uni.hideLoading();
-			  }
-			});
-		  }
-		});
-	},
-	getEnclosure(athId){
-		let md5Sign = md5(
-		  "method=" +"common" +"&timestamp=" + getApp().globalData.globalTimestamp +"&secret=" +getApp().globalData.secret
-		);
-		let url =
-		  getApp().globalData.shareUrl + "api/api.php" +"?method=common&action=attach_ids&timestamp=" +
-		  getApp().globalData.globalTimestamp + "&sign=" + md5Sign;
-		let postData = {
-		  attach_ids: athId,
-		};
-		//获取文章
-		uni.request({
-		  url: url,
-		  method: "POST",
-		  header: {
-		    "content-type": "application/x-www-form-urlencoded",
-		  },
-		  data: postData,
-		  success: (res) => {
-		    if (res.data.code === 200) {
-				this.enClosureList = res.data.data;
-		    }
-		  },
-		  fail: () => {
-		    console.log("连接失败");
-		  },
-		});
-	},
     replaceImg(html) {
       let result = html.replace(
         /<img [^>]*src=['"]([^'"]+)[^>]*>/gi,
@@ -174,19 +119,5 @@ export default {
 </script>
 
 <style lang="scss" scoped>
-	.closure-font {
-		font-size: 28rpx;
-		padding-left: 40rpx;
-		margin-bottom: 20rpx;
-	}
-	.enClosure-box {
-		width: 100%;
-		display: flex;
-		flex-direction: column;
-		font-size: 28rpx;
-		padding-left: 52rpx;
-		color: cornflowerblue;
-		cursor: pointer;
-		margin-bottom: 20rpx;
-	}
+
 </style>