callAppBox.vue
2.6 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<template>
<div class="call-app-box" v-if="callApps">
<!-- Android WeChat内无法唤起APP,提示用浏览器打开蒙层 -->
<mask-layer ref="maskLayer"
:maskLayers="maskLayers">
</mask-layer>
<div class="box">
<div class="logo-box">
<img src="static/img/call_app_logo.png" class="img" />
</div>
<div class="buttons-box">
<div class="btn btn-default" @click="callApp">打开APP</div>
</div>
</div>
</div>
</template>
<script>
// 导入跳转方法组件
import openAppOld from "@/common/openAppOld.js";
import maskLayer from "@/components/maskLayer/maskLayer";
export default {
data: function () {
return {
maskLayers: null, // 蒙层对象
downLoadBtnData: {
data: "",
source: "",
channelName: this.$route.query.channelName, //频道名称
title: "下载网家家,观看更多优质内容",
}
}
},
props: ["callApps"],
components: {
maskLayer
},
methods: {
/**
* H5唤起App按钮事件
*/
callApp() {
/**
* 走openinstall拉起下载APP
* 通过分享页面下载完可以拉起到指定页面
*/
if (typeof this.callApps.funcs === "object") {
// 拼接参数字符串,根据分享参数拼接
let shareString = "shop_shop_type=" + this.callApps.funcs.callAppParams.shop_shop_type + "&shop_to=" + this.callApps.funcs.callAppParams.shop_to + "&shop_type=" + this.callApps.funcs.callAppParams.shop_type + "&share_mold=" + this.callApps.funcs.callAppParams.share_mold;
// Base64位编码加密
const CryptoJS = require("crypto-js");
const wordArray = CryptoJS.enc.Utf8.parse(shareString);
let shopData = encodeURIComponent(CryptoJS.enc.Base64.stringify(wordArray));
// 设置下载参数
this.$set(this.downLoadBtnData, 'data', 'channel_id=' + (this.mode === 'prod' ? 'cnlive_mall' : 'cnlive_mall_test') + '&type=shop' + '&shopData=' + shopData);
if (this.isiPhone.value) {
openAppOld.submitFn.call(this, this.downLoadBtnData);
} else if (this.isAndroid.value) {
if (this.isWeChat.value) {
// 设置蒙层图片
this.$set(this, "maskLayers", {
img: "/static/img/mask_layer_browser.png",
});
// 显示蒙层
this.$refs.maskLayer.showLayer();
} else {
openAppOld.submitFn.call(this, this.downLoadBtnData);
}
}
}
}
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style rel="stylesheet/less" lang="less">
@import './callAppBox';
</style>