download.js
1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
const serverDownloadMixin = {
methods: {
async isDownloadBarHide() {
return true;
},
async isMiniapp() {
return false;
},
openByBrowser() {
}
}
};
const clientDownloadMixin = {
methods: {
async isDownloadBarHide() {
let isMiniapp = await this.isMiniapp();
if (isMiniapp) {
return true;
}
return document.getElementById('no-download');
},
isMiniapp() {
/* eslint-disable-next-line */
return this.$store.$context.env.isMiniApp;
},
sleep(ns) {
return new Promise(resolve => {
setTimeout(resolve, ns);
});
},
openByBrowser() {
let appPathUrl = window.location.pathname;
const query = Object.assign({}, this.$route.query, {
headerid: -1,
toplayoutByH5: 'Y'
});
const openBy = {
action: 'go.h5',
params: {
url: 'http://m.yohobuy.com' + appPathUrl,
param: JSON.stringify(query)
}
};
this.$router.push({
name: 'openByBrowser',
query: {
'openby:yohobuy': encodeURIComponent(JSON.stringify(openBy)),
share: false
}
});
}
}
};
export default process.env.VUE_ENV === 'server' ?
serverDownloadMixin :
clientDownloadMixin;