diTu.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <template>
  2. <view class="box">
  3. <u-navbar :autoBack="true" title="文物地图" bgColor="rgba(255,255,255,0)" :placeholder="true" titleStyle="font-weight:bold;color:#000000"></u-navbar>
  4. <view class="fiex_top">
  5. <view class="top_box">
  6. <view @click="showqy = true" class="tit_box">
  7. <view class="">{{ qyVal ? qyVal : '区域' }}</view>
  8. <view class="">
  9. <image style="width: 40rpx; height: 40rpx" src="/static/img/map_more.png"></image>
  10. </view>
  11. </view>
  12. <view class="tit_box" @click="showlx = true">
  13. <view class="">{{ lxVal ? lxVal : '类型' }}</view>
  14. <view class="">
  15. <image style="width: 40rpx; height: 40rpx" src="/static/img/map_more.png"></image>
  16. </view>
  17. </view>
  18. <view class="tit_box" @click="showjb = true">
  19. <view class="">{{ jbVal ? jbVal : '级别' }}</view>
  20. <view class="">
  21. <image style="width: 40rpx; height: 40rpx" src="/static/img/map_more.png"></image>
  22. </view>
  23. </view>
  24. </view>
  25. <view class="" style="border: 1px solid #eba869; width: 670rpx; margin: auto; margin-top: 32rpx">
  26. <u-search
  27. bgColor="transparent"
  28. v-model="value"
  29. shape="square"
  30. :showAction="true"
  31. actionText="搜索"
  32. @custom="searchBtn"
  33. :actionStyle="{ color: '#985741', fontSize: '28rpx', fontWeight: 'bold', backgroundColor: '#fff9e9' }"
  34. ></u-search>
  35. </view>
  36. </view>
  37. <!-- 选择 -->
  38. <!-- 选择 -->
  39. <u-picker keyName="title" :show="showqy" @cancel="showqy = false" :columns="columnsQy" @close="close" :closeOnClickOverlay="true" @confirm="qyBtn"></u-picker>
  40. <u-picker keyName="title" :show="showlx" @cancel="showlx = false" :columns="columnsLx" @close="close" :closeOnClickOverlay="true" @confirm="lxBtn"></u-picker>
  41. <u-picker keyName="title" :show="showjb" @cancel="showjb = false" :columns="columnsJb" @close="close" :closeOnClickOverlay="true" @confirm="jbBtn"></u-picker>
  42. <!-- 地图 -->
  43. <view class="map_box">
  44. <mapComponent :markers="markers" :height="height" :latitudeAndLongitude="latitudeAndLongitude"></mapComponent>
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. let that;
  50. export default {
  51. data() {
  52. return {
  53. lon: '',
  54. lat: '',
  55. pageSize: 1000,
  56. value: '',
  57. latitudeAndLongitude: {
  58. latitude: '24.46947',
  59. longitude: '118.13673'
  60. },
  61. height: '1360',
  62. showqy: false,
  63. showlx: false,
  64. showjb: false,
  65. levelId: '',
  66. cr_typeId: '',
  67. regionId: '',
  68. qyVal: '',
  69. lxVal: '',
  70. jbVal: '',
  71. columnsQy: [],
  72. columnsLx: [],
  73. columnsJb: [],
  74. markers: []
  75. };
  76. },
  77. onLoad(o) {
  78. that = this;
  79. this.getCulturalRelicCategory();
  80. // 附近文物
  81. if (o.pageSize && o.longitude) {
  82. this.pageSize = o.pageSize;
  83. this.lon = o.longitude;
  84. this.lat = o.latitude;
  85. }
  86. this.getContentList(o);
  87. },
  88. methods: {
  89. // 文物分类列表
  90. getCulturalRelicCategory() {
  91. this.$api.getCulturalRelicCategory({ main_body_id: 1 }, function (res) {
  92. // console.log(res, 565656);
  93. that.columnsQy = [res.data.region_list];
  94. that.columnsLx = [res.data.cr_type_list];
  95. that.columnsJb = [res.data.level_list];
  96. });
  97. },
  98. getContentList(o) {
  99. this.$api.getContentList(
  100. {
  101. model_id: '1',
  102. main_body_id: '1',
  103. page: 1,
  104. pageSize: this.pageSize,
  105. level: this.levelId,
  106. cr_type: this.cr_typeId,
  107. region: this.regionId,
  108. keywords: this.value,
  109. longitude: this.lon,
  110. latitude: this.lat
  111. },
  112. function (res) {
  113. that.markers = [];
  114. // that.latitudeAndLongitude.latitude = res.data[0].latitude;
  115. // that.latitudeAndLongitude.longitude = res.data[0].longitude;
  116. res.data.forEach((item, index) => {
  117. that.markers.push({
  118. id: parseFloat(item.id),
  119. latitude: parseFloat(item.latitude), //纬度
  120. longitude: parseFloat(item.longitude), //经度
  121. iconPath: item.thumbnail, //显示的图标
  122. width: 30, //宽
  123. height: 30, //高
  124. title: item.title, //标注点名
  125. label: {
  126. //自定义标记点上方的文本
  127. content: item.title, //文本
  128. color: '#444444', //文字颜色
  129. fontSize: 14, //文本大小
  130. bgColor: '#f1cdb2', // 背景颜色(半透明黑色)
  131. borderRadius: 5, // 边框圆角
  132. padding: [2, 2], // 内边距
  133. textAlign: 'center', // 文本对齐方式
  134. display: 'ALWAYS' // 始终显示标签
  135. },
  136. joinCluster: true
  137. });
  138. });
  139. // 数据处理完毕,隐藏加载提示
  140. // uni.hideLoading();
  141. }
  142. );
  143. },
  144. lxBtn(e) {
  145. // console.log(e, 'eeeeeee');
  146. this.lxVal = e.value[0].title;
  147. this.showlx = false;
  148. this.markers = [];
  149. // this.page = 1;
  150. this.cr_typeId = e.value[0].id;
  151. this.getContentList();
  152. },
  153. qyBtn(e) {
  154. this.qyVal = e.value[0].title;
  155. this.showqy = false;
  156. this.markers = [];
  157. // this.page = 1;
  158. this.regionId = e.value[0].id;
  159. this.getContentList();
  160. },
  161. jbBtn(e) {
  162. this.jbVal = e.value[0].title;
  163. this.showjb = false;
  164. this.markers = [];
  165. // this.page = 1;
  166. this.levelId = e.value[0].id;
  167. this.getContentList();
  168. },
  169. searchBtn() {
  170. this.qyVal = '';
  171. this.lxVal = '';
  172. this.jbVal = '';
  173. this.levelId = '';
  174. this.cr_typeId = '';
  175. this.regionId = '';
  176. this.page = 1;
  177. this.getContentList();
  178. },
  179. close() {
  180. this.showqy = false;
  181. this.showlx = false;
  182. this.showjb = false;
  183. }
  184. }
  185. };
  186. </script>
  187. <style>
  188. .box {
  189. height: 100%;
  190. }
  191. page {
  192. height: 100%;
  193. width: 100%;
  194. background-color: #fff9e9;
  195. }
  196. .top_box {
  197. display: flex;
  198. width: 90%;
  199. margin: auto;
  200. justify-content: space-between;
  201. }
  202. .tit_box {
  203. display: flex;
  204. align-items: center;
  205. text-align: center;
  206. width: 197rpx;
  207. height: 56rpx;
  208. justify-content: space-around;
  209. border: 2rpx solid #eba869;
  210. }
  211. .map_box {
  212. width: 100%;
  213. height: 1110rpx;
  214. margin: auto;
  215. margin-top: 20rpx;
  216. /* overflow: hidden; */
  217. background: #fcfdfd;
  218. border-radius: 0rpx 0rpx 0rpx 0rpx;
  219. }
  220. .u-search__action--active.data-v-0a306a29 {
  221. height: 60rpx !important;
  222. line-height: 60rpx !important;
  223. }
  224. .u-search__action--active.data-v-2d141374 {
  225. height: 60rpx !important;
  226. line-height: 60rpx !important;
  227. }
  228. </style>