依赖文件
This commit is contained in:
+45
-21
@@ -3,30 +3,32 @@
|
||||
<uni-nav-bar leftText=" " :fixed="true" :border="false" leftIcon="back" @clickLeft="leftClick" color="#000000" backgroundColor="#fff" :statusBar="true" :title="$t('navbar.customerinfo')"></uni-nav-bar>
|
||||
<view class="content">
|
||||
<view class="cell">
|
||||
<view>{{$t('customer.CustomerChannel')}}</view>
|
||||
<view class="item">{{$t('customer.CustomerChannel')}}</view>
|
||||
<view class="right select" @click="showchannel = true">
|
||||
<input :placeholder="$t('customer.CustomerChannelinput')" disabled v-model="channel_name" />
|
||||
<view class="" :class="['content2', { placeholder: !channel_name }]">{{channel_name || $t('customer.CustomerChannelinput')}}</view>
|
||||
<!-- <input :placeholder="$t('customer.CustomerChannelinput')" disabled v-model="channel_name" /> -->
|
||||
<u-icon class="arrowright" name="arrow-right" size="18" color="#747474"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
<u-line></u-line>
|
||||
<view class="cell">
|
||||
<view>{{$t('customer.Medal')}}</view>
|
||||
<view class="item">{{$t('customer.Medal')}}</view>
|
||||
<view class="right select" @click="showmagnitude = true">
|
||||
<input :placeholder="$t('customer.Medalinput')" disabled v-model="magnitude_name" />
|
||||
<view class="" :class="['content2', { placeholder: !magnitude_name }]">{{magnitude_name || $t('customer.Medalinput')}}</view>
|
||||
<!-- <input :placeholder="$t('customer.Medalinput')" disabled v-model="magnitude_name" /> -->
|
||||
<u-icon class="arrowright" name="arrow-right" size="18" color="#747474"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
<u-line></u-line>
|
||||
<view class="cell">
|
||||
<view>{{$t('customer.CustomerName')}} <text class="red">*</text></view>
|
||||
<view class="item">{{$t('customer.CustomerName')}} <text class="red">*</text></view>
|
||||
<view class="right">
|
||||
<input :placeholder="$t('customer.CustomerNameinput')" v-model="form.contacts" />
|
||||
</view>
|
||||
</view>
|
||||
<u-line></u-line>
|
||||
<view class="cell">
|
||||
<view>{{$t('gender')}}</view>
|
||||
<view class="item">{{$t('gender')}}</view>
|
||||
<view class="right">
|
||||
<u-radio-group v-model="form.sex">
|
||||
<u-radio name="0">{{$t('gender0')}}</u-radio>
|
||||
@@ -37,54 +39,58 @@
|
||||
</view>
|
||||
<u-line></u-line>
|
||||
<view class="cell">
|
||||
<view>{{$t('mine.lxcall')}} <text class="red">*</text></view>
|
||||
<view class="item">{{$t('mine.lxcall')}} <text class="red">*</text></view>
|
||||
<view class="right">
|
||||
<input :placeholder="$t('mine.lxcallinputhd')" v-model="form.phone" />
|
||||
</view>
|
||||
</view>
|
||||
<u-line></u-line>
|
||||
<view class="cell">
|
||||
<view>Email</view>
|
||||
<view class="item">Email</view>
|
||||
<view class="right">
|
||||
<input :placeholder="$t('customer.Emailinput')" v-model="form.email" />
|
||||
</view>
|
||||
</view>
|
||||
<u-line></u-line>
|
||||
<view class="cell">
|
||||
<view>WhatsApp</view>
|
||||
<view class="item">WhatsApp</view>
|
||||
<view class="right">
|
||||
<input :placeholder="$t('customer.WhatsAppinput')" v-model="form.WhatsApp" />
|
||||
</view>
|
||||
</view>
|
||||
<u-line></u-line>
|
||||
<view class="cell">
|
||||
<view>{{$t('customer.Customerph')}}</view>
|
||||
<view class="item">{{$t('customer.Customerph')}}</view>
|
||||
<view class="right select" @click="showcartype = true">
|
||||
<input :placeholder="$t('customer.Customerphinput')" disabled v-model="car_type_name" />
|
||||
<view class="" :class="['content2', { placeholder: !car_type_name }]">{{car_type_name || $t('customer.Customerphinput')}}</view>
|
||||
<!-- <input :placeholder="$t('customer.Customerphinput')" disabled v-model="car_type_name" /> -->
|
||||
<u-icon class="arrowright" name="arrow-right" size="18" color="#747474"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
<u-line></u-line>
|
||||
<view class="cell">
|
||||
<view>{{$t('customer.Cstomerfj')}}</view>
|
||||
<view class="item">{{$t('customer.Cstomerfj')}}</view>
|
||||
<view class="right select" @click="showgrade = true">
|
||||
<input :placeholder="$t('customer.Cstomerfjinput')" disabled v-model="grade_name" />
|
||||
<view class="" :class="['content2', { placeholder: !grade_name }]">{{grade_name || $t('customer.Cstomerfjinput')}}</view>
|
||||
<!-- <input :placeholder="$t('customer.Cstomerfjinput')" disabled v-model="grade_name" /> -->
|
||||
<u-icon class="arrowright" name="arrow-right" size="18" color="#747474"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
<u-line></u-line>
|
||||
<view class="cell">
|
||||
<view>{{$t('customer.Country')}}</view>
|
||||
<view class="item">{{$t('customer.Country')}}</view>
|
||||
<view class="right select" @click="showarea = true">
|
||||
<input :placeholder="$t('customer.Countryinput')" disabled v-model="country_name" />
|
||||
<view class="" :class="['content2', { placeholder: !country_name }]">{{country_name || $t('customer.Countryinput')}}</view>
|
||||
<!-- <input :placeholder="$t('customer.Countryinput')" disabled v-model="country_name" /> -->
|
||||
<u-icon class="arrowright" name="arrow-right" size="18" color="#747474"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
<u-line></u-line>
|
||||
<view class="cell">
|
||||
<view>{{$t('customer.Company')}}</view>
|
||||
<view class="item">{{$t('customer.Company')}}</view>
|
||||
<view class="right select" @click="gomap">
|
||||
<input :placeholder="$t('customer.Companyinput')" type="text" disabled v-model="form.address"/>
|
||||
<view class="" :class="['content2', { placeholder: !form.address }]">{{form.address || $t('customer.Companyinput')}}</view>
|
||||
<!-- <input :placeholder="$t('customer.Companyinput')" type="text" disabled v-model="form.address"/> -->
|
||||
<u-icon class="arrowright" name="arrow-right" size="18" color="#747474"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
@@ -97,7 +103,7 @@
|
||||
</view> -->
|
||||
<u-line></u-line>
|
||||
<view class="cell1">
|
||||
<view>{{$t('customer.Remarks')}}</view>
|
||||
<view class="item">{{$t('customer.Remarks')}}</view>
|
||||
<view class="">
|
||||
<textarea auto-height v-model="form.describe" :placeholder="$t('customer.Remarksinputhd')"/>
|
||||
</view>
|
||||
@@ -194,9 +200,18 @@
|
||||
uni.navigateBack({})
|
||||
},
|
||||
gomap(){
|
||||
uni.navigateTo({
|
||||
url: '/pages/customer/map'
|
||||
});
|
||||
// #ifdef H5
|
||||
uni.navigateTo({
|
||||
url: '/pages/customer/maph5'
|
||||
});
|
||||
// #endif
|
||||
|
||||
// #ifdef APP-PLUS
|
||||
uni.navigateTo({
|
||||
url: '/pages/customer/map'
|
||||
});
|
||||
// #endif
|
||||
|
||||
},
|
||||
mapclose(){
|
||||
this.showmap = false
|
||||
@@ -333,6 +348,9 @@
|
||||
.u-m-lr-10{
|
||||
margin: 0px 10px;
|
||||
}
|
||||
.placeholder {
|
||||
color: #999; /* 占位符颜色 */
|
||||
}
|
||||
textarea {
|
||||
min-height: 200rpx;// 设置默认高度 ,解决设置自适应高度之后高度无效问题
|
||||
margin-top: 15px;
|
||||
@@ -360,6 +378,9 @@
|
||||
font-weight: 500;
|
||||
font-size: 32rpx;
|
||||
color: #666666;
|
||||
.item{
|
||||
width: 90px;
|
||||
}
|
||||
}
|
||||
.arrowright{
|
||||
margin-right: -15px;
|
||||
@@ -370,6 +391,9 @@
|
||||
align-items: center;
|
||||
font-weight: 500;
|
||||
color: #666666;
|
||||
.item{
|
||||
width: 100px;
|
||||
}
|
||||
}
|
||||
.right{
|
||||
text-align: right;
|
||||
|
||||
+33
-18
@@ -3,30 +3,32 @@
|
||||
<uni-nav-bar leftText=" " :fixed="true" :border="false" leftIcon="back" @clickLeft="leftClick" color="#000000" backgroundColor="#fff" :statusBar="true" :title="$t('navbar.customerinfo')"></uni-nav-bar>
|
||||
<view class="content">
|
||||
<view class="cell">
|
||||
<view>{{$t('customer.CustomerChannel')}}</view>
|
||||
<view class="item">{{$t('customer.CustomerChannel')}}</view>
|
||||
<view class="right select" @click="showchannel = true">
|
||||
<input :placeholder="$t('customer.CustomerChannelinput')" disabled v-model="channel_name" />
|
||||
<!-- <input :placeholder="$t('customer.CustomerChannelinput')" disabled v-model="channel_name" /> -->
|
||||
<view class="" :class="['content2', { placeholder: !channel_name }]">{{channel_name || $t('customer.CustomerChannelinput')}}</view>
|
||||
<u-icon class="arrowright" name="arrow-right" size="18" color="#747474"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
<u-line></u-line>
|
||||
<view class="cell">
|
||||
<view>{{$t('customer.Medal')}}</view>
|
||||
<view class="item">{{$t('customer.Medal')}}</view>
|
||||
<view class="right select" @click="showmagnitude = true">
|
||||
<input :placeholder="$t('customer.Medalinput')" disabled v-model="magnitude_name" />
|
||||
<!-- <input :placeholder="$t('customer.Medalinput')" disabled v-model="magnitude_name" /> -->
|
||||
<view class="" :class="['content2', { placeholder: !magnitude_name }]">{{magnitude_name || $t('customer.Medalinput')}}</view>
|
||||
<u-icon class="arrowright" name="arrow-right" size="18" color="#747474"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
<u-line></u-line>
|
||||
<view class="cell">
|
||||
<view>{{$t('customer.CustomerName')}} <text class="red">*</text></view>
|
||||
<view class="item">{{$t('customer.CustomerName')}} <text class="red">*</text></view>
|
||||
<view class="right">
|
||||
<input :placeholder="$t('customer.CustomerNameinput')" v-model="form.contacts" />
|
||||
</view>
|
||||
</view>
|
||||
<u-line></u-line>
|
||||
<view class="cell">
|
||||
<view>{{$t('gender')}}</view>
|
||||
<view class="item">{{$t('gender')}}</view>
|
||||
<view class="right">
|
||||
<u-radio-group v-model="form.sex">
|
||||
<u-radio :name="Number(0)">{{$t('gender0')}}</u-radio>
|
||||
@@ -37,60 +39,64 @@
|
||||
</view>
|
||||
<u-line></u-line>
|
||||
<view class="cell">
|
||||
<view>{{$t('customer.lxcall')}} <text class="red">*</text></view>
|
||||
<view class="item">{{$t('mine.lxcall')}} <text class="red">*</text></view>
|
||||
<view class="right">
|
||||
<input :placeholder="$t('mine.lxcallinputhd')" v-model="form.phone" />
|
||||
</view>
|
||||
</view>
|
||||
<u-line></u-line>
|
||||
<view class="cell">
|
||||
<view>Email</view>
|
||||
<view class="item">Email</view>
|
||||
<view class="right">
|
||||
<input :placeholder="$t('customer.Emailinput')" v-model="form.email" />
|
||||
</view>
|
||||
</view>
|
||||
<u-line></u-line>
|
||||
<view class="cell">
|
||||
<view>WhatsApp</view>
|
||||
<view class="item">WhatsApp</view>
|
||||
<view class="right">
|
||||
<input :placeholder="$t('customer.WhatsAppinput')" v-model="form.WhatsApp" />
|
||||
</view>
|
||||
</view>
|
||||
<u-line></u-line>
|
||||
<view class="cell">
|
||||
<view>{{$t('customer.Customerph')}}</view>
|
||||
<view class="item">{{$t('customer.Customerph')}}</view>
|
||||
<view class="right select" @click="showcartype = true">
|
||||
<input :placeholder="$t('customer.Customerphinput')" disabled v-model="car_type_name" />
|
||||
<!-- <input :placeholder="$t('customer.Customerphinput')" disabled v-model="car_type_name" /> -->
|
||||
<view class="" :class="['content2', { placeholder: !car_type_name }]">{{car_type_name || $t('customer.Customerphinput')}}</view>
|
||||
<u-icon class="arrowright" name="arrow-right" size="18" color="#747474"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
<u-line></u-line>
|
||||
<view class="cell">
|
||||
<view>{{$t('customer.Cstomerfj')}}</view>
|
||||
<view class="item">{{$t('customer.Cstomerfj')}}</view>
|
||||
<view class="right select" @click="showgrade = true">
|
||||
<input :placeholder="$t('customer.Cstomerfjinput')" disabled v-model="grade_name" />
|
||||
<!-- <input :placeholder="$t('customer.Cstomerfjinput')" disabled v-model="grade_name" /> -->
|
||||
<view class="" :class="['content2', { placeholder: !grade_name }]">{{grade_name || $t('customer.Cstomerfjinput')}}</view>
|
||||
<u-icon class="arrowright" name="arrow-right" size="18" color="#747474"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
<u-line></u-line>
|
||||
<view class="cell">
|
||||
<view>{{$t('customer.Country')}}</view>
|
||||
<view class="item">{{$t('customer.Country')}}</view>
|
||||
<view class="right select" @click="showarea = true">
|
||||
<input :placeholder="$t('customer.Countryinput')" disabled v-model="country_name" />
|
||||
<!-- <input :placeholder="$t('customer.Countryinput')" disabled v-model="country_name" /> -->
|
||||
<view class="" :class="['content2', { placeholder: !country_name }]">{{country_name || $t('customer.Countryinput')}}</view>
|
||||
<u-icon class="arrowright" name="arrow-right" size="18" color="#747474"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
<u-line></u-line>
|
||||
<view class="cell">
|
||||
<view>{{$t('customer.Company')}}</view>
|
||||
<view class="item">{{$t('customer.Company')}}</view>
|
||||
<view class="right select" @click="gomap">
|
||||
<input :placeholder="$t('customer.Companyinput')" type="text" disabled v-model="form.address"/>
|
||||
<!-- <input :placeholder="$t('customer.Companyinput')" type="text" disabled v-model="form.address"/> -->
|
||||
<view class="" :class="['content2', { placeholder: !address }]">{{address || $t('customer.Companyinput')}}</view>
|
||||
<u-icon class="arrowright" name="arrow-right" size="18" color="#747474"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
<u-line></u-line>
|
||||
<view class="cell1">
|
||||
<view>{{$t('customer.Remarks')}}</view>
|
||||
<view class="item">{{$t('customer.Remarks')}}</view>
|
||||
<view class="">
|
||||
<textarea auto-height v-model="form.describe" :placeholder="$t('customer.Remarksinputhd')"/>
|
||||
</view>
|
||||
@@ -433,6 +439,9 @@
|
||||
.u-m-lr-10{
|
||||
margin: 0px 10px;
|
||||
}
|
||||
.placeholder {
|
||||
color: #999; /* 占位符颜色 */
|
||||
}
|
||||
textarea {
|
||||
min-height: 200rpx;// 设置默认高度 ,解决设置自适应高度之后高度无效问题
|
||||
margin-top: 15px;
|
||||
@@ -461,6 +470,9 @@
|
||||
padding: 18px 20px;
|
||||
align-items: center;
|
||||
font-weight: 500;
|
||||
.item{
|
||||
width: 90px;
|
||||
}
|
||||
}
|
||||
.arrowright{
|
||||
margin-right: -15px;
|
||||
@@ -470,6 +482,9 @@
|
||||
padding: 18px 20px;
|
||||
align-items: center;
|
||||
font-weight: 500;
|
||||
.item{
|
||||
width: 100px;
|
||||
}
|
||||
}
|
||||
.right{
|
||||
text-align: right;
|
||||
|
||||
@@ -3,19 +3,21 @@
|
||||
<uni-nav-bar leftText=" " :fixed="true" :border="false" leftIcon="back" @clickLeft="leftClick" color="#000000" backgroundColor="#fff" :statusBar="true" :title="$t('navbar.addfollowup')"></uni-nav-bar>
|
||||
<view class="content">
|
||||
<view class="cell">
|
||||
<view>{{$t('customer.followtype')}}</view>
|
||||
<view class="item">{{$t('customer.followtype')}}</view>
|
||||
<view class="right">
|
||||
<u-radio-group v-model="form.type">
|
||||
<u-radio name="1">{{$t('customer.Online')}}</u-radio>
|
||||
<u-radio name="1" class="u-m-lr-10">{{$t('customer.Online')}}</u-radio>
|
||||
<u-radio name="0">{{$t('customer.Visit')}}</u-radio>
|
||||
</u-radio-group>
|
||||
</view>
|
||||
</view>
|
||||
<u-line></u-line>
|
||||
<view class="cell">
|
||||
<view>{{$t('customer.followtime')}} </view>
|
||||
<view class="right" @click="show = true">
|
||||
<input :placeholder="$t('customer.followtime')" v-model="form.firstFollowtime" disabled />
|
||||
<view class="cell" @click="show = true" >
|
||||
<view class="item">{{$t('customer.followtime')}} </view>
|
||||
<view class="right" >
|
||||
<!-- <u-input v-model="form.firstFollowtime" :border="false" /> -->
|
||||
<view class="">{{form.firstFollowtime || $t('customer.followtime')}}</view>
|
||||
<!-- <input :placeholder="$t('customer.followtime')" v-model="form.firstFollowtime" disabled /> -->
|
||||
</view>
|
||||
</view>
|
||||
<u-line></u-line>
|
||||
@@ -28,7 +30,7 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="cell" v-if="form.type==0">
|
||||
<view>{{$t('customer.followlocation')}}</view>
|
||||
<view class="item">{{$t('customer.followlocation')}}</view>
|
||||
<view class="right">
|
||||
<input :placeholder="$t('customer.followlocation')" disabled v-model="form.address" />
|
||||
</view>
|
||||
@@ -99,18 +101,22 @@
|
||||
</view>
|
||||
<u-datetime-picker
|
||||
:show="show"
|
||||
closeOnClickOverlay
|
||||
v-model="firstFollow"
|
||||
mode="datetime"
|
||||
@confirm="confirm"
|
||||
@cancel="cancel"
|
||||
@change="change"
|
||||
@close="close('show')"
|
||||
></u-datetime-picker>
|
||||
<u-datetime-picker
|
||||
:show="shownexttime"
|
||||
closeOnClickOverlay
|
||||
v-model="nexttime"
|
||||
mode="datetime"
|
||||
@confirm="confirmnext"
|
||||
@cancel="cancelnext"
|
||||
@close="close('shownexttime')"
|
||||
></u-datetime-picker>
|
||||
</view>
|
||||
</template>
|
||||
@@ -152,6 +158,9 @@
|
||||
leftClick(){
|
||||
uni.navigateBack({})
|
||||
},
|
||||
close(val){
|
||||
this[val]=false
|
||||
},
|
||||
// 获取当前位置
|
||||
getarrd(longitude,latitude){
|
||||
const apiKey = 'AIzaSyBGvV-vX7C72PEbcYrTdmUj3qrubejWzNw';
|
||||
@@ -392,6 +401,9 @@
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.u-m-lr-10{
|
||||
margin: 0px 10px;
|
||||
}
|
||||
textarea {
|
||||
min-height: 200rpx;// 设置默认高度 ,解决设置自适应高度之后高度无效问题
|
||||
margin-top: 15px;
|
||||
@@ -417,6 +429,9 @@
|
||||
font-weight: 500;
|
||||
font-size: 32rpx;
|
||||
color: #666666;
|
||||
.item{
|
||||
width: 90px;
|
||||
}
|
||||
}
|
||||
.arrowright{
|
||||
margin-right: -15px;
|
||||
|
||||
@@ -39,6 +39,7 @@ export default {
|
||||
arr.push(obj)
|
||||
console.log(arr)
|
||||
|
||||
// that.src = 'http://dap?arr='+encodeURIComponent(JSON.stringify(arr))
|
||||
that.src = 'http://219.157.255.213:8082?arr='+encodeURIComponent(JSON.stringify(arr))
|
||||
},
|
||||
fail: function (err) {
|
||||
|
||||
@@ -0,0 +1,222 @@
|
||||
<template>
|
||||
<view>
|
||||
<view id="map" style="height: 100vh;"></view>
|
||||
<!-- 输入框事件 -->
|
||||
<view class="search-box">
|
||||
<input id="search-box" type="text" v-model="cityInfo.address" @input="ListeningInputBox" placeholder="请输入搜索地址...">
|
||||
<view id="btn">确定</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
import { Loader } from "@googlemaps/js-api-loader";
|
||||
const loader = new Loader({
|
||||
// google服务的KEY
|
||||
apiKey: "AIzaSyBGvV-vX7C72PEbcYrTdmUj3qrubejWzNw",
|
||||
version: "weekly",
|
||||
libraries: ["places"]
|
||||
});
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
cityInfo:{
|
||||
lat: '',
|
||||
lng: '',
|
||||
country: "", //国家
|
||||
province: "", //省
|
||||
city: "", //市
|
||||
district: "", //区
|
||||
street: "", //街道
|
||||
door: "", //门牌号
|
||||
address: "", //详细地址
|
||||
}
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.initMap()
|
||||
},
|
||||
methods:{
|
||||
initMap() {
|
||||
var that = this
|
||||
loader
|
||||
.load()
|
||||
.then((google) => {
|
||||
uni.getLocation({
|
||||
type: 'wgs84', // 默认为 wgs84 坐标系,可选 gcj02
|
||||
success: function (res) {
|
||||
console.log(res)
|
||||
const map = new google.maps.Map(document.getElementById("map"),
|
||||
{
|
||||
center: { lat:res.latitude, lng: res.longitude},
|
||||
zoom: 12,// 地图缩放参数
|
||||
maxZoom: 18,// 最大缩放参数
|
||||
minZoom: 4,// 最小缩放参数
|
||||
disableDefaultUI: true// 禁用默认UI
|
||||
}
|
||||
)
|
||||
var marker = new google.maps.Marker({
|
||||
position: { lat:res.latitude, lng: res.longitude},
|
||||
map: map,
|
||||
draggable: true, // 允许拖动标记
|
||||
icon: {
|
||||
url: 'https://now.guua.com/attachs/default/location_shop.png',
|
||||
scaledSize: new google.maps.Size(30, 30),
|
||||
origin: new google.maps.Point(0, 0),
|
||||
anchor: new google.maps.Point(0, 0)
|
||||
}
|
||||
});
|
||||
// 监听标记拖动事件
|
||||
marker.addListener('dragend', () => {
|
||||
const position = marker.getPosition();
|
||||
map.setCenter(position);
|
||||
// 根据标记位置获取地址信息
|
||||
const geocoder = new google.maps.Geocoder();
|
||||
geocoder.geocode({ location: position }, (results, status) => {
|
||||
if (status === 'OK' && results[0]) {
|
||||
console.log(results)
|
||||
console.log(position)
|
||||
that.cityInfo.address = results[0].formatted_address;
|
||||
that.cityInfo.lat = position.lat();
|
||||
that.cityInfo.lng = position.lng();
|
||||
console.log(that.cityInfo)
|
||||
// cityInfo.address = results[0].formatted_address;
|
||||
// updateInfo({
|
||||
// formatted_address: results[0].formatted_address,
|
||||
// geometry: { location: position },
|
||||
// });
|
||||
} else {
|
||||
alert('无法获取地址信息');
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
fail: function (err) {
|
||||
console.log('获取位置失败:', err);
|
||||
},
|
||||
complete: function () {
|
||||
console.log('获取位置完成');
|
||||
}
|
||||
})
|
||||
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log(e)
|
||||
})
|
||||
},
|
||||
ListeningInputBox() {
|
||||
// 创建 Autocomplete 实例
|
||||
const input = document.getElementById("search-box");
|
||||
const autocomplete = new google.maps.places.AutocompleteService();
|
||||
// 设置 Autocomplete 参数
|
||||
// autocomplete.setFields(["geometry", "name"]);
|
||||
// 添加事件监听器,当用户选择某个地点时,在地图上标记出所选位置
|
||||
// LoadAnimation(true)
|
||||
autocomplete.getPlacePredictions(this.cityInfo.address, function() {
|
||||
const place = autocomplete.getPlace();
|
||||
var latlng = JSON.parse(JSON.stringify(place.geometry.location))
|
||||
console.log("place===", latlng)
|
||||
getAddress(latlng.lat, latlng.lng);
|
||||
if (!place.geometry) {
|
||||
console.log("返回的地理信息无效!");
|
||||
return;
|
||||
}
|
||||
// 将地图中心点指向用户所选位置,并设置标记
|
||||
if (searchmarker) { //去除marker标记点
|
||||
searchmarker.setMap(null)
|
||||
searchmarker = ""
|
||||
}
|
||||
map.setCenter(place.geometry.location);
|
||||
searchmarker = new google.maps.Marker({
|
||||
map: map,
|
||||
position: place.geometry.location,
|
||||
title: place.name,
|
||||
});
|
||||
});
|
||||
},
|
||||
getAddress(latitude, longitude) {
|
||||
var that=this
|
||||
// 根据经纬度发起 Reverse Geocoding API 请求,获取地址信息
|
||||
var geocoder = new google.maps.Geocoder();
|
||||
var latlng = {
|
||||
lat: latitude,
|
||||
lng: longitude
|
||||
};
|
||||
this.cityInfo.lats = latitude
|
||||
this.cityInfo.lng = longitude
|
||||
geocoder.geocode({
|
||||
location: latlng
|
||||
}, function(results, status) {
|
||||
if (status === 'OK') {
|
||||
if (results[0]) {
|
||||
console.log(results[0])
|
||||
for (var i = 0; i < results.length; i++) {
|
||||
var components = results[i].address_components;
|
||||
for (var j = 0; j < components.length; j++) {
|
||||
var component = components[j];
|
||||
if (component.types.includes("country")) {
|
||||
console.log("国家: ====>" + component.long_name);
|
||||
cityInfo.country = component.long_name || '暂无';
|
||||
} else if (component.types.includes("administrative_area_level_1")) {
|
||||
console.log("省/州: ====>" + component.long_name);
|
||||
cityInfo.province = component.long_name || '暂无';
|
||||
} else if (component.types.includes("locality")) {
|
||||
console.log("城市: ====> " + component.long_name);
|
||||
cityInfo.city = component.long_name || '暂无';
|
||||
} else if (component.types.includes("sublocality_level_1")) {
|
||||
console.log("区/县: ====>" + component.long_name);
|
||||
cityInfo.district = component.long_name || '暂无';
|
||||
} else if (component.types.includes("route")) {
|
||||
console.log("路/街道名: ====> " + component.long_name);
|
||||
cityInfo.street = component.long_name || '暂无';
|
||||
} else if (component.types.includes("street_number")) {
|
||||
console.log("门牌号: ====> " + component.long_name);
|
||||
cityInfo.door = component.long_name || '暂无';
|
||||
}
|
||||
}
|
||||
}
|
||||
that.cityInfo.address = results[0].formatted_address;
|
||||
console.log("cityInfo==========", that.cityInfo)
|
||||
|
||||
// addInfo(cityInfo)
|
||||
|
||||
} else {
|
||||
alert('找不到地址信息');
|
||||
}
|
||||
} else {
|
||||
alert('获取地址信息失败:' + status);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
<style lang="scss">
|
||||
.search-box{
|
||||
width: 99%;
|
||||
left: 2%;
|
||||
top: 80px;
|
||||
font-size: 12px;
|
||||
position: fixed;
|
||||
padding: 5px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
#search-box {
|
||||
height: 30px;
|
||||
padding: 5px;
|
||||
font-size: 16px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #ccc;
|
||||
box-shadow: 0px 1px 3px #ddd;
|
||||
width:70%;
|
||||
background: #fff;
|
||||
}
|
||||
#btn{
|
||||
padding: 10px 20px;
|
||||
text-align: center;
|
||||
background: #fff;
|
||||
border: 1px solid #bbbbbb;
|
||||
border-radius: 6px;
|
||||
margin-left: 10px;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user