Browse Source

文件下载获取权限

zouling 1 year ago
parent
commit
8822ab86ef

File diff suppressed because it is too large
+ 0 - 0
hybrid/html/js/web-office-sdk-solution-v2.0.6.umd.js


+ 46 - 0
hybrid/html/web-office.html

@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html lang="zh">
+<head>
+	<meta charset="UTF-8">
+	<meta name="viewport" content="width=device-width, initial-scale=1.0">
+	<title>文档在线预览</title>
+</head>
+<body>
+	<div></div>
+</body>
+<script charset="utf-8" src="js/web-office-sdk-solution-v2.0.6.umd.js"></script>
+<script type="text/javascript">
+	window.onload = function() {
+		let query = getQuery('data')
+		if(!query) {
+			alert('参数不存在')
+			return
+		}
+		query = JSON.parse(query)
+		let wps = WebOfficeSDK.init({
+			appId: 'SX20240516EYFBUA',
+			officeType: query.type,
+			fileId: query.file_id,
+			token: query.token,
+			// customArgs:{
+			// 	handel_type: query.handel_type
+			// }
+		})
+		wps.ApiEvent.AddApiEventListener("fileOpen", (data) => {
+			if (!data.success) {
+				alert('文件打开失败');
+			}
+		});
+		
+		function getQuery(name) {
+			let reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
+			let r = window.location.search.substr(1).match(reg);
+			if(r != null) {
+				// 对参数值进行解码
+				return decodeURIComponent(r[2]);
+			}
+			return null;
+		}
+	}
+</script>
+</html>

+ 8 - 0
pages.json

@@ -123,6 +123,14 @@
     "path": "pages/common/webview/index",
     "style": {
       "navigationBarTitleText": "浏览网页"
+    }
+	}, {
+    "path": "pages/common/webview/weboffice",
+    "style": {
+      "navigationBarTitleText": "在线编辑",
+	  "h5":{
+	  	"titleNView":false
+	  	}
     }
   }, {
     "path": "pages/common/textview/index",

+ 52 - 0
pages/common/webview/weboffice.vue

@@ -0,0 +1,52 @@
+<template>
+  <view>
+    <web-view :src="src"></web-view>
+  </view>
+</template>
+
+<script>
+import { getToken } from '@/utils/auth'
+export default {
+    data() {
+      return {
+			src:'',
+        params: {},
+        webviewStyles: {
+          progress: {
+            color: "#FF3333"
+          }
+        }
+      }
+    },
+    props: {
+      // src: {
+      //   type: [String],
+      //   default: null
+      // }
+    },
+    onLoad(e) {
+		this.params = JSON.parse(decodeURIComponent(e.data))
+		console.log(this.params,123)
+		var token=getToken()
+		// const token = await tokenInvalidReturnInfo(3)
+		let data = {
+			file_id: this.params.fileId,
+			type: this.params.type,
+			// handel_type: this.params.handelType,
+			token: token
+		}
+		console.log(data,2)
+		this.src = '/hybrid/html/web-office.html?data='+encodeURIComponent(JSON.stringify(data))
+		
+  //     this.params = event
+  //     if (event.title) {
+  //       uni.setNavigationBarTitle({
+  //         title: event.title
+  //       })
+  //     }
+	 //  wpsInit(){
+		
+	 //  }
+    }
+  }
+</script>

+ 7 - 6
pages/index/index.vue

@@ -89,7 +89,7 @@
 							<view class="txt">一键找回</view>
 						</view>
 					</view>
-					<view class="flexcj tabt pb12" v-if="checkPermi(['system:remind:list'])">
+					<view class="flexcj tabt pb12"  v-if="checkPermi(['system:remind:list'])">
 						<view class="left">待办提醒(<text>{{total}}</text>)</view>
 						<view class="right flexc" @click="getBusListFn(0)" v-if="checkPermi(['system:application:list'])">更多<image :src="rimg"></image></view>
 					</view>
@@ -255,7 +255,6 @@
 		setTimeout(function(){
 			that.getHeightFn()
 		},200)
-		
 	},
 	// 上拉触底加载更多触发事件
 	onReachBottom() {
@@ -380,13 +379,14 @@
 				scanType: ['qrCode'],
 				success: function(red) {
 					let result = red.result;
-					console.log(result,1)
+					var a=JSON.parse(result)
 					if (typeof result == 'string') {
 						try {
+							
 							//type1,认证,2 文件
-							if(result.type==1){
+							if(a.type==1){
 								that.$tab.navigateTo(`/work/pages/prove/index`)
-							}else if(result.type==2){
+							}else if(a.type==2){
 								that.getDown(result.url)
 							}else{
 								
@@ -416,7 +416,8 @@
 			});
 		},
 		getLedgerFn(){
-			this.$tab.navigateTo("/work/pages/file/ledgertable")
+			this.$toast('功能正在开发中~')
+			// this.$tab.navigateTo("/work/pages/file/ledgertable")
 		},
 		getFileFn(){
 			this.$tab.navigateTo("/work/pages/file/list")

+ 0 - 1
static/index.html

@@ -10,7 +10,6 @@
 			var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') || CSS.supports('top: constant(a)'))
 			document.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + (coverSupport ? ', viewport-fit=cover' : '') + '" />')
 		</script>
-		<!-- <script src="web-office-sdk-v1.1.19-a4d86a2/web-office-sdk-v1.1.19.umd.js"></script> -->
 		<link rel="stylesheet" href="<%= BASE_URL %>static/index.<%= VUE_APP_INDEX_CSS_HASH %>.css" />
 	</head>
 	<body>

+ 33 - 36
work/pages/business/add.vue

@@ -2137,19 +2137,16 @@
 					}
 				});
 			},
-			getExportMb(ite){
-				var params=this.datainfo;
-				if(ite.val=='wtdbsqs'){
-					params.type=1;
-				}
-				getExportMb(params).then(res=>{
-					if(res.code==200){
-						var data=res.data;
-						var url=baseUrl+data.path;
-						var name=data.fileName;
-						// var url=baseUrl+res.msg;
-						// var url = baseUrl + ite.url;
-						var name=res.name;
+			getDownloader(path,name){
+				console.log(path,name)
+				// #ifdef APP-PLUS
+				plus.android.requestPermissions([
+						'android.permission.WRITE_EXTERNAL_STORAGE',
+						'android.permission.READ_EXTERNAL_STORAGE',
+						'android.permission.INTERNET',
+						'android.permission.ACCESS_WIFI_STATE'
+					], error => {
+						var url = baseUrl + path;
 						let dtask = plus.downloader.createDownload(url, {
 							filename: 'file://storage/emulated/0/'+baseName+'/' + name
 						}, (d, status) => {
@@ -2179,29 +2176,29 @@
 								});
 							}
 						})
-						dtask.start();	
-						// uni.downloadFile({
-						// 	url: url,//文件的下载路径
-						// 	success(result) {
-						// 			uni.hideLoading()
-						// 		var filePath = result.tempFilePath;
-						// 		// uni.saveFile({
-						// 		//     tempFilePath: filePath[0],
-						// 		//     success: function (res) {
-						// 		//         var savedFilePath = res.savedFilePath;
-						// 		// 		console.log(savedFilePath,1)
-						// 		//     }
-						// 		// });
-						// 		   uni.openDocument({
-						// 		     filePath: filePath,
-						// 		     showMenu: true,
-						// 		     success: function (res) {
-						// 		       // console.log('打开文档成功');
-						// 		     }
-						// 		   });
-						// 	},
-						// 	fail(res) {uni.hideLoading()}
-						// })
+						dtask.start();
+					}, success=> {
+						uni.showToast({
+							title: '无法获取权限,文件下载将出错!',
+							icon: 'none',
+						})
+					})
+				// #endif
+			},
+			getExportMb(ite){
+				var that=this;
+				var params=this.datainfo;
+				if(ite.val=='wtdbsqs'){
+					params.type=1;
+				}else{
+					params.type=11;
+				}
+				getExportMb(params).then(res=>{
+					if(res.code==200){
+						var data=res.data;
+						var url=data.path;
+						var name=data.fileName;
+						that.getDownloader(url,name)
 					}
 				})
 			},

+ 111 - 85
work/pages/business/details.vue

@@ -125,7 +125,7 @@
 				<block v-if="checkPermi(['system:application:cx'])&&stepval!=1&&stepval!=10">
 					<view class="fbtns bga" v-if="userId==datainfo.aUserId&&auditSchedule==3" @click="getCxFn">撤销</view>
 					<view class="fbtns bga" v-if="userId==datainfo.bUserId&&auditSchedule==4" @click="getCxFn">撤销</view>
-					<view class="fbtns" :class="auditSchedule==5?'bga':'bgb'" v-if="(datainfo.auditType!=1||auditSchedule<6&&auditSchedule>4)" @click="getCxFn">撤销</view>
+					<view class="fbtns" :class="auditSchedule==5?'bga':'bgb'" v-if="(datainfo.auditType!=1||auditSchedule<7&&auditSchedule>4)" @click="getCxFn">撤销</view>
 				</block>
 				<!-- 回收站,暂存,归档不能撤  项目进度是申报提交-->
 				<!-- 撤销,管理员在 a待审核 可以撤,  
@@ -188,7 +188,8 @@
 				</block>
 				<!-- 更多操作 -->
 				<block v-if="mtype=='fxmore'">
-					<view @click="getShFn('fxbmsh')" v-if="auditSchedule==6&&checkPermi(['system:application:sh'])">审核</view>
+					<!-- auditSchedule==6&& -->
+					<view @click="getShFn('fxbmsh')" v-if="checkPermi(['system:application:sh'])">审核</view>
 					<view @click="getIssureFn(13)">出具材料合规表</view>
 					<!-- <view @click="getfjEdit('clhgb')">上传附件</view> -->
 					<view @click="getfjEdit('clhgb')">上传材料合规表</view>
@@ -248,6 +249,7 @@
 	import config from '@/config'
 	const baseUrl = config.baseUrl
 	const baseName = config.baseName
+	import { getToken } from '@/utils/auth'
 	import popUp from "@/work/components/popup/popup.vue"
 	import aqyxx from "@/work/components/business/aqyxx.vue"
 	import bfrxx from "@/work/components/business/bfrxx.vue"
@@ -373,6 +375,14 @@
 				mval:-1,
 				mite:"",
 				shtg:'',
+				textType:[
+					{tit:'文字',val:'w',children:['doc','docx','wps']},
+					{tit:'表格',val:'s',children:['xls','xlsx']},
+					{tit:'演示',val:'p',children:['ppt','pptx']},
+					{tit:'PDF',val:'f',children:['pdf','ofd']},
+					{tit:'智能文档',val:'o',children:['otl']},
+					{tit:'多维表格',val:'d',children:['dbt']},
+				]
 			}
 		},
 		onUnload() {
@@ -386,12 +396,12 @@
 			this.init()
 			this.getDetail();
 			this.getScheduleList();
-			// if(checkPermi(['system:hyperlink:list'])){
-			// 	this.getHyperlinkList();//外部链接stepval==5	
-			// }
-			// if(checkPermi(['system:user:noPageList'])){
-			// 	this.getUsernoPageList();//获取用户列表stepval==2||stepval==6
-			// }
+			if(checkPermi(['system:hyperlink:list'])){
+				this.getHyperlinkList();//外部链接stepval==5	
+			}
+			if(checkPermi(['system:user:noPageList'])){
+				this.getUsernoPageList();//获取用户列表stepval==2||stepval==6
+			}
 			this.getCommentsList()//审核意见
 		},
 		mounted() {
@@ -404,7 +414,6 @@
 			setTimeout(function(){
 				that.getHeightFn()
 			},200)
-			
 		},
 		onPageScroll(e) {
 			var scrollTop = Number(e.scrollTop);
@@ -650,6 +659,30 @@
 			// 出具
 			getIssureFn(type){
 				var that=this;
+				var data={
+					fileId: "ca2aa7e3743746e5a52b74aaa5f105e0",
+					fileName: "安徽中新云计算有限公司-担保意向函.docx",
+					path: "/profile/mb/temporarily/RZDB202405081023037034293/安徽中新云计算有限公司-担保意向函.docx",
+				}
+				// var data=res.data;
+				var path=data.path;
+				var name=data.fileName;
+				var fileName = name.replace(/.*(\/|\\)/, ""); // 获得文件名
+				var fileSuffix = (/[.]/.exec(fileName)) ? /[^.]+$/.exec(fileName.toLowerCase()) : ''; // 获得文件后缀
+				var texthz=fileSuffix[0];
+				var type=''
+				// 在线编辑
+				// 获取后缀
+				var textType=that.textType;
+				Object.keys(textType).some((key) => {
+					if (textType[key].children.indexOf(texthz)!=-1) {
+						type=`${textType[key].val}`
+						return true;
+					}
+				})
+				data.type=type
+				that.$tab.navigateTo('/pages/common/webview/weboffice?data='+encodeURIComponent(JSON.stringify(data)))
+				return
 				var params={
 					type:type,
 					loanApplicationId:this.id,
@@ -659,47 +692,72 @@
 						var data=res.data;
 						var path=data.path;
 						var name=data.fileName;
-						this.getDown(path)
-						// that.getDownloader(path,name)
+						var fileName = name.replace(/.*(\/|\\)/, ""); // 获得文件名
+						var fileSuffix = (/[.]/.exec(fileName)) ? /[^.]+$/.exec(fileName.toLowerCase()) : ''; // 获得文件后缀
+						var texthz=fileSuffix[0];
+						var type=''
+						// 在线编辑
+						// 获取后缀
+						var textType=that.textType;
+						Object.keys(textType).some((key) => {
+							if (textType[key].children.indexOf(texthz)!=-1) {
+								type=`${textType[key].val}`
+								return true;
+							}
+						})
+						data.type=type
+						that.$tab.navigateTo('/pages/common/webview/weboffice?data='+encodeURIComponent(JSON.stringify(data)))
 					}
 				})
 			},
 			getDownloader(path,name){
-				console.log(url)
-				var that=this;
-				// var url='http://192.168.101.245:8056/profile/upload/RZDB202405101456481709599/上一年度财务报表_20240510151142A015.xlsx'
+				console.log(path,name)
 				// #ifdef APP-PLUS
-				var url = baseUrl + path;
-				let dtask = plus.downloader.createDownload(url, {
-					filename: 'file://storage/emulated/0/'+baseName+'/' + name
-				}, (d, status) => {
-					//d为下载的文件对象
-					if (status == 200) {
-						uni.hideLoading();
-						uni.showToast({
-							icon: 'none',
-							mask: true,
-							title: '已保存到文件夹:/'+baseName+'/'+ name, //保存路径
-							duration: 3000,
-						});
-						
-						//下载成功,d.filename是文件在保存在本地的相对路径,使用下面的API可转为平台绝对路径
-						let fileSaveUrl = plus.io.convertLocalFileSystemURL(d.filename);
-						setTimeout(() => {
-							plus.runtime.openFile(d.filename); //选择软件打开文件
-						}, 1500)
-					} else {
-						//下载失败
-						uni.hideLoading();
-						plus.downloader.clear(); //清除下载任务
+				plus.android.requestPermissions([
+						'android.permission.WRITE_EXTERNAL_STORAGE',
+						'android.permission.READ_EXTERNAL_STORAGE',
+						'android.permission.INTERNET',
+						'android.permission.ACCESS_WIFI_STATE'
+					], error => {
+						console.log(error,1)
+						var url = baseUrl + path;
+						let dtask = plus.downloader.createDownload(url, {
+							filename: 'file://storage/emulated/0/'+baseName+'/' + name
+						}, (d, status) => {
+							//d为下载的文件对象
+							if (status == 200) {
+								uni.hideLoading();
+								uni.showToast({
+									icon: 'none',
+									mask: true,
+									title: '已保存到文件夹:/'+baseName+'/'+ name, //保存路径
+									duration: 3000,
+								});
+								
+								//下载成功,d.filename是文件在保存在本地的相对路径,使用下面的API可转为平台绝对路径
+								let fileSaveUrl = plus.io.convertLocalFileSystemURL(d.filename);
+								setTimeout(() => {
+									plus.runtime.openFile(d.filename); //选择软件打开文件
+								}, 1500)
+							} else {
+								//下载失败
+								uni.hideLoading();
+								plus.downloader.clear(); //清除下载任务
+								uni.showToast({
+									icon: 'none',
+									mask: true,
+									title: '下载失败,请稍后重试',
+								});
+							}
+						})
+						dtask.start();
+					}, success=> {
+						console.log(error,2)
 						uni.showToast({
+							title: '无法获取权限,文件下载将出错!',
 							icon: 'none',
-							mask: true,
-							title: '下载失败,请稍后重试',
-						});
-					}
-				})
-				dtask.start();	
+						})
+					})
 				// #endif
 			},
 			getClose(){
@@ -799,6 +857,7 @@
 					confirmText: '确认',
 					success: function(res) {
 						if (res.confirm) {
+							that.mtype=''
 							var params={
 								loanApplicationId:that.id,
 								auditSchedule:that.auditSchedule,
@@ -940,14 +999,14 @@
 							this.basicFj=res.data.basicFj;
 						}
 						this.stepval=res.data.loanSchedule||0;
-						var auditSchedule=res.data.auditSchedule
-						if(checkPermi(['system:hyperlink:list'])&&auditSchedule==6){
-							this.getHyperlinkList();//外部链接stepval==5
-						}else if(auditSchedule==1||auditSchedule==7){
-							if(checkPermi(['system:user:noPageList'])){
-								this.getUsernoPageList();//获取用户列表stepval==2||stepval==6
-							}
-						}
+						// var auditSchedule=res.data.auditSchedule
+						// if(checkPermi(['system:hyperlink:list'])&&auditSchedule==6){
+						// 	this.getHyperlinkList();//外部链接stepval==5
+						// }else if(auditSchedule==1||auditSchedule==7){
+						// 	if(checkPermi(['system:user:noPageList'])){
+						// 		this.getUsernoPageList();//获取用户列表stepval==2||stepval==6
+						// 	}
+						// }
 					}
 				})
 			},
@@ -981,40 +1040,7 @@
 				// this.datainfo.zsyzFjList=JSON.parse(JSON.stringify(this.filelist))
 			},
 			getXzFn(ite){
-				// 本地路径开头使用file://,跟上手机文件本地目录storage/emulated/0,
-				// 后缀是用于文件命名和格式修改,大家可以使用变量。
-				var url = baseUrl + ite.url;
-				var name=ite.name;
-				let dtask = plus.downloader.createDownload(url, {
-					filename: 'file://storage/emulated/0/'+baseName+'/' + name
-				}, (d, status) => {
-					//d为下载的文件对象
-					if (status == 200) {
-						uni.hideLoading();
-						uni.showToast({
-							icon: 'none',
-							mask: true,
-							title: '已保存到文件夹:/'+baseName+'/'+ name, //保存路径
-							duration: 3000,
-						});
-						
-						//下载成功,d.filename是文件在保存在本地的相对路径,使用下面的API可转为平台绝对路径
-						let fileSaveUrl = plus.io.convertLocalFileSystemURL(d.filename);
-						setTimeout(() => {
-							plus.runtime.openFile(d.filename); //选择软件打开文件
-						}, 1500)
-					} else {
-						//下载失败
-						uni.hideLoading();
-						plus.downloader.clear(); //清除下载任务
-						uni.showToast({
-							icon: 'none',
-							mask: true,
-							title: '下载失败,请稍后重试',
-						});
-					}
-				})
-				dtask.start();				
+				this.getDownloader(ite.url,ite.name)
 			},
 			getDown(e){
 				uni.showLoading({

+ 50 - 31
work/pages/file/list.vue

@@ -106,41 +106,60 @@
 				this.reachflag=true;
 				this.getDataFn()
 			},
+			getDownloader(path,name){
+				console.log(path,name)
+				// #ifdef APP-PLUS
+				plus.android.requestPermissions([
+						'android.permission.WRITE_EXTERNAL_STORAGE',
+						'android.permission.READ_EXTERNAL_STORAGE',
+						'android.permission.INTERNET',
+						'android.permission.ACCESS_WIFI_STATE'
+					], error => {
+						var url = baseUrl + path;
+						let dtask = plus.downloader.createDownload(url, {
+							filename: 'file://storage/emulated/0/'+baseName+'/' + name
+						}, (d, status) => {
+							//d为下载的文件对象
+							if (status == 200) {
+								uni.hideLoading();
+								uni.showToast({
+									icon: 'none',
+									mask: true,
+									title: '已保存到文件夹:/'+baseName+'/'+ name, //保存路径
+									duration: 3000,
+								});
+								
+								//下载成功,d.filename是文件在保存在本地的相对路径,使用下面的API可转为平台绝对路径
+								let fileSaveUrl = plus.io.convertLocalFileSystemURL(d.filename);
+								setTimeout(() => {
+									plus.runtime.openFile(d.filename); //选择软件打开文件
+								}, 1500)
+							} else {
+								//下载失败
+								uni.hideLoading();
+								plus.downloader.clear(); //清除下载任务
+								uni.showToast({
+									icon: 'none',
+									mask: true,
+									title: '下载失败,请稍后重试',
+								});
+							}
+						})
+						dtask.start();
+					}, success=> {
+						uni.showToast({
+							title: '无法获取权限,文件下载将出错!',
+							icon: 'none',
+						})
+					})
+				// #endif
+			},
 			getXzFn(ite){
 				// 本地路径开头使用file://,跟上手机文件本地目录storage/emulated/0,
 				// 后缀是用于文件命名和格式修改,大家可以使用变量。
-				var url = baseUrl + ite.url;
+				var url =ite.url;
 				var name=ite.name;
-				let dtask = plus.downloader.createDownload(url, {
-					filename: 'file://storage/emulated/0/'+baseName+'/' + name
-				}, (d, status) => {
-					//d为下载的文件对象
-					if (status == 200) {
-						uni.hideLoading();
-						uni.showToast({
-							icon: 'none',
-							mask: true,
-							title: '已保存到文件夹:/'+baseName+'/'+ name, //保存路径
-							duration: 3000,
-						});
-						
-						//下载成功,d.filename是文件在保存在本地的相对路径,使用下面的API可转为平台绝对路径
-						let fileSaveUrl = plus.io.convertLocalFileSystemURL(d.filename);
-						setTimeout(() => {
-							plus.runtime.openFile(d.filename); //选择软件打开文件
-						}, 1500)
-					} else {
-						//下载失败
-						uni.hideLoading();
-						plus.downloader.clear(); //清除下载任务
-						uni.showToast({
-							icon: 'none',
-							mask: true,
-							title: '下载失败,请稍后重试',
-						});
-					}
-				})
-				dtask.start();				
+				this.getDownloader(url,name)			
 			},
 			getDataFn(){
 				var params={

Some files were not shown because too many files changed in this diff