From fea27b66cf4913cfda76b74a12a2df83a6c19478 Mon Sep 17 00:00:00 2001
From: XiaoMo <xiaomo.drip@gmail.com>
Date: Mon, 21 Apr 2025 14:12:54 +0800
Subject: [PATCH] =?UTF-8?q?feat(=E6=B4=97=E8=BD=A6):=20=E6=96=B0=E5=A2=9E?=
 =?UTF-8?q?=E6=B4=97=E8=BD=A6=E9=A1=B5=E9=9D=A2=E5=8F=8A=E7=9B=B8=E5=85=B3?=
 =?UTF-8?q?=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

新增洗车页面,包括页面结构、样式和逻辑处理。支持显示进行中的洗车订单,并提供结算功能。同时,在首页添加了洗车订单的提示入口,方便用户查看订单状态
---
 app.json                   |   1 +
 pages/index/index.js       |   2 +
 pages/index/index.wxml     |  18 +++-
 pages/index/index.wxss     |  14 ++++
 pages/washing/washing.js   | 163 ++++++++++++++++++++++++++++++++++++
 pages/washing/washing.json |   5 ++
 pages/washing/washing.wxml |  42 ++++++++++
 pages/washing/washing.wxss | 167 +++++++++++++++++++++++++++++++++++++
 8 files changed, 408 insertions(+), 4 deletions(-)
 create mode 100644 pages/washing/washing.js
 create mode 100644 pages/washing/washing.json
 create mode 100644 pages/washing/washing.wxml
 create mode 100644 pages/washing/washing.wxss

diff --git a/app.json b/app.json
index 10e7a0c..d3d179c 100644
--- a/app.json
+++ b/app.json
@@ -25,6 +25,7 @@
     "pages/wangdian/wangdian",
     "pages/duiquan/duiquan",
     "pages/refund/refund",
+    "pages/washing/washing",
     "pages/OnlineCarHailing/OnlineCarHailing"
   ],
   "window": {
diff --git a/pages/index/index.js b/pages/index/index.js
index 8546907..2c0bc09 100644
--- a/pages/index/index.js
+++ b/pages/index/index.js
@@ -94,6 +94,8 @@ Page({
             a.setData({
                 user: e.data || [],
             });
+            // 存储进度订单
+            wx.setStorageSync('progressorder', e.data.progressorder || []);
         });
     },
     load: function (e) {
diff --git a/pages/index/index.wxml b/pages/index/index.wxml
index f8595eb..ad37654 100644
--- a/pages/index/index.wxml
+++ b/pages/index/index.wxml
@@ -6,12 +6,22 @@
     <view class="money">
         <my-money user="{{user}}"></my-money>
         <view class="marquee-wrap" wx:if="{{notice}}">
-            <view bindtap="toPage" class="marquee-content" data-refresh="1" data-url="{{noticeurl}}"> {{notice}} </view>
+            <view bindtap="toPage" class="marquee-content" data-refresh="1" data-url="{{noticeurl}}">
+                {{notice}}
+            </view>
         </view>
+        <navigator class="washing" hoverClass="hover" url="/pages/washing/washing" wx:if="{{user.progressorder}}">
+            <view class="l">您有一笔洗车订单进行中...</view>
+            <view class="r">点击查看></view>
+        </navigator>
     </view>
     <template is="pageList" data="{{urlList:urlList}}"></template>
     <template is="wangdianList" data="{{wangdianList:wangdianList}}"></template>
     <service-tel></service-tel>
-    <view bindtap="toScan" class="scan-btn" wx:if="{{!isScan}}"><view class="sha">扫码启动</view></view>
-    <view bindtap="toStart" class="scan-btn" wx:if="{{isScan}}"><view class="sha">立即启动</view></view>
-</view>
+    <view bindtap="toScan" class="scan-btn" wx:if="{{!isScan}}">
+        <view class="sha">扫码启动</view>
+    </view>
+    <view bindtap="toStart" class="scan-btn" wx:if="{{isScan}}">
+        <view class="sha">立即启动</view>
+    </view>
+</view>
\ No newline at end of file
diff --git a/pages/index/index.wxss b/pages/index/index.wxss
index be5e925..0a1cbba 100644
--- a/pages/index/index.wxss
+++ b/pages/index/index.wxss
@@ -157,4 +157,18 @@
     right: 0;
     display: block;
     background-color: #37CE05;
+}
+
+.washing {
+    justify-content: space-between;
+    margin: 30rpx 0 0;
+    padding: 20rpx 28rpx;
+    display: flex;
+    background-color: #0056A3;
+    color: #fff;
+    font-size: 28rpx;
+}
+
+.washing .l {
+  flex: 1;
 }
\ No newline at end of file
diff --git a/pages/washing/washing.js b/pages/washing/washing.js
new file mode 100644
index 0000000..20d8038
--- /dev/null
+++ b/pages/washing/washing.js
@@ -0,0 +1,163 @@
+var t = getApp(), e = require("../../utils/login.js");
+
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    countdown: '',
+    agentname: '',
+    devicecode: '',
+    remainingTime: 0,
+    orderid: ''
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad(options) {
+    const orderInfo = wx.getStorageSync('progressorder');
+    if (!orderInfo) {
+      wx.showToast({
+        title: '没有进行中的订单',
+        icon: 'none',
+        duration: 2000
+      });
+      setTimeout(() => {
+        wx.switchTab({
+          url: '/pages/index/index'
+        });
+      }, 2000);
+      return;
+    }
+
+    const currentTime = Math.floor(Date.now() / 1000);
+    const remainingTime = Math.max(0, orderInfo.timestamp + orderInfo.siteoccupationTime * 60 - currentTime);
+
+    this.setData({
+      agentname: orderInfo.agentname,
+      devicecode: orderInfo.devicecode,
+      remainingTime: remainingTime,
+      orderid: orderInfo.id
+    });
+
+    if (remainingTime > 0) {
+      this.countdown();
+    }
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload() {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh() {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom() {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage() {
+
+  },
+  handleSettlement() {
+    wx.showModal({
+      title: '确认结算',
+      content: '确定要结算此次洗车订单吗?',
+      success: (res) => {
+        if (res.confirm) {
+          e.request('/miniprogram/machine/shutdown', {
+            orderid: this.data.orderid
+          }, true).then((res) => {
+            if (res.code === 200) {
+              wx.showToast({
+                title: res.message || '结算成功',
+                icon: 'success',
+                duration: 2000
+              });
+              setTimeout(() => {
+                wx.removeStorageSync('progressorder');
+                wx.reLaunch({
+                  url: '/pages/index/index'
+                });
+              }, 2000);
+            }
+          }).catch((err) => {
+            // setTimeout(() => {
+            //   wx.removeStorageSync('progressorder');
+            //   wx.reLaunch({
+            //     url: '/pages/index/index'
+            //   });
+            // }, 2000);
+          })
+        }
+      }
+    });
+  },
+
+  countdown() {
+
+    // 没有  Cannot read property 'remainingTime' of undefined
+    if (!this.data.remainingTime) {
+      this.setData({
+        countdown: '00:00'
+      });
+      return;
+    }
+
+
+    if (this.data.remainingTime <= 0) {
+      this.setData({
+        countdown: '00:00'
+      });
+      return;
+    }
+
+    const minute = Math.floor(this.data.remainingTime / 60);
+    const second = this.data.remainingTime % 60;
+    const formattedMinute = minute < 10 ? '0' + minute : minute;
+    const formattedSecond = second < 10 ? '0' + second : second;
+
+    this.setData({
+      countdown: formattedMinute + ':' + formattedSecond,
+      remainingTime: this.data.remainingTime - 1
+    });
+
+    setTimeout(this.countdown, 1000);
+  },
+})
\ No newline at end of file
diff --git a/pages/washing/washing.json b/pages/washing/washing.json
new file mode 100644
index 0000000..d78ffd9
--- /dev/null
+++ b/pages/washing/washing.json
@@ -0,0 +1,5 @@
+{
+  "usingComponents": {
+    "service-tel": "../../template/serviceTel/serviceTel"
+  }
+}
\ No newline at end of file
diff --git a/pages/washing/washing.wxml b/pages/washing/washing.wxml
new file mode 100644
index 0000000..bf361d5
--- /dev/null
+++ b/pages/washing/washing.wxml
@@ -0,0 +1,42 @@
+<view class="spinner">
+  <view class="time">
+    <text class="wangdian">{{agentname}}</text>
+    <text class="mactime">{{countdown}}</text>
+    <text class="macid">{{devicecode}}</text>
+
+  </view>
+  <view class="spinner-container container1">
+    <view class="circle1"></view>
+    <view class="circle2"></view>
+    <view class="circle3"></view>
+    <view class="circle4"></view>
+  </view>
+  <view class="spinner-container container2">
+    <view class="circle1"></view>
+    <view class="circle2"></view>
+    <view class="circle3"></view>
+    <view class="circle4"></view>
+  </view>
+  <view class="spinner-container container3">
+    <view class="circle1"></view>
+    <view class="circle2"></view>
+    <view class="circle3"></view>
+    <view class="circle4"></view>
+  </view>
+  <view class="spinner-container container4">
+    <view class="circle1"></view>
+    <view class="circle2"></view>
+    <view class="circle3"></view>
+    <view class="circle4"></view>
+  </view>
+  <view class="spinner-container container5">
+    <view class="circle1"></view>
+    <view class="circle2"></view>
+    <view class="circle3"></view>
+    <view class="circle4"></view>
+  </view>
+</view>
+<view class="btn">
+  <button type="primary" bindtap="handleSettlement">结 算 洗 车</button>
+</view>
+<service-tel></service-tel>
\ No newline at end of file
diff --git a/pages/washing/washing.wxss b/pages/washing/washing.wxss
new file mode 100644
index 0000000..c16203b
--- /dev/null
+++ b/pages/washing/washing.wxss
@@ -0,0 +1,167 @@
+.btn {
+  padding: 80rpx 100rpx 40rpx;
+}
+
+.spinner {
+  margin: 200rpx auto 80rpx;
+  width: 400rpx;
+  height: 400rpx;
+  position: relative;
+  border-radius: 400rpx;
+  border: 10rpx solid green;
+}
+
+.spinner .time {
+  font-family: 'Consolas', 'Lucida Console', 'DejaVu Sans Mono', monospace;
+  position: absolute;
+  width: 400rpx;
+  height: 320rpx;
+  padding-top: 80rpx;
+  text-align: center;
+  color: green;
+}
+
+.spinner .time text {
+  display: block;
+}
+.wangdian, .macid {
+ line-height: 2;
+ font-size: 40rpx;
+}
+.mactime {
+  font-size: 80rpx;
+  font-weight: 700;
+}
+
+.container1 > view, .container2 > view, .container3 > view, .container4 > view, .container5 > view {
+  width: 20rpx;
+  height: 20rpx;
+  background-color: green;
+  border-radius: 100%;
+  position: absolute;
+  -webkit-animation: bouncedelay 2.2s infinite ease-in-out;
+  animation: bouncedelay 2.2s infinite ease-in-out;
+  -webkit-animation-fill-mode: both;
+  animation-fill-mode: both;
+}
+.spinner .spinner-container {
+  position: absolute;
+  width: 100%;
+  height: 100%;
+}
+.container2 {
+  -webkit-transform: rotateZ(22.5deg);
+  transform: rotateZ(22.5deg);
+}
+.container3 {
+  -webkit-transform: rotateZ(45deg);
+  transform: rotateZ(45deg);
+}
+.container4 {
+  -webkit-transform: rotateZ(67.5deg);
+  transform: rotateZ(67.5deg);
+}
+.container5 {
+  -webkit-transform: rotateZ(90deg);
+  transform: rotateZ(90deg);
+}
+
+.circle1 { top: 0; left: 0; }
+.circle2 { top: 0; right: 0; }
+.circle3 { right: 0; bottom: 0; }
+.circle4 { left: 0; bottom: 0; }
+.container1 .circle1 {
+  -webkit-animation-delay: -2s;
+  animation-delay: -2s;
+}
+.container2 .circle1 {
+  -webkit-animation-delay: -1.9s;
+  animation-delay: -1.9s;
+}
+.container3 .circle1 {
+  -webkit-animation-delay: -1.8s;
+  animation-delay: -1.8s;
+}
+.container4 .circle1 {
+  -webkit-animation-delay: -1.7s;
+  animation-delay: -1.7s;
+}
+.container5 .circle1 {
+  -webkit-animation-delay: -1.6s;
+  animation-delay: -1.6s;
+}
+.container1 .circle2 {
+  -webkit-animation-delay: -1.5s;
+  animation-delay: -1.5s;
+}
+.container2 .circle2 {
+  -webkit-animation-delay: -1.4s;
+  animation-delay: -1.4s;
+}
+.container3 .circle2 {
+  -webkit-animation-delay: -1.3s;
+  animation-delay: -1.3s;
+}
+.container4 .circle2 {
+  -webkit-animation-delay: -1.2s;
+  animation-delay: -1.2s;
+}
+.container5 .circle2 {
+  -webkit-animation-delay: -1.1s;
+  animation-delay: -1.1s;
+}
+.container1 .circle3 {
+  -webkit-animation-delay: -1s;
+  animation-delay: -1s;
+}
+.container2 .circle3 {
+  -webkit-animation-delay: -0.9s;
+  animation-delay: -0.9s;
+}
+.container3 .circle3 {
+  -webkit-animation-delay: -0.8s;
+  animation-delay: -0.8s;
+}
+.container4 .circle3 {
+  -webkit-animation-delay: -0.7s;
+  animation-delay: -0.7s;
+}
+.container5 .circle3 {
+  -webkit-animation-delay: -0.6s;
+  animation-delay: -0.6s;
+}
+.container1 .circle4 {
+  -webkit-animation-delay: -0.5s;
+  animation-delay: -0.5s;
+}
+.container2 .circle4 {
+  -webkit-animation-delay: -0.4s;
+  animation-delay: -0.4s;
+}
+.container3 .circle4 {
+  -webkit-animation-delay: -0.3s;
+  animation-delay: -0.3s;
+}
+.container4 .circle4 {
+  -webkit-animation-delay: -0.2s;
+  animation-delay: -0.2s;
+}
+.container5 .circle4 {
+  -webkit-animation-delay: -0.1s;
+  animation-delay: -0.1s;
+}
+@-webkit-keyframes bouncedelay {
+  0%, 80%, 100% { -webkit-transform: scale(0.0) }
+  40% { -webkit-transform: scale(2.0) }
+}
+@keyframes bouncedelay {
+  0%, 80%, 100% {
+    transform: scale(0.0);
+    -webkit-transform: scale(0.0);
+  } 40% {
+    transform: scale(2.0);
+    -webkit-transform: scale(2.0);
+  }
+}
+
+