distribution.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  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">黑龙江中天...</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" :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. nowLocation: {
  64. longitude: '',
  65. latitude: ''
  66. },
  67. showType: false,
  68. enterpriseList: [],
  69. typeStr: '全部类型',
  70. typeList: [{
  71. name: "全部"
  72. },
  73. {
  74. name: "粮库"
  75. },
  76. {
  77. name: "加工厂"
  78. }
  79. ],
  80. title: 'map',
  81. latitude: 39.909,
  82. longitude: 116.39742,
  83. covers: [{
  84. id: 0,
  85. latitude: 39.9085,
  86. longitude: 116.39747,
  87. iconPath: '../../../static/img/location.png',
  88. }]
  89. }
  90. },
  91. onLoad() {
  92. //获取当前位置
  93. this.getLocation()
  94. },
  95. methods: {
  96. selectType() {
  97. this.showType = true
  98. },
  99. typeConfirm(e) {
  100. console.log(e)
  101. this.typeStr = this.typeList[e[0]].name
  102. },
  103. getLocation() {
  104. let that = this;
  105. uni.getLocation({
  106. type: 'gcj02',
  107. success: function(res) {
  108. that.nowLocation.longitude = res.longitude
  109. that.nowLocation.latitude = res.latitude
  110. that.covers[0].longitude = res.longitude
  111. that.covers[0].latitude = res.latitude
  112. let _coverrsData = []
  113. for (let i = 0; i < 50; i++) {
  114. let _obj = {
  115. id: i,
  116. latitude: res.latitude += 0.00150,
  117. longitude: res.longitude + 0.00150,
  118. iconPath: '../../../static/img/location.png',
  119. callout: { //自定义标记点上方的气泡窗口 点击有效
  120. content: '中天昊元粮库', //文本
  121. color: '#333333', //文字颜色
  122. fontSize: 12, //文本大小
  123. borderRadius: 20, //边框圆角
  124. bgColor: 'white', //背景颜色
  125. display: 'ALWAYS', //常显
  126. },
  127. }
  128. _coverrsData.push(_obj)
  129. }
  130. that.covers = _coverrsData
  131. console.log('当前位置的经度:' + res.longitude);
  132. console.log('当前位置的纬度:' + res.latitude);
  133. }
  134. });
  135. }
  136. }
  137. }
  138. </script>
  139. <style lang="scss" scoped>
  140. .header{
  141. display: flex;
  142. padding:20rpx 35rpx;
  143. background: white;
  144. justify-content: space-between;
  145. align-items: center;
  146. .selectType{
  147. display: flex;
  148. justify-content: center;
  149. align-items: flex-end;
  150. .icon{
  151. position: relative;
  152. top: -4rpx
  153. }
  154. }
  155. .header-type{
  156. font-size: 26rpx;
  157. color: #333333;
  158. margin-right: 10rpx;
  159. }
  160. .now-location{
  161. display: flex;
  162. align-items: center;
  163. .icon{
  164. margin-right: 10rpx;
  165. }
  166. .text{
  167. font-size: 32rpx;
  168. color: #333333;
  169. }
  170. }
  171. }
  172. .content {
  173. height: 100vh;
  174. .map {
  175. width: 100%;
  176. height: 100%;
  177. }
  178. }
  179. .no-enterprise {
  180. position: fixed;
  181. bottom: 20px;
  182. height: 84rpx;
  183. width: 94%;
  184. left: 0;
  185. right: 0;
  186. margin: auto;
  187. background: #FFFFFF;
  188. font-size: 26rpx;
  189. color: #333333;
  190. display: flex;
  191. justify-content: center;
  192. align-items: center;
  193. border-radius: 20rpx;
  194. }
  195. .content2 {
  196. position: fixed;
  197. bottom: 0;
  198. width: 100%;
  199. background: white;
  200. border-radius: 20px 20px 0 0;
  201. padding: 37rpx 35rpx 20rpx 35rpx;
  202. .warp {
  203. .top-line {
  204. width: 68rpx;
  205. height: 8rpx;
  206. background: #B4B7C3;
  207. border-radius: 4px;
  208. content: '';
  209. display: block;
  210. position: absolute;
  211. top: 16rpx;
  212. left: 0;
  213. right: 0;
  214. margin: auto;
  215. }
  216. .bottom-list-item {
  217. display: flex;
  218. justify-content: space-between;
  219. align-items: flex-start;
  220. border-bottom:1px solid #EEEEEE;
  221. padding: 20rpx 0;
  222. .left{
  223. img{
  224. width: 102rpx;
  225. border-radius: 10px;
  226. background: red;
  227. }
  228. }
  229. .middle{
  230. position: relative;
  231. left: -10rpx;
  232. .title{
  233. font-size: 32rpx;
  234. color: #333333;
  235. margin-bottom: 6rpx;
  236. }
  237. .location{
  238. font-size: 24rpx;
  239. color: #AFB3BF;
  240. }
  241. }
  242. .line{
  243. width: 1px;
  244. height: 80rpx;
  245. border: 1px solid #EEEEEE;
  246. }
  247. .right{
  248. display: flex;
  249. flex-direction: column;
  250. justify-content: center;
  251. align-items: center;
  252. img{
  253. width: 21px;
  254. }
  255. .bottom{
  256. font-size: 24rpx;
  257. color: #AFB3BF;
  258. }
  259. }
  260. }
  261. }
  262. }
  263. </style>