Ver código fonte

修改导出专利

zhuliu 1 ano atrás
pai
commit
fc844024e2

+ 13 - 12
pages/searchResults/searchResults.js

@@ -2,6 +2,7 @@
 const app = getApp()
 const api = require('../../api/index')
 const showImage = require('../../utils/showImage')
+const downLoad = require('../../utils/downLoad')
 Page({
 
   /**
@@ -509,19 +510,19 @@ export(){
   api.exportPatent(params).then(res=>{
     if(res.code == 200){
       var url = that.data.imgHttp + res.data.data
-      wx.setClipboardData({
-        data: url,
-        success(res) {
-          wx.showToast({
-            title: '复制成功,快到浏览器打开/下载!',
-            icon: 'none',
-            duration: 3000
-          })
-        }
-      })
-      // downLoad.downLoadFile(res.data.data).then(res=>{
-        
+      // wx.setClipboardData({
+      //   data: url,
+      //   success(res) {
+      //     wx.showToast({
+      //       title: '复制成功,快到浏览器打开/下载!',
+      //       icon: 'none',
+      //       duration: 3000
+      //     })
+      //   }
       // })
+      downLoad.downLoadFile(res.data.data).then(res=>{
+        
+      })
     }
   })
 },

+ 14 - 13
pages/selectedPatents/selectedPatents.js

@@ -3,6 +3,7 @@ import { $wuxGallery} from '../../miniprogram_npm/wux-weapp/index'
 const app = getApp()
 const api = require('../../api/index')
 const showImage = require('../../utils/showImage')
+const downLoad = require('../../utils/downLoad')
 Page({
 
   /**
@@ -102,20 +103,20 @@ export(){
   var that = this
   api.exportPatent(params).then(res=>{
     if(res.code == 200){
-      var url = that.data.imgHttp + res.data.data
-      wx.setClipboardData({
-        data: url,
-        success(res) {
-          wx.showToast({
-            title: '复制成功,快到浏览器打开/下载!',
-            icon: 'none',
-            duration: 3000
-          })
-        }
-      })
-      // downLoad.downLoadFile(res.data.data).then(res=>{
-        
+      // var url = that.data.imgHttp + res.data.data
+      // wx.setClipboardData({
+      //   data: url,
+      //   success(res) {
+      //     wx.showToast({
+      //       title: '复制成功,快到浏览器打开/下载!',
+      //       icon: 'none',
+      //       duration: 3000
+      //     })
+      //   }
       // })
+      downLoad.downLoadFile(res.data.data).then(res=>{
+        
+      })
     }
   })
 },

+ 25 - 16
utils/downLoad.js

@@ -1,10 +1,10 @@
 import Notify from '../miniprogram_npm/@vant/weapp/notify/notify';
 const config = {  
-  // baseURL: 'http://192.168.1.2:8801', // 基础URL 
-  baseURL: 'https://www.xsip.cn', // 基础URL   
+  baseURL: 'http://192.168.2.111:8802', // 基础URL 
+  // baseURL: 'https://www.xsip.cn', // 基础URL   
   timeout: 30000, // 超时时间(单位ms)  
   header: {  
-    // 'content-type': 'application/json', // 默认请求头  
+    'content-type': 'application/xls', // 默认请求头  
     // 其他全局请求头... 
    
   },  
@@ -29,7 +29,9 @@ function downLoad(url){
     wx.downloadFile({
         url:config.baseURL + '/fileManager/downloadFile?fileId=' + url,
         // filePath: 'filePath',
-        // header: header,
+        header: {
+          ...config.header
+        },
         // timeout: 0,
         success: (result) => {
           wx.hideLoading()
@@ -40,19 +42,26 @@ function downLoad(url){
           console.log(result)
           if (result.statusCode === 200) {
             const tempFilePath = result.tempFilePath; // 临时文件路径
-            wx.saveFile({  
-              tempFilePath: tempFilePath, // 传入临时文件路径  
-              success(saveRes) {  
-                const savedFilePath = saveRes.savedFilePath;  
-                console.log('文件已保存到本地', savedFilePath);  
-                resolve(saveRes)
-                // 可以在这里做后续操作,如打开文件或通知用户  
-              },  
-              fail(error) {  
-                console.error('保存文件失败', error);  
-                reject('保存文件失败')
-              }  
+            wx.openDocument({
+              filePath: tempFilePath,
+              showMenu:true,
+              success: function (res) {
+                console.log('打开文档成功')
+              }
             })
+            // wx.saveFile({  
+            //   tempFilePath: tempFilePath, // 传入临时文件路径  
+            //   success(saveRes) {  
+            //     const savedFilePath = saveRes.savedFilePath;  
+            //     console.log('文件已保存到本地', savedFilePath);  
+            //     resolve(saveRes)
+            //     // 可以在这里做后续操作,如打开文件或通知用户  
+            //   },  
+            //   fail(error) {  
+            //     console.error('保存文件失败', error);  
+            //     reject('保存文件失败')
+            //   }  
+            // })
             
           }
           

+ 1 - 1
utils/request.js

@@ -15,7 +15,7 @@ const config = {
   tabbar:["pages/index/index","pages/hotProduct/hotProduct","pages/mine/mine"]
 };  
 const apiUrl = {  
-  develop: 'https://www.xsip.cn', // 开发环境地址  
+  develop: 'http://192.168.2.111:8902', // 开发环境地址  
   trial: 'https://www.xsip.cn/test', // 测试环境地址  
   release: 'https://www.xsip.cn' // 生产环境地址  
 };