提交
This commit is contained in:
@@ -102,7 +102,9 @@ export default {
|
||||
{ key: 'latest', label: '最新发布' },
|
||||
{ key: 'near', label: '距离最近' }
|
||||
],
|
||||
currentTab: 'latest',
|
||||
latitude:'',
|
||||
longitude:'',
|
||||
currentTab:'latest',
|
||||
flist: [],
|
||||
slist: [],
|
||||
selfChecked: false,
|
||||
@@ -122,6 +124,11 @@ export default {
|
||||
},
|
||||
onShow() {
|
||||
this.loadCategoryList();
|
||||
this.getFuzzy().then(res => {
|
||||
this.latitude = res.latitude
|
||||
this.longitude = res.longitude
|
||||
console.log(res);
|
||||
}).catch(err => console.error(err));
|
||||
// this.syncTabbar()
|
||||
// // 从详情页返回后,重新拉取当前分类数据
|
||||
// if (this.categoriesLoaded) {
|
||||
@@ -129,6 +136,29 @@ export default {
|
||||
// }
|
||||
},
|
||||
methods: {
|
||||
getFuzzy() {
|
||||
return new Promise((resolve, reject) => {
|
||||
wx.getSetting({
|
||||
success: (st) => {
|
||||
const ok = st.authSetting['scope.userFuzzyLocation'];
|
||||
const run = () => wx.getFuzzyLocation({
|
||||
type: 'wgs84',
|
||||
success: resolve,
|
||||
fail: reject
|
||||
});
|
||||
|
||||
if (ok) return run();
|
||||
|
||||
wx.authorize({
|
||||
scope: 'scope.userFuzzyLocation',
|
||||
success: run,
|
||||
fail: () => wx.openSetting({ success: () => reject(new Error('未授权')) })
|
||||
});
|
||||
},
|
||||
fail: reject
|
||||
});
|
||||
});
|
||||
},
|
||||
goprivacy(){
|
||||
uni.navigateTo({
|
||||
url: '/pages/login/agreement',// 替换为你要跳转的页面路径
|
||||
@@ -215,6 +245,7 @@ export default {
|
||||
|
||||
// 根据分类id加载分类下的内容
|
||||
loadCategoryData(categoryId, isLoadMore = false) {
|
||||
const collectUrl = this.currentTab=='latest' ? 'common/post/list' : 'common/post/nearby'
|
||||
// 防止重复请求:如果是加载更多,需要检查所有加载状态
|
||||
if (isLoadMore) {
|
||||
if (this.loadingMore || this.loading || this.refreshing) {
|
||||
@@ -236,15 +267,23 @@ export default {
|
||||
this.hasMore = true;
|
||||
this.slist = []; // 清空之前的数据
|
||||
}
|
||||
|
||||
var that = this;
|
||||
const params = {
|
||||
current:this.page,
|
||||
size:10,
|
||||
status:1,
|
||||
category_id:categoryId
|
||||
};
|
||||
// 添加排序参数(如果后端支持)
|
||||
if(this.currentTab=='near'){
|
||||
params.lng = this.longitude;
|
||||
params.lat = this.latitude;
|
||||
} else {
|
||||
}
|
||||
request({
|
||||
url:'common/post/list',
|
||||
url:collectUrl,
|
||||
method:'GET',
|
||||
data:{
|
||||
category_id:categoryId,
|
||||
current: this.page,
|
||||
size: this.pageSize
|
||||
}
|
||||
data:params
|
||||
}).then(res => {
|
||||
this.loading = false;
|
||||
this.loadingMore = false;
|
||||
|
||||
Reference in New Issue
Block a user