distribution.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  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">{{position.name}}</text>
  7. </view>
  8. <view class="selectType">
  9. <picker @change="bindPickerChange" :value="index" :range="typeList">
  10. <text class="uni-input header-type">{{typeList[index]}}</text>
  11. </picker>
  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="content2">
  22. <view class="no-enterprise Regular" v-if="enterpriseList.length!=0">
  23. 附近暂无相关企业
  24. </view>
  25. <view class="warp">
  26. <view class="line-style" @click="lineClick">
  27. <text class="top-line"></text>
  28. </view>
  29. <scroll-view :scroll-top="scrollTop" :scroll-y="isscroll" @scrolltoupper="upper" @scrolltolower="lower"
  30. @scroll="scroll" :class="{'active':isActive}" class="scroll-style">
  31. <view class="bottom-list-item" v-for="(item,index) in datalist" :key="index">
  32. <img class="left-img" :src="item.attachmentAddress" alt="">
  33. <view class="middle">
  34. <text class="title Medium">{{item.title}}</text>
  35. <text
  36. class="localtion Regular">{{item.province}}{{item.city}}{{item.area}}{{item.detailedAddress}}</text>
  37. </view>
  38. <text class="line"></text>
  39. <view class="right">
  40. <img class="right-img" src="/static/img/dizhi.png" alt="">
  41. <text class="right-bottom Regular">{{metreList[index]}}</text>
  42. </view>
  43. </view>
  44. </scroll-view>
  45. </view>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. // import amap from '@/js_sdk/js-amap/amap-wx.130.js'
  51. import * as config from '@/config'
  52. export default {
  53. data() {
  54. return {
  55. isscroll: true,
  56. scrollTop: 0,
  57. old: {
  58. scrollTop: 0
  59. },
  60. metreList: [],
  61. datalist: [],
  62. "isActive": false,
  63. position: {},
  64. nowLocation: {
  65. latitude: 39.9085,
  66. longitude: 116.39747,
  67. },
  68. showType: false,
  69. enterpriseList: [],
  70. // typeStr: '全部类型',
  71. index: 0,
  72. typeList: ['全部类型', '粮仓', '加工厂'],
  73. title: 'map',
  74. covers: [{
  75. id: 0,
  76. latitude: 39.9085,
  77. longitude: 116.39747,
  78. iconPath: '../../../static/img/location.png',
  79. }],
  80. }
  81. },
  82. onShow() {
  83. },
  84. onLoad(e) {
  85. if (Object.keys(e).length) {
  86. this.position = JSON.parse(e.position)
  87. this.nowLocation.latitude = this.position.location.split(',')[1]
  88. this.nowLocation.longitude = this.position.location.split(',')[0]
  89. //获取列表数据
  90. }
  91. this.getList()
  92. },
  93. methods: {
  94. getList(val) {
  95. this.metreList = []
  96. let detailedAddress = ""
  97. if (val) {
  98. detailedAddress = this.position.name
  99. }
  100. console.log("-----------------------")
  101. getApp().nvueRequst('get', '/settledCompanyInfo/selectSettledCompanyInfo', {
  102. pageSize: 10000,
  103. currentPage: 1,
  104. detailedAddress:detailedAddress
  105. }).then(res => {
  106. console.log('res',res)
  107. if (res.data.code == 200) {
  108. this.datalist = res.data.data.records
  109. let lat1 = this.nowLocation.latitude
  110. let lng1 = this.nowLocation.longitude
  111. for(let i = 0;i<this.datalist.length;i++){
  112. let lat2 = this.datalist[i].latitude
  113. let lng2 = this.datalist[i].longitude
  114. let _metre = this.utils.getDistance(lat1,lng1,lat2,lng2) +"千米"
  115. this.metreList.push(_metre)
  116. }
  117. }
  118. })
  119. },
  120. lineClick() {
  121. this.isActive = !this.isActive
  122. // this.isscroll = !this.isscroll
  123. },
  124. upper: function(e) {
  125. console.log(e)
  126. },
  127. lower: function(e) {
  128. console.log(e)
  129. },
  130. scroll: function(e) {
  131. console.log(e)
  132. this.old.scrollTop = e.detail.scrollTop
  133. },
  134. bindPickerChange: function(e) {
  135. console.log('picker发送选择改变,携带值为', e.target)
  136. this.index = e.detail.value
  137. },
  138. confirm() {
  139. console.log('确定')
  140. this.showType = false
  141. },
  142. cancel() {
  143. console.log('取消')
  144. this.showType = false
  145. },
  146. selectType() {
  147. this.showType = true
  148. console.log(1)
  149. },
  150. // typeConfirm(e) {
  151. // console.log(e)
  152. // this.typeStr = this.typeList[e[0]].name
  153. // },
  154. getLocation() {
  155. let that = this;
  156. // uni.getLocation({
  157. // type: 'gcj02',
  158. // geocode: true,
  159. // success: function(res) {
  160. // that.nowLocation.longitude = res.longitude
  161. // that.nowLocation.latitude = res.latitude
  162. // that.covers[0].longitude = res.longitude
  163. // that.covers[0].latitude = res.latitude
  164. // let _coverrsData = []
  165. // for (let i = 0; i < 50; i++) {
  166. // let _obj = {
  167. // id: i,
  168. // latitude: res.latitude += 0.00150,
  169. // longitude: res.longitude + 0.00150,
  170. // iconPath: '../../../static/img/location.png',
  171. // width: 30,
  172. // height: 30,
  173. // callout: {
  174. // content: '中天昊元粮库',
  175. // color: '#333333',
  176. // fontSize: 12,
  177. // borderRadius: 20,
  178. // padding: 4,
  179. // bgColor: 'white',
  180. // display: 'ALWAYS',
  181. // },
  182. // }
  183. // _coverrsData.push(_obj)
  184. // }
  185. // that.covers = _coverrsData
  186. // console.log('获取位置数据:', res);
  187. // console.log('当前位置的经度:' + res.longitude);
  188. // console.log('当前位置的纬度:' + res.latitude);
  189. // //拼接当前定位回显地址
  190. // // #ifdef APP-PLUS
  191. // let _address = res.address
  192. // that.address = _address.province + _address.city + _address.district + _address.poiName
  193. // console.log(that.address)
  194. // // #endif
  195. // }
  196. // });
  197. },
  198. markertap(e) {
  199. console.log(e)
  200. uni.showToast({
  201. title: "点击id为" + e.detail.markerId + "的坐标",
  202. icon: 'none',
  203. duration: 2000
  204. })
  205. },
  206. getLst() {
  207. console.log("加载数据")
  208. }
  209. }
  210. }
  211. </script>
  212. <style scoped>
  213. .active {
  214. height: 583rpx !important;
  215. }
  216. .header {
  217. flex-direction: row;
  218. justify-content: space-between;
  219. margin-bottom: 20rpx;
  220. padding: 20rpx;
  221. }
  222. .title {
  223. font-size: 32rpx;
  224. font-weight: 500;
  225. color: #333333;
  226. }
  227. .content {
  228. width: 750px;
  229. flex: 1;
  230. }
  231. .map {
  232. height: 1350rpx;
  233. }
  234. .content2 {
  235. position: fixed;
  236. bottom: 0;
  237. width: 750rpx;
  238. flex: 1;
  239. font-size: 34rpx;
  240. background: white;
  241. border-top-left-radius: 20rpx;
  242. border-top-right-radius: 20rpx;
  243. }
  244. .warp {
  245. /* flex-direction: row;
  246. justify-content: center; */
  247. }
  248. .header-type {
  249. font-size: 26rpx;
  250. font-weight: 400;
  251. color: #333333;
  252. }
  253. .alert {
  254. flex: 1;
  255. }
  256. .select-alert {
  257. background-color: green;
  258. position: fixed;
  259. bottom: 0;
  260. width: 750rpx;
  261. flex: 1;
  262. }
  263. .select-top {
  264. flex-direction: row;
  265. align-items: center;
  266. justify-content: space-around;
  267. background: yellow;
  268. height: 80rpx;
  269. }
  270. .select {
  271. width: 750rpx;
  272. flex: 1;
  273. flex-direction: column;
  274. justify-content: center;
  275. align-items: center;
  276. background: white;
  277. }
  278. .cancel {
  279. font-size: 24rpx;
  280. color: white;
  281. font-weight: bold;
  282. }
  283. .confirm {
  284. font-size: 24rpx;
  285. color: green;
  286. font-weight: bold;
  287. }
  288. .select-item {
  289. font-size: 24rpx;
  290. }
  291. .warp {}
  292. .bottom-list-item {
  293. flex-direction: row;
  294. justify-content: space-between;
  295. margin-bottom: 20rpx;
  296. padding-bottom: 20rpx;
  297. margin-top: 20rpx;
  298. border-bottom: 1px solid #EEEEEE;
  299. }
  300. .left {}
  301. .left-img {
  302. width: 102rpx;
  303. height: 106rpx;
  304. }
  305. .localtion {
  306. font-size: 24rpx;
  307. font-weight: 400;
  308. color: #AFB3BF;
  309. }
  310. .localtion {
  311. flex-direction: column;
  312. }
  313. .right-img {
  314. width: 21rpx;
  315. height: 26rpx;
  316. }
  317. .right {
  318. flex-direction: column;
  319. justify-content: center;
  320. align-items: center;
  321. }
  322. .middle {
  323. flex-direction: column;
  324. justify-content: center;
  325. }
  326. .warp {
  327. padding: 20rpx;
  328. }
  329. .right-bottom {
  330. font-size: 24rpx;
  331. font-weight: 400;
  332. color: #AFB3BF;
  333. }
  334. .top-line {
  335. width: 68px;
  336. height: 8px;
  337. background: #B4B7C3;
  338. border-radius: 4px;
  339. flex-direction: row;
  340. margin-bottom: 30rpx;
  341. }
  342. .line-style {
  343. flex-direction: row;
  344. justify-content: center;
  345. }
  346. .scroll-style {
  347. height: 130rpx;
  348. }
  349. </style>