index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <template>
  2. <view class="map-page">
  3. <view class="map-view" id="ol-map-view"></view>
  4. <!-- 以下view只是为了向视图层传参 start-->
  5. <!-- openlayers的弹窗,由于只能传dom,所以单独写一个 -->
  6. <view class="ol-popup" id="ol-popup-box" v-show="markerPopInfo.dataList">
  7. <view class="pop-header">
  8. <view class="title">
  9. {{ markerPopInfo.title }}
  10. </view>
  11. <view class="close" @tap="closeOlPopUp"></view>
  12. </view>
  13. <view class="pop-body" @tap="handleLookPop">
  14. <view class="info-item" v-for="(item, index) in markerPopInfo.dataList" :key="index">
  15. <view class="item-label">
  16. {{ item.indexName }}
  17. </view>
  18. <view class="item-value" :class="{'warn-value':item.indexStatus==='1'}">
  19. {{ item.indexValue }}{{ item.indexUnit }}
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. import moment from 'moment';
  28. import {wgs84togcj02} from '@/utils/coordTransform.js'
  29. export default {
  30. data() {
  31. return {
  32. // 弹窗需要的数据
  33. markerPopInfo: {}, //设备弹窗信息
  34. }
  35. },
  36. methods: {
  37. //给renderJS调用的方法
  38. methodForRenderJs: async function(val) {
  39. console.log('我是逻辑层,被视图层调用了,并且收到参数:')
  40. console.log(val)
  41. if (val.type === 'startInitMap') {
  42. uni.showLoading({
  43. title: '加载中...'
  44. })
  45. }
  46. // 地图初始化完成,生成设备点位
  47. if (val.type === 'initMap') {
  48. uni.hideLoading()
  49. }
  50. },
  51. closeOlPopUp(){
  52. },
  53. handleLookPop(){
  54. },
  55. address: function(item) {
  56. console.log(item)
  57. let latitude = parseFloat(parseFloat(item.coordiateY).toFixed(6))
  58. let longitude = parseFloat(parseFloat(item.coordiateX).toFixed(6))
  59. let amapEnd = wgs84togcj02(longitude, latitude)
  60. if (plus.os.name == 'Android') {
  61. let Intent = plus.android.importClass('android.content.Intent');
  62. let intent = new Intent();
  63. intent.setAction(Intent.ACTION_VIEW);
  64. intent.addCategory(Intent.CATEGORY_DEFAULT);
  65. let Uri = plus.android.importClass("android.net.Uri");
  66. //将功能Scheme以URI的方式传入data
  67. let uri = Uri.parse(`androidamap://navi?sourceApplication=武都监测&lat=${amapEnd[1]}&lon=${amapEnd[0]}&dev=0`);
  68. intent.setData(uri);
  69. intent.setPackage("com.autonavi.minimap");
  70. var main = plus.android.runtimeMainActivity();
  71. main.startActivity(intent);
  72. }else{
  73. console.log("环境不对,无法导航")
  74. }
  75. }
  76. }
  77. }
  78. </script>
  79. <script lang="renderjs" module="MapRender">
  80. import {
  81. olRenderJs
  82. } from './olRender.js';
  83. export default {
  84. mixins: [olRenderJs]
  85. }
  86. </script>
  87. <style lang="scss" scoped>
  88. .map-page {
  89. height: calc(100vh - var(--window-top) - var(--window-bottom));
  90. .map-view {
  91. width: 100%;
  92. height: 100%;
  93. position: relative;
  94. overflow: hidden;
  95. }
  96. .ol-popup {
  97. position: absolute;
  98. top: 0;
  99. left: -240rpx;
  100. width: 480rpx;
  101. height: auto;
  102. background-color: #ffffff;
  103. border-radius: 4rpx;
  104. padding: 4rpx;
  105. .pop-header {
  106. padding: 10rpx 0;
  107. display: flex;
  108. align-items: center;
  109. .sb-status {
  110. margin-left: 20rpx;
  111. width: 76rpx;
  112. height: 40rpx;
  113. border-radius: 4rpx;
  114. background: #E92B2B;
  115. font-size: 20rpx;
  116. font-family: Source Han Sans;
  117. line-height: 40rpx;
  118. font-weight: bold;
  119. text-align: center;
  120. color: #FFFFFF;
  121. }
  122. .normal {
  123. background: #05B244;
  124. }
  125. .out-line {
  126. background: #666666;
  127. }
  128. .title {
  129. margin-left: 20rpx;
  130. // padding: 10rpx 0;
  131. height: 40rpx;
  132. line-height: 40rpx;
  133. width: 100%;
  134. // text-align: center;
  135. font-family: 思源黑体;
  136. font-size: 28rpx;
  137. color: rgba(0, 0, 0, 0.85);
  138. }
  139. .close {
  140. position: absolute;
  141. width: 30rpx;
  142. height: 30rpx;
  143. background: url('../../static/images/components/close.png') no-repeat;
  144. background-size: 100% 100%;
  145. top: 12rpx;
  146. right: 20rpx;
  147. }
  148. }
  149. .pop-body {
  150. max-height: 400rpx;
  151. padding: 10rpx 20rpx;
  152. overflow: auto;
  153. .info-item {
  154. padding: 10rpx 0;
  155. display: flex;
  156. justify-content: space-between;
  157. &:first-child {
  158. padding: 0 0 10rpx;
  159. }
  160. .item-label {
  161. width: 200rpx;
  162. overflow: hidden;
  163. text-overflow: ellipsis;
  164. white-space: nowrap;
  165. font-family: 思源黑体;
  166. font-size: 24rpx;
  167. color: #999999;
  168. }
  169. .item-value {
  170. font-family: 思源黑体;
  171. font-size: 24rpx;
  172. color: #333333;
  173. }
  174. }
  175. }
  176. .pop-fun {
  177. display: flex;
  178. justify-content: flex-end;
  179. padding: 10rpx;
  180. .btn {
  181. width: 100rpx;
  182. height: 40rpx;
  183. background-color: #ffffff;
  184. box-sizing: border-box;
  185. line-height: 40rpx;
  186. text-align: center;
  187. color: #2d74e7;
  188. }
  189. }
  190. }
  191. }
  192. </style>