|
@@ -4,6 +4,10 @@ const { request, serverName,imgServer } = require('../../utils/services');
|
|
const { Toast, qqmapsdk } = require('../../utils/util.js');
|
|
const { Toast, qqmapsdk } = require('../../utils/util.js');
|
|
const { defaultImg, noExhibitionImg } = require('../../utils/images');
|
|
const { defaultImg, noExhibitionImg } = require('../../utils/images');
|
|
const WxParse = require('../../common/component/wxParse/wxParse.js');
|
|
const WxParse = require('../../common/component/wxParse/wxParse.js');
|
|
|
|
+const {
|
|
|
|
+ newRequestFns,
|
|
|
|
+ newServerName
|
|
|
|
+} = require('../../utils/newServices.js');
|
|
|
|
|
|
// const QQMapWX = require('../../common/component/mapSDK/qqmap-wx-jssdk.min.js');
|
|
// const QQMapWX = require('../../common/component/mapSDK/qqmap-wx-jssdk.min.js');
|
|
|
|
|
|
@@ -51,7 +55,7 @@ Page({
|
|
interval: 5000,
|
|
interval: 5000,
|
|
duration: 1000,
|
|
duration: 1000,
|
|
activeIndex: 0,
|
|
activeIndex: 0,
|
|
- locationName: "珠海",
|
|
|
|
|
|
+ locationName: "北京",
|
|
locationNameDesp:"",
|
|
locationNameDesp:"",
|
|
isLike: false,
|
|
isLike: false,
|
|
showConfirm: false,
|
|
showConfirm: false,
|
|
@@ -95,15 +99,33 @@ Page({
|
|
|
|
|
|
},
|
|
},
|
|
onShow: function () {
|
|
onShow: function () {
|
|
- let { city, clickToSelect, collectedArr, collectedChange } = app.globalData;
|
|
|
|
|
|
+ let { city, clickToSelect, collectedArr, collectedChange, latitude, longitude, locationName } = app.globalData;
|
|
let { activeIndex, exhibitionList } = this.data
|
|
let { activeIndex, exhibitionList } = this.data
|
|
if (clickToSelect) {
|
|
if (clickToSelect) {
|
|
|
|
+ // 使用 globalData 中的位置信息
|
|
|
|
+ let finalLocationName = locationName || city || "北京";
|
|
|
|
+
|
|
this.setData({
|
|
this.setData({
|
|
- locationName: city || "珠海",
|
|
|
|
|
|
+ locationName: finalLocationName,
|
|
exhibitionList: [],
|
|
exhibitionList: [],
|
|
activeIndex: 0,
|
|
activeIndex: 0,
|
|
type: 5
|
|
type: 5
|
|
});
|
|
});
|
|
|
|
+
|
|
|
|
+ // 如果有完整的位置信息,也设置坐标
|
|
|
|
+ if (latitude && longitude) {
|
|
|
|
+ this.setData({
|
|
|
|
+ latitude: latitude,
|
|
|
|
+ longitude: longitude
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 确保 city 与 locationName 一致
|
|
|
|
+ if (finalLocationName && finalLocationName !== "北京") {
|
|
|
|
+ app.globalData.city = finalLocationName;
|
|
|
|
+ } else {
|
|
|
|
+ app.globalData.city = "北京";
|
|
|
|
+ }
|
|
|
|
|
|
if (activeIndex == 1) {
|
|
if (activeIndex == 1) {
|
|
this.getNearByList(1);
|
|
this.getNearByList(1);
|
|
@@ -151,7 +173,7 @@ Page({
|
|
|
|
|
|
let loginSessionKey = wx.getStorageSync('token') || "";
|
|
let loginSessionKey = wx.getStorageSync('token') || "";
|
|
// if (loginSessionKey){
|
|
// if (loginSessionKey){
|
|
- request['isCollect']({
|
|
|
|
|
|
+ newRequestFns['isCollect']({
|
|
loginSessionKey,
|
|
loginSessionKey,
|
|
exhibitionId: id,
|
|
exhibitionId: id,
|
|
type: Number(type),
|
|
type: Number(type),
|
|
@@ -218,55 +240,102 @@ Page({
|
|
},
|
|
},
|
|
|
|
|
|
getLocationName: function () {
|
|
getLocationName: function () {
|
|
- // 调用接口
|
|
|
|
- wx.getLocation({
|
|
|
|
- type: 'wgs84',
|
|
|
|
- success: (res) => {
|
|
|
|
- this.setData({
|
|
|
|
- latitude: res.latitude,
|
|
|
|
- longitude: res.longitude
|
|
|
|
- })
|
|
|
|
- //2、根据坐标获取当前位置名称,显示在顶部:腾讯地图逆地址解析
|
|
|
|
- qqmapsdk.reverseGeocoder({
|
|
|
|
- location: {
|
|
|
|
- latitude: res.latitude,
|
|
|
|
- longitude: res.longitude
|
|
|
|
- },
|
|
|
|
- success: (res) => {
|
|
|
|
- let { city: locationName } = res.result.address_component;
|
|
|
|
- locationName = locationName.substring(0, 2);
|
|
|
|
- app.globalData.city = locationName;
|
|
|
|
-
|
|
|
|
- this.setData({
|
|
|
|
- locationName,
|
|
|
|
- locationNameDesp: locationName
|
|
|
|
- })
|
|
|
|
- this.getList(1)
|
|
|
|
- },
|
|
|
|
- fail: function (res) {
|
|
|
|
- this.setData({
|
|
|
|
- locationName: ""
|
|
|
|
- })
|
|
|
|
- },
|
|
|
|
- complete: function (res) {
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
|
|
+ // 检查 globalData 是否已有位置信息
|
|
|
|
+ // if (app.globalData.latitude && app.globalData.longitude && app.globalData.locationName) {
|
|
|
|
+ // 使用 globalData 中的值
|
|
|
|
+ this.setData({
|
|
|
|
+ latitude: app.globalData.latitude,
|
|
|
|
+ longitude: app.globalData.longitude,
|
|
|
|
+ locationName: app.globalData.locationName,
|
|
|
|
+ locationNameDesp: app.globalData.locationName
|
|
|
|
+ });
|
|
|
|
+ app.globalData.city = app.globalData.locationName || '北京';
|
|
|
|
+ this.getList(1);
|
|
|
|
+ return;
|
|
|
|
+ // }
|
|
|
|
+
|
|
|
|
+ // 没有完整位置信息,获取位置
|
|
|
|
+ // wx.getLocation({
|
|
|
|
+ // type: 'wgs84',
|
|
|
|
+ // success: (res) => {
|
|
|
|
+ // // 保存到 globalData
|
|
|
|
+ // app.globalData.latitude = res.latitude;
|
|
|
|
+ // app.globalData.longitude = res.longitude;
|
|
|
|
+
|
|
|
|
+ // this.setData({
|
|
|
|
+ // latitude: res.latitude,
|
|
|
|
+ // longitude: res.longitude
|
|
|
|
+ // })
|
|
|
|
+ // //2、根据坐标获取当前位置名称,显示在顶部:腾讯地图逆地址解析
|
|
|
|
+ // qqmapsdk.reverseGeocoder({
|
|
|
|
+ // location: {
|
|
|
|
+ // latitude: res.latitude,
|
|
|
|
+ // longitude: res.longitude
|
|
|
|
+ // },
|
|
|
|
+ // success: (res) => {
|
|
|
|
+ // let { city: locationName } = res.result.address_component;
|
|
|
|
+ // locationName = locationName.substring(0, 2);
|
|
|
|
+
|
|
|
|
+ // // 保存到 globalData
|
|
|
|
+ // app.globalData.city = locationName;
|
|
|
|
+ // app.globalData.locationName = locationName;
|
|
|
|
+
|
|
|
|
+ // this.setData({
|
|
|
|
+ // locationName,
|
|
|
|
+ // locationNameDesp: locationName
|
|
|
|
+ // })
|
|
|
|
+ // this.getList(1)
|
|
|
|
+ // },
|
|
|
|
+ // fail: function (res) {
|
|
|
|
+ // // 失败时设置默认值
|
|
|
|
+ // app.globalData.city = "北京";
|
|
|
|
+ // app.globalData.locationName = "北京";
|
|
|
|
+ // this.setData({
|
|
|
|
+ // locationName: "北京"
|
|
|
|
+ // })
|
|
|
|
+ // },
|
|
|
|
+ // complete: function (res) {
|
|
|
|
+ // }
|
|
|
|
+ // });
|
|
|
|
+ // }
|
|
|
|
+ // })
|
|
},
|
|
},
|
|
|
|
|
|
offlineRecommend: function () {
|
|
offlineRecommend: function () {
|
|
- wx.getLocation({
|
|
|
|
- type: 'wgs84',
|
|
|
|
- success: (res) => {
|
|
|
|
- this.setData({
|
|
|
|
- latitude: res.latitude,
|
|
|
|
- longitude: res.longitude
|
|
|
|
- })
|
|
|
|
|
|
+ // 检查 globalData 是否已有位置信息
|
|
|
|
+ if (app.globalData.latitude && app.globalData.longitude) {
|
|
|
|
+ // 使用 globalData 中的经纬度
|
|
|
|
+ this.setData({
|
|
|
|
+ latitude: app.globalData.latitude,
|
|
|
|
+ longitude: app.globalData.longitude
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // 处理 city 设置
|
|
|
|
+ if (app.globalData.locationName) {
|
|
|
|
+ app.globalData.city = app.globalData.locationName;
|
|
|
|
+ } else {
|
|
|
|
+ app.globalData.city = "北京";
|
|
}
|
|
}
|
|
- })
|
|
|
|
|
|
+ }
|
|
|
|
+ // else {
|
|
|
|
+ // // 没有位置信息,获取位置
|
|
|
|
+ // wx.getLocation({
|
|
|
|
+ // type: 'wgs84',
|
|
|
|
+ // success: (res) => {
|
|
|
|
+ // // 保存到 globalData
|
|
|
|
+ // app.globalData.latitude = res.latitude;
|
|
|
|
+ // app.globalData.longitude = res.longitude;
|
|
|
|
+
|
|
|
|
+ // this.setData({
|
|
|
|
+ // latitude: res.latitude,
|
|
|
|
+ // longitude: res.longitude
|
|
|
|
+ // })
|
|
|
|
+ // }
|
|
|
|
+ // })
|
|
|
|
+ // }
|
|
|
|
+
|
|
let { latitude: lat, longitude: lng } = this.data;
|
|
let { latitude: lat, longitude: lng } = this.data;
|
|
- request["offlineRecommend"]({
|
|
|
|
|
|
+ newRequestFns["offlineRecommend"]({
|
|
lat,
|
|
lat,
|
|
lng,
|
|
lng,
|
|
}, "", res => {
|
|
}, "", res => {
|
|
@@ -289,7 +358,7 @@ Page({
|
|
this.setData({
|
|
this.setData({
|
|
loading: true
|
|
loading: true
|
|
})
|
|
})
|
|
- request["getExhibitionListOffline"]({
|
|
|
|
|
|
+ newRequestFns["getExhibitionListOffline"]({
|
|
page: page,
|
|
page: page,
|
|
type: type,
|
|
type: type,
|
|
loginSessionKey,
|
|
loginSessionKey,
|
|
@@ -302,25 +371,42 @@ Page({
|
|
let tempContent = this.data.exhibitionList
|
|
let tempContent = this.data.exhibitionList
|
|
? this.data.exhibitionList
|
|
? this.data.exhibitionList
|
|
: [];
|
|
: [];
|
|
- let { last: lastPage, totalPages, totalElements, content: exhibitionList } = res.data.data;
|
|
|
|
|
|
+ let { pageData: exhibitionList, total } = res.data.data;
|
|
|
|
+
|
|
|
|
+ // 判断是否为最后一页(返回空数组表示没有更多数据)
|
|
|
|
+ let isLastPage = !exhibitionList || exhibitionList.length === 0;
|
|
|
|
|
|
|
|
+ if (isLastPage) {
|
|
|
|
+ this.setData({
|
|
|
|
+ loading: false,
|
|
|
|
+ lastPage: true, // 标记为最后一页
|
|
|
|
+ exhiNum: total || 0
|
|
|
|
+ });
|
|
|
|
+ wx.stopPullDownRefresh();
|
|
|
|
+ if (total <= 3) {
|
|
|
|
+ this.offlineRecommend();
|
|
|
|
+ }
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
|
|
exhibitionList.forEach((currentValue) => {
|
|
exhibitionList.forEach((currentValue) => {
|
|
currentValue.product ? currentValue.product.link = escape(currentValue.product.link) : '';
|
|
currentValue.product ? currentValue.product.link = escape(currentValue.product.link) : '';
|
|
})
|
|
})
|
|
|
|
|
|
- let { openTime } = exhibitionList;
|
|
|
|
|
|
+ // 拼接新数据
|
|
|
|
+ let newExhibitionList = tempContent.concat(exhibitionList);
|
|
|
|
+
|
|
this.setData({
|
|
this.setData({
|
|
- currentPage: res.data.data.number + 1,
|
|
|
|
- lastPage,
|
|
|
|
|
|
+ currentPage: page,
|
|
|
|
+ lastPage: false, // 有数据时设为false
|
|
loading: false,
|
|
loading: false,
|
|
- exhibitionList: tempContent.concat(exhibitionList),
|
|
|
|
- exhiNum: totalElements
|
|
|
|
|
|
+ exhibitionList: newExhibitionList,
|
|
|
|
+ exhiNum: total
|
|
});
|
|
});
|
|
wx.stopPullDownRefresh();
|
|
wx.stopPullDownRefresh();
|
|
// WxParse.wxParseTemArray("replyTemArray", 'reply', replyArr.length, that)
|
|
// WxParse.wxParseTemArray("replyTemArray", 'reply', replyArr.length, that)
|
|
|
|
|
|
- if (this.data.exhiNum <= 3){
|
|
|
|
|
|
+ if (total <= 3){
|
|
this.offlineRecommend();
|
|
this.offlineRecommend();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -334,7 +420,7 @@ Page({
|
|
getNearByList: function (page) {
|
|
getNearByList: function (page) {
|
|
let { type, locationName, latitude, longitude } = this.data;
|
|
let { type, locationName, latitude, longitude } = this.data;
|
|
let loginSessionKey = wx.getStorageSync("token");
|
|
let loginSessionKey = wx.getStorageSync("token");
|
|
-
|
|
|
|
|
|
+ console.log(locationName, latitude, longitude, 999)
|
|
wx.getSetting({
|
|
wx.getSetting({
|
|
success: res => {
|
|
success: res => {
|
|
if (!res.authSetting['scope.userLocation']) {
|
|
if (!res.authSetting['scope.userLocation']) {
|
|
@@ -351,45 +437,127 @@ Page({
|
|
getLocationBtn: false
|
|
getLocationBtn: false
|
|
})
|
|
})
|
|
if (!longitude && !latitude) {
|
|
if (!longitude && !latitude) {
|
|
- wx.getLocation({
|
|
|
|
- success: res => {
|
|
|
|
- let longitude = (this.longitude = res.longitude);
|
|
|
|
- let latitude = (this.latitude = res.latitude);
|
|
|
|
- request["getNearByList"]({
|
|
|
|
- page: page,
|
|
|
|
- loginSessionKey,
|
|
|
|
- city: locationName,
|
|
|
|
- lng: longitude,
|
|
|
|
- lat: latitude
|
|
|
|
- }, '', res => {
|
|
|
|
-
|
|
|
|
- let tempContent = this.data.exhibitionList
|
|
|
|
- ? this.data.exhibitionList
|
|
|
|
- : [];
|
|
|
|
- let { last: lastPage, totalPages, content: exhibitionList } = res.data.data;
|
|
|
|
-
|
|
|
|
- let { openTime } = exhibitionList;
|
|
|
|
|
|
+ // 检查 globalData 是否已有位置信息
|
|
|
|
+ if (app.globalData.latitude && app.globalData.longitude) {
|
|
|
|
+ // 使用 globalData 中的经纬度
|
|
|
|
+ let longitude = app.globalData.longitude;
|
|
|
|
+ let latitude = app.globalData.latitude;
|
|
|
|
+
|
|
|
|
+ // 处理 city 设置
|
|
|
|
+ if (app.globalData.locationName) {
|
|
|
|
+ app.globalData.city = app.globalData.locationName;
|
|
|
|
+ } else {
|
|
|
|
+ app.globalData.city = "北京";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.setData({
|
|
|
|
+ longitude,
|
|
|
|
+ latitude
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ newRequestFns["getNearByList"]({
|
|
|
|
+ page: page,
|
|
|
|
+ loginSessionKey,
|
|
|
|
+ city: locationName,
|
|
|
|
+ lng: longitude,
|
|
|
|
+ lat: latitude
|
|
|
|
+ }, '', res => {
|
|
|
|
+
|
|
|
|
+ let tempContent = this.data.exhibitionList
|
|
|
|
+ ? this.data.exhibitionList
|
|
|
|
+ : [];
|
|
|
|
+ let { pageData: exhibitionList, total } = res.data.data;
|
|
|
|
+
|
|
|
|
+ // 判断是否为最后一页(返回空数组表示没有更多数据)
|
|
|
|
+ let isLastPage = !exhibitionList || exhibitionList.length === 0;
|
|
|
|
+
|
|
|
|
+ if (isLastPage) {
|
|
this.setData({
|
|
this.setData({
|
|
- currentPage: res.data.data.number + 1,
|
|
|
|
- lastPage,
|
|
|
|
loading: false,
|
|
loading: false,
|
|
- longitude,
|
|
|
|
- latitude,
|
|
|
|
- exhibitionList: tempContent.concat(exhibitionList),
|
|
|
|
|
|
+ lastPage: true
|
|
});
|
|
});
|
|
wx.stopPullDownRefresh();
|
|
wx.stopPullDownRefresh();
|
|
-
|
|
|
|
- // WxParse.wxParseTemArray("replyTemArray", 'reply', replyArr.length, that)
|
|
|
|
-
|
|
|
|
- }, err => {
|
|
|
|
-
|
|
|
|
- }, complete => {
|
|
|
|
-
|
|
|
|
- })
|
|
|
|
- },
|
|
|
|
- })
|
|
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 拼接新数据
|
|
|
|
+ let newExhibitionList = tempContent.concat(exhibitionList);
|
|
|
|
+
|
|
|
|
+ this.setData({
|
|
|
|
+ currentPage: page,
|
|
|
|
+ lastPage: false, // 有数据时设为false
|
|
|
|
+ loading: false,
|
|
|
|
+ exhibitionList: newExhibitionList,
|
|
|
|
+ });
|
|
|
|
+ wx.stopPullDownRefresh();
|
|
|
|
+
|
|
|
|
+ // WxParse.wxParseTemArray("replyTemArray", 'reply', replyArr.length, that)
|
|
|
|
+
|
|
|
|
+ }, err => {
|
|
|
|
+
|
|
|
|
+ }, complete => {
|
|
|
|
+
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ // 没有位置信息,获取位置
|
|
|
|
+ // wx.getLocation({
|
|
|
|
+ // success: res => {
|
|
|
|
+ // // 保存到 globalData
|
|
|
|
+ // app.globalData.latitude = res.latitude;
|
|
|
|
+ // app.globalData.longitude = res.longitude;
|
|
|
|
+
|
|
|
|
+ // let longitude = (this.longitude = res.longitude);
|
|
|
|
+ // let latitude = (this.latitude = res.latitude);
|
|
|
|
+ // newRequestFns["getNearByList"]({
|
|
|
|
+ // page: page,
|
|
|
|
+ // loginSessionKey,
|
|
|
|
+ // city: locationName,
|
|
|
|
+ // lng: longitude,
|
|
|
|
+ // lat: latitude
|
|
|
|
+ // }, '', res => {
|
|
|
|
+
|
|
|
|
+ // let tempContent = this.data.exhibitionList
|
|
|
|
+ // ? this.data.exhibitionList
|
|
|
|
+ // : [];
|
|
|
|
+ // let { pageData: exhibitionList, total } = res.data.data;
|
|
|
|
+
|
|
|
|
+ // // 判断是否为最后一页(返回空数组表示没有更多数据)
|
|
|
|
+ // let isLastPage = !exhibitionList || exhibitionList.length === 0;
|
|
|
|
+
|
|
|
|
+ // if (isLastPage) {
|
|
|
|
+ // this.setData({
|
|
|
|
+ // loading: false,
|
|
|
|
+ // lastPage: true
|
|
|
|
+ // });
|
|
|
|
+ // wx.stopPullDownRefresh();
|
|
|
|
+ // return;
|
|
|
|
+ // }
|
|
|
|
+
|
|
|
|
+ // // 拼接新数据
|
|
|
|
+ // let newExhibitionList = tempContent.concat(exhibitionList);
|
|
|
|
+
|
|
|
|
+ // this.setData({
|
|
|
|
+ // currentPage: page,
|
|
|
|
+ // lastPage: false, // 有数据时设为false
|
|
|
|
+ // loading: false,
|
|
|
|
+ // longitude,
|
|
|
|
+ // latitude,
|
|
|
|
+ // exhibitionList: newExhibitionList,
|
|
|
|
+ // });
|
|
|
|
+ // wx.stopPullDownRefresh();
|
|
|
|
+
|
|
|
|
+ // // WxParse.wxParseTemArray("replyTemArray", 'reply', replyArr.length, that)
|
|
|
|
+
|
|
|
|
+ // }, err => {
|
|
|
|
+
|
|
|
|
+ // }, complete => {
|
|
|
|
+
|
|
|
|
+ // })
|
|
|
|
+ // },
|
|
|
|
+ // })
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
- request["getNearByList"]({
|
|
|
|
|
|
+ newRequestFns["getNearByList"]({
|
|
page: page,
|
|
page: page,
|
|
loginSessionKey,
|
|
loginSessionKey,
|
|
city: locationName,
|
|
city: locationName,
|
|
@@ -400,15 +568,29 @@ Page({
|
|
let tempContent = this.data.exhibitionList
|
|
let tempContent = this.data.exhibitionList
|
|
? this.data.exhibitionList
|
|
? this.data.exhibitionList
|
|
: [];
|
|
: [];
|
|
- let { last: lastPage, totalPages, content: exhibitionList } = res.data.data;
|
|
|
|
-
|
|
|
|
- let { openTime } = exhibitionList;
|
|
|
|
- this.setData({
|
|
|
|
- currentPage: res.data.data.number + 1,
|
|
|
|
- lastPage,
|
|
|
|
- loading: false,
|
|
|
|
- exhibitionList: tempContent.concat(exhibitionList),
|
|
|
|
- });
|
|
|
|
|
|
+ let { pageData: exhibitionList, total } = res.data.data;
|
|
|
|
+
|
|
|
|
+ // 判断是否为最后一页(返回空数组表示没有更多数据)
|
|
|
|
+ let isLastPage = !exhibitionList || exhibitionList.length === 0;
|
|
|
|
+
|
|
|
|
+ if (isLastPage) {
|
|
|
|
+ this.setData({
|
|
|
|
+ loading: false,
|
|
|
|
+ lastPage: true
|
|
|
|
+ });
|
|
|
|
+ wx.stopPullDownRefresh();
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 拼接新数据
|
|
|
|
+ let newExhibitionList = tempContent.concat(exhibitionList);
|
|
|
|
+
|
|
|
|
+ this.setData({
|
|
|
|
+ currentPage: page,
|
|
|
|
+ lastPage: false, // 有数据时设为false
|
|
|
|
+ loading: false,
|
|
|
|
+ exhibitionList: newExhibitionList,
|
|
|
|
+ });
|
|
wx.stopPullDownRefresh();
|
|
wx.stopPullDownRefresh();
|
|
}, err => {
|
|
}, err => {
|
|
}, complete => {
|
|
}, complete => {
|
|
@@ -449,6 +631,7 @@ Page({
|
|
},
|
|
},
|
|
|
|
|
|
tabClick: function (e) {
|
|
tabClick: function (e) {
|
|
|
|
+ console.log(111111)
|
|
this.setData({
|
|
this.setData({
|
|
exhibitionList: [],
|
|
exhibitionList: [],
|
|
activeIndex: e.currentTarget.id,
|
|
activeIndex: e.currentTarget.id,
|
|
@@ -480,11 +663,119 @@ Page({
|
|
this.getList(1)
|
|
this.getList(1)
|
|
},
|
|
},
|
|
to_search: function () {
|
|
to_search: function () {
|
|
- wx.navigateTo({
|
|
|
|
- url: './search/index',
|
|
|
|
- success: function (res) { },
|
|
|
|
- fail: function (res) { },
|
|
|
|
- complete: function (res) { },
|
|
|
|
- })
|
|
|
|
|
|
+ // 检查 globalData 是否已有位置信息
|
|
|
|
+ if (app.globalData.latitude && app.globalData.longitude && app.globalData.locationName) {
|
|
|
|
+ // 已有位置信息,直接跳转
|
|
|
|
+ wx.navigateTo({
|
|
|
|
+ url: './search/index',
|
|
|
|
+ success: function (res) { },
|
|
|
|
+ fail: function (res) { },
|
|
|
|
+ complete: function (res) { },
|
|
|
|
+ })
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // // 没有位置信息,显示弹窗
|
|
|
|
+ // wx.showModal({
|
|
|
|
+ // title: '获取你的位置信息',
|
|
|
|
+ // content: '将获取你的具体位置信息,用于推荐你所在定位附近的展览',
|
|
|
|
+ // confirmText: '同意',
|
|
|
|
+ // cancelText: '拒绝',
|
|
|
|
+ // success: (res) => {
|
|
|
|
+ // if (res.confirm) {
|
|
|
|
+ // // 用户点击同意,获取位置信息(使用 getLocationName 的逻辑)
|
|
|
|
+ // wx.getLocation({
|
|
|
|
+ // type: 'wgs84',
|
|
|
|
+ // success: (locationRes) => {
|
|
|
|
+ // // 设置坐标到 globalData 和页面数据
|
|
|
|
+ // app.globalData.latitude = locationRes.latitude;
|
|
|
|
+ // app.globalData.longitude = locationRes.longitude;
|
|
|
|
+ // this.setData({
|
|
|
|
+ // latitude: locationRes.latitude,
|
|
|
|
+ // longitude: locationRes.longitude
|
|
|
|
+ // });
|
|
|
|
+
|
|
|
|
+ // // 使用腾讯地图逆地址解析获取城市名称
|
|
|
|
+ // qqmapsdk.reverseGeocoder({
|
|
|
|
+ // location: {
|
|
|
|
+ // latitude: locationRes.latitude,
|
|
|
|
+ // longitude: locationRes.longitude
|
|
|
|
+ // },
|
|
|
|
+ // success: (geoRes) => {
|
|
|
|
+ // let { city: locationName } = geoRes.result.address_component;
|
|
|
|
+ // locationName = locationName.substring(0, 2);
|
|
|
|
+
|
|
|
|
+ // // 保存到 globalData
|
|
|
|
+ // app.globalData.city = locationName;
|
|
|
|
+ // app.globalData.locationName = locationName;
|
|
|
|
+
|
|
|
|
+ // this.setData({
|
|
|
|
+ // locationName,
|
|
|
|
+ // locationNameDesp: locationName
|
|
|
|
+ // });
|
|
|
|
+
|
|
|
|
+ // // 获取位置成功,跳转到搜索页面
|
|
|
|
+ // wx.navigateTo({
|
|
|
|
+ // url: './search/index',
|
|
|
|
+ // success: function (res) { },
|
|
|
|
+ // fail: function (res) { },
|
|
|
|
+ // complete: function (res) { },
|
|
|
|
+ // })
|
|
|
|
+ // },
|
|
|
|
+ // fail: (geoErr) => {
|
|
|
|
+ // // 逆地址解析失败,使用默认城市(北京),直接跳转
|
|
|
|
+ // app.globalData.city = "北京";
|
|
|
|
+ // app.globalData.locationName = "北京";
|
|
|
|
+ // this.setData({
|
|
|
|
+ // locationName: "北京"
|
|
|
|
+ // });
|
|
|
|
+ // wx.navigateTo({
|
|
|
|
+ // url: './search/index',
|
|
|
|
+ // success: function (res) { },
|
|
|
|
+ // fail: function (res) { },
|
|
|
|
+ // complete: function (res) { },
|
|
|
|
+ // })
|
|
|
|
+ // }
|
|
|
|
+ // });
|
|
|
|
+ // },
|
|
|
|
+ // fail: (locationErr) => {
|
|
|
|
+ // // 获取位置失败,保持默认城市(北京),直接跳转
|
|
|
|
+ // console.log('获取位置失败:', locationErr);
|
|
|
|
+ // app.globalData.city = "北京";
|
|
|
|
+ // app.globalData.locationName = "北京";
|
|
|
|
+ // this.setData({
|
|
|
|
+ // getLocationBtn: true,
|
|
|
|
+ // locationName: "北京"
|
|
|
|
+ // });
|
|
|
|
+ // wx.navigateTo({
|
|
|
|
+ // url: './search/index',
|
|
|
|
+ // success: function (res) { },
|
|
|
|
+ // fail: function (res) { },
|
|
|
|
+ // complete: function (res) { },
|
|
|
|
+ // })
|
|
|
|
+ // }
|
|
|
|
+ // })
|
|
|
|
+ // } else if (res.cancel) {
|
|
|
|
+ // // 用户点击拒绝,保持默认城市(北京),直接跳转
|
|
|
|
+ // app.globalData.city = "北京";
|
|
|
|
+ // app.globalData.locationName = "北京";
|
|
|
|
+ // wx.navigateTo({
|
|
|
|
+ // url: './search/index',
|
|
|
|
+ // success: function (res) { },
|
|
|
|
+ // fail: function (res) { },
|
|
|
|
+ // complete: function (res) { },
|
|
|
|
+ // })
|
|
|
|
+ // }
|
|
|
|
+ // },
|
|
|
|
+ // fail: function (res) {
|
|
|
|
+ // // 弹窗失败,直接跳转
|
|
|
|
+ // wx.navigateTo({
|
|
|
|
+ // url: './search/index',
|
|
|
|
+ // success: function (res) { },
|
|
|
|
+ // fail: function (res) { },
|
|
|
|
+ // complete: function (res) { },
|
|
|
|
+ // })
|
|
|
|
+ // }
|
|
|
|
+ // })
|
|
}
|
|
}
|
|
})
|
|
})
|