distribution.vue 6.8 KB

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