<style>
</style>

<template>
    <div class="download-index2">
        <div class="logo-wrap">
            <h1>饭盒视频</h1>
            <p>发现更精彩的游戏世界</p>
        </div>
        <p class="intro">海量优质游戏短视频 ,好玩好看尽在饭盒</p>
        <div v-if="isInit==1" class="dl-btns">
            <a :href='url' v-if="phoneType==1" class="btn btn-ios">iOS版</a>
            <a :href='url' v-if="phoneType==2" class="btn btn-android">Anroid版</a>
        </div>
    </div>
</template>

<script>
import Vue from 'vue';
import $ from 'jquery';
import lib from 'lib';

import swiper from '../../depend/swiper/swiper';

export default {
    data() {
        return {
            isInit : 0,
            phoneType : 0,
            url : "http://a.app.qq.com/o/simple.jsp?pkgname=com.ouj.fhvideo"
        }
    },
    mounted() {
        this.initDownloadUrl();
    },
    beforeDestroy() {
    },
    methods: {
        initDownloadUrl(){
            var u = navigator.userAgent;
            var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
            var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端

            this.isInit = 1;
            if (isiOS) {
                this.phoneType = 1;
            } else if(isAndroid) {
                this.phoneType = 2;
            }
        },
        wxHandler: function () {
            let self = this;
            if (!navigator.userAgent.toLowerCase().match(/MicroMessenger/i) == "micromessenger") {
                return;
            }
            var url = 'http://m.hiyd.com/weixin/getJsSign',
                data = {
                    url: location.href,
                    appid: 7
                };

            $.ajax({
                type: "get",
                url: url,
                data: data,
                dataType: "jsonp",

                success: function (ret) {
                    ret.data.debug = false;
                    ret.data.jsApiList = ["onMenuShareTimeline", "onMenuShareAppMessage"];
                    wx.config(ret.data);
                    wx.ready(function () {
                        //分享到朋友圈
                        wx.onMenuShareTimeline({
                            title: self.shareObj.desc,		//分享标题
                            imgUrl: self.shareObj.img,		//分享图标
                            success: function () {

                            },
                            cancel: function () {
                                // 用户取消分享后执行的回调函数
                            }
                        });
                        //分享给朋友
                        wx.onMenuShareAppMessage({
                            title: self.shareObj.title, 		//分享标题
                            desc: self.shareObj.desc,
                            imgUrl: self.shareObj.img, 	//分享图标
                            success: function () {
                            },
                            cancel: function () {
                                // 用户取消分享后执行的回调函数
                            }
                        });
                    });
                }
            });
        }
    }
}
</script>
