邓洁:地理位置

This commit is contained in:
邓洁
2023-11-08 11:22:19 +08:00
parent 0d9a94e350
commit 52fe2a05fc
5 changed files with 62 additions and 30 deletions

View File

@@ -35,25 +35,37 @@
},
data() {
return {
position: '定位1'
position: '定位12',
location: ''
};
},
options: {
styleIsolation: 'shared', // 解除样式隔离
},
created() {
console.log('createsd');
this.open()
console.log('location', this.location);
},
watch: {
location(val) {
console.log('foo变化了变化后的值是', val)
// 具体操作=>doSomething
}
},
onShow() {
console.log('onshow');
// const location = this.open()
// console.log('location', this.location);
},
methods: {
getLocation1() {
let qqmapsdk = new QQMapWX({
key: 'ZRKBZ-Q7FWL-GVZPK-MCRBU-4XFB5-ATBDB'
});
uni.getLocation({
uni.getFuzzyLocation({
type: 'wgs84',
// geocode: true, // 返回城市信息
// enableHighAccuracy: false, // 开启高精度模式
success: function(res) {
success(res) {
console.log('res.latitude', res.latitude);
console.log('res.longitude', res.longitude);
qqmapsdk.reverseGeocoder({
@@ -65,24 +77,24 @@
console.log("解析地址成功", res);
console.log(re.result.ad_info.city, '成都市==');
console.log(re.result.ad_info.district, '武侯区==');
this.position = re.result.ad_info.city
console.log('thisposition', this.position);
this.location = re.result.ad_info
console.log('success', this.location);
},
fail: (re) => {
console.log(re, '失败信息');
}
})
},
fail: () => {
console.log("获取经纬度失败");
fail(err) {
console.log("获取经纬度失败", err);
},
});
},
//提示用户开启定位服务
open() {
var that=this
var that = this
uni.authorize({
scope: 'scope.userLocation',
scope: 'scope.userFuzzyLocation',
success: function() {
console.log('授权成功');
that.getLocation1()

View File

@@ -59,9 +59,12 @@
// 获取当前的地理位置、速度 配置
"scope.userLocation": {
"desc": "你的位置信息将用于小程序位置接口的效果展示"
},
"scope.userFuzzyLocation": {
"desc": "你的位置信息将用于小程序位置的效果展示"
}
}
},
"requiredPrivateInfos": ["choosePoi", "chooseAddress", "getFuzzyLocation"]
},
"mp-alipay": {
"usingComponents": true

View File

@@ -97,17 +97,16 @@
}
}
,{
"path" : "pages/Partnerships/Partnerships",
"style" :
{
"navigationBarTitleText": "成功合伙人",
"enablePullDownRefresh": false
}
}
],
, {
"path": "pages/Partnerships/Partnerships",
"style": {
"navigationBarTitleText": "成功合伙人",
"enablePullDownRefresh": false
}
}
],
"tabBar": {
"color": "#CCCCCC",
"borderStyle": "white",
@@ -146,6 +145,11 @@
"navigationBarBackgroundColor": "#F8F8F8",
"backgroundColor": "#F8F8F8"
},
"permission": {
"scope.userFuzzyLocation": {
"desc": "你的位置信息将用于小程序位置的效果展示"
}
},
"uniIdRouter": {},
"condition": { //模式配置,仅开发期间生效
"current": 0, //当前激活的模式(list 的索引项)

View File

@@ -1,6 +1,6 @@
<template>
<view class="nav-card">
<u-grid :col="4" customStyle="height: 334rpx;align-content: normal" >
<u-grid :col="4" customStyle="height: 334rpx;align-content: normal">
<u-grid-item v-for="(item, index) in navItems" :key="item.icon" @click="handleItemClick(index)">
<u-icon :name="item.icon" :size="46"></u-icon>
<view class="grid-text">{{ item.text }}</view>
@@ -54,6 +54,11 @@
// 在这里处理点击事件,并使用下标值
console.log(`项目 ${index} 被点击了`);
// 或者执行其他需要的操作
if (index == 5) {
uni.navigateTo({
url: '/pages/index/map/map'
})
}
}
}
};

View File

@@ -12,7 +12,7 @@
:longitude="lng"></map>
</view>
<view class="down-shop">
<ShowShopListItem :shopInfo="shopList"></ShowShopListItem>
<ShowShopListItem :shopInfo="shopList" :is-adshow="true" :show-style="0"></ShowShopListItem>
</view>
</view>
</template>
@@ -45,11 +45,19 @@
}
],
shopList: {
shopid: 1,
imageUrl: 'https://alifei01.cfp.cn/creative/vcg/800/new/VCG41175510742.jpg',
title: '琴行铺面转让',
promotionNum: 23,
price: 5000,
date: '2023-11-02'
price: 6000,
date: '2023-11-02',
pos: '锦江区',
exactPos: '锦江区-汇源南路366号',
sqr: 100,
zrfText: "转让费20万",
category: '餐饮美食',
uname: "张先生",
phoneNum: 13348946108,
}
}
},
@@ -119,8 +127,8 @@
position: absolute;
z-index: 1;
bottom: 60rpx;
left: 10%;
transform: translateX(-10%);
left: 50%;
transform: translateX(-50%);
.list-border {
margin: 0;