1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <template>
- <view class="container">
- <serviceItem :item='init_list' :skipType='0'></serviceItem>
- <u-empty v-if="init_list.length == 0" mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png" > </u-empty>
- </view>
- </template>
- <script>
- import { getHomePageApi,getCurrentLocation } from '@/api/home';
- import serviceItem from '@/components/service/index.vue';
- export default{
- data(){
- return{
- queryParams:{
- region:null,//地区编码
- longitude:null,//经度
- latitude:null,//纬度
- },
- init_list:[]
- }
- },
- components:{
- serviceItem
- },
- mounted() {
- this.handlerInitLocation()
- },
- methods:{
- // 获取当前经纬度
- handlerInitLocation(){
- uni.getLocation({
- type: 'gcj02',
- success: res => {
- this.queryParams.longitude = res.longitude;
- this.queryParams.latitude = res.latitude;
- let point = {
- latitude: res.latitude,
- longitude: res.longitude
- }
- getCurrentLocation(point).then(rc=>{
- this.queryParams.region = rc.data.id
- this.handlerInitList()
- })
- },
- fail: (rs) => {
- uni.showToast({
- title:rs,
- icon:'none'
- })
- }
- });
- },
- // 初始化列表信息
- handlerInitList(){
- getHomePageApi(this.queryParams).then(res=>{
- this.init_list = res.data.nears
- this.total = res.data.nears.total
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .container{
- }
- </style>
|