map.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <view>
  3. <view class="search">
  4. <view class="bbc">
  5. <u-search placeholder="搜索工作" :disabled="true" bgColor="white" :showAction="false" @click="go('/pages/job/search')"></u-search>
  6. </view>
  7. </view>
  8. <map :latitude="param.latitude" scale="10.3" show-location :longitude="param.longitude" :markers="markers" @markertap="click"></map>
  9. <view class="footer" v-show="item.id">
  10. <view class="bbc">
  11. <view class="item_job" @click="go('/pages/job/detail?id=' + item.id)">
  12. <view class="top">
  13. <view class="title omit">{{ item.title }}</view>
  14. <view class="salary">{{ item.salary }}</view>
  15. </view>
  16. <view class="bot">
  17. <view class="address omit">
  18. <text>{{ item.regionName }}</text>
  19. <text class="icon">&#xe757;</text>
  20. <text>{{ item.location }}</text>
  21. </view>
  22. <view class="distance" v-if="item.distance">距离你{{ item.distance }}km</view>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. export default {
  31. data() {
  32. return {
  33. a1: 'https://chenglantimes.com/prod-api/profile/upload/2024/06/15/a1.png',
  34. a2: 'https://chenglantimes.com/prod-api/profile/upload/2024/06/15/a2.png',
  35. item: {},
  36. list: [],
  37. param: { orderBy: 'id', type: 0 },
  38. markers: []
  39. };
  40. },
  41. onLoad(e) {
  42. if (this.getLocation()) {
  43. this.param.latitude = this.getLocation().latitude;
  44. this.param.longitude = this.getLocation().longitude;
  45. }
  46. this.getData();
  47. },
  48. methods: {
  49. getData() {
  50. this.http.request({
  51. url: '/app/position/map',
  52. data: this.param,
  53. success: (res) => {
  54. this.list = res.data.data;
  55. this.list.forEach((item, index) => {
  56. this.markers.push({
  57. id: index,
  58. width: 40,
  59. height: 40,
  60. latitude: item.latitude,
  61. longitude: item.longitude,
  62. iconPath: this.a1
  63. });
  64. });
  65. }
  66. });
  67. },
  68. click(e) {
  69. this.item = this.list[e.markerId];
  70. let marker = this.markers.filter((item) => item.id == e.markerId)[0];
  71. this.markers.forEach((item) => (item.iconPath = this.a1));
  72. marker.iconPath = this.a2;
  73. },
  74. go(url) {
  75. uni.navigateTo({ url: url });
  76. }
  77. }
  78. };
  79. </script>
  80. <style lang="scss">
  81. .search {
  82. position: fixed;
  83. width: 100%;
  84. top: 0px;
  85. z-index: 11;
  86. }
  87. map {
  88. width: 100%;
  89. height: 100%;
  90. position: fixed;
  91. top: 0px;
  92. z-index: 1;
  93. }
  94. .bbc {
  95. padding: 15px;
  96. .item_job {
  97. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.2);
  98. }
  99. }
  100. .footer {
  101. position: fixed;
  102. width: 100%;
  103. bottom: 20px;
  104. z-index: 11;
  105. }
  106. </style>