mapLocationInfo.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. <template>
  2. <view class="">
  3. <navbar :config="config" backColor="#999999" :key="navKey"></navbar>
  4. <view class="map-location" v-if="detail">
  5. <view class="content-info">
  6. <image v-if="detail.icon" class="info-logo" :src="detail.icon" mode="scaleToFill"></image>
  7. <image v-else class="info-logo" src="@/static/map/default-icon.png" mode="scaleToFill"></image>
  8. <view class="info-text">
  9. <text class="info-name zw-one-row">
  10. {{detail.name}}
  11. </text>
  12. <view class="info-more">
  13. <view class="more-text">
  14. <view class="">
  15. <text class="info-tag">{{getTypeName(detail)}}</text>
  16. </view>
  17. <text class="info-site zw-one-row">{{getDistance(detail.distance)}}</text>
  18. <text class="info-site zw-one-row">{{detail.detailedAddress}}</text>
  19. </view>
  20. <view class="more-btn" @click.stop="toHere(detail)">
  21. <image class="toimg" src="@/static/map/location.png" mode="scaleToFill">
  22. </image>
  23. <text class="btn-text">到这里</text>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. <view class="location-details">{{detail.intro}}</view>
  29. <view class="location-function" v-if="detail.modules && detail.modules.length>0">
  30. <view class="fun-btn" v-for="(item,index) in detail.modules" :key="item.id" @click="$openPage(item)">
  31. <image class="funimg" :src="item.icon" mode="aspectFit"></image>
  32. <!-- <text class="funtxt">{{item.name}}</text> -->
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. import {
  40. getLocationIinfo
  41. } from "@/api/government.js"
  42. import {
  43. distanceCalculate
  44. } from "@/utils/tool.js"
  45. export default {
  46. data() {
  47. return {
  48. config: {
  49. back: true,
  50. title: '',
  51. color: 'black',
  52. backgroundColor: [1, '#fff'],
  53. statusBarFontColor: 'black'
  54. },
  55. defaultDetail: null,
  56. detail: null,
  57. classifyList: [],
  58. navKey: 1,
  59. keyWord: '',
  60. activeClassify: ''
  61. }
  62. },
  63. onLoad(options) {
  64. const eventChannel = this.getOpenerEventChannel();
  65. // 监听acceptDataFromOpenerPage事件,获取上一页面通过eventChannel传送到当前页面的数据
  66. eventChannel.on('MapInfo', res => {
  67. const val = res.data?.val || {};
  68. this.config.title = val?.name;
  69. this.navKey = Math.random()
  70. this.classifyList = res.data.classifyList;
  71. this.keyWord = res.data.keyWord;
  72. this.activeClassify = res.data.activeClassify;
  73. this.defaultDetail = val || null;
  74. this.getDetails();
  75. });
  76. },
  77. onPullDownRefresh() {
  78. // this.initAtPresent()
  79. this.getDetails()
  80. },
  81. methods: {
  82. getDetails() {
  83. if (!this.defaultDetail || this.defaultDetail.locationType === 'gd') {
  84. this.detail = this.defaultDetail || null;
  85. uni.stopPullDownRefresh();
  86. } else {
  87. try {
  88. getLocationIinfo(this.defaultDetail.id, this.defaultDetail.latitude, this.defaultDetail.longitude)
  89. .then(res => {
  90. this.detail = res.data || this.defaultDetail || null;
  91. if (this.detail) {
  92. this.detail.distance = this.defaultDetail.distance;
  93. }
  94. }).catch(err => {
  95. this.detail = this.defaultDetail || null;
  96. }).finally(() => {
  97. uni.stopPullDownRefresh();
  98. })
  99. } catch (e) {
  100. //TODO handle the exception
  101. uni.stopPullDownRefresh();
  102. }
  103. }
  104. },
  105. getDistance(num) {
  106. return distanceCalculate(num)
  107. },
  108. getTypeName(item) {
  109. let val = this.classifyList.find(el => el.id === item.classifyId);
  110. // console.log('----', val, this.keyWord, this.activeClassify?.name)
  111. return val?.name || this.keyWord || this.activeClassify?.name || ''
  112. // let item = this.classifyList.find(el => el.id === id);
  113. // return item.name || this.keyWord || this.activeClassify?.name || ''
  114. },
  115. toHere(item) {
  116. uni.openLocation({
  117. latitude: parseFloat(item.latitude), // 要去的地址经度,浮点数
  118. longitude: parseFloat(item.longitude), // 要去的地址纬度,浮点数
  119. name: item.name, // 位置名
  120. address: item.detailedAddress, // 要去的地址详情说明
  121. scale: 16, // 地图缩放级别,整形值,范围从1~28。默认为最大
  122. });
  123. },
  124. }
  125. }
  126. </script>
  127. <style lang="scss" scoped>
  128. .map-location {
  129. padding: 66rpx 30rpx 30rpx;
  130. }
  131. .content-info {
  132. display: flex;
  133. flex-direction: row;
  134. align-items: stretch;
  135. justify-content: space-between;
  136. .info-logo {
  137. width: 196rpx;
  138. height: 196rpx;
  139. border-radius: 20rpx;
  140. }
  141. .info-text {
  142. width: calc(100% - 196rpx);
  143. padding: 10rpx 0 10rpx 30rpx;
  144. flex-direction: column;
  145. .info-name {
  146. width: 100%;
  147. height: 52rpx;
  148. font-family: PingFang SC, PingFang SC-Bold;
  149. font-size: 36rpx;
  150. font-weight: 600;
  151. color: #1a1a1a;
  152. }
  153. .info-more {
  154. width: 100%;
  155. height: calc(100% - 52rpx);
  156. display: flex;
  157. flex-direction: row;
  158. justify-content: space-between;
  159. align-items: flex-end;
  160. .more-text {
  161. // width: 268rpx;
  162. width: calc(100% - 122rpx);
  163. height: 100%;
  164. display: flex;
  165. flex-direction: column;
  166. justify-content: space-between;
  167. padding-right: 20rpx;
  168. .info-tag {
  169. display: inline-flex;
  170. padding: 5rpx 22rpx;
  171. background: #e3fcfc;
  172. border-radius: 20rpx 0px;
  173. font-size: 24rpx;
  174. font-family: PingFang SC, PingFang SC-Regular;
  175. font-weight: 400;
  176. color: #43bdd6;
  177. }
  178. .info-site {
  179. font-size: 24rpx;
  180. font-family: PingFang SC, PingFang SC-Medium;
  181. color: #666666;
  182. }
  183. }
  184. .more-btn {
  185. width: 122rpx;
  186. height: 50rpx;
  187. // background: linear-gradient(90deg,#45c7d5 4%, #3cb7d1 93%);
  188. background-color: #45c7d5;
  189. border-radius: 25rpx;
  190. display: flex;
  191. flex-direction: row;
  192. justify-content: center;
  193. align-items: center;
  194. .toimg {
  195. width: 22rpx;
  196. height: 24rpx;
  197. }
  198. .btn-text {
  199. font-size: 24rpx;
  200. font-family: PingFang SC, PingFang SC-Regular;
  201. font-weight: 400;
  202. color: #ffffff;
  203. padding-left: 4rpx;
  204. }
  205. }
  206. }
  207. }
  208. }
  209. .location-details {
  210. font-size: 26rpx;
  211. font-weight: 300;
  212. color: #666666;
  213. padding: 20rpx 0 40rpx;
  214. border-bottom: 1px solid $zw-border-color;
  215. }
  216. .location-function {
  217. padding-top: 40rpx;
  218. display: flex;
  219. flex-direction: row;
  220. align-items: center;
  221. flex-wrap: wrap;
  222. .fun-btn {
  223. width: 210rpx;
  224. height: 77rpx;
  225. // display: flex;
  226. // flex-direction: row;
  227. // justify-content: center;
  228. align-items: center;
  229. margin-right: 30rpx;
  230. margin-bottom: 20rpx;
  231. border-radius: 20rpx;
  232. &:nth-child(3n) {
  233. margin-right: 0;
  234. }
  235. // height: 77rpx;
  236. // border-radius: 15rpx;
  237. .funimg {
  238. width: 100%;
  239. height: 100%;
  240. }
  241. .funtxt {
  242. font-size: 28rpx;
  243. margin-left: 10rpx;
  244. }
  245. // &:nth-child(3n) {
  246. // margin-right: 0;
  247. // border: 1px solid #76bcb1;
  248. // background: #e8f4f6;
  249. // .funtxt {
  250. // color: #76bcb1;
  251. // }
  252. // }
  253. // &:nth-child(3n - 1) {
  254. // border: 1px solid #3fb9d4;
  255. // background: #edfdfd;
  256. // .funtxt {
  257. // color: #3fb9d4;
  258. // }
  259. // }
  260. // &:nth-child(3n - 2) {
  261. // border: 1px solid #215dd9;
  262. // background: #e6edfa;
  263. // .funtxt {
  264. // color: #215dd9;
  265. // }
  266. // }
  267. }
  268. }
  269. </style>