callAppBox.vue 2.6 KB
<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>