index copy 3.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <view class="chooseCity">
  3. <view class="map">
  4. <view class="page-section page-section-gap">
  5. <map style="width: 100%; height: 300px;" :latitude="latitude" :longitude="longitude" :markers="covers">
  6. </map>
  7. </view>
  8. </view>
  9. <view class="nearsMap">附近地址</view>
  10. <view class="city">
  11. <view class="citeItem1">某某省某某市某某区某某</view>
  12. <view class="citeItem2">某某省某某市</view>
  13. </view>
  14. <view class="city">
  15. <view class="citeItem1">某某省某某市某某区某某</view>
  16. <view class="citeItem2">某某省某某市</view>
  17. </view>
  18. <view class="city">
  19. <view class="citeItem1">某某省某某市某某区某某</view>
  20. <view class="citeItem2">某某省某某市</view>
  21. </view>
  22. <view class="city">
  23. <view class="citeItem1">某某省某某市某某区某某</view>
  24. <view class="citeItem2">某某省某某市</view>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. import { getHomePage } from '@/api/home';
  30. export default {
  31. data() {
  32. return {
  33. id:0, // 使用 marker点击事件 需要填写id
  34. title: 'map',
  35. latitude: 0,
  36. longitude: 0,
  37. covers: [{
  38. latitude: 0,
  39. longitude: 0,
  40. iconPath: '../../../static/location.png'
  41. }, {
  42. latitude: 0,
  43. longitude: 0,
  44. iconPath: '../../../static/location.png'
  45. }]
  46. }
  47. },
  48. methods: {
  49. onShow() {
  50. uni.getLocation({
  51. type: 'gcj02',
  52. success: res => {
  53. console.log('当前位置的经度:' + res.longitude);
  54. console.log('当前位置的纬度:' + res.latitude);
  55. this.location.longitude = res.longitude;
  56. this.location.latitude = res.latitude;
  57. this.$store.commit('SET_LOCATION', { longitude: res.longitude, latitude: res.latitude });
  58. getHomePage(this.location)
  59. .then(res => {
  60. console.log(res);
  61. })
  62. .catch(err => {
  63. console.log(err);
  64. });
  65. },
  66. });
  67. },
  68. }
  69. }
  70. </script>
  71. <style lang="scss" scoped>
  72. .chooseCity {
  73. background-color: #fff;
  74. .map {
  75. width: 100%;
  76. height: 600rpx;
  77. text-align: center;
  78. line-height: 600rpx;
  79. }
  80. .nearsMap {
  81. font-size: 36rpx;
  82. padding: 30rpx;
  83. border-bottom: 2rpx solid #d9d9d9;
  84. }
  85. .city {
  86. width: 100%;
  87. height: 150rpx;
  88. padding: 30rpx;
  89. box-sizing: border-box;
  90. .citeItem1 {
  91. font-size: 34rpx;
  92. color: #343434;
  93. margin-bottom: 20rpx;
  94. }
  95. .citeItem2 {
  96. font-size: 26rpx;
  97. color: #999999;
  98. }
  99. }
  100. .city:nth-of-type(2n) {
  101. background-color: #efefef;
  102. }
  103. }
  104. </style>