Browse Source

腾讯地图的定位

lisu_V4.3.1
是小王呀\24601 1 year ago
parent
commit
fcf73178f1
  1. 62
      subpages/InspectionReport/pages/InspectionReport/InspectionReport.js
  2. 4
      subpages/InspectionReport/pages/InspectionReport/InspectionReport.wxml
  3. 1
      subpages/InspectionReport/pages/InspectionReport/InspectionReport.wxss
  4. 5
      subpages/safetyinspection/pages/safetyinspection/safetyinspection.wxml
  5. 12
      subpages/safetyinspection/pages/safetyinspection/safetyinspection.wxss

62
subpages/InspectionReport/pages/InspectionReport/InspectionReport.js

@ -1,18 +1,33 @@
// subpages/InspectionReport/pages/InspectionReport/InspectionReport.js // subpages/InspectionReport/pages/InspectionReport/InspectionReport.js
const QQMapWX = require('../../../../utils/qqmap-wx-jssdk')
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
addressContent:'',
fmData: {
gridId: '',
attachmentList:[],//图片
voiceList:[],
latitude:"",
longitude:"",
resiId:"",
happenTime:"",
content:"",//内容
address:"",//地址
},
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad(options) { onLoad(options) {
this.data.qqMapWX = new QQMapWX({
key: 'CMJBZ-4DECI-JXGGN-5B4WU-QLV2H-B5BEJ'
})
this.reverseLocation()
}, },
/** /**
@ -26,7 +41,7 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow() { onShow() {
this.reverseLocation
}, },
/** /**
@ -60,7 +75,44 @@ Page({
/** /**
* 用户点击右上角分享 * 用户点击右上角分享
*/ */
onShareAppMessage() { onShareAppMessage() {},
//跳转地图选点
toughGetLocation() {
// this.getLocation(false);
wx.chooseLocation({
success: res => {
console.log('resadddres', res)
const {
fmData
} = this.data;
this.setData({
fmData: {
...fmData,
address: res.address,
longitude: res.longitude,
latitude: res.latitude
},
addressContent: res.address
});
console.log(this.data.fmData);
} }
}) })
},
reverseLocation() {
const _this = this
this.data.qqMapWX.reverseGeocoder({
success(res) {
console.log(res);
_this.setData({
addressContent:res.result.address,
'fmData.address': res.result.address,
'fmData.longitude':res.result.location.lng,
'fmData.latitude':res.result.location.lat,
})
},
fail(err) {
console.debug(err)
}
})
},
})

4
subpages/InspectionReport/pages/InspectionReport/InspectionReport.wxml

@ -3,11 +3,11 @@
<view class="header_left"> <view class="header_left">
<image src="../../../../images/location.png" class="header_img"></image> <image src="../../../../images/location.png" class="header_img"></image>
<view class="inside"> <view class="inside">
<text class="text1">定位的信息</text> <text class="text1">{{addressContent}}</text>
<text class="text2">如定位不在事发地,请重新选择定位</text> <text class="text2">如定位不在事发地,请重新选择定位</text>
</view> </view>
</view> </view>
<view class="header_right"> <view class="header_right" bind:tap="toughGetLocation">
<text class="text3">重新定位</text> <text class="text3">重新定位</text>
</view> </view>
</view> </view>

1
subpages/InspectionReport/pages/InspectionReport/InspectionReport.wxss

@ -162,6 +162,7 @@ page {
flex-direction: column; flex-direction: column;
width: 650rpx; width: 650rpx;
margin-left: 40rpx; margin-left: 40rpx;
height: 90rpx;
} }
.add{ .add{
display: flex; display: flex;

5
subpages/safetyinspection/pages/safetyinspection/safetyinspection.wxml

@ -10,7 +10,8 @@
<image src="../../../../images/right.png" class="prosecutors_img"></image> <image src="../../../../images/right.png" class="prosecutors_img"></image>
</view> </view>
</view> </view>
<view class="prosecutors_top"> <view class="hidden">
<view class="hidden_top">
<view class="prosecutors"> <view class="prosecutors">
<view> <view>
<text class="prosecutors_req">*</text> <text class="prosecutors_req">*</text>
@ -34,6 +35,8 @@
<text class="text3">在添加一条</text> <text class="text3">在添加一条</text>
</view> </view>
</view> </view>
</view>
<view class="prosecutors"> <view class="prosecutors">
<view> <view>
<text class="prosecutors_req">*</text> <text class="prosecutors_req">*</text>

12
subpages/safetyinspection/pages/safetyinspection/safetyinspection.wxss

@ -222,3 +222,15 @@ page {
line-height: 48rpx; line-height: 48rpx;
margin-bottom: 20rpx; margin-bottom: 20rpx;
} }
.hidden{
display: flex;
flex-direction: column;
}
.hidden_top{
display: flex;
flex-direction:row;
align-items: center;
margin: 20rpx;
justify-content: space-between;
height: 50rpx;
}
Loading…
Cancel
Save