needcode 2 лет назад
Родитель
Сommit
64ee76c13d

+ 47 - 20
src/pages-charge/appointment/appointment.vue

@@ -1,6 +1,6 @@
 <template>
 <template>
   <!--  #ifdef MP-WEIXIN -->
   <!--  #ifdef MP-WEIXIN -->
-  <page-meta page-style="overflow: {{O || U ? 'hidden' : 'visible'}}" />
+  <page-meta page-style="overflow: {{X || R ? 'hidden' : 'visible'}}" />
   <!--  #endif -->
   <!--  #endif -->
   <view :class="['page']">
   <view :class="['page']">
     <view v-if="data && priceInfo">
     <view v-if="data && priceInfo">
@@ -102,28 +102,40 @@
           >
           >
             <view class="fs-28 color-000 fw-500">充电时间</view>
             <view class="fs-28 color-000 fw-500">充电时间</view>
             <view class="flex-align-center lh-28">
             <view class="flex-align-center lh-28">
-              <view
-                v-if="chargeTime.format"
-                class="fs-28 color-333 fw-500 mr-16"
-                >{{ chargeTime.format }}</view
-              >
-              <view v-else class="fs-26 mr-16" style="color: #cacaca"
-                >请选择</view
-              >
-              <uni-icons type="right" size="16" color="#CACACA"></uni-icons>
+              <block v-if="chargeTime.isPowerSaving">
+                <view class="fs-28 color-333 fw-500 mr-16">00:00 - 08:00</view>
+              </block>
+              <block v-else>
+                <view
+                  v-if="chargeTime.format"
+                  class="fs-28 color-333 fw-500 mr-16"
+                  >{{ chargeTime.format }}</view
+                >
+                <view v-else class="fs-26 mr-16" style="color: #cacaca"
+                  >请选择</view
+                >
+                <uni-icons type="right" size="16" color="#CACACA"></uni-icons>
+              </block>
             </view>
             </view>
           </view>
           </view>
           <view class="pt-40 pb-40 flex-between">
           <view class="pt-40 pb-40 flex-between">
             <view class="fs-28 color-000 fw-500">预计费用</view>
             <view class="fs-28 color-000 fw-500">预计费用</view>
             <view class="flex-align-center lh-28">
             <view class="flex-align-center lh-28">
-              <view
-                v-if="chargeTime.formatPrice"
-                class="fs-28 color-333 fw-500"
-                >{{ chargeTime.formatPrice }}</view
-              >
-              <view v-else class="fs-26 mr-16" style="color: #cacaca"
-                >选择时间后显示</view
-              >
+              <block v-if="chargeTime.isPowerSaving">
+                <view class="fs-28 color-333 fw-500"
+                  >低至{{ priceInfo.minPrice }}元/kwh</view
+                >
+              </block>
+              <block v-else>
+                <view
+                  v-if="chargeTime.formatPrice"
+                  class="fs-28 color-333 fw-500"
+                  >{{ chargeTime.formatPrice }}</view
+                >
+                <view v-else class="fs-26 mr-16" style="color: #cacaca"
+                  >选择时间后显示</view
+                >
+              </block>
             </view>
             </view>
           </view>
           </view>
         </view>
         </view>
@@ -375,6 +387,13 @@ const buildHours = (hour: number, day: Date) => {
 };
 };
 
 
 const selectTime = () => {
 const selectTime = () => {
+  if (chargeTime.value.isPowerSaving) {
+    uni.showToast({
+      title: "省电模式将在00:00-08:00进行充电",
+      icon: "none",
+    });
+    return;
+  }
   if (!appointmentData.value && chargeType.value === 1) {
   if (!appointmentData.value && chargeType.value === 1) {
     uni.showToast({
     uni.showToast({
       title: "请选择预约模式",
       title: "请选择预约模式",
@@ -615,7 +634,11 @@ const formatAppointmentCountDown = (time: string) => {
 };
 };
 
 
 const submit = () => {
 const submit = () => {
-  if (chargeType.value === 0 && !chargeTime.value.hour) {
+  if (
+    chargeType.value === 0 &&
+    !chargeTime.value.isPowerSaving &&
+    !chargeTime.value.hour
+  ) {
     uni.showToast({
     uni.showToast({
       title: "请选择充电时间",
       title: "请选择充电时间",
       icon: "none",
       icon: "none",
@@ -625,6 +648,7 @@ const submit = () => {
   const now = new Date();
   const now = new Date();
   let startTime = chargeTime.value.time;
   let startTime = chargeTime.value.time;
   if (chargeTime.value.isPowerSaving) {
   if (chargeTime.value.isPowerSaving) {
+    startTime = now.getTime();
     // 省电模式
     // 省电模式
     if (
     if (
       now.getHours() >= 8 &&
       now.getHours() >= 8 &&
@@ -637,7 +661,9 @@ const submit = () => {
   if (chargeType.value === 0) {
   if (chargeType.value === 0) {
     query += "isBooking=true";
     query += "isBooking=true";
     query += `&startTime=${format("y-M-d", startTime)} ${
     query += `&startTime=${format("y-M-d", startTime)} ${
-      chargeTime.value.isPowerSaving ? "00:00:00" : `${chargeTime.value.hour}:00`
+      chargeTime.value.isPowerSaving
+        ? "00:00:00"
+        : `${chargeTime.value.hour}:00`
     }`;
     }`;
     if (chargeTime.value.isPowerSaving) {
     if (chargeTime.value.isPowerSaving) {
       query += `&endTime=${format("y-M-d", startTime)} 08:00:00`;
       query += `&endTime=${format("y-M-d", startTime)} 08:00:00`;
@@ -649,6 +675,7 @@ const submit = () => {
   if (discountIndex.value >= 0) {
   if (discountIndex.value >= 0) {
     query += `&rechargeRightsId=${discountList.value[discountIndex.value].id}`;
     query += `&rechargeRightsId=${discountList.value[discountIndex.value].id}`;
   }
   }
+  console.log(query)
   uni.showLoading({
   uni.showLoading({
     title: "提交中",
     title: "提交中",
     mask: true,
     mask: true,

+ 4 - 4
src/pages-charge/order/order.vue

@@ -29,9 +29,9 @@ onLoad((options: any) => {
       const discountAmountText = res.rightsDesc;
       const discountAmountText = res.rightsDesc;
       const reg = new RegExp("\B(?=(\d{3})+(?!\d))", "g");
       const reg = new RegExp("\B(?=(\d{3})+(?!\d))", "g");
       const start = new Date(res.startTime.replace(/-/g, "/"));
       const start = new Date(res.startTime.replace(/-/g, "/"));
-      const end = new Date(
-        res.endTime ? res.endTime.replace(/-/g, "/") : undefined
-      );
+      const end = res.endTime
+        ? new Date(res.endTime.replace(/-/g, "/"))
+        : new Date();
       const diff = parseInt(`${(end.getTime() - start.getTime()) / 1000}`);
       const diff = parseInt(`${(end.getTime() - start.getTime()) / 1000}`);
       const min = parseInt(`${diff / 60}`);
       const min = parseInt(`${diff / 60}`);
       const time =
       const time =
@@ -56,7 +56,7 @@ onLoad((options: any) => {
         },
         },
         {
         {
           label: "结束时间",
           label: "结束时间",
-          value: res.endTime,
+          value: res.chargeStatus === 2 ? '充电中' : res.endTime,
         },
         },
         {
         {
           label: "充电用时",
           label: "充电用时",

+ 6 - 2
src/pages-charge/ordering/ordering.vue

@@ -212,7 +212,9 @@ const finish = () => {
     .then((res) => {
     .then((res) => {
       if (res.isStarted) {
       if (res.isStarted) {
         // 当前充电中
         // 当前充电中
-        const start = new Date(res.startTime ? res.startTime.replace(/-/g, "/") : undefined);
+        const start = res.startTime
+          ? new Date(res.startTime.replace(/-/g, "/"))
+          : new Date();
         const end = new Date();
         const end = new Date();
         const diff = parseInt(`${(end.getTime() - start.getTime()) / 1000}`);
         const diff = parseInt(`${(end.getTime() - start.getTime()) / 1000}`);
         const min = parseInt(`${diff / 60}`);
         const min = parseInt(`${diff / 60}`);
@@ -299,7 +301,9 @@ const finish = () => {
     });
     });
 };
 };
 const setChargeData = (res: any) => {
 const setChargeData = (res: any) => {
-  const start = new Date(res.startTime ? res.startTime.replace(/-/g, "/") : undefined);
+  const start = res.startTime
+          ? new Date(res.startTime.replace(/-/g, "/"))
+          : new Date();
   const end = new Date();
   const end = new Date();
   const diff = parseInt(`${(end.getTime() - start.getTime()) / 1000}`);
   const diff = parseInt(`${(end.getTime() - start.getTime()) / 1000}`);
   const min = parseInt(`${diff / 60}`);
   const min = parseInt(`${diff / 60}`);