index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  1. <template>
  2. <view class="page-container">
  3. <uv-navbar title="门店详情" bgColor="#C6171E" leftIconColor="#FFFFFF" :titleStyle="{ color: '#FFFFFF' }" :autoBack="true" :placeholder="true"></uv-navbar>
  4. <!-- 内容区域 -->
  5. <scroll-view class="content-scroll" scroll-y="true">
  6. <!-- 轮播图 -->
  7. <view class="swiper-wrapper" v-if="swiperImages.length">
  8. <swiper
  9. class="station-swiper"
  10. indicator-dots
  11. indicator-color="rgba(255, 255, 255, 0.5)"
  12. indicator-active-color="#C6171E"
  13. autoplay
  14. circular
  15. >
  16. <swiper-item v-for="(img, index) in swiperImages" :key="index">
  17. <image :src="img" mode="aspectFill" class="swiper-image"></image>
  18. </swiper-item>
  19. </swiper>
  20. </view>
  21. <!-- 站点信息 -->
  22. <view class="station-section">
  23. <WashStation :item="state.station" ref="station_ref"></WashStation>
  24. </view>
  25. <!-- 设备列表 -->
  26. <view class="device-section">
  27. <view class="section-header">
  28. <view class="header-dot"></view>
  29. <text class="header-title">可用设备</text>
  30. <text class="header-count" v-if="state.deviceList.length">{{ state.deviceList.length }}台</text>
  31. </view>
  32. <!-- 加载中 -->
  33. <view class="status-wrapper" v-if="deviceLoading">
  34. <uv-loading-icon mode="spinner" size="32" color="#C6171E" text="加载设备中..." textSize="13"></uv-loading-icon>
  35. </view>
  36. <!-- 空状态 -->
  37. <view class="status-wrapper" v-else-if="!state.deviceList.length">
  38. <uv-empty mode="data" text="暂无可用设备" :marginTop="60"></uv-empty>
  39. </view>
  40. <!-- 设备列表 -->
  41. <view class="device-list" v-else>
  42. <view
  43. class="device-card"
  44. v-for="device in state.deviceList"
  45. :key="device.id"
  46. @click="handleClickDevice(device)"
  47. >
  48. <view class="device-header">
  49. <view class="device-name">
  50. <uv-icon name="car" size="18" color="#C6171E"></uv-icon>
  51. <text>{{ device.seqName }}</text>
  52. </view>
  53. <view class="device-status" :class="'status-' + getDeviceStatusClass(device.state)">
  54. {{ fmtDictName('WashDevice.state', device.state) }}
  55. </view>
  56. </view>
  57. <view class="device-info">
  58. <view class="info-row">
  59. <text class="info-label">设备编号</text>
  60. <text class="info-value">{{ device.shortId }}</text>
  61. </view>
  62. </view>
  63. <view class="device-functions" v-if="device.functionList && device.functionList.length">
  64. <view class="function-tag" v-for="(f, i) in device.functionList" :key="i">{{ f }}</view>
  65. </view>
  66. <view class="device-action">
  67. <uv-icon name="arrow-right" size="14" color="#C0C4CC"></uv-icon>
  68. <text>点击选择此设备</text>
  69. </view>
  70. </view>
  71. </view>
  72. </view>
  73. <view class="bottom-spacer"></view>
  74. </scroll-view>
  75. <!-- 底部操作栏 -->
  76. <view class="bottom-bar">
  77. <view class="bottom-buttons">
  78. <view class="btn-nav">
  79. <uv-button
  80. shape="circle"
  81. type="info"
  82. text="门店导航"
  83. @click="handleNavStation"
  84. icon="map"
  85. ></uv-button>
  86. </view>
  87. <view class="btn-scan">
  88. <uv-button
  89. shape="circle"
  90. type="primary"
  91. icon="scan"
  92. iconColor="#FFFFFF"
  93. color="#C6171E"
  94. text="扫码洗车"
  95. @click="handleClickScan"
  96. ></uv-button>
  97. </view>
  98. </view>
  99. </view>
  100. </view>
  101. </template>
  102. <script setup lang="ts">
  103. import { computed, reactive, ref } from "vue";
  104. import { onLoad } from "@dcloudio/uni-app";
  105. import { get } from "@/utils/https";
  106. import { fmtDictName } from "@/utils/common";
  107. import WashStation from "@/components/station/index.vue";
  108. const station_ref = ref();
  109. const deviceLoading = ref(false);
  110. const initState = () => ({
  111. deviceList: [] as any[],
  112. station: {} as any,
  113. currentUserId: 0,
  114. });
  115. const state = reactive(initState());
  116. // 安全解析轮播图片列表
  117. const swiperImages = computed(() => {
  118. const pictures = state.station.pictures;
  119. if (!pictures) return [];
  120. return pictures.split("|").filter(Boolean);
  121. });
  122. onLoad((options: any) => {
  123. const id = options?.id;
  124. const cached = getApp<any>().globalData.last?.station;
  125. if (cached && String(cached.id) === String(id)) {
  126. state.station = cached;
  127. } else if (id) {
  128. state.station.id = id;
  129. }
  130. loadStationDeviceList();
  131. });
  132. const handleClickScan = () => {
  133. uni.navigateTo({ url: "/pages-wash/scan/index" });
  134. };
  135. const loadStationDeviceList = () => {
  136. const stationId = state.station.stationId || state.station.id;
  137. if (!stationId) return;
  138. deviceLoading.value = true;
  139. get("/wash-device/listWashDevice", { stationId })
  140. .then((deviceList: any) => {
  141. deviceList.forEach((item: any) => {
  142. item.functionList = item.functions ? item.functions.split("|") : [];
  143. });
  144. state.deviceList = deviceList;
  145. })
  146. .catch(() => {
  147. uni.showToast({ title: "加载失败,下拉重试", icon: "none" });
  148. })
  149. .finally(() => {
  150. deviceLoading.value = false;
  151. });
  152. };
  153. const handleNavStation = () => {
  154. station_ref.value?.handleNav();
  155. };
  156. const handleClickDevice = (device: any) => {
  157. if (device.currentUserId && device.currentUserId !== state.currentUserId) {
  158. uni.showToast({ title: "设备已被他人占用", icon: "none" });
  159. return;
  160. }
  161. getApp<any>().globalData.last.device = device;
  162. uni.navigateTo({
  163. url:
  164. "/pages-wash/device/index?shortId=" +
  165. device.shortId +
  166. "&stationId=" +
  167. device.stationId,
  168. });
  169. };
  170. const getDeviceStatusClass = (stateVal: string) => {
  171. switch (stateVal) {
  172. case "idle":
  173. return "success";
  174. case "working":
  175. case "busy":
  176. return "warning";
  177. case "fault":
  178. case "error":
  179. return "error";
  180. default:
  181. return "success";
  182. }
  183. };
  184. </script>
  185. <style lang="scss" scoped>
  186. .page-container {
  187. width: 100vw;
  188. height: 100vh;
  189. background: $uni-bg-color-page;
  190. display: flex;
  191. flex-direction: column;
  192. position: relative;
  193. }
  194. .content-scroll {
  195. flex: 1;
  196. width: 100%;
  197. box-sizing: border-box;
  198. }
  199. // 轮播图
  200. .swiper-wrapper {
  201. padding: 16rpx 30rpx 24rpx;
  202. .station-swiper {
  203. height: 360rpx;
  204. border-radius: 24rpx;
  205. overflow: hidden;
  206. }
  207. .swiper-image {
  208. width: 100%;
  209. height: 100%;
  210. display: block;
  211. }
  212. }
  213. // 站点信息 — 组件自带卡片样式,这里只做外边距
  214. .station-section {
  215. margin: 0 30rpx 24rpx;
  216. }
  217. // 设备区域
  218. .device-section {
  219. margin: 0 30rpx;
  220. .section-header {
  221. display: flex;
  222. align-items: center;
  223. gap: 12rpx;
  224. margin-bottom: 24rpx;
  225. padding: 0 8rpx;
  226. .header-dot {
  227. width: 10rpx;
  228. height: 10rpx;
  229. background: $uni-color-primary;
  230. border-radius: 50%;
  231. flex-shrink: 0;
  232. }
  233. .header-title {
  234. font-size: 30rpx;
  235. font-weight: $uni-font-weight-semibold;
  236. color: $uni-text-color-dark;
  237. flex: 1;
  238. }
  239. .header-count {
  240. font-size: 24rpx;
  241. color: $uni-text-color-hint;
  242. background: $uni-bg-color-page;
  243. padding: 6rpx 16rpx;
  244. border-radius: 12rpx;
  245. }
  246. }
  247. }
  248. .status-wrapper {
  249. display: flex;
  250. align-items: center;
  251. justify-content: center;
  252. padding: 80rpx 0;
  253. }
  254. // 设备卡片
  255. .device-list {
  256. .device-card {
  257. padding: 28rpx;
  258. margin-bottom: 20rpx;
  259. @include card-interactive(24rpx);
  260. .device-header {
  261. display: flex;
  262. justify-content: space-between;
  263. align-items: center;
  264. margin-bottom: 20rpx;
  265. .device-name {
  266. display: flex;
  267. align-items: center;
  268. gap: 8rpx;
  269. font-size: 28rpx;
  270. font-weight: $uni-font-weight-semibold;
  271. color: $uni-text-color-dark;
  272. }
  273. .device-status {
  274. font-size: 22rpx;
  275. padding: 6rpx 16rpx;
  276. border-radius: 20rpx;
  277. font-weight: $uni-font-weight-medium;
  278. &.status-success {
  279. background: rgba($uni-color-success, 0.1);
  280. color: $uni-color-success;
  281. }
  282. &.status-warning {
  283. background: rgba($uni-color-warning, 0.1);
  284. color: $uni-color-warning;
  285. }
  286. &.status-error {
  287. background: rgba($uni-color-error, 0.1);
  288. color: $uni-color-error;
  289. }
  290. }
  291. }
  292. .device-info {
  293. padding: 16rpx 0;
  294. border-top: 1rpx solid $uni-border-color-light;
  295. border-bottom: 1rpx solid $uni-border-color-light;
  296. .info-row {
  297. display: flex;
  298. justify-content: space-between;
  299. align-items: center;
  300. .info-label {
  301. font-size: 24rpx;
  302. color: $uni-text-color-hint;
  303. }
  304. .info-value {
  305. font-size: 26rpx;
  306. color: $uni-text-color-dark;
  307. font-weight: $uni-font-weight-medium;
  308. }
  309. }
  310. }
  311. .device-functions {
  312. display: flex;
  313. flex-wrap: wrap;
  314. gap: 12rpx;
  315. margin: 16rpx 0;
  316. .function-tag {
  317. font-size: 22rpx;
  318. padding: 6rpx 16rpx;
  319. background: rgba($uni-color-primary, 0.08);
  320. color: $uni-color-primary;
  321. border-radius: 16rpx;
  322. font-weight: $uni-font-weight-medium;
  323. }
  324. }
  325. .device-action {
  326. display: flex;
  327. align-items: center;
  328. justify-content: flex-end;
  329. gap: 4rpx;
  330. font-size: 24rpx;
  331. color: $uni-text-color-hint;
  332. margin-top: 12rpx;
  333. }
  334. }
  335. }
  336. .bottom-spacer {
  337. height: 160rpx;
  338. }
  339. // 底部操作栏
  340. .bottom-bar {
  341. position: fixed;
  342. bottom: 0;
  343. left: 0;
  344. right: 0;
  345. background: $uni-bg-color-card;
  346. padding: 20rpx 30rpx;
  347. padding-bottom: calc(20rpx + constant(safe-area-inset-bottom));
  348. padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
  349. box-shadow: 0 -2rpx 12rpx rgba($uni-text-color, 0.04);
  350. z-index: 100;
  351. .bottom-buttons {
  352. display: flex;
  353. gap: 20rpx;
  354. .btn-nav {
  355. flex: 1;
  356. }
  357. .btn-scan {
  358. flex: 2;
  359. }
  360. }
  361. }
  362. </style>