Browse Source

首页 定位

master
邓宏 2 years ago
parent
commit
72adc4b49e
  1. 58
      pages/home/index.vue

58
pages/home/index.vue

@ -3,6 +3,23 @@
background:#F6F6F6;
padding-bottom:20rpx;
min-height:100%;
&>.top{
position:absolute;
top:0;
left:0;
width:100%;
z-index: 20;
padding:calc(var(--status-bar-height) + 10rpx) 30rpx 0;
color:#fff;
font-size:24rpx;
display:flex;
justify-content: space-between;
background:rgba(0,0,0,0.1);
.plant-dingweixiao:before{
font-size:20rpx;
margin-right:5rpx;
}
}
&>.head{
padding:30rpx;
width:calc(100% - 60rpx);
@ -225,6 +242,9 @@
</style>
<template>
<view class="container">
<view class="top">
<text class="plant-dingweixiao" @click="!adderss.isOk && refreshPosition()">{{adderss.isOk?adderss.city:"点击重新获取定位"}}</text> <text class="date">{{new Date().format("M月 d日")}}</text>
</view>
<swiper autoplay :interval="5*1000" v-if="headImgs.length>0" class="headImg" circular>
<swiper-item v-for="(v,k) in headImgs" :key="k">
<u-image :src="`${host}/${v}`" width="100%" height="100%" mode="aspectFill">
@ -322,6 +342,7 @@ import request,{host} from '@/common/request'
baseInfo:{},
baseIndex:"",
stockList:[],
adderss:{},
}
},
computed:{
@ -354,6 +375,20 @@ import request,{host} from '@/common/request'
}
this.$provise.on("updateMassif", this.getMassif)
this.$provise.on("updateStock", this.getStock)
uni.getLocation({
type:"gcj02",
geocode:true,
isHighAccuracy:true,
success:res=>{
this.adderss={
...res.address,
longitude:res.longitude,
latitude:res.latitude,
isOk:true
}
}
})
},
methods: {
async getHeadImg(){
@ -446,6 +481,29 @@ import request,{host} from '@/common/request'
}
}
},
//
refreshPosition(){
uni.getLocation({
type:"gcj02",
geocode:true,
isHighAccuracy:true,
success:res=>{
this.adderss={
...res.address,
longitude:res.longitude,
latitude:res.latitude,
isOk:true
}
},
fail(){
uni.showModal({
title:"提示",
content:"获取定位失败!",
showCancel:false,
})
},
})
},
},
onUnload(){
this.$provise.off("updateMassif")

Loading…
Cancel
Save