diff --git a/pages/index/index/index.vue b/pages/index/index/index.vue index f90725b..10faadd 100644 --- a/pages/index/index/index.vue +++ b/pages/index/index/index.vue @@ -37,7 +37,7 @@ - {{ city||'定位失败下拉重新获取' }} + {{ city }}   |   @@ -144,7 +144,17 @@ var city_id = res.city_info.city_id; getApp().globalData.city_id = city_id; this.refresh_info(city_id); - }); + }).catch(rej=>{ + if(rej==='定位未开启'){ + getApp().globalData.locationPermise =false + location_city("beijing").then((res) => { + var city = res.city_info.city_name; + var city_id = res.city_info.city_id; + getApp().globalData.city_id = city_id; + this.refresh_info(city_id); + }) + } + }) } else { this.refresh_info(getApp().globalData.city_id); } diff --git a/unpackage/dist/dev/mp-alipay/common/vendor.js b/unpackage/dist/dev/mp-alipay/common/vendor.js index 6daed72..39b510d 100644 --- a/unpackage/dist/dev/mp-alipay/common/vendor.js +++ b/unpackage/dist/dev/mp-alipay/common/vendor.js @@ -19419,6 +19419,7 @@ var location_city = function location_city() { success: function success(res) { console.log(res); if (!res.longitude) { + reject('定位未开启'); setting(); return; } @@ -19435,6 +19436,8 @@ var location_city = function location_city() { }); }, fail: function fail(res) { + // reject('定位失败,下拉重试或点击选择城市') + reject('定位未开启'); setting(); } }); @@ -19448,7 +19451,8 @@ var setting = function setting() { var statu = res.authSetting; if (!statu['scope.userLocation']) {//判断是否授权,没有授权就提示下面的信息 wx.showModal({ - title: '需要获取您的地理位置,请确认授权定位,否则小程序功能将无法使用', + // title: '需要获取您的地理位置,请确认授权定位,否则小程序功能将无法使用', + title: '需要获取您的地理位置,请确认授权定位,当前定位为北京', cancelColor: '#666666', success: function success(tip) { if (tip.confirm) {//查看是否点击确定 @@ -19486,11 +19490,11 @@ var setting = function setting() { } }); } else { - wx.showToast({ - title: '首页下拉重新授权定位!', - icon: 'error', - duration: 1000 }); - + // wx.showToast({ + // title: '重新进入小程序唤起定位授权', + // icon: 'error', + // duration: 1000 + // }) } } }); diff --git a/unpackage/dist/dev/mp-alipay/pages/index/index/index.acss b/unpackage/dist/dev/mp-alipay/pages/index/index/index.acss index a21d974..d93dbb8 100644 --- a/unpackage/dist/dev/mp-alipay/pages/index/index/index.acss +++ b/unpackage/dist/dev/mp-alipay/pages/index/index/index.acss @@ -423,6 +423,16 @@ + + + + + + + + + + diff --git a/unpackage/dist/dev/mp-alipay/pages/index/index/index.axml b/unpackage/dist/dev/mp-alipay/pages/index/index/index.axml index 281c631..be7733f 100644 --- a/unpackage/dist/dev/mp-alipay/pages/index/index/index.axml +++ b/unpackage/dist/dev/mp-alipay/pages/index/index/index.axml @@ -1 +1 @@ -×{{city||'定位失败下拉重新获取'}}{{placeholder}}{{''+item+''}}{{item.start_date+"-"+item.end_date}}{{item.show_name}}¥{{item.lowest_price}}别滑了,已经到底啦~ \ No newline at end of file +×{{city}}{{placeholder}}{{''+item+''}}{{item.start_date+"-"+item.end_date}}{{item.show_name}}¥{{item.lowest_price}}别滑了,已经到底啦~ \ No newline at end of file diff --git a/unpackage/dist/dev/mp-alipay/pages/index/index/index.js b/unpackage/dist/dev/mp-alipay/pages/index/index/index.js index 9bcf286..7b9ff84 100644 --- a/unpackage/dist/dev/mp-alipay/pages/index/index/index.js +++ b/unpackage/dist/dev/mp-alipay/pages/index/index/index.js @@ -276,6 +276,16 @@ var _util = __webpack_require__(/*! ../../../utils/util */ 143);function _toCons var city_id = res.city_info.city_id; getApp().globalData.city_id = city_id; _this.refresh_info(city_id); + }).catch(function (rej) { + if (rej === '定位未开启') { + getApp().globalData.locationPermise = false; + (0, _util.location_city)("beijing").then(function (res) { + var city = res.city_info.city_name; + var city_id = res.city_info.city_id; + getApp().globalData.city_id = city_id; + _this.refresh_info(city_id); + }); + } }); } else { this.refresh_info(getApp().globalData.city_id); diff --git a/utils/util.js b/utils/util.js index 6f51884..8d11b0e 100644 --- a/utils/util.js +++ b/utils/util.js @@ -206,7 +206,8 @@ const location_city = function() { success(res) { console.log(res); - if (!res.longitude) { + if (!res.longitude) { + reject('定位未开启') setting() return } @@ -222,7 +223,9 @@ const location_city = function() { resolve(res1) }) }, - fail(res) { + fail(res) { + // reject('定位失败,下拉重试或点击选择城市') + reject('定位未开启') setting() } }) @@ -236,7 +239,8 @@ const setting = function() { var statu = res.authSetting; if (!statu['scope.userLocation']) { //判断是否授权,没有授权就提示下面的信息 wx.showModal({ - title: '需要获取您的地理位置,请确认授权定位,否则小程序功能将无法使用', + // title: '需要获取您的地理位置,请确认授权定位,否则小程序功能将无法使用', + title: '需要获取您的地理位置,请确认授权定位,当前定位为北京', cancelColor: '#666666', success: function(tip) { if (tip.confirm) { //查看是否点击确定 @@ -274,11 +278,11 @@ const setting = function() { } }) } else { - wx.showToast({ - title: '首页下拉重新授权定位!', - icon: 'error', - duration: 1000 - }) + // wx.showToast({ + // title: '重新进入小程序唤起定位授权', + // icon: 'error', + // duration: 1000 + // }) } } })