distribution.vue 6.3 KB

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