mapPage.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. <template>
  2. <!-- 地图 -->
  3. <view class="global">
  4. <view class="left_box" >
  5. <view class="" style="display: flex;width: 100%;height: 6%;">
  6. <view @click="backBtn" class="back">⬅返回上一级</view>
  7. <view class="left_t" @click="jia"><image class="img" src="/static/img/jia.png"></image></view>
  8. <view class="left_t" @click="jian" ><image class="img" src="/static/img/jian.png"></view>
  9. </view>
  10. <view class="jz_box_tab" style="">
  11. <view class="btm_tab" @click="cityBtn(index)" v-for="(item, index) in cityList" :key="item.id" :class="{ active2: btmtab == index }">
  12. {{ item.name }}
  13. </view>
  14. </view>
  15. <view style="width: 100%;height: 70%; ">
  16. <view class="" v-for="(item, index) in marker" :key="item.id" style="height: 8%; color: #67493c; font-size: 10px;line-height: 25px; width: 100%; display: flex;justify-content: space-around;">
  17. <view @click="markertaps(index)" style="width: 58% ;overflow: hidden;text-overflow: ellipsis; white-space: nowrap;" :class="{ active2: btmtab2 == index }">{{ item.title }} </view>
  18. <view @click="detailsBtn(item.id)" class="" style="height: 75%; border-radius: 20px; color: #ffffff; background-color: #67493c; width: 20%; text-align: center;" :class="{ active3: id == item.id }">
  19. 详情
  20. </view>
  21. </view>
  22. <view class="page_box" v-if="btmtab==1">
  23. <view class="page_size" @click="previousPage">
  24. 上一页
  25. </view>
  26. <view class="page_size" @click="nextPage">
  27. 下一页
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. <map
  33. id="map"
  34. :circles="circles"
  35. :latitude="latitude"
  36. :longitude="longitude"
  37. :markers="marker"
  38. :scale="scale"
  39. @markertap="markertap"
  40. style="width: 85%; height: 100%"
  41. >
  42. </map>
  43. </view>
  44. </template>
  45. <script>
  46. import { login } from '../../../config/api';
  47. let that;
  48. export default {
  49. data() {
  50. return {
  51. page:1,
  52. aa:0,
  53. id:'',
  54. btmtab: 0,
  55. btmtab2: 0,
  56. marker: [],
  57. circles: [],
  58. latitude: 24.511709899939145, //纬度
  59. longitude: 118.14707269879153, //经度
  60. scale: 13, //缩放级别,
  61. isRequesting: false,
  62. cityList: [
  63. {
  64. name: '闽南',
  65. id: '5'
  66. },
  67. {
  68. name: '厦门',
  69. id: '1'
  70. },
  71. {
  72. name: '漳州',
  73. id: '2'
  74. },
  75. {
  76. name: '泉州',
  77. id: '3'
  78. }
  79. ]
  80. };
  81. },
  82. onLoad(o) {
  83. that = this;
  84. this.getCity();
  85. if(o.id){
  86. this.getContentDetail(o.id)
  87. }else{
  88. this.ditu();
  89. }
  90. },
  91. methods: {
  92. getContentDetail(id){
  93. this.$api.getContentDetails({
  94. id:id,
  95. main_body_id:5
  96. },function(res){
  97. that.latitude = res.data.latitude;
  98. that.longitude = res.data.longitude;
  99. that.marker.push({
  100. id: res.data.id,
  101. latitude: parseFloat(res.data.latitude), //纬度
  102. longitude: parseFloat(res.data.longitude), //经度
  103. iconPath: '/static/img/icon_map.png', //显示的图标
  104. width: 30, //宽
  105. height: 30, //高
  106. title: res.data.title, //标注点名
  107. alpha: 0.5, //透明度,
  108. callout: {
  109. //自定义标记点上方的气泡窗口 点击有效
  110. content: res.data.title, //文本
  111. color: '#ffffff', //文字颜色
  112. fontSize: 15, //文本大小
  113. borderRadius: 15, //边框圆角
  114. padding: '10',
  115. bgColor: '#5c3c2e', //背景颜色
  116. display: 'ALWAYS' //常显
  117. },
  118. label: {
  119. //自定义标记点上方的文本
  120. content: res.data.title, //文本
  121. color: '#5c3c2e', //文字颜色
  122. fontSize: 20, //文本大小
  123. bgColor: 'rgba(0,0,0,.2)', // 背景颜色(半透明黑色)
  124. borderRadius: 10, // 边框圆角
  125. padding: [2, 2], // 内边距
  126. textAlign: 'center', // 文本对齐方式
  127. display: 'ALWAYS' // 始终显示标签
  128. }
  129. });
  130. })
  131. },
  132. cityBtn(i) {
  133. this.scale= 13,
  134. this.btmtab = i;
  135. this.page=1
  136. this.ditu(this.cityList[i].id);
  137. },
  138. previousPage(){
  139. if(this.page<=1){
  140. uni.showToast({
  141. title: '没有更多了',
  142. icon: 'error'
  143. });
  144. return;
  145. }
  146. this.aa=0
  147. this.page--
  148. this.ditu(this.cityList[this.btmtab].id);
  149. },
  150. // 未返回总数量,先写死
  151. nextPage(){
  152. this.aa = this.marker.length + this.aa
  153. if (this.aa >= 88) {
  154. uni.showToast({
  155. title: '没有更多了',
  156. icon: 'error'
  157. });
  158. return;
  159. }
  160. this.page++
  161. this.ditu(this.cityList[this.btmtab].id);
  162. },
  163. // 顶部城市
  164. getCity() {
  165. this.$api.getCity({ main_body_id: '' }, function (res) {
  166. that.cityList = res.data;
  167. // console.log(that.cityList, 'that.cityList');
  168. });
  169. },
  170. // 点击标记点时触发
  171. markertap(e) {
  172. uni.navigateTo({
  173. url: `/pages/index2/JZ_xiangQing/JZ_xiangQing?id=${e.target.markerId}`
  174. });
  175. },
  176. detailsBtn(id){
  177. this.id=id
  178. uni.navigateTo({
  179. url: '/pages/index2/JZ_xiangQing/JZ_xiangQing?id='+this.id
  180. });
  181. },
  182. // 文物列表
  183. markertaps(i) {
  184. this.btmtab2 = i;
  185. this.latitude = this.marker[i].latitude;
  186. this.longitude = this.marker[i].longitude;
  187. },
  188. jia() {
  189. this.scale++;
  190. },
  191. jian() {
  192. this.scale--;
  193. },
  194. ditu(id) {
  195. this.$api.getContentList(
  196. {
  197. model_id: '1',
  198. main_body_id: id ? id : '5',
  199. page:this.page ,
  200. pageSize: '12'
  201. },
  202. function (res) {
  203. that.marker = [];
  204. res.data.forEach((item, index) => {
  205. // console.log(item, 'itemitem');
  206. that.latitude = item.latitude;
  207. that.longitude = item.longitude;
  208. that.marker.push({
  209. id: item.id,
  210. latitude: parseFloat(item.latitude), //纬度
  211. longitude: parseFloat(item.longitude), //经度
  212. iconPath: '/static/img/icon_map.png', //显示的图标
  213. width: 30, //宽
  214. height: 30, //高
  215. title: item.title, //标注点名
  216. alpha: 0.5, //透明度,
  217. callout: {
  218. //自定义标记点上方的气泡窗口 点击有效
  219. content: item.title, //文本
  220. color: '#ffffff', //文字颜色
  221. fontSize: 15, //文本大小
  222. borderRadius: 15, //边框圆角
  223. padding: '10',
  224. bgColor: '#5c3c2e', //背景颜色
  225. display: 'ALWAYS' //常显
  226. },
  227. label: {
  228. //自定义标记点上方的文本
  229. content: item.title, //文本
  230. color: '#5c3c2e', //文字颜色
  231. fontSize: 20, //文本大小
  232. bgColor: 'rgba(0,0,0,.2)', // 背景颜色(半透明黑色)
  233. borderRadius: 10, // 边框圆角
  234. padding: [2, 2], // 内边距
  235. textAlign: 'center', // 文本对齐方式
  236. display: 'ALWAYS' // 始终显示标签
  237. }
  238. });
  239. });
  240. }
  241. );
  242. },
  243. backBtn() {
  244. uni.navigateBack({
  245. delta: 1
  246. });
  247. }
  248. }
  249. };
  250. </script>
  251. <style>
  252. .active2 {
  253. width: 480rpx;
  254. /* height: 140rpx; */
  255. color: #67493c !important;
  256. background: transparent !important;
  257. }
  258. .active3 {
  259. background: transparent !important;
  260. color: #8e6c4f !important;
  261. }
  262. /deep/.amap-logo {
  263. display: none !important;
  264. }
  265. /deep/.amap-copyright {
  266. display: none !important;
  267. }
  268. /deep/.amap-mcode {
  269. display: none !important;
  270. }
  271. .global {
  272. display: flex;
  273. width: 100%;
  274. height: 100vh;
  275. overflow: hidden;
  276. }
  277. .page_box{
  278. width: 76%;
  279. height: 20%;
  280. display: flex;
  281. justify-content: space-around;
  282. color: #ffffff;
  283. font-size: 12px;
  284. text-align: center;
  285. position: absolute;
  286. top: 85%;
  287. }.page_size{
  288. width: 30%;
  289. height: 20%;
  290. line-height: 26px;
  291. background: #5f4033;
  292. border-radius: 100px;
  293. }
  294. .left_box{
  295. position: relative;
  296. width: 17%;
  297. height: 100%;
  298. padding: 2%;
  299. background: url('https://huli-app.wenlvti.net/app_static/minnanhun/image/cb_bg.png') no-repeat;
  300. background-size: 100% 100%;
  301. }
  302. .left_t{
  303. width:20% ;
  304. height: 88%;
  305. }
  306. .img{
  307. width: 100%;
  308. height: 100%;
  309. }
  310. .jz_box_tab {
  311. position: relative;
  312. top: 2%;
  313. left: 0;
  314. width: 100%;
  315. height: 8%;
  316. display: flex;
  317. justify-content: space-around;
  318. }
  319. .btm_tab {
  320. width: 20%;
  321. height: 48%;
  322. color: #ffffff;
  323. font-size: 12px;
  324. text-align: center;
  325. line-height: 25px;
  326. border-radius: 100px;
  327. background: #5f4033;
  328. }
  329. .back {
  330. width: 63%;
  331. position: relative;
  332. z-index: 999;
  333. margin-left: 1%;
  334. margin-top: 1%;
  335. font-size: 12px;
  336. color: #5c3c2e;
  337. }
  338. </style>