factoryindex7 - 副本.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <template>
  2. <view class="page">
  3. <!-- 1. 顶部标题 -->
  4. <view class="header">
  5. <text class="title">{{title}}</text>
  6. <!-- 新增地图按钮 -->
  7. <!-- <image
  8. class="map-btn"
  9. src="/static/img/map.png"
  10. mode="aspectFit"
  11. @tap="goMap"
  12. /> -->
  13. </view>
  14. <!-- 2. 轮播图 -->
  15. <swiper
  16. class="swiper"
  17. circular
  18. :indicator-dots="true"
  19. :autoplay="true"
  20. :interval="3000"
  21. :duration="800"
  22. >
  23. <swiper-item v-for="(item, index) in picture" :key="index">
  24. <image :src="item" class="swiper-item" mode="aspectFill" />
  25. </swiper-item>
  26. </swiper>
  27. <view style="display: flex;width: 100%;flex-direction:row-reverse;background: white;">
  28. <text class="title2" @tap="goMap">地图</text>
  29. <text class="title2" @tap="goMap2">板块</text>
  30. </view>
  31. <!-- 3. 九宫格导航 -->
  32. <view class="grid-box">
  33. <view
  34. v-for="(item,index) in parkList2"
  35. :key="index"
  36. class="grid-card"
  37. @tap="goListByValue(item.label)"
  38. >
  39. <!-- 上:名称 -->
  40. <text class="grid-label">{{item.building_cnt}}</text>
  41. <!-- 下:数量 -->
  42. <text class="grid-num">{{item.label}}</text>
  43. </view>
  44. </view>
  45. <!-- 地图已注释,如需恢复直接放开即可 -->
  46. <!--
  47. <view class="map-box">
  48. <view @touchend="onTouchEnd" class="map-wrap">
  49. <canvas canvas-id="ydChart" id="ydChart" class="map-canvas" />
  50. </view>
  51. </view>
  52. -->
  53. </view>
  54. </template>
  55. <script>
  56. // import * as echarts from 'echarts' // 如不用地图可注释
  57. import loginService from "@/api/auth/loginService";
  58. export default {
  59. data() {
  60. return {
  61. title: '盐都区可入驻厂房分布图',
  62. picture: [
  63. 'https://ydwqfw.com.cn/yd_qycpfbH5/bg1.jpg',
  64. 'https://ydwqfw.com.cn/yd_qycpfbH5/bg2.jpg',
  65. 'https://ydwqfw.com.cn/yd_qycpfbH5/bg3.jpg',
  66. 'https://ydwqfw.com.cn/yd_qycpfbH5/bg4.jpg'
  67. ],
  68. parkList2: []
  69. }
  70. },
  71. /* 地图相关生命周期,如不用可全部注释
  72. async onReady() {
  73. const json = await this.loadGeoJSON()
  74. echarts.registerMap('yanduqu', json)
  75. ...
  76. },
  77. methods: {
  78. loadGeoJSON() { ... },
  79. onTouchEnd(e) { ... },
  80. renderMap() { ... }
  81. }
  82. */
  83. onShow() {
  84. loginService.getIndustryList().then(({
  85. data
  86. }) => {
  87. let alls=0;
  88. for(var i = 0; i < data.length; i++){
  89. alls=alls+data[i].building_cnt;
  90. }
  91. this.allcount=alls;
  92. this.parkList2=data;
  93. // this.parkList2.unshift({total_area: 0, total_idle_area: 0, building_cnt: alls, label: "全部"})
  94. }).catch(e => {
  95. })
  96. },
  97. methods: {
  98. // 九宫格跳转
  99. goListByValue(val) {
  100. uni.navigateTo({
  101. url: `/pages/factoryBuildings/factoryBuildingsList?parkid=${val}`
  102. })
  103. },
  104. goMap() {
  105. uni.navigateTo({
  106. url: `/pages/index/factoryindex4` // 换成你的地图页面路径
  107. })
  108. },
  109. goMap2() {
  110. uni.navigateTo({
  111. url: `/pages/index/factoryindex` // 换成你的地图页面路径
  112. })
  113. },
  114. }
  115. }
  116. </script>
  117. <style scoped>
  118. .page {
  119. display: flex;
  120. flex-direction: column;
  121. min-height: 100vh;
  122. background: #f5f5f5;
  123. }
  124. /* 顶部标题 */
  125. .header {
  126. position: relative; /* 让子元素绝对定位参照它 */
  127. padding: 20rpx 0;
  128. text-align: center;
  129. background: #fff;
  130. }
  131. .title {
  132. font-size: 36rpx;
  133. font-weight: bold;
  134. color: #333;
  135. }
  136. /* 右上角地图按钮 */
  137. .map-btn {
  138. position: absolute;
  139. right: 30rpx;
  140. top: 50%;
  141. transform: translateY(-50%);
  142. width: 48rpx;
  143. height: 48rpx;
  144. }
  145. /* 轮播图 */
  146. .swiper {
  147. width: 100%;
  148. height: 300rpx;
  149. }
  150. .swiper-item {
  151. width: 100%;
  152. height: 100%;
  153. }
  154. /* 九宫格区域 */
  155. .grid-box {
  156. width: 100%;
  157. padding: 30rpx;
  158. box-sizing: border-box;
  159. display: grid;
  160. grid-template-columns: repeat(4, 1fr);
  161. gap: 24rpx;
  162. background: #fff;
  163. }
  164. .grid-num {
  165. margin-top: 8rpx;
  166. font-size: 24rpx;
  167. height: 70rpx;
  168. display: flex;
  169. align-items: center;
  170. color: rgba(0, 0, 0, 0.8);
  171. }
  172. .grid-card {
  173. display: flex;
  174. align-items: center;
  175. justify-content: center;
  176. height: 160rpx;
  177. border-radius: 16rpx;
  178. transition: transform 0.15s;
  179. flex-direction: column;
  180. }
  181. .grid-card:active {
  182. transform: scale(0.96);
  183. }
  184. .grid-label {
  185. font-size: 30rpx;
  186. font-weight: 600;
  187. padding-left: 8rpx;
  188. padding-right: 8rpx;
  189. text-align: center;
  190. color: #00aaff;
  191. }
  192. .title2{
  193. background: #1296db;
  194. border-radius: 15rpx;
  195. color: white;
  196. margin-top: 8rpx;
  197. margin-right: 30rpx;
  198. padding-top: 8rpx;
  199. padding-bottom: 8rpx;
  200. padding-right: 40rpx;
  201. padding-left: 40rpx;
  202. }
  203. </style>