factoryindex.vue 4.9 KB

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