distribution.vue 6.4 KB

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