107 lines
2.9 KiB
Vue
107 lines
2.9 KiB
Vue
|
|
<template>
|
||
|
|
<view>
|
||
|
|
<u-navbar bgColor="#fff" title="商圈" :placeholder="true" leftIconSize="0"></u-navbar>
|
||
|
|
<shop :list="storeEnclosureList"></shop>
|
||
|
|
<!-- <tabbar></tabbar> -->
|
||
|
|
</view>
|
||
|
|
</template>
|
||
|
|
|
||
|
|
<script>
|
||
|
|
import url from "@/common/http/url.js";
|
||
|
|
import shop from "./modules/shop.vue"
|
||
|
|
import publics from "@/common/utils/public.js"
|
||
|
|
import tabbar from "@/components/tabbar.vue";
|
||
|
|
import { checkOpenGPSService } from "@/common/utils/index.js";
|
||
|
|
import { mapState, mapMutations } from 'vuex';
|
||
|
|
export default {
|
||
|
|
components: { tabbar, shop },
|
||
|
|
data () {
|
||
|
|
return {
|
||
|
|
storeEnclosureList: [],
|
||
|
|
wxBtnHeight: 20
|
||
|
|
};
|
||
|
|
},
|
||
|
|
computed: {
|
||
|
|
...mapState(["locationObj"])
|
||
|
|
},
|
||
|
|
mounted () {
|
||
|
|
|
||
|
|
let _this = this
|
||
|
|
// #ifdef APP-PLUS
|
||
|
|
//是否开启位置权限
|
||
|
|
if (this.locationObj) this.getStoreEnclosureList();
|
||
|
|
else {
|
||
|
|
checkOpenGPSService(result => {
|
||
|
|
_this.isOpenPosition = result
|
||
|
|
if (result) {
|
||
|
|
//设置地址
|
||
|
|
_this.getMyLocation();
|
||
|
|
} else _this.getMyLocation();
|
||
|
|
})
|
||
|
|
}
|
||
|
|
// #endif
|
||
|
|
|
||
|
|
// #ifndef APP-PLUS
|
||
|
|
this.getMyLocation()
|
||
|
|
// #endif
|
||
|
|
// this.getStoreEnclosureList()
|
||
|
|
},
|
||
|
|
|
||
|
|
methods: {
|
||
|
|
...mapMutations(["setLocation"]),
|
||
|
|
// 下拉刷新
|
||
|
|
pullDownRefresh () {
|
||
|
|
// 获取轮播图、弹框
|
||
|
|
this.storeEnclosureList = []
|
||
|
|
this.getStoreEnclosureList();
|
||
|
|
},
|
||
|
|
getMyLocation () {
|
||
|
|
let _this = this;
|
||
|
|
uni.showLoading({
|
||
|
|
mask: true,
|
||
|
|
title: '定位中'
|
||
|
|
})
|
||
|
|
uni.getLocation({
|
||
|
|
type: 'gcj02',
|
||
|
|
geocode: true,
|
||
|
|
success: function (res) {
|
||
|
|
console.log("获取当前位置成功。。。。", res)
|
||
|
|
//设置地址
|
||
|
|
publics.setMyaddressLngLat(JSON.stringify(res));
|
||
|
|
_this.myAddressData = res;
|
||
|
|
_this.setLocation(res)
|
||
|
|
//设置当前位置名称
|
||
|
|
if (res.address) {
|
||
|
|
_this.addressName = res.address.district + (res.address.poiName || res.address.street);
|
||
|
|
}
|
||
|
|
|
||
|
|
}, fail: function (err) { // 定位权限没开启
|
||
|
|
console.log('getLocation.error.', err)
|
||
|
|
// _this.openMap()
|
||
|
|
}, complete: function (info) {
|
||
|
|
console.log('info', info)
|
||
|
|
_this.getStoreEnclosureList()
|
||
|
|
}
|
||
|
|
});
|
||
|
|
},
|
||
|
|
// 获取附近的店铺
|
||
|
|
async getStoreEnclosureList () {
|
||
|
|
let params = {
|
||
|
|
pageNum: this.storeEnclosureList.length,
|
||
|
|
lng: this.locationObj ? this.locationObj.longitude : 115, //经度
|
||
|
|
lat: this.locationObj ? this.locationObj.latitude : 34 //纬度
|
||
|
|
};
|
||
|
|
console.log('商圈请求参数params=====', params)
|
||
|
|
let res = await this.$http('GET', url.store.getNearbyStores, params);
|
||
|
|
console.log('res.data', res.data)
|
||
|
|
uni.hideLoading()
|
||
|
|
this.storeEnclosureList = this.storeEnclosureList.concat(res.data);
|
||
|
|
this.nearbyLoading = res.data.length < 12 ? 'nomore' : 'more'
|
||
|
|
uni.stopPullDownRefresh();
|
||
|
|
},
|
||
|
|
}
|
||
|
|
}
|
||
|
|
</script>
|
||
|
|
|
||
|
|
<style lang="scss"></style>
|