index.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <template>
  2. <view class="station_item"
  3. @click="handleNavStation(item)">
  4. <view class="station_item-title">
  5. <text class="station_item-idle" v-if="item.idleParkingNum !== undefined && item.idleParkingNum !== null">空闲{{ item.idleParkingNum }}</text>
  6. <text class="station_item-name">{{ item.stationName }}</text>
  7. </view>
  8. <view class="station_item-status">
  9. <text class="station_item-status-text">{{ fmtDictName('WashStation.status', item.stationStatus) }}</text>
  10. </view>
  11. <view class="station_item-content">
  12. <view class="station_item-content-address">
  13. <uv-icon name="empty-address" size="18" color="#999999"></uv-icon>
  14. <text class="station_address">{{ item.address }}</text>
  15. <text class="station_distance" v-if="item.distance !== undefined && item.distance !== null" @click.stop="handleNavMap(item)">{{ item.distance }}km</text>
  16. </view>
  17. </view>
  18. <view class="station_item-footer">
  19. <view class="footer-info">
  20. <view class="footer-row">
  21. <uv-icon name="clock" size="14" color="#909399"></uv-icon>
  22. <text class="business_hours">营业时间: {{ item.businessHours }}</text>
  23. </view>
  24. <view class="footer-row" v-if="item.parkingFee">
  25. <text class="parking-icon">P</text>
  26. <text class="parking-fee">{{ item.parkingFee }}</text>
  27. </view>
  28. </view>
  29. <view class="footer-phone" v-if="showPhone && (item.serviceTel || item.stationTel)" @click.stop="handleCallStation">
  30. <uv-icon name="phone" size="22" color="#C6171E"></uv-icon>
  31. </view>
  32. </view>
  33. </view>
  34. </template>
  35. <script setup lang="ts" name="Station">
  36. import {fmtDictName} from "@/utils/common"
  37. const props = defineProps({
  38. item: {
  39. type: Object,
  40. },
  41. showPhone: {
  42. type: Boolean,
  43. default: false,
  44. },
  45. })
  46. const handleNavMap = (station: any) => {
  47. let location = JSON.parse(station.location)
  48. uni.openLocation({
  49. latitude: Number(location.stationLat),
  50. longitude: Number(location.stationLng),
  51. scale: 18,
  52. name: station.stationName,
  53. address: station.address,
  54. });
  55. }
  56. const handleCallStation = () => {
  57. const phone = props.item.serviceTel || props.item.stationTel;
  58. if (!phone) return;
  59. uni.showModal({
  60. title: "联系站点",
  61. content: "是否拨打站点服务电话?",
  62. confirmText: "拨打",
  63. confirmColor: "#C6171E",
  64. success: (res) => {
  65. if (res.confirm) {
  66. uni.makePhoneCall({ phoneNumber: phone });
  67. }
  68. },
  69. });
  70. };
  71. const handleNavStation = (station: any) => {
  72. let currentPages = getCurrentPages();
  73. let currentPageRoute = currentPages[currentPages.length - 1].route;
  74. if (currentPageRoute?.includes('pages-wash/station/index')) {
  75. return;
  76. }
  77. getApp<any>().globalData.last.station = station
  78. uni.navigateTo({
  79. url: '/pages-wash/station/index?id=' + station.id
  80. })
  81. }
  82. const handleNav = () => {
  83. handleNavMap(props.item);
  84. }
  85. defineExpose({
  86. handleNav
  87. })
  88. </script>
  89. <style scoped lang="scss">
  90. .station_item {
  91. display: flex;
  92. flex-direction: column;
  93. margin-top: 20rpx;
  94. padding: 24rpx;
  95. position: relative;
  96. cursor: pointer;
  97. -webkit-tap-highlight-color: transparent;
  98. @include card-interactive(16rpx, 0.08);
  99. &-title {
  100. display: flex;
  101. align-items: center;
  102. gap: 12rpx;
  103. margin-bottom: 20rpx;
  104. padding-right: 120rpx;
  105. min-width: 0;
  106. }
  107. &-idle {
  108. background: $uni-color-primary;
  109. padding: 4rpx 14rpx;
  110. color: #fff;
  111. font-size: 22rpx;
  112. font-weight: 600;
  113. border-radius: 20rpx;
  114. flex-shrink: 0;
  115. line-height: 1.5;
  116. }
  117. &-name {
  118. font-weight: $uni-font-weight-semibold;
  119. font-size: $uni-font-size-xl;
  120. color: $uni-text-color;
  121. overflow: hidden;
  122. text-overflow: ellipsis;
  123. white-space: nowrap;
  124. flex: 1;
  125. min-width: 0;
  126. }
  127. &-status {
  128. position: absolute;
  129. right: 24rpx;
  130. top: 24rpx;
  131. &-text {
  132. background: $uni-color-primary;
  133. padding: 6rpx 16rpx;
  134. color: $uni-text-color-inverse;
  135. font-size: $uni-font-size-xs;
  136. border-radius: 16rpx;
  137. }
  138. }
  139. &-content {
  140. width: 100%;
  141. margin-bottom: 16rpx;
  142. box-sizing: border-box;
  143. &-address {
  144. display: flex;
  145. align-items: center;
  146. gap: 8rpx;
  147. font-size: $uni-font-size-sm;
  148. color: $uni-text-color-secondary;
  149. line-height: $uni-line-height-sm;
  150. overflow: hidden;
  151. }
  152. }
  153. &-footer {
  154. display: flex;
  155. justify-content: space-between;
  156. align-items: center;
  157. padding-top: 16rpx;
  158. border-top: 1px solid $uni-border-color-light;
  159. .footer-info {
  160. display: flex;
  161. flex-direction: column;
  162. gap: 10rpx;
  163. flex: 1;
  164. }
  165. .footer-row {
  166. display: flex;
  167. align-items: center;
  168. gap: 8rpx;
  169. }
  170. .business_hours {
  171. font-size: $uni-font-size-sm;
  172. color: $uni-text-color-tertiary;
  173. }
  174. .footer-phone {
  175. display: flex;
  176. align-items: center;
  177. justify-content: center;
  178. width: 68rpx;
  179. height: 68rpx;
  180. background: rgba($uni-color-primary, 0.08);
  181. border-radius: 50%;
  182. flex-shrink: 0;
  183. }
  184. .parking-fee {
  185. font-size: $uni-font-size-sm;
  186. color: $uni-color-primary;
  187. font-weight: $uni-font-weight-medium;
  188. }
  189. .parking-icon {
  190. width: 28rpx;
  191. height: 28rpx;
  192. line-height: 28rpx;
  193. text-align: center;
  194. font-size: 18rpx;
  195. font-weight: $uni-font-weight-bold;
  196. color: #fff;
  197. background: $uni-color-primary;
  198. border-radius: 4rpx;
  199. flex-shrink: 0;
  200. }
  201. }
  202. }
  203. .station_address {
  204. flex: 1;
  205. overflow: hidden;
  206. text-overflow: ellipsis;
  207. white-space: nowrap;
  208. min-width: 0;
  209. }
  210. .station_distance {
  211. font-size: $uni-font-size-sm;
  212. color: $uni-color-primary;
  213. font-weight: $uni-font-weight-semibold;
  214. flex-shrink: 0;
  215. margin-left: 4rpx;
  216. &:active {
  217. opacity: 0.7;
  218. }
  219. }
  220. </style>