123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232 |
- <template>
- <view class="container">
- <view class="content">
- <view class='address' @click='naviageToPage("/pages/grain_pulse/position/position")'>
- <image class='location' src="@/static/img/liangmai/icon_ditu@2x.png" mode=""></image>
- <text v-if="position.name" class="title-style">{{position.name}}</text>
- <text v-else class="title-style">点击定位</text>
- </view>
- <map class="map" @tap="tap" @markertap="markertap" :latitude="position.latitude"
- :longitude="position.longitude" :markers="covers"
- :style="{height: nowMapIndex ? nintyPercentScreenHeight : seventyPercentScreenHeight,width:'750rpx,flex:1'}">
- </map>
- </view>
- <view class="bottom">
- <view class="bottom-left">
- <text class="bottom-content bottom-content1">经度:{{position.longitude}}</text>
- <text class="bottom-content">纬度:{{position.latitude}}</text>
- </view>
- <text class="config-btn" @click="config">确定</text>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- nowMapIndex: true,
- phoneHeight: '', //屏幕高
- phoneWidth: '', //屏幕宽
- position: {
- longitude: 116.39747,
- latitude: 39.9085,
- address: '未指定地点'
- },
- longitude: 116.39747,
- latitude: 39.9085,
- title: 'map',
- // covers: [{
- // id: 0,
- // latitude: 39.9085,
- // longitude: 116.39747,
- // iconPath: '../../../static/img/location.png',
- // }],
- covers: [],
- amapPlugin:null,
- mapKey:''
- }
- },
- onReady() {
- // 计算屏幕高度 ,宽度
- let _this = this;
- uni.getSystemInfo({
- success(res) {
- _this.phoneHeight = res.windowHeight;
- _this.phoneWidth = res.windowWidth
- }
- });
- },
- computed: { //计算
- nintyPercentScreenHeight() { //百分之百的屏幕高
- if (this.phoneHeight !== '' && this.phoneWidth !== '') {
- return 750 / (this.phoneWidth) * (this.phoneHeight) + 'rpx'
- } else {
- return '1250rpx'
- }
- },
- seventyPercentScreenHeight() { //百分之七十的屏幕高
- if (this.phoneHeight !== '' && this.phoneWidth !== '') {
- return 750 / (this.phoneWidth) * (this.phoneHeight) * 0.7 + 'rpx'
- } else {
- return '1000rpx'
- }
- },
- },
- onLoad(options) {
- console.log(11111)
- // if(options){
- console.log(options)
- // }
- },
- onShow() {
- let that = this
- uni.getStorage({
- key: 'setPosition',
- success: (res) => {
- console.log(res.data)
- that.position = res.data
- that.position.longitude = res.data.location.split(',')[0];
- that.position.latitude = res.data.location.split(',')[1];
-
- console.log(that.position.longitude)
- console.log(that.position.latitude)
- // uni.removeStorage({
- // key: 'setLocaltion'
- // })
- },
-
- })
- },
- onLoad() {
- // this.getLocation()
- },
- methods: {
- naviageToPage(item) {
- uni.setStorage({
- key: 'setPositionType',
- data:{type:1},
- success: function(res) {
- console.log(item)
- uni.navigateTo({
- url: item
- })
- }
- });
-
- },
- tap(e) {
- var that = this
- let newmarker =[];
- var id=1;
-
- // this.position.longitude = e.detail.longitude;
- // this.position.latitude = e.detail.latitude;
- // console.log(this.longitude)
- // console.log(this.latitude)
- // let maker= {
- // id: id++,
- // latitude: this.position.latitude,
- // longitude:e.detail.longitude,
- // iconPath: '../../../static/img/location.png',
- // }
- // newmarker.push(maker)
- // this.covers = newmarker
- var lnglat = e.detail.longitude+','+e.detail.latitude
- console.log("lnglat",lnglat)
- let parameters = {
- key: 'dd701d394d116b50268dc16470ddd615',
- location: lnglat
- }
- uni.request({
- url: 'https://restapi.amap.com/v3/geocode/regeo?parameters',
- data: parameters,
- success: (res) => {
- that.position=res.data.regeocode.addressComponent
- console.log(res.data.regeocode.addressComponent)
- that.position.longitude = res.data.regeocode.addressComponent.streetNumber.location.split(',')[0];
- that.position.latitude = res.data.regeocode.addressComponent.streetNumber.location.split(',')[1];
- let maker= {
- id: id++,
- latitude: that.position.latitude,
- longitude:that.position.longitude,
- iconPath: '../../../static/img/location.png',
- }
- newmarker.push(maker)
- that.covers = newmarker
- }
- });
- },
- config() {
- uni.setStorageSync('position', this.position);
- uni.navigateBack({
-
- })
- }
- }
- }
- </script>
- <style scoped>
- .content {
- flex: 1;
- width: 750rpx;
- background: white;
- }
- .bottom {
- position: fixed;
- bottom: 54rpx;
- left: 25rpx;
- right: 0;
- width:700rpx;
- background: white;
- flex-direction: row;
- flex: 1;
- justify-content: space-between;
- align-items: center;
- padding: 22rpx 20rpx 22rpx 49rpx;
- border-radius: 20rpx;
- }
- .title-style {
- font-size: 32rpx;
- font-weight: 500;
- color: #333333;
- padding-left: 20rpx;
- }
- .config-btn{
- width: 144rpx;
- height: 67rpx;
- line-height: 67rpx;
- background: #22C572;
- border-radius: 10rpx;
- color: white;
- text-align: center;
- font-size: 28rpx;
- }
- .bottom-content{
- font-size: 28rpx;
- }
- .location {
- width: 27rpx;
- height: 31rpx;
- }
- .address{
- flex-direction: row;
- align-items: center;
- margin: 20rpx;
- /* margin-left: 80rpx;
- margin-top: 10rpx;
- margin-bottom: 20rpx; */
- }
- .bottom-left{
- flex-direction: row;
- justify-content: space-between;
- }
- .bottom-content1{
- margin-right: 40rpx;
- }
- </style>
|