distribution.vue 6.0 KB

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