1***@qq.com
1***@qq.com
  • 发布:2019-06-18 15:02
  • 更新:2019-06-26 15:56
  • 阅读:771

ShareService对象在js中如何使用?

分类:HTML5+
interface plus.oauth.AuthService {  
    // Attributes  
    attribute String id;  
    attribute String description;  
    attribute AuthInfo authResult;  
    attribute UserInfo userInfo;  
    attribute JSON extra;  

    // Methods   
    function void author(successCallback, errorCallback, options);  
    function void login(successCallback, errorCallback, options);  
    function void logout(successCallback, errorCallback);  
    function void getUserInfo(successCallback, errorCallback);  
    function void addPhoneNumber(successCallback, errorCallback);  
}  

ShareService对象用于表示分享服务,在JS中为对象,用于向系统请求分享操作。

2019-06-18 15:02 负责人:无 分享
已邀请:
1***@qq.com

1***@qq.com (作者) - 不忘初心

已解决!

话不多说,直接上代码!

<template>  
    <div class="LoginSanfang" v-show="!iswx">  
        <h3>&nbsp;&nbsp;第三方账号登录</h3>  
        <div style="margin-top: .4rem;">  
            <span style="margin-right: 1rem;"><img :src="require('@/assets/img/account/qqbg.png')" alt="" @click="qqlogin"></span>  
            <span><img :src="require('@/assets/img/account/wechatbg.png')" alt="" @click="weixinlogin"></span>  
        </div>  
        <span id="qqLoginBtn"></span>  
    </div>  
</template>  

export default {  
        name: 'LoginSanfang',  
        data() {  
            return {  
                timeOut: '',  
                iswx: false,  
                qq: null,  
                auths: null,  
                aweixin: null,  
            }  
        },  
        beforeCreate() {  
            function plusready() {  
                this.updateServices();  
            }  
            if (window.plus) {  
                plusready();  
            } else {  
                document.addEventListener("plusready", plusready, false);  
            }  
        },  
        methods: {  
            //判断是否为微信浏览器  
            isweixin() {  
                const ua = window.navigator.userAgent.toLowerCase();  
                if (ua.match(/MicroMessenger/i) == 'micromessenger') {  
                    this.iswx = true;  
                    return true;  
                } else {  
                    this.iswx = false;  
                    return false;  
                }  
            },  
            //更新oauth服务  
            updateServices() {  
                let _self = this;  
                plus.oauth.getServices(function(services) {  
                    _self.auths = services;  
                    for (var i in services) {  
                        if ('weixin' == services[i].id) {  
                            _self.aweixin = services[i];  
                        }  
                    }  
                    for (var i in services) {  
                        if ('qq' == services[i].id) {  
                            _self.aqq = services[i];  
                        }  
                    }  
                }, function(e) {  
                    plus.nativeUI.alert("获取登录授权服务列表失败:" + JSON.stringify(e));  
                });  
            },  

            //拉起QQ客户端  
            qqlogin() {  

                this.aqq.login(function(e){  
                    console.log(e)  
                    plus.nativeUI.alert("授权成功:"+JSON.stringify(e));  
                }, function(e) {  
                    console.log(e)  
                    plus.nativeUI.alert("授权失败:"+JSON.stringify(e));  
                });  
            },  

            //微信授权登录  
            weixinlogin() {  

                this.aweixin.login(function(e){  
                    console.log(e)  
                    plus.nativeUI.alert("授权成功:"+JSON.stringify(e));  
                }, function(e) {  
                    console.log(e)  
                    plus.nativeUI.alert("授权失败:"+JSON.stringify(e));  
                });  
            }  
        },  
        mounted() {  
            this.isweixin();  
            if(window.plus) this.updateServices();  
        }  
    }

该问题目前已经被锁定, 无法添加新回复