<template>
  <view class="collect">
    <view class="text">以下是您收藏的商品服务</view>

    <!-- 收藏的服务 -->
    <service v-for="item in 2" :key="item" />
  </view>
</template>

<script>
  import service from '@/components/service'
  import { maintainFavoritePaging } from "@/api/mine.js"
  import { getCurrentLocation } from '@/api/home';

  export default {
    components: {
      service,
    },
    data() {
      return {
        queryParams:{
          size:10,
          type:'MERCHANT',
          region:null,//地区编码
          longitude:null,//经度
          latitude:null,//纬度
        },
        init_list:[]
      };
    },
    onLoad() {
      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(){
        maintainFavoritePaging(this.queryParams).then(res=>{
          console.log('getHomePageApi',res);
        })
      }
    },
  };
</script>

<style lang="scss" scoped>
  .collect {
    height: 100vh;
    background-color: #efefef;

    .text {
      text-align: center;
      padding: 40rpx;
      color: #999;
    }
  }
</style>
