coordinate.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <view class="container">
  3. <view class="content">
  4. <view @click='naviageToPage("/pages/grain_pulse/position/position")'>
  5. <image class='location' src="@/static/img/liangmai/icon_ditu.png" mode=""></image>
  6. <text class="title-style">{{position.name}}</text>
  7. </view>
  8. <map class="map" @tap="tap" @markertap="markertap" :latitude="position.latitude"
  9. :longitude="position.longitude" :markers="covers"
  10. :style="{height: nowMapIndex ? nintyPercentScreenHeight : seventyPercentScreenHeight,width:'750rpx,flex:1'}">
  11. </map>
  12. </view>
  13. <view class="bottom">
  14. <view class="bottom-left">
  15. <text class="bottom-content">经度:{{position.longitude}}</text>
  16. <text class="bottom-content">纬度:{{position.latitude}}</text>
  17. </view>
  18. <text class="config-btn" @click="config">确定</text>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. export default {
  24. data() {
  25. return {
  26. nowMapIndex: true,
  27. phoneHeight: '', //屏幕高
  28. phoneWidth: '', //屏幕宽
  29. position: {
  30. longitude: 116.39747,
  31. latitude: 39.9085,
  32. address: '未指定地点'
  33. },
  34. longitude: 116.39747,
  35. latitude: 39.9085,
  36. title: 'map',
  37. // covers: [{
  38. // id: 0,
  39. // latitude: 39.9085,
  40. // longitude: 116.39747,
  41. // iconPath: '../../../static/img/location.png',
  42. // }],
  43. covers: []
  44. }
  45. },
  46. onReady() {
  47. // 计算屏幕高度 ,宽度
  48. let _this = this;
  49. uni.getSystemInfo({
  50. success(res) {
  51. _this.phoneHeight = res.windowHeight;
  52. _this.phoneWidth = res.windowWidth
  53. }
  54. });
  55. },
  56. computed: { //计算
  57. nintyPercentScreenHeight() { //百分之百的屏幕高
  58. if (this.phoneHeight !== '' && this.phoneWidth !== '') {
  59. return 750 / (this.phoneWidth) * (this.phoneHeight) + 'rpx'
  60. } else {
  61. return '1250rpx'
  62. }
  63. },
  64. seventyPercentScreenHeight() { //百分之七十的屏幕高
  65. if (this.phoneHeight !== '' && this.phoneWidth !== '') {
  66. return 750 / (this.phoneWidth) * (this.phoneHeight) * 0.7 + 'rpx'
  67. } else {
  68. return '1000rpx'
  69. }
  70. },
  71. },
  72. onShow() {
  73. let that = this
  74. uni.getStorage({
  75. key: 'setPosition',
  76. success: (res) => {
  77. console.log(res.data)
  78. that.position = res.data
  79. that.position.longitude = res.data.location.split(',')[0];
  80. that.position.latitude = res.data.location.split(',')[1];
  81. console.log(that.position.longitude)
  82. console.log(that.position.latitude)
  83. // uni.removeStorage({
  84. // key: 'setLocaltion'
  85. // })
  86. },
  87. })
  88. },
  89. onLoad() {
  90. // this.getLocation()
  91. },
  92. methods: {
  93. naviageToPage(item) {
  94. uni.setStorage({
  95. key: 'setPositionType',
  96. data:{type:1},
  97. success: function(res) {
  98. console.log(item)
  99. uni.navigateTo({
  100. url: item
  101. })
  102. }
  103. });
  104. },
  105. tap(e) {
  106. let newmarker =[];
  107. var id=1;
  108. this.position.longitude = e.detail.longitude;
  109. this.position.latitude = e.detail.latitude;
  110. console.log(this.longitude)
  111. console.log(this.latitude)
  112. let maker= {
  113. id: id++,
  114. latitude: this.position.latitude,
  115. longitude:this.position.longitude,
  116. iconPath: '../../../static/img/location.png',
  117. }
  118. newmarker.push(maker)
  119. this.covers = newmarker
  120. },
  121. config() {debugger
  122. uni.navigateTo({
  123. url:"/pages/grain_pulse/enter?position="+JSON.stringify(this.position)
  124. })
  125. }
  126. }
  127. }
  128. </script>
  129. <style scoped>
  130. .content {
  131. flex: 1;
  132. width: 750rpx;
  133. }
  134. .bottom {
  135. position: fixed;
  136. bottom: 54rpx;
  137. left: 25rpx;
  138. right: 0;
  139. width:700rpx;
  140. background: white;
  141. flex-direction: row;
  142. flex: 1;
  143. justify-content: space-between;
  144. align-items: center;
  145. padding: 22rpx 20rpx 22rpx 49rpx;
  146. border-radius: 20rpx;
  147. }
  148. .title-style {
  149. font-size: 32rpx;
  150. font-weight: 500;
  151. color: #333333;
  152. }
  153. .config-btn{
  154. width: 144rpx;
  155. height: 67rpx;
  156. line-height: 67rpx;
  157. background: #22C572;
  158. border-radius: 10rpx;
  159. color: white;
  160. text-align: center;
  161. font-size: 28rpx;
  162. }
  163. .bottom-content{
  164. font-size: 28rpx;
  165. }
  166. .location {
  167. width: 27rpx;
  168. height: 31rpx;
  169. }
  170. </style>