needcode преди 2 години
родител
ревизия
c2c64f1574

+ 15 - 4
src/api/user.ts

@@ -69,7 +69,7 @@ declare const wx: any;
 
 export function insertMoney(amount: number) {
   if (isDebug) {
-    return Promise.resolve()
+    return Promise.resolve();
   }
   return userHttp
     .post("/payment/wxPay", {
@@ -106,9 +106,16 @@ export function logout() {
   return userHttp.get("/user/logout");
 }
 
-export function fetchWallet(type: number, page: number, pageSize: number) {
+export function fetchWallet(
+  type: number,
+  page: number,
+  pageSize: number,
+  query?: string
+) {
   return userHttp.get(
-    `/account/walletDetail?page=${page}&page_size=${pageSize}&type=${type}`
+    `/account/walletDetail?page=${page}&page_size=${pageSize}&type=${type}${
+      query ? "&" + query : ""
+    }`
   );
 }
 
@@ -117,5 +124,9 @@ export function fetchOrder(orderid: string) {
 }
 
 export function applyRefund(reason: string) {
-  return userHttp.get(`/payment/wxApplyRefund?reason=${reason}`);
+  return userHttp.post(`/payment/wxApplyRefund`, {
+    data: {
+      reason,
+    },
+  });
 }

+ 90 - 26
src/pages-charge/appointment/appointment.vue

@@ -118,7 +118,10 @@
             </view>
           </view>
         </view>
-        <view class="mt-20 block flex-align-center pl-30 pr-30 pt-30 pb-30" v-if="chargeType === 0">
+        <view
+          class="mt-20 block flex-align-center pl-30 pr-30 pt-30 pb-30"
+          v-if="chargeType === 0"
+        >
           <view class="flex-column">
             <view class="fs-28 lh-28 color-000 fw-500">省钱模式</view>
             <view class="fs-24 lh-30 color-999 mt-8"
@@ -191,8 +194,14 @@
             >
           </view>
         </view>
-        <view class="flex-grow" style="height: 840rpx; overflow-y: auto">
+        <scroll-view
+          scroll-y
+          class="flex-grow"
+          style="height: 840rpx"
+          :scroll-into-view="chargeTime.scrollId"
+        >
           <view
+            :id="`hour-${hour.format}`"
             class="flex-align-center pl-40 height-90 fs-32"
             v-for="(hour, index) in timesInfo.hour"
             :key="index"
@@ -207,7 +216,7 @@
           >
             {{ hour.format }}
           </view>
-        </view>
+        </scroll-view>
       </view>
     </style-dialog>
     <PriceDesc
@@ -246,7 +255,7 @@ const timesInfo = ref<any>({
 const chargeType = ref(1);
 const chargeTypes = ref([
   {
-    title: "预约省钱充电",
+    title: "预约充电",
     tip: "预约特定时间点开始充电",
   },
   {
@@ -255,12 +264,13 @@ const chargeTypes = ref([
 ]);
 const chargeTimeDialog = ref(false);
 const chargeTime = ref({
-  isPowerSaving: false, // 省电模式
   time: 0, // 时间戳
   day: "",
   hour: "",
   format: "",
   formatPrice: "",
+  scrollId: "",
+  isPowerSaving: false, // 省电模式
 });
 const appointmentData = ref();
 const appointmentCountDown = ref();
@@ -278,6 +288,42 @@ const isPassTime = (hour: string, time: number) => {
   return now.getHours() >= _hour && now.getDate() === Number(format("d", time));
 };
 
+const getHourPrice = (hour: string) => {
+  let price = "";
+  priceInfo.value.policyInfos.forEach((item: any) => {
+    if (Number(hour) >= Number(item.startTime.substring(0, 2))) {
+      price = item.totalPrice;
+    }
+  });
+  return price;
+};
+
+const rebuildHours = (now: Date) => {
+  timesInfo.value.hour = [];
+  let hourTemp = "";
+  let priceTemp = "";
+  for (let index = 0; index < 24; index++) {
+    hourTemp = index >= 10 ? `${index}` : `0${index}`;
+    priceTemp = getHourPrice(hourTemp);
+    timesInfo.value.hour.push({
+      format: `${hourTemp}:00`,
+      formatPrice: priceTemp,
+      disabled: isPassTime(
+        `${hourTemp}:00`,
+        chargeTime.value.time ? chargeTime.value.time : now.getTime()
+      ),
+    });
+    timesInfo.value.hour.push({
+      format: `${hourTemp}:30`,
+      formatPrice: priceTemp,
+      disabled: isPassTime(
+        `${hourTemp}:30`,
+        chargeTime.value.time ? chargeTime.value.time : now.getTime()
+      ),
+    });
+  }
+};
+
 const selectTime = () => {
   if (!appointmentData.value && chargeType.value === 1) {
     uni.showToast({
@@ -306,21 +352,31 @@ const selectTime = () => {
     },
   ];
   // 时间
-  timesInfo.value.hour = priceInfo.value.policyInfos.map((item: any) => {
-    return {
-      format: item.startTime,
-      formatPrice: item.totalPrice,
-      disabled: isPassTime(
-        item.startTime,
-        chargeTime.value.time ? chargeTime.value.time : now.getTime()
-      ),
-    };
-  });
+  // timesInfo.value.hour = priceInfo.value.policyInfos.map((item: any) => {
+  //   return {
+  //     format: item.startTime,
+  //     formatPrice: item.totalPrice,
+  //     disabled: isPassTime(
+  //       item.startTime,
+  //       chargeTime.value.time ? chargeTime.value.time : now.getTime()
+  //     ),
+  //   };
+  // });
+  rebuildHours(now);
 
   // 预约时间
-  if (!appointmentData.value && !chargeTime.value.day) {
-    chargeTime.value.time = timesInfo.value.day[0].time;
-    chargeTime.value.day = timesInfo.value.day[0].format;
+  if (!appointmentData.value) {
+    if (!chargeTime.value.day) {
+      chargeTime.value.time = timesInfo.value.day[0].time;
+      chargeTime.value.day = timesInfo.value.day[0].format;
+    }
+    // 滚动到特定位置
+    if (chargeTime.value.hour) {
+      chargeTime.value.scrollId = `hour-${chargeTime.value.hour}`;
+    } else {
+      let hourNow = now.getHours();
+      chargeTime.value.scrollId = `hour-${hourNow}:00`;
+    }
   }
   // 修改时间
   if (appointmentData.value) {
@@ -345,13 +401,9 @@ const changeDay = (index: number) => {
     chargeTime.value.hour = "";
     chargeTime.value.formatPrice = "";
   }
-  timesInfo.value.hour = priceInfo.value.policyInfos.map((item: any) => {
-    return {
-      format: item.startTime,
-      formatPrice: item.totalPrice,
-      disabled: isPassTime(item.startTime, chargeTime.value.time),
-    };
-  });
+  const now = new Date(chargeTime.value.time);
+  rebuildHours(now);
+  chargeTime.value.scrollId = "";
 };
 
 const changeHour = (index: number) => {
@@ -426,6 +478,7 @@ const closeTime = () => {
       isPowerSaving: chargeTime.value.isPowerSaving, // 省电模式
       format: "",
       formatPrice: "",
+      scrollId: "",
     };
   }
 };
@@ -528,7 +581,7 @@ const submit = () => {
   if (chargeType.value === 0) {
     query += "isBooking=true";
     query += `&startTime=${format("y-M-d", startTime)} ${
-      chargeTime.value.isPowerSaving ? "00:00:00" : chargeTime.value.hour
+      chargeTime.value.isPowerSaving ? "00:00:00" : `${chargeTime.value.hour}:00`
     }`;
     if (chargeTime.value.isPowerSaving) {
       query += `&endTime=${format("y-M-d", startTime)} 08:00:00`;
@@ -569,6 +622,10 @@ const submit = () => {
     })
     .catch((err) => {
       uni.hideLoading();
+      uni.showModal({
+        content: `${err.errMsg}`,
+        showCancel: false,
+      });
     });
 };
 
@@ -585,6 +642,13 @@ const submitNow = () => {
       uni.navigateTo({
         url: `/pages-charge/ordering/ordering?sn=${options.value.sn}&start=1`,
       });
+    })
+    .catch((err) => {
+      uni.hideLoading();
+      uni.showModal({
+        content: `${err.errMsg}`,
+        showCancel: false,
+      });
     });
 };
 

+ 5 - 3
src/pages-charge/machines/charge-machine/charge-machine.vue

@@ -16,7 +16,8 @@
         style="width: 100%"
         v-else-if="
           item.connectorStatusInfo.status === 0 ||
-          item.connectorStatusInfo.status === 255
+          item.connectorStatusInfo.status === 255 ||
+          item.connectorStatusInfo.status === 2
         "
         src="/pages-charge/static/icon-status-3.png"
         mode="widthFix"
@@ -38,7 +39,8 @@
             'flex-center',
             'ml-8',
             item.connectorStatusInfo.status === 255 ||
-            item.connectorStatusInfo.status === 0
+            item.connectorStatusInfo.status === 0 ||
+            item.connectorStatusInfo.status === 2
               ? 'tag-disabled'
               : 'tag-warning',
           ]"
@@ -135,13 +137,13 @@ export default {
     width: 56rpx;
     border-radius: 50%;
     &-0,
+    &-2,
     &-255 {
       background-color: #b1b1b1;
     }
     &-1 {
       background-color: #00dab3;
     }
-    &-2,
     &-3,
     &-4 {
       background-color: var(--color-warning);

+ 3 - 1
src/pages-charge/ordering/ordering.vue

@@ -266,7 +266,9 @@ const finish = () => {
               });
               return;
             }
-            step.value = 3;
+            setTimeout(() => {
+              step.value = 3;
+            }, 3000);
           })
           .catch((err) => {
             console.log(err);

+ 4 - 2
src/pages-charge/orders/orders.vue

@@ -90,8 +90,9 @@ const checkAll = ref(false);
 const checkedPrice = ref(0);
 const checkedCount = ref(0);
 
+// 0-未开票 1-开票中 2-已开票
 const infiniteScroller = useInfiniteScroll(10, (page) => {
-  return fetchWallet(3, page, 10).then((res: any) => {
+  return fetchWallet(3, page, 10, "invoiceStatus=2").then((res: any) => {
     if (res && res.length) {
       res.forEach((item: any) => {
         item.amount = (Number(item.amount) / 100).toFixed(2);
@@ -180,7 +181,8 @@ onLoad(() => {
 });
 onPullDownRefresh(() => {
   if (isInvoice.value) {
-    return
+    uni.stopPullDownRefresh();
+    return;
   }
   infiniteScroller.refresh();
 });

+ 4 - 6
src/pages-user/wallet-refund/wallet-refund.vue

@@ -17,7 +17,8 @@
       </view>
       <view class="height-94 flex-align-center">
         <view class="fs-28 color-999"
-          >可退金额 {{ user ? user.refundableAmount : 0 }} 元,优惠金额 {{ user ? user.discountAmount : 0 }} 元</view
+          >可退金额 {{ user ? user.refundableAmount : 0 }} 元,优惠金额
+          {{ user ? user.discountAmount : 0 }} 元</view
         >
         <!-- <view class="fs-28 color-primary" @click="allRefund">全部提现</view> -->
       </view>
@@ -130,12 +131,9 @@ const submit = () => {
       uni.hideLoading();
       success.value = true;
     })
-    .catch(() => {
+    .catch((err) => {
+      console.log(err);
       uni.hideLoading();
-      uni.showModal({
-        title: "温馨提示",
-        content: "提交失败,请重试",
-      });
     });
 };
 const close = () => {

+ 1 - 1
src/pages-user/wallet/wallet.vue

@@ -100,7 +100,7 @@
 
 <script setup lang="ts">
 import { useInfiniteScroll } from "../../utils/infinite-scroll";
-import { onLoad, onReachBottom, onPullDownRefresh, onShow } from "@dcloudio/uni-app";
+import { onReachBottom, onPullDownRefresh, onShow } from "@dcloudio/uni-app";
 import { fetchWallet } from "../../api/user";
 import { to } from "../../utils/navigate";
 import { ref } from "vue";

+ 46 - 26
src/pages/map/map.vue

@@ -3,21 +3,14 @@
     <navigation-bar @ready="handleNavReady"></navigation-bar>
     <view class="dialog" v-if="styleData.dialog" :style="styleData.dialog">
       <view class="height-88 flex-align-center bg-fff">
-        <image
-          mode="widthFix"
-          src="/static/images/map-logo.png"
-          style="width: 156rpx"
-          class="ml-24"
-        ></image>
-        <image
-          mode="widthFix"
-          src="/static/images/map-input.png"
-          class="ml-24"
-          style="width: 352rpx"
-          @click="toSearch"
-        ></image>
+        <view class="dialog_logo ml-24"></view>
+        <view class="dialog_search ml-24" @click.stop="toSearch"></view>
       </view>
-      <view class="height-72 flex" style="background-color: #f9f9f9">
+      <view
+        class="height-72 flex"
+        style="background-color: #f9f9f9"
+        v-if="ready"
+      >
         <view class="width-half flex-center" @click.stop="checkFilterDistance">
           <view class="fs-26 color-000-6 mr-8">距离</view>
           <view
@@ -33,8 +26,8 @@
             ></uni-icons>
           </view>
         </view>
-        <view class="width-half flex-center" style="opacity: 0">
-          <view
+        <view class="width-half flex-center">
+          <!-- <view
             class="width-32 height-32 br-round lh-20 text-center"
             :style="{
               border: filterDialog.discounts
@@ -58,7 +51,7 @@
               filterDialog.discounts ? 'color-primary' : 'color-000-6',
             ]"
             >支持省钱充电</view
-          >
+          > -->
         </view>
       </view>
       <view
@@ -90,7 +83,7 @@
           >
         </view>
       </view>
-      <view class="dialog_event" v-if="ready && !filterDialog.distanceSelector">
+      <view class="dialog_event" v-if="ready && mapBanner.length > 0">
         <swiper
           class="swiper"
           circular
@@ -102,7 +95,7 @@
             class="full-percent"
             v-for="(item, index) in mapBanner"
             :key="index"
-            @click="to(`/pages-common/activity/activity?id=${item.activityId}`);"
+            @click="to(`/pages-common/activity/activity?id=${item.activityId}`)"
           >
             <view
               class="full-percent"
@@ -500,7 +493,9 @@ const handleNavReady = (e: any) => {
 };
 
 const toSearch = () => {
-  if (!ready.value || station.value.length) {
+  console.log(ready.value);
+
+  if (!ready.value) {
     return;
   }
   uni.navigateTo({
@@ -569,7 +564,9 @@ onLoad((query: any) => {
 
 onShow(() => {
   if (token.value) {
-    fetchCharging();
+    setTimeout(() => {
+      fetchCharging();
+    }, 3000);
   }
 });
 
@@ -592,6 +589,9 @@ const fetchBanner = () => {
 // };
 
 const checkFilterDistance = () => {
+  if (isIgnoreChangeLocation) {
+    return;
+  }
   if (!mapMode.value) {
     mapMode.value = true;
   }
@@ -636,9 +636,9 @@ const mapChange = (e: any) => {
     return;
   }
   if (e.type === "end" && markers.value.length) {
-    console.log("map change end", {
-      ...e.detail.centerLocation,
-    });
+    // console.log("map change end", {
+    //   ...e.detail.centerLocation,
+    // });
     const current = e.target.centerLocation;
     const { latitude, longitude } = current;
     stationPage.value.page = 1;
@@ -761,7 +761,25 @@ page {
   top: 0;
   left: 0;
   width: 100%;
-  z-index: 99;
+  z-index: 1000;
+
+  &_logo {
+    width: 156rpx;
+    height: 100%;
+    background-position: center;
+    background-size: 100% auto;
+    background-repeat: no-repeat;
+    background-image: url("/static/images/map-logo.png");
+  }
+
+  &_search {
+    width: 352rpx;
+    height: 100%;
+    background-position: center;
+    background-size: 100% auto;
+    background-repeat: no-repeat;
+    background-image: url("/static/images/map-input.png");
+  }
 
   &_event {
     margin-top: 20rpx;
@@ -775,6 +793,8 @@ page {
         background-position: center;
         background-repeat: no-repeat;
         background-size: 100% auto;
+        border-radius: 16rpx;
+        overflow: hidden;
       }
     }
   }
@@ -843,7 +863,7 @@ page {
   position: fixed;
   width: 100%;
   left: 0px;
-  z-index: 999;
+  z-index: 1000;
   transition: all 0.3s;
   box-shadow: 0px 8rpx 20rpx rgba(0, 0, 0, 0.2);
   background-color: #fff;

+ 1 - 3
src/utils/infinite-scroll.ts

@@ -16,9 +16,6 @@ export function useInfiniteScroll<T = any>(
     uni.showLoading({
       title: "加载中",
     });
-    if (list.value) {
-      list.value = [];
-    }
     loading.value = true;
     return loadData(1)
       .then((res) => {
@@ -31,6 +28,7 @@ export function useInfiniteScroll<T = any>(
       })
       .catch(() => {
         uni.hideLoading();
+        uni.stopPullDownRefresh();
         loading.value = false;
       });
   };