detail.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. <template>
  2. <view class="detail-container">
  3. <!-- 顶部导航栏 -->
  4. <view class="header-nav">
  5. <view class="nav-left" @click="goBack">
  6. <AppIcon name="chevron-left" size="20" color="#FFFFFF" />
  7. </view>
  8. <text class="nav-title">{{ stationName || '站点详情' }}</text>
  9. <view class="nav-right"></view>
  10. </view>
  11. <!-- 加载状态 -->
  12. <view class="loading-overlay" v-if="loading">
  13. <view class="loading-spinner"></view>
  14. <text class="loading-text">加载中...</text>
  15. </view>
  16. <!-- 站点详情 -->
  17. <view class="detail-content" v-if="!loading && detail">
  18. <!-- 站点图片 -->
  19. <view class="image-section" v-if="detail.pictures && detail.pictures.length > 0">
  20. <image
  21. v-for="(pic, index) in detail.pictures"
  22. :key="index"
  23. :src="pic"
  24. mode="aspectFill"
  25. class="station-image"
  26. @click="previewImage(pic)" />
  27. </view>
  28. <!-- 基本信息卡片 -->
  29. <view class="info-card">
  30. <text class="card-title">基本信息</text>
  31. <view class="info-list">
  32. <view class="info-item">
  33. <text class="item-label">站点ID</text>
  34. <text class="item-value">{{ detail.stationId || '-' }}</text>
  35. </view>
  36. <view class="info-item">
  37. <text class="item-label">站点名称</text>
  38. <text class="item-value">{{ detail.stationName || '-' }}</text>
  39. </view>
  40. <view class="info-item">
  41. <text class="item-label">站点状态</text>
  42. <text class="item-value status" :style="getStatusStyle(detail.stationStatus)">{{ fmtDictName('WashStation.status', detail.stationStatus) }}</text>
  43. </view>
  44. <view class="info-item">
  45. <text class="item-label">站点类型</text>
  46. <text class="item-value">{{ fmtDictName('WashStation.type', detail.stationType) }}</text>
  47. </view>
  48. <view class="info-item">
  49. <text class="item-label">地址</text>
  50. <text class="item-value">{{ detail.address || '-' }}</text>
  51. </view>
  52. <view class="info-item">
  53. <text class="item-label">服务电话</text>
  54. <text class="item-value">{{ detail.serviceTel || '-' }}</text>
  55. </view>
  56. <view class="info-item">
  57. <text class="item-label">站点电话</text>
  58. <text class="item-value">{{ detail.stationTel || '-' }}</text>
  59. </view>
  60. </view>
  61. </view>
  62. <!-- 运营信息卡片 -->
  63. <view class="info-card">
  64. <text class="card-title">运营信息</text>
  65. <view class="info-list">
  66. <view class="info-item">
  67. <text class="item-label">运营主体</text>
  68. <text class="item-value">{{ detail.operationEntity || '-' }}</text>
  69. </view>
  70. <view class="info-item">
  71. <text class="item-label">统一社会信用代码</text>
  72. <text class="item-value">{{ detail.creditCode || '-' }}</text>
  73. </view>
  74. <view class="info-item">
  75. <text class="item-label">场站联系人</text>
  76. <text class="item-value">{{ detail.contactPerson || '-' }}</text>
  77. </view>
  78. <view class="info-item">
  79. <text class="item-label">营业时间</text>
  80. <text class="item-value">{{ detail.businessHours || '-' }}</text>
  81. </view>
  82. <view class="info-item">
  83. <text class="item-label">工位数量</text>
  84. <text class="item-value">{{ detail.parkingNum || '-' }}</text>
  85. </view>
  86. <view class="info-item">
  87. <text class="item-label">停车费用</text>
  88. <text class="item-value">{{ detail.parkingFee || '-' }}</text>
  89. </view>
  90. <view class="info-item">
  91. <text class="item-label">备注</text>
  92. <text class="item-value">{{ detail.remark || '-' }}</text>
  93. </view>
  94. </view>
  95. </view>
  96. <!-- 位置信息 -->
  97. <view class="info-card" v-if="detail.stationLat || detail.stationLng">
  98. <text class="card-title">位置信息</text>
  99. <view class="info-list">
  100. <view class="info-item">
  101. <text class="item-label">经度</text>
  102. <text class="item-value">{{ detail.stationLng || '-' }}</text>
  103. </view>
  104. <view class="info-item">
  105. <text class="item-label">纬度</text>
  106. <text class="item-value">{{ detail.stationLat || '-' }}</text>
  107. </view>
  108. </view>
  109. </view>
  110. <!-- 时间信息 -->
  111. <view class="info-card">
  112. <text class="card-title">时间信息</text>
  113. <view class="info-list">
  114. <view class="info-item">
  115. <text class="item-label">创建时间</text>
  116. <text class="item-value">{{ formatTime(detail.createTime) }}</text>
  117. </view>
  118. <view class="info-item">
  119. <text class="item-label">更新时间</text>
  120. <text class="item-value">{{ formatTime(detail.updateTime) }}</text>
  121. </view>
  122. </view>
  123. </view>
  124. </view>
  125. <!-- 空状态 -->
  126. <view class="empty-state" v-if="!loading && !detail">
  127. <view class="empty-icon-wrapper"><AppIcon name="home" size="48" color="#BFBFBF" /></view>
  128. <text class="empty-text">站点信息不存在</text>
  129. </view>
  130. </view>
  131. </template>
  132. <script setup>
  133. import { ref } from 'vue'
  134. import { onLoad, onPullDownRefresh } from '@dcloudio/uni-app'
  135. import { getStationDetail } from '../../api/station.js'
  136. import { formatTime, fmtDictName, getDictColor } from '../../utils/index.js'
  137. import { loadDicts } from '../../utils/dict.js'
  138. const loading = ref(true)
  139. const detail = ref(null)
  140. const stationName = ref('')
  141. const stationId = ref('')
  142. onLoad(async (options) => {
  143. await loadDicts()
  144. const id = options.id || ''
  145. stationName.value = decodeURIComponent(options.name || '')
  146. if (id) {
  147. stationId.value = id
  148. loadDetail(id)
  149. }
  150. })
  151. // 下拉刷新:重新加载站点详情
  152. onPullDownRefresh(async () => {
  153. try {
  154. if (stationId.value) {
  155. await loadDetail(stationId.value)
  156. }
  157. } finally {
  158. uni.stopPullDownRefresh()
  159. }
  160. })
  161. const goBack = () => {
  162. uni.navigateBack()
  163. }
  164. const getStatusStyle = (status) => {
  165. const color = getDictColor('WashStation.status', status)
  166. if (color) return { color, backgroundColor: `${color}1A` }
  167. return {}
  168. }
  169. const loadDetail = async (id) => {
  170. loading.value = true
  171. try {
  172. const res = await getStationDetail(id)
  173. if (res && res.code === 200) {
  174. detail.value = res.data
  175. if (!stationName.value && res.data.stationName) {
  176. stationName.value = res.data.stationName
  177. }
  178. }
  179. } catch (error) {
  180. console.error('加载站点详情失败:', error)
  181. } finally {
  182. loading.value = false
  183. }
  184. }
  185. const previewImage = (url) => {
  186. uni.previewImage({
  187. urls: detail.value.pictures,
  188. current: url
  189. })
  190. }
  191. </script>
  192. <style scoped>
  193. .detail-container {
  194. min-height: 100vh;
  195. background-color: #F5F7FA;
  196. padding-bottom: 100rpx;
  197. }
  198. .header-nav {
  199. display: flex;
  200. align-items: center;
  201. justify-content: space-between;
  202. padding-top: calc(24rpx + var(--status-bar-height));
  203. padding-right: 30rpx;
  204. padding-bottom: 24rpx;
  205. padding-left: 30rpx;
  206. background: #C6171E;
  207. }
  208. .nav-left, .nav-right { width: 120rpx; }
  209. .back-btn { font-size: 36rpx; color: #FFFFFF; }
  210. .nav-title { font-size: 34rpx; color: #FFFFFF; font-weight: 600; }
  211. .loading-overlay {
  212. display: flex;
  213. flex-direction: column;
  214. align-items: center;
  215. justify-content: center;
  216. padding: 200rpx 0;
  217. }
  218. .loading-spinner {
  219. width: 60rpx;
  220. height: 60rpx;
  221. border: 4rpx solid #E0E0E0;
  222. border-top-color: #C6171E;
  223. border-radius: 50%;
  224. animation: spin 0.8s linear infinite;
  225. }
  226. .loading-text { font-size: 28rpx; color: #999999; margin-top: 20rpx; }
  227. .image-section {
  228. display: flex;
  229. padding: 20rpx;
  230. gap: 12rpx;
  231. overflow-x: auto;
  232. }
  233. .station-image {
  234. width: 280rpx;
  235. height: 200rpx;
  236. border-radius: 16rpx;
  237. flex-shrink: 0;
  238. }
  239. .info-card {
  240. background-color: #FFFFFF;
  241. border-radius: 20rpx;
  242. padding: 24rpx;
  243. margin: 0 20rpx 20rpx;
  244. box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.06);
  245. }
  246. .card-title {
  247. font-size: 30rpx;
  248. font-weight: 600;
  249. color: #1A1A1A;
  250. margin-bottom: 20rpx;
  251. display: block;
  252. padding-bottom: 12rpx;
  253. border-bottom: 1rpx solid #F0F0F0;
  254. }
  255. .info-list {
  256. display: flex;
  257. flex-direction: column;
  258. }
  259. .info-item {
  260. display: flex;
  261. justify-content: space-between;
  262. align-items: center;
  263. padding: 12rpx 0;
  264. border-bottom: 1rpx solid #F8F8F8;
  265. }
  266. .info-item:last-child {
  267. border-bottom: none;
  268. }
  269. .item-label {
  270. font-size: 26rpx;
  271. color: #999999;
  272. }
  273. .item-value {
  274. font-size: 26rpx;
  275. color: #1A1A1A;
  276. max-width: 400rpx;
  277. text-align: right;
  278. }
  279. .item-value.status {
  280. font-size: 22rpx;
  281. padding: 6rpx 16rpx;
  282. border-radius: 20rpx;
  283. font-weight: 500;
  284. }
  285. .empty-state {
  286. display: flex;
  287. flex-direction: column;
  288. align-items: center;
  289. padding: 200rpx 0;
  290. }
  291. .empty-icon { font-size: 120rpx; margin-bottom: 20rpx; }
  292. .empty-text { font-size: 28rpx; color: #999999; }
  293. </style>