jufubao-admin-library 1.1.145 → 1.1.147
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -63,6 +63,8 @@ import XdPagination from "@/components/XdPagination.vue"
|
|
|
63
63
|
import XdTable from "@/components/XdTable"
|
|
64
64
|
import XdSearch from "@/components/XdSearch"
|
|
65
65
|
import downloadJs from "downloadjs";
|
|
66
|
+
import {isPlatform} from "@/utils/xd.base";
|
|
67
|
+
|
|
66
68
|
import {
|
|
67
69
|
mapActions,
|
|
68
70
|
mapState,
|
|
@@ -294,6 +296,50 @@ export default {
|
|
|
294
296
|
];
|
|
295
297
|
},
|
|
296
298
|
|
|
299
|
+
downLoadPdf(url,file_name,file_ext, loading){
|
|
300
|
+
let filename = `${file_name}.${file_ext}`;
|
|
301
|
+
let userAgent = window.navigator.userAgent;
|
|
302
|
+
|
|
303
|
+
//safari浏览器走访问模式,手机端和百度浏览器
|
|
304
|
+
//360,baidu,qq,chrome (下载正常)
|
|
305
|
+
if(!isPlatform().isPc || /^.+(baidu)/i.test(userAgent)) {
|
|
306
|
+
//alert('!isPC');
|
|
307
|
+
loading.close();
|
|
308
|
+
const link = document.createElement('a');
|
|
309
|
+
link.href = url;
|
|
310
|
+
link.download = filename;
|
|
311
|
+
document.body.appendChild(link);
|
|
312
|
+
link.click();
|
|
313
|
+
document.body.removeChild(link);
|
|
314
|
+
return
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
//360浏览器,safari,遨游(直接打开,无法下载)-- PC
|
|
318
|
+
let x = new XMLHttpRequest();
|
|
319
|
+
x.open("GET", url, true);
|
|
320
|
+
x.responseType = "blob";
|
|
321
|
+
x.onload = (e) => {
|
|
322
|
+
console.log('XMLHttpRequest',e);
|
|
323
|
+
if (e.target['status'] === 200) {
|
|
324
|
+
downloadJs(e.target.response, filename, 'application/pdf');
|
|
325
|
+
loading.close()
|
|
326
|
+
} else if (e.target['status'] === 404) {
|
|
327
|
+
console.error('error', e);
|
|
328
|
+
loading.close()
|
|
329
|
+
} else {
|
|
330
|
+
console.error('error', e);
|
|
331
|
+
loading.close()
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
x.onerror = (e) => {
|
|
335
|
+
console.log('onerror')
|
|
336
|
+
console.log('error', e);
|
|
337
|
+
loading.close()
|
|
338
|
+
}
|
|
339
|
+
x.send();
|
|
340
|
+
|
|
341
|
+
},
|
|
342
|
+
|
|
297
343
|
/**
|
|
298
344
|
*按钮操作
|
|
299
345
|
**/
|
|
@@ -321,7 +367,9 @@ export default {
|
|
|
321
367
|
let loading = this.$loading({})
|
|
322
368
|
this.getDownloadUrl({serial_no})
|
|
323
369
|
.then(res=>{
|
|
324
|
-
let download_url = ''
|
|
370
|
+
let download_url = '';
|
|
371
|
+
let userAgent = window.navigator.userAgent;
|
|
372
|
+
|
|
325
373
|
//#ifdef partner-site
|
|
326
374
|
if(res['download_url']) {
|
|
327
375
|
download_url = res['download_url']
|
|
@@ -333,8 +381,17 @@ export default {
|
|
|
333
381
|
}
|
|
334
382
|
// #endif
|
|
335
383
|
|
|
336
|
-
|
|
337
|
-
|
|
384
|
+
//打印userAgent
|
|
385
|
+
if(window.location.href.indexOf('UA=1') !== -1) {
|
|
386
|
+
alert(userAgent);
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
//pdf下载
|
|
390
|
+
if(/^.+(\.pdf)$/.test(download_url.split('?')[0])){
|
|
391
|
+
this.downLoadPdf(download_url,file_name,file_ext,loading);
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
|
|
338
395
|
let reg = /^.+(baidu|UCBrowser)/i;
|
|
339
396
|
if(reg.test(userAgent)) {
|
|
340
397
|
window.location.href = download_url;
|