123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269 |
- <template>
- <view class="container">
- <view class="header">
- <view class="now-location">
- <u-icon name="map" size="36" class="icon"></u-icon>
- <text class="text Medium title">{{address}}</text>
- </view>
- <view class="selectType">
- <text @click="selectType" class="header-type Regular">{{typeStr}}</text>
- <!-- <u-icon :style="{transform:(showType?'rotate(180deg)':'')}" name="arrow-down-fill" size="8"
- color="#AFB3BF" class="icon"></u-icon> -->
- </view>
- </view>
- <view class="uni-common-mt">
- <view class="content">
- <map class="map" @markertap="markertap" :latitude="nowLocation.latitude"
- :longitude="nowLocation.longitude" :markers="covers" :enable-poi="true">
- </map>
- </view>
- </view>
- <view class="alert">
- <view class="select-alert" v-if="showType">
- <view class="select-top">
- <text class="cancel" @click="cancel">取消</text>
- <text class="confirm" @click="confirm">确定</text>
- </view>
- <view class="select">
- <text class="select-item" v-for="(item,index) in typeList" :key="index">
- {{item.name}}
- </text>
- </view>
- </view>
- </view>
- <view class="content2">
- <view class="no-enterprise Regular" v-if="enterpriseList.length!=0">
- 附近暂无相关企业
- </view>
- <view class="warp">
- <view class="top-line"></view>
- <view class="bottom-list-item">
- <view class="left"><img src="../../../static/img/location.png" alt=""></view>
- <view class="middle">
- <view class="title Medium">中天昊元粮库中天昊元粮库</view>
- <view class="location Regular">辽宁省营口市鲅鱼圈区xx路108号</view>
- </view>
- <view class="line"></view>
- <view class="right">
- <view class="top">
- <img src="../../../static/img/location.png" alt="">
- </view>
- <view class="bottom Regular">500m</view>
- </view>
- </view>
- <view class="bottom-list-item">
- <view class="left"><img src="../../../static/img/location.png" alt=""></view>
- <view class="middle">
- <view class="title Medium">中天昊元粮库中天昊元粮库</view>
- <view class="location Regular">辽宁省营口市鲅鱼圈区xx路108号</view>
- </view>
- <view class="line"></view>
- <view class="right">
- <view class="top">
- <img src="../../../static/img/location.png" alt="">
- </view>
- <view class="bottom Regular">500m</view>
- </view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- // import amap from '@/js_sdk/js-amap/amap-wx.130.js'
- export default {
- data() {
- return {
- address: {},
- nowLocation: {
- longitude: '',
- latitude: ''
- },
- showType: false,
- enterpriseList: [],
- typeStr: '全部类型',
- typeList: [{
- name: "全部"
- },
- {
- name: "粮库"
- },
- {
- name: "加工厂"
- }
- ],
- title: 'map',
- latitude: 39.909,
- longitude: 116.39742,
- covers: [{
- id: 0,
- latitude: 39.9085,
- longitude: 116.39747,
- iconPath: '../../../static/img/location.png',
- }]
- }
- },
- onShow() {
- },
- onLoad() {
- //获取当前位置
- this.getLocation()
- // var subnvue = uni.getSubNVueById('popup') // 获取nvue
- // subnvue.show() // 显示nvue
- // uni.$on('popup', (data) => {
- // console.log(data)
- // })
- },
- methods: {
- confirm() {
- console.log('确定')
- this.showType = false
- },
- cancel() {
- console.log('取消')
- this.showType = false
- },
- selectType() {
- this.showType = true
- console.log(1)
- },
- typeConfirm(e) {
- console.log(e)
- this.typeStr = this.typeList[e[0]].name
- },
- getLocation() {
- let that = this;
- uni.getLocation({
- type: 'gcj02',
- geocode: true,
- success: function(res) {
- that.nowLocation.longitude = res.longitude
- that.nowLocation.latitude = res.latitude
- that.covers[0].longitude = res.longitude
- that.covers[0].latitude = res.latitude
- let _coverrsData = []
- for (let i = 0; i < 50; i++) {
- let _obj = {
- id: i,
- latitude: res.latitude += 0.00150,
- longitude: res.longitude + 0.00150,
- iconPath: '../../../static/img/location.png',
- width:30,
- height:30,
- callout: {
- content: '中天昊元粮库',
- color: '#333333',
- fontSize: 24,
- borderRadius: 20,
- padding:10,
- bgColor: 'white',
- display: 'ALWAYS',
- },
- }
- _coverrsData.push(_obj)
- }
- that.covers = _coverrsData
- console.log('获取位置数据:', res);
- console.log('当前位置的经度:' + res.longitude);
- console.log('当前位置的纬度:' + res.latitude);
- //拼接当前定位回显地址
- let _address = res.address
- that.address = _address.province + _address.city + _address.district + _address.poiName
- console.log(that.address)
- }
- });
- },
- markertap(e) {
- console.log(e)
- uni.showToast({
- title: "点击id为" + e.detail.markerId + "的坐标",
- icon: 'none',
- duration: 2000
- })
- }
- }
- }
- </script>
- <style scoped>
- .header {
- flex-direction: row;
- justify-content: space-between;
- margin-bottom: 20rpx;
- padding: 20rpx;
- }
- .title {
- font-size: 32rpx;
- }
- .content {
- width: 750px;
- flex: 1;
- }
- .map {
- height: 1350rpx;
- }
- .content2 {
- position: fixed;
- bottom: 0;
- width: 750rpx;
- flex: 1;
- font-size: 34px;
- background: pink;
- }
- .header-type {
- font-size: 26rpx;
- }
- .alert {
- flex: 1;
- }
- .select-alert {
- background-color: green;
- position: fixed;
- bottom: 0;
- width: 750rpx;
- flex: 1;
- }
- .select-top {
- flex-direction: row;
- align-items: center;
- justify-content: space-around;
- background: yellow;
- height: 80rpx;
- }
- .select {
- width: 750rpx;
- flex: 1;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- background: white;
- }
- .cancel{
- font-size: 24rpx;
- color: white;
- font-weight: bold;
- }
- .confirm{
- font-size: 24rpx;
- color: green;
- font-weight: bold;
- }
- .select-item{
- font-size: 24rpx;
- }
- </style>
|