suerprisePlus
2024-05-30 7452857e6eb0d23dbd71a29f25985ada5208f25d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<template>
  <van-floating-panel id="panel" v-model:height="height" :anchors="anchors" :content-draggable="false"
    :height-change="setPanelChange(height)">
    <div class="boxContent">
      <van-search v-model="searchTitle" placeholder="请输入搜索关键词" @focus="searchFocus" @input="setSearchInput"
        @clear="setSearchInput" @search="onSearch"> </van-search>
      <div class="boxMenu">
        <van-cell-group>
          <van-cell v-for="(item, index) in searchData" :key="index" size="large" @click="setCellItemClick(item)">
            <div class="cellItem">
              <div v-if="item.attributes.XMMC">{{ item.attributes.XMMC }}</div>
              <div v-else-if="item.attributes.SWLYMC">{{ item.attributes.SWLYMC }}</div>
              <div v-else-if="item.attributes.MC">{{ item.attributes.MC }}</div>
              <div v-else-if="item.attributes.TDQLR">{{ item.attributes.TDQLR }}</div>
              <div v-else></div>
              <div class="cellLeft">
                <sourceType :parentData="item.attributes.DL"></sourceType>
                <div class="cellMore"></div>
              </div>
            </div>
          </van-cell>
        </van-cell-group>
      </div>
      <!-- <template #action>
        <div class="searchButton"
             @click="onClickButton">搜索</div>
      </template> -->
    </div>
  </van-floating-panel>
</template>
 
<script setup>
import { ref, reactive, onMounted, computed, shallowRef, watch } from 'vue';
import { getJsonData } from '../api/api.js';
import { useStore } from 'vuex';
import mapData from '../assets/js/mapData';
import mapMenu from '../assets/js/mapMenu.js';
import sourceType from './sourceType.vue';
import mapLayer from '../assets/js/mapLayer.js';
import { showToast } from 'vant';
const store = useStore();
const searchData = ref([]);
const searchTitle = ref('');
const devceType = ref(false);
const anchors = [90, Math.round(0.5 * window.innerHeight), window.innerHeight - 150];
const height = ref(anchors[0]);
// 监听键盘是否显示
const keyboard = ref(true);
const setSearchDataRest = () => {
  height.value = anchors[0];
  searchTitle.value = '';
  searchData.value = mapData.searchData;
  store.state.setSearchData = false;
};
const setSearchInput = e => {
  var val = e.target.value;
  if (keyboard.value) {
    height.value = 320;
  }
  if (val) {
    const obj = mapData.setSearchFliter(val);
    if (obj.length > 0) {
      searchData.value = obj;
    }
  } else {
    height.value = anchors[0];
    searchData.value = mapData.searchData;
  }
};
const setPanelChange = res => {
  // 手机虚拟键盘显示高度控制
  if (keyboard.value) {
    if (height.value > 320) {
      height.value = 320;
    }
  }
};
const setCellItemClick = res => {
  store.state.setCellItem = res;
  const obj = res.geometry;
  const judgeMentData = mapData.setJudgmentData(obj);
  if (judgeMentData) {
    mapData.setMqpJump({
      x: obj.coordinates[0],
      y: obj.coordinates[1]
    });
    mapLayer.getlocationEntity(res);
  } else {
 
    showToast('该资产缺少坐标!');
  }
  mapMenu.setMenuChange('details');
};
watch(
  () => store.state.setSearchData,
  (nVal, oVal) => {
    if (nVal) {
      setSearchDataRest();
    }
  }
);
const setKeyboardChange = res => {
  keyboard.value = res;
};
const setKeyBoardStart = () => {
  keyboard.value = false;
  var winHeight = $(window).height(); //获取当前页面高度
  $(window).resize(function () {
    var thisHeight = $(window).height();
    if (winHeight - thisHeight > 140) {
      //键盘弹出
      setKeyboardChange(true);
    } else {
      //键盘收起
      setKeyboardChange(false);
    }
  });
};
onMounted(() => {
  keyboard.value = false;
  const userAgent = window.navigator.userAgent;
  const isAndroid = /Android/.test(userAgent);
  devceType.value = isAndroid ? true : false;
  setKeyBoardStart();
  setSearchDataRest();
});
</script>
 
<style scoped lang="less">
.searchButton {
  color: rgba(53, 77, 110, 1);
}
 
.boxContent {
  width: 100%;
  height: 100%;
 
  display: flex;
  flex-direction: column;
}
 
.boxMenu {
  flex: 1;
  overflow: auto;
}
 
.cellItem {
  width: 100%;
  display: flex;
  justify-content: space-between;
  color: rgba(0, 0, 0, 1);
  text-align: left;
 
  .cellMore {
    width: 21px;
    height: 21px;
    background: url('../assets/img/more.png') no-repeat;
    background-size: 100% 100%;
  }
 
  .cellLeft {
    display: flex;
    align-items: center;
  }
}
</style>