3***@qq.com
3***@qq.com
  • 发布:2018-02-21 13:31
  • 更新:2018-04-27 16:29
  • 阅读:3267

魅族/小米手机微信登录提示未安装微信客户端。

分类:HBuilder
        <script>  
            (function($, doc) {  
                $.plusReady(function() {  
                    plus.screen.lockOrientation("portrait-primary");  
                    var phonecode = plus.device.uuid;  
                    var state = JSON.stringify(app.getState());  
                    var toMain = function() {  
                        var id = setInterval(function () {  
                                clearInterval(id);  
                                var list = plus.webview.getWebviewById('tab4.html');  
                                mui.fire(list,'rush');  
                                var ws=plus.webview.currentWebview();  
                                plus.webview.close(ws);  
                        },20);  
                    };  

                    app.setState(null);  
                    var authBtns = ['weixin'];  
                    var auths = {};  
                    var oauthArea = doc.querySelector('.oauth-area');  
                    plus.oauth.getServices(function(services) {                           
                        for (var i in services) {  
                            var service = services[i];  
                            auths[service.id] = service;                                  
                            if (~authBtns.indexOf(service.id)) {  
                                var isInstalled = app.isInstalled(service.id);  
                                var btn = document.createElement('div');  
                                btn.setAttribute('class', 'oauth-btn' + (!isInstalled && service.id === 'weixin' ? (' disabled') : ''));  
                                btn.authId = service.id;                                      
                                btn.style.backgroundImage = 'url("img/weixin.png")';  
                                oauthArea.appendChild(btn);  
                            }  
                        }  
                        $(oauthArea).on('tap', '.oauth-btn', function() {  
                            if (this.classList.contains('disabled')) {  
                                plus.nativeUI.toast('您尚未安装微信客户端');  
                                return;  
                            }  
                            var auth = auths[this.authId];  
                            var waiting = plus.nativeUI.showWaiting("登录中...", {padlock:true});  
                            auth.login(function() {  

                                auth.getUserInfo(function() {  
                                    var name = auth.userInfo.nickname || auth.userInfo.name;  
                                    console.log(auth.userInfo.unionid);  
                                     mui.post('http://',{  
                                            userInfo:auth.userInfo,  
                                            phonecode:phonecode  
                                        },function(data){  
                                            console.log(JSON.stringify(data));  
                                                waiting.close();      
                                                app.createState(data.user.isvip,data.user.viptime,data.user.viptimes,data.user.username,data.user.id, data.user.nickname,data.user.headimgurl, function(err) {  
                                                    if (err) {  
                                                        plus.nativeUI.toast(err);  
                                                        return;  
                                                    }  
                                                    toMain();  
                                                });  
                                        },'json'  
                                    );  
                                }, function(e) {  
                                    plus.nativeUI.toast("获取用户信息失败:" + e.message+ e.code);  
                                });  
                            }, function(e) {  
                                waiting.close();  
                                plus.nativeUI.toast("登录认证失败:" + e.message+ e.code);  
                            });  
                        });  
                    }, function(e) {  
                        oauthArea.style.display = 'none';  
                        console.log("获取登录认证失败:" + e.message+ e.code);  
                    });                   
                });  
            }(mui, document));  
        </script>

直接引用实例中的微信登录,魅族手机/小米手机上提示未安装微信。
这是什么原因?

2018-02-21 13:31 负责人:无 分享
已邀请:
1***@qq.com

1***@qq.com

同问,楼主~~~我也遇到这个问题了,请问楼主你解决了吗?

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