|
@@ -292,23 +292,21 @@
|
|
|
threshold: 200
|
|
|
}
|
|
|
}, function(ret, err) {
|
|
|
- getAddress();
|
|
|
- });
|
|
|
- //应用从后台回到前台事件
|
|
|
- api.addEventListener({
|
|
|
- name: 'resume'
|
|
|
- }, function(ret, err) {
|
|
|
- _isload = false;
|
|
|
- _minid = '';
|
|
|
- _isrefurbish = true;
|
|
|
- // getAddress();
|
|
|
- // getmsgtotal();
|
|
|
+ if(!_isload && _lon!="0"){
|
|
|
+ _page++;
|
|
|
+ getRouteHotelData(true);
|
|
|
+ }
|
|
|
});
|
|
|
+
|
|
|
//应用每次显示
|
|
|
api.addEventListener({
|
|
|
name: 'viewappear'
|
|
|
}, function(ret, err) {
|
|
|
- getAddress();
|
|
|
+ if(_lon=='0'){
|
|
|
+ getAddress(true);
|
|
|
+ }else{
|
|
|
+ getAddress();
|
|
|
+ }
|
|
|
getmsgtotal();
|
|
|
});
|
|
|
};
|
|
@@ -599,23 +597,13 @@
|
|
|
$('.weui-gallery').remove()
|
|
|
getAddress();
|
|
|
}
|
|
|
-
|
|
|
- function getRouteHotelData() {
|
|
|
- console.log("进来了");
|
|
|
- if (_lon == '0') {
|
|
|
- $(".border-none").removeClass("mask-hidden");
|
|
|
- return false;
|
|
|
- } else {
|
|
|
- $(".border-none").addClass("mask-hidden");
|
|
|
- }
|
|
|
- if (_isload) {
|
|
|
- return false;
|
|
|
- }
|
|
|
+ //获取初始数据
|
|
|
+ function getRouteHotelData(is) {
|
|
|
$.ajax({
|
|
|
url: siteurl + 'v2/entry/storeList',
|
|
|
data: {
|
|
|
page: _page,
|
|
|
- page_size: '20',
|
|
|
+ page_size: '10',
|
|
|
minid: _minid,
|
|
|
lon: _lon,
|
|
|
lat: _lat
|
|
@@ -631,12 +619,10 @@
|
|
|
if (datas.data.store_list.length > 0) {
|
|
|
var html = '<div class="h20"></div>';
|
|
|
$.each(datas.data.store_list, function(index, item) {
|
|
|
-
|
|
|
var _tags_0 = item.store_summary.split(' ');
|
|
|
_tags_0 = jQuery.grep(_tags_0, function(a) {
|
|
|
return a !== '';
|
|
|
});
|
|
|
-
|
|
|
html += '<div class="home-hotel-list" keyid="' + item.store_id +
|
|
|
'"><div class="home-hotel-left"><img src="' + siteurl + 'uploads/home/store/' + item.store_id + '/' +
|
|
|
item.store_banner + '"/></div>';
|
|
@@ -655,19 +641,12 @@
|
|
|
html += '</div></div></div>';
|
|
|
i++;
|
|
|
});
|
|
|
- if (_page == 1) {
|
|
|
- $("#hotel-list").html(html);
|
|
|
- $(".border-none").addClass("mask-hidden");
|
|
|
- $("#hotel-list").removeClass("mask-hidden");
|
|
|
- } else {
|
|
|
+ if (is) {
|
|
|
$("#hotel-list").append(html);
|
|
|
+ } else {
|
|
|
+ $("#hotel-list").html(html);
|
|
|
}
|
|
|
- _page++;
|
|
|
} else {
|
|
|
- if (_page == 1) {
|
|
|
- $(".border-none").removeClass("mask-hidden");
|
|
|
- $("#hotel-list").addClass("mask-hidden");
|
|
|
- }
|
|
|
_isload = true;
|
|
|
}
|
|
|
} else {
|
|
@@ -677,6 +656,92 @@
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+ //重新定位
|
|
|
+ function openDw() {
|
|
|
+ $(this).attr("src", "../image/home_local2.png");
|
|
|
+ var _that = $(this);
|
|
|
+ setTimeout(function() {
|
|
|
+ _that.attr("src", "../image/home_local.png");
|
|
|
+ }, 800);
|
|
|
+ api.toast({
|
|
|
+ msg: '正在获取当前位置...'
|
|
|
+ });
|
|
|
+ _page="1";
|
|
|
+ _isload=false;
|
|
|
+ isShowLoad=true;
|
|
|
+ getAddress(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取定位
|
|
|
+ function getAddress(is) {
|
|
|
+ if(!is){
|
|
|
+ getRouteHotelData();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ var has = hasPermission('location');
|
|
|
+ var aMap = api.require('aMap');
|
|
|
+ if (!has || !has[0] || !has[0].granted) {
|
|
|
+ if(api.systemType == '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{
|
|
|
+ api.requestPermission({list:['location']}, function(ret, err){});
|
|
|
+ }
|
|
|
+ $("#hotel-list").hide();
|
|
|
+ $(".border-none").show();
|
|
|
+ return false;
|
|
|
+ }else{
|
|
|
+ $("#hotel-list").show();
|
|
|
+ $(".border-none").hide();
|
|
|
+ }
|
|
|
+ if (api.systemType == 'ios') {
|
|
|
+ aMap.hide();
|
|
|
+ aMap.open({
|
|
|
+ rect: {x: 0,y: 0,w: 0,h: 0},
|
|
|
+ showUserLocation: true,
|
|
|
+ zoomLevel: 11,
|
|
|
+ center: {lon: 116.4021310000,lat: 39.9994480000},
|
|
|
+ fixedOn: api.frameName,
|
|
|
+ fixed: true
|
|
|
+ }, function(ret, err) {})
|
|
|
+ }
|
|
|
+ aMap.getLocation(function(ret, err) {//获取经纬度
|
|
|
+ if (ret.status) {
|
|
|
+ _lon = ret.lon;
|
|
|
+ _lat = ret.lat;
|
|
|
+ aMap.getNameFromCoords({//获取地址
|
|
|
+ lon: ret.lon,
|
|
|
+ lat: ret.lat
|
|
|
+ }, function(ret, err) {
|
|
|
+ if (ret.status) {
|
|
|
+ if(ret.city||ret.township||ret.street||ret.number){
|
|
|
+ $(".local-name").text(ret.city + ret.township + ret.street + ret.number);
|
|
|
+ }else{
|
|
|
+ $(".local-name").text('定位失败');
|
|
|
+ }
|
|
|
+ aMap.close();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ getRouteHotelData();
|
|
|
+ } else {
|
|
|
+ $(".local-name").text(JSON.stringify(err));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
$(".home-search").on("tap", function() {
|
|
|
api.openWin({
|
|
|
name: 'hotelsearch',
|
|
@@ -779,81 +844,6 @@
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- function openDw() {
|
|
|
- $(this).attr("src", "../image/home_local2.png");
|
|
|
- var _that = $(this);
|
|
|
- setTimeout(function() {
|
|
|
- _that.attr("src", "../image/home_local.png");
|
|
|
- }, 800);
|
|
|
- api.toast({
|
|
|
- msg: '正在获取当前位置...'
|
|
|
- });
|
|
|
- isShowLoad=true;
|
|
|
- getAddress();
|
|
|
- }
|
|
|
-
|
|
|
- function getAddress() {
|
|
|
- var has = hasPermission('location');
|
|
|
- var aMap = api.require('aMap');
|
|
|
- if (!has || !has[0] || !has[0].granted) {
|
|
|
- if(api.systemType == '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{
|
|
|
- api.requestPermission({list:['location']}, function(ret, err){});
|
|
|
- }
|
|
|
- $(".border-none").removeClass("mask-hidden");
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- if (api.systemType == 'ios') {
|
|
|
- aMap.hide();
|
|
|
- aMap.open({
|
|
|
- rect: {x: 0,y: 0,w: 0,h: 0},
|
|
|
- showUserLocation: true,
|
|
|
- zoomLevel: 11,
|
|
|
- center: {lon: 116.4021310000,lat: 39.9994480000},
|
|
|
- fixedOn: api.frameName,
|
|
|
- fixed: true
|
|
|
- }, function(ret, err) {})
|
|
|
- }
|
|
|
- aMap.getLocation(function(ret, err) {
|
|
|
- if (ret.status) {
|
|
|
- _lon = ret.lon;
|
|
|
- _lat = ret.lat;
|
|
|
- aMap.getNameFromCoords({
|
|
|
- lon: ret.lon,
|
|
|
- lat: ret.lat
|
|
|
- }, function(ret, err) {
|
|
|
- if (ret.status) {
|
|
|
- aMap.close();
|
|
|
- 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();
|
|
|
- } else {
|
|
|
- $(".local-name").text(JSON.stringify(err));
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
function jpushInit() {
|
|
|
jpush = api.require('ajpush');
|
|
@@ -899,7 +889,6 @@
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
- /////
|
|
|
function initJPush() {
|
|
|
jpush.init(function(ret, err) {
|
|
|
if (ret && ret.status) {
|