Browse Source

APP首页定位问题

git-svn-id: svn://svn7.apicloud.com/A6007457911931/%E5%9C%88%E5%A4%9A%E5%A4%9A@663 0e1a2743-8d03-4e5a-a60c-7e26af42b145
1149931599@qq.com 4 years ago
parent
commit
5e4ea2d340
4 changed files with 51 additions and 18 deletions
  1. 0 1
      home.html
  2. 43 13
      html/frame0.html
  3. 0 1
      html/frame2.html
  4. 8 3
      html/home/hoteldtl.html

+ 0 - 1
home.html

@@ -116,7 +116,6 @@ function redirectAdv() {
         dataType: 'json',
         type: 'post',
         success: function(datas) {
-          console.log(datas.data);
             if (datas.result) {
                 if (datas.data.enable == 1) {
                     $('.adv').attr('style', 'background-image: url('+siteurl+'/uploads/home/adv/'+datas.data.images+')');

+ 43 - 13
html/frame0.html

@@ -12,7 +12,7 @@
 		<link rel="stylesheet" type="text/css" href="../css/style.css" />
 		<link rel="stylesheet" type="text/css" href="../css/swiper.min.css" />
 		<style>
-				 .swiper-container {
+		.swiper-container {
           width: 100%;
           height: 100%;
         }
@@ -186,7 +186,7 @@
 		<section>
 			<div id="header" class="header">
 				<div class="home-top" style="padding: 0.1rem 0;">
-					<div class="home-top-left"><img id="set-local" class="home-top-local" src="../image/home_local.png" /> <span class="local-name">&nbsp;正在搜索您附近的酒店</span></div>
+					<div class="home-top-left" onclick="openDw()"><img id="set-local" class="home-top-local" src="../image/home_local.png" /> <span class="local-name"></span></div>
 					<div class="home-top-right" style="margin-top: -0.05rem;">
 						<div class="scan-barcode" style="right: 1rem;"><img class="home-top-local" src="../image/home_scan.png" />
 							<p>扫一扫</p>
@@ -248,6 +248,8 @@
 		var _adv_article_id = '0';
 		var _webinkeyid = '0';
 		var _webinstoreid = '0';
+		var jpush;
+		var isShowLoad=true;
 		apiready = function() {
 			var $header = $api.byId('header');
 			$api.fixIos7Bar($header);
@@ -263,8 +265,6 @@
 			if (!storage || !storage[0] || !storage[0].granted) {
 				reqPermission('storage')
 			}
-
-
 			get_adv();//弹窗
 			getRouteData();//轮播吞
 			webtoappinit();
@@ -285,8 +285,8 @@
 				_isload = false;
 				_minid = '';
 				_isrefurbish = true;
-				getAddress();
-				getmsgtotal();
+				// getAddress();
+				// getmsgtotal();
 			});
 			//应用每次显示
 			api.addEventListener({
@@ -597,6 +597,7 @@
 			} else {
 				$(".border-none").addClass("mask-hidden");
 			}
+			console.log("123");
 			if (_isload) {
 				return false;
 			}
@@ -679,7 +680,6 @@
 			return false;
 		})
 		$(".swiper-wrapper").on("tap", ".swiper-slide", function() {
-			console.log("3")
 			var _type = $(this).attr("type");
 			var _keyid = $(this).attr("keyid");
 			if (_type == 'store') {
@@ -769,7 +769,7 @@
 			return false;
 		}
 
-		$("#set-local").on("tap", function() {
+		function openDw() {
 			$(this).attr("src", "../image/home_local2.png");
 			var _that = $(this);
 			setTimeout(function() {
@@ -778,17 +778,41 @@
 			api.toast({
 				msg: '正在获取当前位置...'
 			});
+			isShowLoad=true;
 			getAddress();
-		})
+		}
 
 		function getAddress() {
 			var has = hasPermission('location');
+			var aMap = api.require('aMap');
+			console.log(JSON.stringify(has));
 			if (!has || !has[0] || !has[0].granted) {
-				reqPermission('location');
+				
+				if(api.systemType == 'ios'){
+					console.log("ios");
+						if(isShowLoad){
+							api.confirm({
+							    title: '提醒',
+							    msg:'没有获得定位服务权限\n是否前往设置?',
+							    buttons: ['去设置', '取消']
+							}, function(ret, err) {
+								isShowLoad=false;
+							    if(1 == ret.buttonIndex){
+							    	api.requestPermission({list:['location']}, function(ret, err){});
+							    }else{
+									$(".local-name").text('定位失败');
+								}
+							});
+						}							
+				}else{
+					
+					console.log("安卓");
+					api.requestPermission({list:['location']}, function(ret, err){});
+				}
 				$(".border-none").removeClass("mask-hidden");
 				return false;
 			}
-			var aMap = api.require('aMap');
+				
 			if (api.systemType == 'ios') {
 				aMap.hide();
 				aMap.open({
@@ -810,7 +834,12 @@
 					}, function(ret, err) {
 						if (ret.status) {
 							aMap.close();
-							$(".local-name").text(ret.city + ret.township + ret.street + ret.number);
+							if(ret.city||ret.township||ret.street||ret.number){
+								$(".local-name").text(ret.city + ret.township + ret.street + ret.number);
+							}else{
+								$(".local-name").text('定位失败');
+							}
+							
 						}
 					});
 					getRouteHotelData();
@@ -869,6 +898,7 @@
 		function initJPush() {
 			jpush.init(function(ret, err) {
 				if (ret && ret.status) {
+					// console.log(JSON.stringify(ret))
 					bindAliasAndTags();
 				} else {
 					api.toast({
@@ -893,8 +923,8 @@
 				tags: ['tag1', 'qdduser']
 			};
 			jpush.bindAliasAndTags(param, function(ret) {
-				var statusCode = ret.statusCode;
 				// alert(JSON.stringify(ret));
+				var statusCode = ret.statusCode;
 			});
 		}
 

+ 0 - 1
html/frame2.html

@@ -249,7 +249,6 @@ function getNum(){
 	    headers: { "X-TOKEN": $api.getStorage("accesstoken")},
 	    type: 'get',
 	    success: function(res) {
-			console.log(JSON.stringify(res.data));
       $(".dian").hide();
 			var data=res.data;
 			if(data.waiting_count >0){

+ 8 - 3
html/home/hoteldtl.html

@@ -54,7 +54,7 @@
         width: 0.3rem !important;
         height: 0.3rem !important;
       }
-        .hotel-top{
+      .hotel-top{
        width:100%;
        height: 4.03rem;
        background: url('../../image/881649.jpg') ;
@@ -344,7 +344,7 @@
 			z-index: 501;
 			left: 0;
 			right: 0;
-			top:32.5px;
+			top:0;
 			z-index: 999;
 			transform: translateZ(0);-webkit-transform: translateZ(0);
 		}
@@ -380,7 +380,7 @@
 				<div class="swiper-pagination"></div>
 			</div>
 			<section class="ft" style="padding: 0;padding-bottom: 0.2rem;">
-				<div class="h20"></div>
+				<div style="height: 0.75rem;"></div>
 				<div class="hotel-top-line">
 					<ul class="flex-box flex-v-ce">
 						<li style="width: 0.61rem;padding-left: 0.04rem;" class="back-btn">
@@ -507,6 +507,11 @@
 		var imgUrl = "";
 		apiready = function() {
 			_storeid = api.pageParam.keyid;
+			 $(".ft").css("top",'3px');
+			// var statusBar = api.require('statusBar');
+			// statusBar.getStatusBarHeight(function(ret, err){
+			   
+			// });
 			$(".goods-list").attr("page", "1");
 			setIosTopBar();
 			getstoreCategory();