share.html 7.5 KB
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title></title>
    <script src="../../assets/js/fontsize.js"></script>
    <!--<link rel="stylesheet" href="../../assets/css/api.css"/>-->
    <!--<link rel="stylesheet" href="http://at.alicdn.com/t/font_641470_jg64l6ijsg4lsor.css">-->
    <link rel="stylesheet" href="../../assets/icon/iconfont.css">
    <style>
        body, html {
            background-color: transparent !important;
            height: 100%;
        }

        .meal {
            display: flex;
            flex-direction: column;
            justify-content: flex-end;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
        }

        .meal_item {
            display: flex;
            align-items: center;
            justify-content: space-around;
            padding: 0.25rem 0;
            background-color: #fff;
        }

        .share_top {
            font-size: 18px;
            color: #555;
            text-align: center;
            padding: 0.2rem 0;
            border-bottom: 1px solid #E4E4E4;
            background-color: #fff;
        }

        .share_item {
            display: flex;
            align-items: center;
            flex-direction: column;
            font-size: 16px;
            color: #555;
        }

        .share_item .icon {
            font-size: 25px;
            width: 30px;
            height: 30px;
            margin-bottom: 0.1rem;
        }

        .cancel {
            text-align: center;
            font-size: 16px;
            color: #fff;
            background-color: #dbb25f;
            padding: 0.15rem 0;
        }
    </style>
</head>
<body>
<div id="app">
    <div @click="close" class="meal">
        <div class="share_top">分享到</div>
        <div class="meal_item" @click.stop>
            <div class="share_item" @click="share_f('session')">
                <svg class="icon" aria-hidden="true">
                    <use xlink:href="#icon-weixin"></use>
                </svg>
                <span class="">微信</span>
            </div>
            <div class="share_item" @click="share_f('timeline')">
                <svg class="icon" aria-hidden="true">
                    <use xlink:href="#icon-pengyouquan"></use>
                </svg>
                <span class="">微信朋友圈</span>
            </div>
            <div class="share_item">
                <svg class="icon" aria-hidden="true">
                    <use xlink:href="#icon-QQgai" @click="share_qq"></use>
                </svg>
                <span class="">腾讯QQ</span>
            </div>
            <div class="share_item" @click="clipBoard">
                <svg class="icon" aria-hidden="true">
                    <use xlink:href="#icon-fuzhilianjie1"></use>
                </svg>
                <span class="">复制链接</span>
            </div>
        </div>
        <div class="cancel" @click="api.closeFrame()">取消</div>
    </div>
</div>
</body>
</html>
<script type="text/javascript" src="../../assets/js/api.js"></script>
<script type="text/javascript" src="../../assets/js/public.js"></script>
<script type="text/javascript" src="../../assets/js/fastclick.js"></script>
<script>
    new FastClick(document.body);
</script>
<script type="text/javascript" src="../../assets/js/vue.min.js"></script>
<script type="text/javascript" src="../../assets/js/swiper-3.4.2.min.js"></script>
<!--<script type="text/javascript" src="http://at.alicdn.com/t/font_641470_jg64l6ijsg4lsor.js"></script>-->
<script type="text/javascript" src="../../assets/icon/iconfont.js"></script>
<script type="text/javascript" src="../../assets/js/axios.min.js"></script>
<script>
    var app = new Vue({
        el: '#app',
        data: {
            url: '',
            title: '',
            des: '',
            img: '',
            default_img: '../../asset/image/logo200.png',
            id: '',
            invite_type: ''
        },
        created: function () {
            apiready = function () {
                app.url = api.pageParam.share_url;
                app.title = api.pageParam.share_title;
                app.desc = api.pageParam.share_desc;
                app.img = api.pageParam.share_img;
                app.id = api.pageParam.share_id;
                app.invite_type = api.pageParam.invite_type;
                // alert(JSON.stringify(app.img))
            }
        },
        methods: {
            close: function () {
                api.closeFrame();
            },
            share_f: function (type) {
                var wx = api.require('wx');
                wx.isInstalled(function (ret, err) {
                    if (ret.installed) {
                        wx.shareWebpage({
                            apiKey: '',
                            scene: type,
                            title: app.title,
                            description: app.desc,
                            thumb: 'widget://assets/image/logo200.png',
                            contentUrl:app.url?app.url: goodUrl + 'download.html'
                        }, function (ret, err) {
                            if (ret.status) {
                                toastMsg('分享成功');
                            } else {
                                toastMsg('取消分享');
                            }
                            api.closeFrame();
                        });
                    } else {
                        toastMsg('当前设备未安装微信客户端');
                    }
                });

            },
            share_qq: function () {
                var qq = api.require('qq');
                qq.installed(function (ret, err) {
                    if (ret.status) {
                        qq.shareNews({
                            url: app.url?app.url: goodUrl + 'download.html',
                            type: 'QFriend',
                            title: app.title,
                            description: app.desc,
                            imgUrl: 'widget://assets/image/logo200.png'
                        }, function (ret, err) {
                            // alert(JSON.stringify(ret))
                            if (ret.status) {
                                toastMsg("分享成功!");
                            } else {
                                toastMsg(err.code)
                            }
                            api.closeFrame()
                        });
                    } else {
                        toastMsg('请安装腾讯QQ')
                    }
                });
            },
            clipBoard: function () {
                var clipBoard = api.require('clipBoard');
                clipBoard.set({
                    value:app.url?app.url: goodUrl + 'download.html'
                }, function (ret, err) {
                    if (ret) {
                        clipBoard.get(function (ret, err) {
                            if (ret) {
                                toastMsg('复制成功')
                            } else {
                                toastMsg('复制失败,请重试')
                            }
                            api.closeFrame();
                        });
                    } else {
                    }
                });
            }
        }
    })
</script>