12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <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.recommends;
- // this.total = res.data.nears.total
- });
- },
- },
- };
- </script>
|