distribution.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. <template>
  2. <view class="container">
  3. <!-- <view class="header">
  4. <view class="now-location">
  5. <u-icon name="map" size="36" class="icon"></u-icon>
  6. <view class="text Medium">{{address}}</view>
  7. </view>
  8. <view class="selectType">
  9. <view @click="selectType" class="header-type Regular">{{typeStr}}</view>
  10. <u-icon :style="{transform:(showType?'rotate(180deg)':'')}" name="arrow-down-fill" size="8"
  11. color="#AFB3BF" class="icon"></u-icon>
  12. </view>
  13. <u-picker mode="selector" v-model="showType" @confirm='typeConfirm' confirm-color='#22C572'
  14. :range="typeList" range-key="name" :default-selector="[0]"></u-picker>
  15. </view> -->
  16. <view class="uni-common-mt">
  17. <view class="content">
  18. <map class="map" @markertap="markertap" :latitude="nowLocation.latitude"
  19. :longitude="nowLocation.longitude" :markers="covers" :enable-poi="true">
  20. </map>
  21. </view>
  22. </view>
  23. <!-- <view class="content2">
  24. <view class="no-enterprise Regular" v-if="enterpriseList.length!=0">
  25. 附近暂无相关企业
  26. </view>
  27. <view class="warp">
  28. <view class="top-line"></view>
  29. <view class="bottom-list-item">
  30. <view class="left"><img src="../../../static/img/location.png" alt=""></view>
  31. <view class="middle">
  32. <view class="title Medium">中天昊元粮库中天昊元粮库</view>
  33. <view class="location Regular">辽宁省营口市鲅鱼圈区xx路108号</view>
  34. </view>
  35. <view class="line"></view>
  36. <view class="right">
  37. <view class="top">
  38. <img src="../../../static/img/location.png" alt="">
  39. </view>
  40. <view class="bottom Regular">500m</view>
  41. </view>
  42. </view>
  43. <view class="bottom-list-item">
  44. <view class="left"><img src="../../../static/img/location.png" alt=""></view>
  45. <view class="middle">
  46. <view class="title Medium">中天昊元粮库中天昊元粮库</view>
  47. <view class="location Regular">辽宁省营口市鲅鱼圈区xx路108号</view>
  48. </view>
  49. <view class="line"></view>
  50. <view class="right">
  51. <view class="top">
  52. <img src="../../../static/img/location.png" alt="">
  53. </view>
  54. <view class="bottom Regular">500m</view>
  55. </view>
  56. </view>
  57. </view>
  58. </view> -->
  59. </view>
  60. </template>
  61. <script>
  62. // import amap from '@/js_sdk/js-amap/amap-wx.130.js'
  63. export default {
  64. data() {
  65. return {
  66. address: "黑龙江中天...",
  67. nowLocation: {
  68. longitude: '',
  69. latitude: ''
  70. },
  71. showType: false,
  72. enterpriseList: [],
  73. typeStr: '全部类型',
  74. typeList: [{
  75. name: "全部"
  76. },
  77. {
  78. name: "粮库"
  79. },
  80. {
  81. name: "加工厂"
  82. }
  83. ],
  84. title: 'map',
  85. latitude: 39.909,
  86. longitude: 116.39742,
  87. covers: [{
  88. id: 0,
  89. latitude: 39.9085,
  90. longitude: 116.39747,
  91. iconPath: '../../../static/img/location.png',
  92. }]
  93. }
  94. },
  95. onShow() {
  96. const subnvue = uni.getSubNVueById('popup') // 获取nvue
  97. subnvue.show() // 显示nvue
  98. },
  99. onLoad() {
  100. //获取当前位置
  101. this.getLocation()
  102. },
  103. methods: {
  104. selectType() {
  105. this.showType = true
  106. },
  107. typeConfirm(e) {
  108. console.log(e)
  109. this.typeStr = this.typeList[e[0]].name
  110. },
  111. getLocation() {
  112. let that = this;
  113. uni.getLocation({
  114. type: 'gcj02',
  115. geocode: true,
  116. success: function(res) {
  117. that.nowLocation.longitude = res.longitude
  118. that.nowLocation.latitude = res.latitude
  119. that.covers[0].longitude = res.longitude
  120. that.covers[0].latitude = res.latitude
  121. let _coverrsData = []
  122. for (let i = 0; i < 50; i++) {
  123. let _obj = {
  124. id: i,
  125. latitude: res.latitude += 0.00150,
  126. longitude: res.longitude + 0.00150,
  127. iconPath: '../../../static/img/location.png',
  128. callout: {
  129. content: '中天昊元粮库',
  130. color: '#333333',
  131. fontSize: 12,
  132. borderRadius: 20,
  133. bgColor: 'white',
  134. display: 'ALWAYS',
  135. },
  136. }
  137. _coverrsData.push(_obj)
  138. }
  139. that.covers = _coverrsData
  140. console.log('获取位置数据:', res);
  141. console.log('当前位置的经度:' + res.longitude);
  142. console.log('当前位置的纬度:' + res.latitude);
  143. //拼接当前定位回显地址
  144. // let _address = res.address
  145. // this.address = _address
  146. }
  147. });
  148. },
  149. markertap(e) {
  150. console.log(e)
  151. uni.showToast({
  152. title: "点击id为" + e.detail.markerId + "的坐标",
  153. icon: 'none',
  154. duration: 2000
  155. })
  156. }
  157. }
  158. }
  159. </script>
  160. <style lang="scss" scoped>
  161. .header {
  162. display: flex;
  163. padding: 20rpx 35rpx;
  164. background: white;
  165. justify-content: space-between;
  166. align-items: center;
  167. .selectType {
  168. display: flex;
  169. justify-content: center;
  170. align-items: flex-end;
  171. .icon {
  172. position: relative;
  173. top: -4rpx
  174. }
  175. }
  176. .header-type {
  177. font-size: 26rpx;
  178. color: #333333;
  179. margin-right: 10rpx;
  180. }
  181. .now-location {
  182. display: flex;
  183. align-items: center;
  184. .icon {
  185. margin-right: 10rpx;
  186. }
  187. .text {
  188. font-size: 32rpx;
  189. color: #333333;
  190. }
  191. }
  192. }
  193. .content {
  194. height: calc(100vh - 100px);
  195. .map {
  196. width: 100%;
  197. height: 100%;
  198. }
  199. }
  200. .no-enterprise {
  201. position: fixed;
  202. bottom: 20px;
  203. height: 84rpx;
  204. width: 94%;
  205. left: 0;
  206. right: 0;
  207. margin: auto;
  208. background: #FFFFFF;
  209. font-size: 26rpx;
  210. color: #333333;
  211. display: flex;
  212. justify-content: center;
  213. align-items: center;
  214. border-radius: 20rpx;
  215. }
  216. .content2 {
  217. position: fixed;
  218. bottom: 0;
  219. width: 100%;
  220. background: white;
  221. border-radius: 20px 20px 0 0;
  222. padding: 37rpx 35rpx 20rpx 35rpx;
  223. .warp {
  224. .top-line {
  225. width: 68rpx;
  226. height: 8rpx;
  227. background: #B4B7C3;
  228. border-radius: 4px;
  229. content: '';
  230. display: block;
  231. position: absolute;
  232. top: 16rpx;
  233. left: 0;
  234. right: 0;
  235. margin: auto;
  236. }
  237. .bottom-list-item {
  238. display: flex;
  239. justify-content: space-between;
  240. align-items: flex-start;
  241. border-bottom: 1px solid #EEEEEE;
  242. padding: 20rpx 0;
  243. .left {
  244. img {
  245. width: 102rpx;
  246. border-radius: 10px;
  247. background: red;
  248. }
  249. }
  250. .middle {
  251. position: relative;
  252. left: -10rpx;
  253. .title {
  254. font-size: 32rpx;
  255. color: #333333;
  256. margin-bottom: 6rpx;
  257. }
  258. .location {
  259. font-size: 24rpx;
  260. color: #AFB3BF;
  261. }
  262. }
  263. .line {
  264. width: 1px;
  265. height: 80rpx;
  266. border: 1px solid #EEEEEE;
  267. }
  268. .right {
  269. display: flex;
  270. flex-direction: column;
  271. justify-content: center;
  272. align-items: center;
  273. img {
  274. width: 21px;
  275. }
  276. .bottom {
  277. font-size: 24rpx;
  278. color: #AFB3BF;
  279. }
  280. }
  281. }
  282. }
  283. }
  284. </style>