<style>
</style>

<template>
    <div class="download-index">
        <div class="download-header">
            <h1>饭盒视频</h1>
        </div>
        <div class="download-body">
            <div class="dl-slide-wrap">
                <div class="swiper-container" data-role="slide-primary">
                    <ul class="swiper-wrapper" data-switchable-role="content">
                        <li class="swiper-slide slide-pic01"></li>
                        <li class="swiper-slide slide-pic02"></li>
                        <li class="swiper-slide slide-pic03"></li>
                    </ul>
                </div>
            </div>
        </div>
        <footer class="download-footer">
            <a :href='url' class='footer-link'>
                <section class="f-left-content">
                    <i class="icon-logo"></i>
                </section>
                <section class="f-middle-content">
                    <strong>饭盒视频</strong>
                </section>
                <section class="f-right-content">
                    <span class="btn-dl">立即下载</span>
                </section>
            </a>
        </footer>
    </div>
</template>

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

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

export default {
    data() {
        return {
            // url : this.initDownloadUrl()
            url : "http://a.app.qq.com/o/simple.jsp?pkgname=com.ouj.fhvideo"
        }
    },
    mounted() {
        this.initSwrpe();
    },
    beforeDestroy() {
    },
    methods: {
        initSwrpe(){
            var mySwiper = new Swiper('.swiper-container', {
                autoplay: 2000
            })
        },
        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终端

            if (isAndroid) {
                return 'http://www.hiyd.com/static/apkDownload?appid=12';
            } else if(isiOS) {
                return 'https://itunes.apple.com/us/app/%E9%A5%AD%E7%9B%92%E8%A7%86%E9%A2%91/id1237446875?l=zh&ls=1&mt=8';
            }
        },
        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>
