map.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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">
  10. <view class="bbc" v-if="item.id">
  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 class="bbc" v-else>
  27. <view class="item_job">
  28. <view class="address omit">
  29. <text>地图共有:{{ list.length }}个全职岗位</text>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. export default {
  38. data() {
  39. return {
  40. a1: 'https://chenglantimes.com/prod-api/profile/upload/2024/06/15/a1.png',
  41. a2: 'https://chenglantimes.com/prod-api/profile/upload/2024/06/15/a2.png',
  42. item: {},
  43. list: [],
  44. param: { orderBy: 'id', type: 0 },
  45. markers: []
  46. };
  47. },
  48. onLoad(e) {
  49. if (this.getLocation()) {
  50. this.param.latitude = this.getLocation().latitude;
  51. this.param.longitude = this.getLocation().longitude;
  52. }
  53. this.getData();
  54. },
  55. methods: {
  56. getData() {
  57. this.http.request({
  58. url: '/app/position/map',
  59. data: this.param,
  60. success: (res) => {
  61. this.list = res.data.data;
  62. this.list.forEach((item, index) => {
  63. this.markers.push({
  64. id: index,
  65. width: 40,
  66. height: 40,
  67. latitude: item.latitude,
  68. longitude: item.longitude,
  69. iconPath: this.a1
  70. });
  71. });
  72. }
  73. });
  74. },
  75. click(e) {
  76. this.item = this.list[e.markerId];
  77. let marker = this.markers.filter((item) => item.id == e.markerId)[0];
  78. this.markers.forEach((item) => (item.iconPath = this.a1));
  79. marker.iconPath = this.a2;
  80. },
  81. go(url) {
  82. uni.navigateTo({ url: url });
  83. }
  84. }
  85. };
  86. </script>
  87. <style lang="scss">
  88. .search {
  89. position: fixed;
  90. width: 100%;
  91. top: 0px;
  92. z-index: 11;
  93. }
  94. map {
  95. width: 100%;
  96. height: 100%;
  97. position: fixed;
  98. top: 0px;
  99. z-index: 1;
  100. }
  101. .bbc {
  102. padding: 15px;
  103. .item_job {
  104. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.2);
  105. }
  106. }
  107. .footer {
  108. position: fixed;
  109. width: 100%;
  110. bottom: 20px;
  111. z-index: 11;
  112. }
  113. </style>