Browse Source

file show and click

zizhong.wang 3 years ago
parent
commit
0a58ed0753
1 changed files with 71 additions and 1 deletions
  1. 71 1
      pages/makeField/fieldForm.vue

+ 71 - 1
pages/makeField/fieldForm.vue

@@ -43,7 +43,7 @@
         </view>
         <view class="approve-box">
 			<view class="approve-title">请下载格式审批单,填写信息并加盖企业公章后上传</view>
-			<view class="approve-content">格式审批单下载:<text>临空产业园党群服务中心线上预约审批单</text></view>
+			<view class="approve-content">格式审批单下载:<text @click="()=>openFile(areaObj.file_path)">{{areaObj.file_name}}</text></view>
 		</view>
 	  </view>
     </view>
@@ -77,13 +77,83 @@ export default {
       uploadList: [],
       imgIdList: [],
 	  timeObj:{},
+	  areaObj:{},
     };
   },
   onLoad(option) {
     this.timeObj = option;
+	this.id = option.id
+	this.getAreaDeatil(option.id);
 	console.log(this.timeObj)
   },
   methods: {
+	openFile(files){
+				uni.showLoading({
+					mask:true,
+					title:'加载中...',
+					icon:'none'
+				})  
+				uni.downloadFile({
+					url: getApp().globalData.shareUrl + files,
+					success: function(res) {
+						var filePath = res.tempFilePath;
+						//打开文件有效值 doc, xls, ppt, pdf, docx, xlsx, pptx
+						uni.openDocument({
+							filePath:filePath,
+							showMenu:true,
+							success: function(res) {
+								uni.hideLoading();
+								//that.downloadFile_onoff = true;
+							},
+							fail(res) {
+								uni.showToast({
+									title: '暂不支持此类型',
+									icon:'none',
+									duration: 2000
+								});
+								uni.hideLoading();
+								//that.downloadFile_onoff = true;
+							}
+						}); 
+						}
+					});
+	},  
+	getAreaDeatil(areaId) {
+	  let md5Sign = md5(
+	    "method=" +
+	      "area" +
+	      "&timestamp=" +
+	      getApp().globalData.globalTimestamp +
+	      "&secret=" +
+	      getApp().globalData.secret
+	  );
+	  let url =
+	    getApp().globalData.shareUrl +
+	    "api/api.php" +
+	    "?method=area&source=area&action=info_by_id&timestamp=" +
+	    getApp().globalData.globalTimestamp +
+	    "&sign=" +
+	    md5Sign;
+	  let postData = {
+	    area_id: areaId,
+	  };
+	  uni.request({
+	    url: url,
+	    method: "POST",
+	    header: {
+	      "content-type": "application/x-www-form-urlencoded",
+	    },
+	    data: postData,
+	    success: (res) => {
+	      if (res.data.code == 200) {
+	        this.areaObj = res.data.data;
+	      }
+	    },
+	    fail: () => {
+	      console.log("连接失败");
+	    },
+	  });
+	},  
     submit() {
 		if (
 		  !this.company.name ||