起步软件技术论坛
搜索
 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 5323|回复: 3

[处理中3] 求助,打包安装后定位的问题

[复制链接]

6

主题

17

帖子

91

积分

初级会员

Rank: 2

积分
91
QQ
发表于 2018-5-29 14:50:37 | 显示全部楼层 |阅读模式
版本: 小版本号:
数据库: 服务器操作系统: 其它(帖子中说明) 应用服务器: Tomcat
客户端操作系统: Windows 其它 浏览器: Chrome
本帖最后由 cbb66 于 2018-5-29 17:00 编辑

打包成app后,定位失败后会进入手机的定位服务设置,不会提示定位失败。
Model.prototype.setLocation = function() {
                if(typeof device === "undefined") return;
                var _this = this;
                navigator.geolocation.getCurrentPosition(function(position){
            var lat = position.coords.latitude;//获取到纬度
            var lon = position.coords.longitude;//获取到经度
            _this.lat = lat;
            _this.lon = lon;
            var url = 'https://api.map.baidu.com/geocoder/v2/?ak=XwQGPoOFhERnqBlGHtp7QQ4UgjAkoqc6&callback=renderReverse&location=' + lat + ',' + lon + '&output=json&pois=1';
            $.ajax({
                    url : url,
                    dataType : 'jsonp',
                    processData : false,
                    type : 'get',
                    success : function(data) {
                                     _this.isLocationFlag = true;
                                     if(!_this.getElementByXid('locating')){
                                             return;
                                     }
                                     _this.getElementByXid('locating').style.display = "none";
                                     _this.getElementByXid('signName').style.display = "block";
                                     _this.getElementByXid('time').style.display = "block";
                                     _this.clockingInAdddress = data.result.pois[0].name;
                             $(_this.getElementByXid('address')).html("考勤地点:"+data.result.pois[0].name);
                    },
                    error : function(XMLHttpRequest, textStatus, errorThrown) {
                                    if(!_this.getElementByXid('locating')){
                                                        return;
                                    }
                            $(_this.getElementByXid('locating')).html('重新定位');
                    }
              });

                },function(err){
                        console.error(err);
                        if (device && device.platform == "Android") {
                                if(cordova.plugins.settings && typeof cordova.plugins.settings.openSetting != "undefined"){
                                        cordova.plugins.settings.openSetting("location_source", function(){
                                   
                                },
                                function(){
                                        main_this.comp('msgDialog').show({
                                            type: 'OK',
                                            message: '打开定位服务失败!'
                                    });
                                });
                                }
                        } else {
                                //iOS无需添加参数
                            cordova.plugins.settings.open(function(){
                            console.log("opened settings");
                        },
                        function(){
                                main_this.comp('msgDialog').show({
                                    type: 'OK',
                                    message: '打开定位服务失败!'
                            });
                        });
                        }
                       
                },{ timeout: 60000},"bd09ll");
                //再次调用函数关闭GPS
        //navigator.geolocation.getCurrentPosition(function(){},function(){},null,"bd09ll");
        };

定位失败后会跳转到此页面

定位失败后会跳转到此页面

91

主题

13万

帖子

3万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
35918
发表于 2018-5-29 15:13:17 | 显示全部楼层
安装apploader,运行你的定位功能测试看看是否正确
远程的联系方法QQ1392416607,添加好友时,需在备注里注明其论坛名字及ID,公司等信息
发远程时同时也发一下帖子地址,方便了解要解决的问题  WeX5教程  WeX5下载



如按照该方法解决,请及时跟帖,便于版主结贴
回复 支持 反对

使用道具 举报

6

主题

17

帖子

91

积分

初级会员

Rank: 2

积分
91
QQ
 楼主| 发表于 2018-5-29 17:39:48 | 显示全部楼层
jishuang 发表于 2018-5-29 15:13
安装apploader,运行你的定位功能测试看看是否正确

使用apploader时定位没有问题,打包后定位就有问题了
回复 支持 反对

使用道具 举报

91

主题

13万

帖子

3万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
35918
发表于 2018-5-29 18:26:02 | 显示全部楼层
x5具体用的什么版本?打包时插件都选择了哪些?
远程的联系方法QQ1392416607,添加好友时,需在备注里注明其论坛名字及ID,公司等信息
发远程时同时也发一下帖子地址,方便了解要解决的问题  WeX5教程  WeX5下载



如按照该方法解决,请及时跟帖,便于版主结贴
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|X3技术论坛|Justep Inc.    

GMT+8, 2024-4-26 21:11 , Processed in 0.118150 second(s), 28 queries .

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表