localtion.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <view class="container">
  3. <view class="content">
  4. <map class="map" @markertap="markertap" :latitude="nowLocation.latitude" :longitude="nowLocation.longitude"
  5. :markers="covers">
  6. </map>
  7. </view>
  8. <view class="bottom">
  9. <view class="title Medium">
  10. {{dataList.title}}
  11. </view>
  12. <view class="bottom-content Regular">
  13. {{dataList.content}}
  14. </view>
  15. <view class="Regular location">
  16. <view class="left">
  17. <u-icon name="map" size="36" class="icon"></u-icon>
  18. <view>{{dataList.localtion}}</view>
  19. </view>
  20. <view class="metre">
  21. <u-line color="#A3A9B8" direction='col' length="20rpx"/>
  22. <text class="line" >
  23. {{dataList.rice}}</text>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. export default {
  31. data() {
  32. return {
  33. dataList: {
  34. title: '中天昊元粮库中天昊元粮库',
  35. content: '我是企业介绍我是企业介绍我是企业介绍我是企业介绍我是企业介绍…',
  36. localtion: "辽宁省营口市鲅鱼圈区熊岳镇火车站…",
  37. rice: '500m'
  38. },
  39. nowLocation: {
  40. longitude: '',
  41. latitude: ''
  42. },
  43. title: 'map',
  44. latitude: 39.909,
  45. longitude: 116.39742,
  46. covers: [{
  47. id: 0,
  48. latitude: 39.9085,
  49. longitude: 116.39747,
  50. iconPath: '../../../static/img/location.png',
  51. }]
  52. }
  53. },
  54. onLoad() {
  55. this.getLocation()
  56. },
  57. methods: {
  58. getLocation() {
  59. let that = this;
  60. uni.getLocation({
  61. type: 'gcj02',
  62. geocode: true,
  63. success: function(res) {
  64. that.nowLocation.longitude = res.longitude
  65. that.nowLocation.latitude = res.latitude
  66. that.covers[0].longitude = res.longitude
  67. that.covers[0].latitude = res.latitude
  68. console.log('获取位置数据:', res);
  69. console.log('当前位置的经度:' + res.longitude);
  70. console.log('当前位置的纬度:' + res.latitude);
  71. //拼接当前定位回显地址
  72. // let _address = res.address
  73. // this.address = _address
  74. }
  75. });
  76. },
  77. }
  78. }
  79. </script>
  80. <style lang="scss" scoped>
  81. .content {
  82. width: 100vw;
  83. height: 100vh;
  84. }
  85. .map {
  86. width: 100%;
  87. height: 100%;
  88. }
  89. .bottom {
  90. width: 96%;
  91. background: white;
  92. position: fixed;
  93. bottom: 54rpx;
  94. left: 0;
  95. right: 0;
  96. margin: auto;
  97. padding: 27rpx 37rpx;
  98. .title {
  99. font-size: 30rpx;
  100. color: #333333;
  101. margin-bottom: 12rpx;
  102. }
  103. .bottom-content {
  104. font-size: 22rpx;
  105. }
  106. .location {
  107. color: #AFB3BF;
  108. display: flex;
  109. justify-content: space-between;
  110. align-items: center;
  111. margin-top: 15rpx;
  112. .left {
  113. display: flex;
  114. flex-wrap: nowrap;
  115. }
  116. .metre{
  117. display: flex;
  118. justify-content: space-between;
  119. align-items: center;
  120. .line{
  121. margin-left:13rpx ;
  122. }
  123. }
  124. }
  125. }
  126. </style>