mapLocationInfo.vue 7.5 KB

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