Explorar el Código

feat 添加解析pdf文件功能

yezhihao hace 3 meses
padre
commit
23a412fc76
Se han modificado 2 ficheros con 43 adiciones y 7 borrados
  1. 3 2
      common/httpRequest.js
  2. 40 5
      pages/my/attachment.vue

+ 3 - 2
common/httpRequest.js

@@ -289,7 +289,7 @@ module.exports = {
 			}
 		});
 	},
-	getT: function(url, data, header) {
+	getT: function(url, data, header, timeout, hideToast) {
 		header = header || "application/x-www-form-urlencoded";
 		return ensureDomainReady().then(() => {
 			const host = this.config('APIHOST1')
@@ -305,6 +305,7 @@ module.exports = {
 							"content-type": header,
 							"token": token
 						},
+						timeout: timeout ? timeout : 60000,
 						success: function(result) {
 							if (result.data.code == 401) {
 								uni.removeStorageSync("token")
@@ -321,7 +322,7 @@ module.exports = {
 									title: '请先登录,以便更好使用!',
 									icon: 'none'
 								})
-							} else if (result.data.code != 0 && result.data.msg != '未进入公司') {
+							} else if (result.data.code != 0 && result.data.msg != '未进入公司' && !hideToast) {
 								uni.showToast({
 									title: result.data.msg || '查询失败',
 									icon: 'none'

+ 40 - 5
pages/my/attachment.vue

@@ -278,13 +278,20 @@ export default {
 
 		},
 		more(id) {
-			var that = this
 			uni.showActionSheet({
-				itemList: ["删除"],
+				itemList: ["AI解析", "删除"],
 				itemColor: "#3273db",
-				success(res) {
-					if (res.tapIndex == 0)
-						that.deleteAttachment(id)
+				success: res => {
+					if (res.tapIndex == 0) {
+						let [resume] = this.content.filter(item => item.resumesAttachmentId == id)
+						if (resume) {
+							this.analyserResumeByUrl(resume?.attachmentAddress)
+						} else {
+							this.$queue.showToast('获取简历失败')
+						}
+					} else if (res.tapIndex == 1) {
+						this.deleteAttachment(id)
+					}
 				},
 				fail(res) {
 					console.log(res.errMsg);
@@ -528,6 +535,34 @@ export default {
 				content,
 				showCancel: false
 			})
+		},
+		
+		// 通过文件地址解析简历
+		analyserResumeByUrl(filePath) {
+			this.showLoadCard = true
+			this.$Request.getT('/app/resumes/resumesAnalysisAttach', {
+				filePath
+			}, null, 480000, true).then(res => {
+				if (!res) {
+					this.showModal('解析失败,请稍后重试')
+					this.stopLoadStatus()
+					return
+				}
+				if (res.code == 0 && res.data) {
+					// 识别前,先清空数据
+					this.clearResumeData()
+					this.setAiResumesAnalysis(JSON.parse(res.data))
+					
+					this.getUserInfo()
+				} else {
+					this.showModal(res?.msg || '解析失败,请稍后重试')
+				}
+				
+				this.stopLoadStatus()
+			}).catch(err => {
+				this.showModal('解析失败,请稍后重试')
+				this.stopLoadStatus()
+			})
 		}
 	},
 	// userphone(){