123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- <template>
- <view class="safety" id="container">
- <map style="width: 100%; height: 75%;" :latitude="latitude" :longitude="longitude" scale="10"
- :markers="markers" :show-location="true" @markertap="markertap">
- </map>
- <view class="model">
- <view class="info">
- <image class="img" :src="image(model.shopsPic)"></image>
- <view class="info-data">
- <view class="info-title">名称:{{model.shopsName ? model.shopsName : '-'}}</view>
- <view class="info-text">电话:{{model.shopsTel ? model.shopsTel : '-'}}</view>
- <view class="info-shopsIntroduce">地址:{{model.shopsAddress ? model.shopsAddress : '-'}}</view>
- <view class="info-shopsIntroduce">简介:{{model.shopsIntroduce ? model.shopsIntroduce : '-'}}</view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import amap from '@/lib/amap-wx.130.js'
- import server from "@/api/index";
- import http from '@/common/http.js'
- export default {
- data() {
- return {
- pageNo: 1,
- pageSize: 10,
- id: 0,
- clickable: true,
- latitude: 43.616996,
- longitude: 125.323643,
- mapKey: '1dc63f21c12985e199a715faf4c02f36',
- markers: [],
- list: [],
- model:{
- shopsName: '',
- shopsTel: '',
- shopsIntroduce: '',
- shopsPic: '',
- shopsAddress: ''
- }
- }
- },
- onLoad() {
- let that = this;
- this.amapPlugin = new amap.AMapWX({
- key: this.mapKey //该key 是在高德中申请的微信小程序key
- });
- this.amapPlugin.getRegeo({
- type: 'gcj02', //map 组件使用的经纬度是国测局坐标, type 为 gcj02
- success: function(res) {
- const latitude = res[0].latitude;
- const longitude = res[0].longitude;
- that.longitude = longitude;
- that.latitude = latitude;
- console.log(that.longitude, that.latitude)
- that.mapInfo = res[0];
- },
- fail: (res) => {
- console.log(JSON.stringify(res));
- }
- });
- this.getFn()
- },
- methods: {
- image(e) {
- return http.webUrl + e
- },
- getFn() {
- server.getYongJun().then(res =>{
- res.forEach((item, index) => {
- this.markers.push({
- id: item.shopsId,
- latitude: Number(item.shopsLat),
- longitude: Number(item.shopsLng),
- iconPath: '../../../static/dian.png',
- width: 24,
- height: 24,
- clickable: true,
- shopsName: item.shopsName,
- shopsTel: item.shopsTel,
- shopsIntroduce: item.shopsIntroduce,
- shopsPic: item.shopsPic,
- shopsAddress: item.shopsAddress
- })
- })
- if (this.markers[0]) {
- this.model.shopsName = this.markers[0].shopsName
- this.model.shopsTel = this.markers[0].shopsTel
- this.model.shopsIntroduce = this.markers[0].shopsIntroduce
- this.model.shopsPic = this.markers[0].shopsPic
- this.model.shopsAddress = this.markers[0].shopsAddress
- }
- })
- },
- markertap(e) {
- this.markers.forEach(item => {
- if (e.detail.markerId === item.id) {
- this.model.shopsName = item.shopsName
- this.model.shopsTel = item.shopsTel
- this.model.shopsIntroduce = item.shopsIntroduce
- this.model.shopsPic = item.shopsPic
- this.model.shopsAddress = item.shopsAddress
- }
- })
-
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .safety {
- position: absolute;
- width: 100%;
- height: 100%;
- box-sizing: border-box;
- }
- .model {
- width: 100%;
- height: 25%;
- position: absolute;
- left: 0upx;
- bottom: 0upx;
- background-color: #FFFFFF;
- z-index: 9999;
- padding: 0rpx 30rpx;
- .info {
- width: 100%;
- height: 100%;
- display: flex;
- flex-direction: row;
- align-items: center;
- justify-content: space-around;
- .img{
- width: 180rpx;
- height: 180rpx;
- }
- .info-data{
- width: calc(100% - 180rpx);
- padding-left: 20upx;
-
- }
- .info-title{
- }
- .info-text{
- padding-top: 10upx;
- }
- .info-shopsIntroduce{
- padding-top: 10upx;
- line-height: 40rpx;
- height: auto;
- overflow: visible;
- }
- }
- }
- </style>
|