needcode 2 年 前
コミット
9db7b806ac

+ 1 - 1
src/api/charge.ts

@@ -135,7 +135,7 @@ export function fetchChargeStatus(
           title: "温馨提示",
           content: "当前已有进行中的订单,请结束订单再扫码充电",
           showCancel: false,
-          confirmText: "查看当前",
+          confirmText: "查看详情",
           confirmColor: "#347DFF",
           success(modal) {
             if (modal.confirm) {

+ 6 - 2
src/api/index.ts

@@ -20,5 +20,9 @@ export function applyInvoice(startChargeSeqs: string[]) {
 }
 
 export function fetchHomeBanner() {
-  return indexHttp.get('/banner')
-}
+  return indexHttp.get("/banner");
+}
+
+export function fetchInvoiceList() {
+  return indexHttp.get("/invoice/list?status=1");
+}

+ 8 - 0
src/api/user.ts

@@ -123,6 +123,14 @@ export function fetchOrder(orderid: string) {
   return userHttp.get(`/charge/orderDetail/${orderid}`);
 }
 
+export function fetchOrders(page: number, pageSize: number, query?: string) {
+  return userHttp.get(
+    `/charge/listUserChargeOrders?pageNum=${page}&pageSize=${pageSize}${
+      query ? "&" + query : ""
+    }`
+  );
+}
+
 export function applyRefund(reason: string) {
   return userHttp.post(`/payment/wxApplyRefund`, {
     data: {

+ 10 - 2
src/pages-charge/appointment/appointment.vue

@@ -1,5 +1,7 @@
 <template>
-  <view class="page">
+  <view
+    :class="['page', chargeTimeDialog || priceDescVisible ? 'page-hidden' : '']"
+  >
     <template v-if="data && priceInfo">
       <view class="block">
         <view class="station">
@@ -581,7 +583,9 @@ 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}:00`
+      chargeTime.value.isPowerSaving
+        ? "00:00:00"
+        : `${chargeTime.value.hour}:00`
     }`;
     if (chargeTime.value.isPowerSaving) {
       query += `&endTime=${format("y-M-d", startTime)} 08:00:00`;
@@ -700,6 +704,10 @@ onLoad((_options: any) => {
   padding: 20rpx;
   background-color: #f6f7fa;
 }
+.page-hidden {
+  height: 100vh;
+  overflow: hidden;
+}
 .block {
   border-radius: 20rpx;
   background: #fff;

+ 91 - 31
src/pages-charge/orders/orders.vue

@@ -13,14 +13,27 @@
         <style-checkbox :checked="item.checked"></style-checkbox>
       </view>
       <view>
-        <view class="fs-30 fw-500" key="title" duration="300">充电费用</view>
+        <view class="flex-align-center">
+          <view class="fs-30 fw-500">充电费用</view>
+          <view
+            v-if="
+              isInvoice &&
+              (item.invoiceStatus === 1 ||
+                item.invoiceStatus === 2 ||
+                item.invoiceStatus === 3)
+            "
+            class="flex-center ml-24 fs-24 color-000-6 width-96 height-46 br-8"
+            style="background: #e5e5e5"
+            >{{ isInvoiceTitles[item.invoiceStatus] }}</view
+          >
+        </view>
         <view class="fs-24 mt-10" style="color: rgba(0, 0, 0, 0.4)">{{
-          item.transactionTime
+          item.endTime
         }}</view>
       </view>
       <view class="ml-auto" style="text-align: right">
         <view class="fs-36 fw-500">
-          <text>{{ item.amount }}</text>
+          <text>{{ item.totalMoney }}</text>
           <text class="fs-24 ml-6">元</text>
         </view>
       </view>
@@ -36,13 +49,20 @@
     v-if="infiniteScroller.list && infiniteScroller.list.length <= 0"
     >暂无数据</view
   >
-
+  <view class="invoice-placeholder" v-if="isInvoice"></view>
   <view class="foot-placeholder"></view>
 
   <style-bottom-view>
-    <view class="foot flex-align-center flex-justify-end" v-if="!isInvoice">
+    <view class="foot flex-align-center" v-if="!isInvoice">
+      <!-- <view
+        class="flex-center height-72 br-72"
+        style="width: 176rpx"
+        @click="openInvoiceHistory"
+      >
+        <view class="fs-28 color-333 mr-12">发票历史</view>
+      </view> -->
       <view
-        class="flex-center mr-40 height-72 br-72"
+        class="flex-center ml-auto mr-40 height-72 br-72"
         style="width: 176rpx; border: 1rpx solid rgba(0, 0, 0, 0.2)"
         @click="openInvoice"
       >
@@ -79,27 +99,36 @@
 </template>
 
 <script setup lang="ts">
-import { onLoad, onPullDownRefresh, onReachBottom } from "@dcloudio/uni-app";
-import { fetchWallet } from "../../api/user";
-import { applyInvoice } from "../../api/index";
+import {
+  onLoad,
+  onPullDownRefresh,
+  onReachBottom,
+  onShow,
+} from "@dcloudio/uni-app";
+import { fetchOrders } from "../../api/user";
+import { applyInvoice, fetchInvoiceList } from "../../api/index";
 import { useInfiniteScroll } from "../../utils/infinite-scroll";
 import { ref } from "vue";
+import { to } from "@/utils/navigate";
 
 const isInvoice = ref(false);
+const isInvoiceing = ref(false);
+const isInvoiceHistory = ref(false);
+const isInvoiceTitles = ref(["未开票", "已开票", "已作废", "开票中"]);
 const checkAll = ref(false);
 const checkedPrice = ref(0);
 const checkedCount = ref(0);
 
-// 0-未开票 1-开票 2-已开票
+// 0-未开票 1-开票 2-已作废 3-开票
 const infiniteScroller = useInfiniteScroll(10, (page) => {
-  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);
+  return fetchOrders(page, 10).then((res: any) => {
+    if (res && res.list && res.list.length) {
+      res.list.forEach((item: any) => {
+        item.totalMoney = (Number(item.totalMoney) / 100).toFixed(2);
         item.checked = false;
       });
     }
-    return res;
+    return res.list;
   });
 });
 
@@ -109,7 +138,7 @@ const setCheckData = () => {
   infiniteScroller.list.forEach((item: any) => {
     if (item.checked) {
       count++;
-      price += Number(item.amount);
+      price += Number(item.totalMoney);
     }
   });
   checkAll.value = infiniteScroller.list.every((item: any) => item.checked);
@@ -121,33 +150,50 @@ const detail = (index: number) => {
     return;
   }
   if (isInvoice.value) {
-    infiniteScroller.list[index].checked =
-      !infiniteScroller.list[index].checked;
-    setCheckData();
+    if ([0, 3].includes(infiniteScroller.list[index].invoiceStatus)) {
+      infiniteScroller.list[index].checked =
+        !infiniteScroller.list[index].checked;
+      setCheckData();
+    }
+    if ([1].includes(infiniteScroller.list[index].invoiceStatus)) {
+      to(
+        `/pages-common/invoice/invoice?id=${infiniteScroller.list[index].startChargeSeq}`
+      );
+    }
     return;
   }
-  uni.navigateTo({
-    url: `/pages-charge/order/order?id=${infiniteScroller.list[index].orderNo}`,
-  });
+  to(
+    `/pages-charge/order/order?id=${infiniteScroller.list[index].startChargeSeq}`
+  );
 };
 const openInvoice = () => {
   isInvoice.value = true;
 };
+// 获取发票历史
+const openInvoiceHistory = () => {
+  uni.showLoading({
+    title: "请求中",
+  });
+  fetchInvoiceList().then((res) => {
+    uni.hideLoading();
+    if (res.length <= 0) {
+      uni.showToast({
+        title: "无开票历史",
+        icon: "none",
+      });
+      return;
+    }
+    isInvoiceHistory.value = true;
+  });
+};
 const nextInvoice = () => {
-  // const ids = infiniteScroller.list
-  //   .filter((item: any) => item.checked)
-  //   .map((item: any) => item.orderNo)
-  //   .join("|");
-  //   uni.navigateTo({
-  //   url: `/pages-common/invoice/invoice?ids=${ids}`,
-  // });
   uni.showLoading({
     title: "请求中",
   });
   applyInvoice(
     infiniteScroller.list
       .filter((item: any) => item.checked)
-      .map((item: any) => item.orderNo)
+      .map((item: any) => item.startChargeSeq)
   )
     .then((res) => {
       uni.hideLoading();
@@ -156,13 +202,14 @@ const nextInvoice = () => {
         path: res.miniprogramPath,
         success(res) {
           console.log("打开成功");
+          isInvoiceing.value = true;
         },
       });
     })
     .catch((err) => {
       uni.hideLoading();
       uni.showModal({
-        content: `${err.errMsg},请重试`,
+        content: `${err.errMsg}`,
       });
     });
 };
@@ -179,6 +226,13 @@ const checkPage = () => {
 onLoad(() => {
   infiniteScroller.refresh();
 });
+onShow(() => {
+  if (isInvoiceing.value) {
+    isInvoiceing.value = false;
+    isInvoice.value = false;
+    infiniteScroller.refresh();
+  }
+});
 onPullDownRefresh(() => {
   if (isInvoice.value) {
     uni.stopPullDownRefresh();
@@ -195,6 +249,12 @@ onReachBottom(() => {
 .item {
   height: 170rpx;
   border-bottom: 1rpx solid rgba(0, 0, 0, 0.1);
+  &:last-child {
+    border-bottom: none;
+  }
+}
+.invoice-placeholder {
+  height: 60rpx;
 }
 .foot-placeholder {
   height: 112rpx;

+ 1 - 1
src/pages-common/activity/activity.vue

@@ -49,7 +49,7 @@ onLoad((options: any) => {
     title: "加载中",
   });
   fetchProfile().then((res) => {
-    const activity = res.activityList.find((item) => item.id === options.id);
+    const activity = res.activityList.find((item: any) => item.id === options.id);
     uni.setNavigationBarTitle({
       title: activity.name,
     });

+ 15 - 32
src/pages-common/invoice/invoice.vue

@@ -1,47 +1,30 @@
 <template>
   <view class="page">
-    <style-bottom-view background="#f6f7fa">
-      <view class="pt-20 pl-60 pr-60 pb-20">
-        <style-button type="primary" size="small" @click="openPath">提交</style-button>
-      </view>
-    </style-bottom-view>
   </view>
 </template>
 
 <script setup lang="ts">
-import { applyInvoice } from "@/api";
 import { onLoad } from "@dcloudio/uni-app";
 import { ref } from "vue";
 
-const path = ref();
-
 onLoad((options: any) => {
-  uni.showLoading({
-    title: "加载中",
-  });
-  applyInvoice(options.ids.split("|"))
-    .then((res) => {
-      console.log(res);
-      path.value = res;
-      uni.hideLoading();
-    })
-    .catch((err) => {
-      uni.hideLoading();
-      uni.showModal({
-        content: `${err.errMsg},请重试`,
-      });
-    });
+  // uni.showLoading({
+  //   title: "加载中",
+  // });
+  // applyInvoice(options.ids.split("|"))
+  //   .then((res) => {
+  //     console.log(res);
+  //     path.value = res;
+  //     uni.hideLoading();
+  //   })
+  //   .catch((err) => {
+  //     uni.hideLoading();
+  //     uni.showModal({
+  //       content: `${err.errMsg},请重试`,
+  //     });
+  //   });
 });
 
-const openPath = () => {
-  uni.navigateToMiniProgram({
-    appId: path.value.miniprogramAppid,
-    path: path.value.miniprogramPath,
-    success(res) {
-      console.log('打开成功')
-    },
-  });
-};
 const chooseInvoiceTitle = () => {
   uni.chooseInvoiceTitle({
     success: (res) => {

+ 43 - 30
src/pages-user/profile/profile.vue

@@ -49,35 +49,36 @@ import { onLoad, onShow } from "@dcloudio/uni-app";
 import { ref } from "vue";
 const avatar = ref<string>();
 const menu = ref<any[]>([]);
+const MENU_TEMPLATE = [
+  {
+    title: "昵称",
+    key: "nickname",
+    value: "",
+  },
+  {
+    title: "电话",
+    key: "",
+    disabled: true,
+  },
+  {
+    title: "车牌号",
+    key: "defaultPlateNo",
+    value: "",
+  },
+  {
+    title: "VIN码",
+    key: "vin",
+    value: "",
+  },
+  // {
+  //   title: "充电卡",
+  //   key: "",
+  //   value: "",
+  // },
+];
 
 const refresh = () => {
-  const _menu = [
-    {
-      title: "昵称",
-      key: "nickname",
-      value: "",
-    },
-    {
-      title: "电话",
-      key: "",
-      disabled: true,
-    },
-    {
-      title: "车牌号",
-      key: "defaultPlateNo",
-      value: "",
-    },
-    {
-      title: "VIN码",
-      key: "vin",
-      value: "",
-    },
-    // {
-    //   title: "充电卡",
-    //   key: "",
-    //   value: "",
-    // },
-  ];
+  const _menu = [...MENU_TEMPLATE];
   fetchProfile().then(() => {
     const user = getApp<any>().globalData.user;
     if (user) {
@@ -129,8 +130,8 @@ const chooseAvatar = (e: any) => {
           .then(() => {
             uni.hideLoading();
             uni.showToast({
-              title: '已更新',
-              icon: 'success'
+              title: "已更新",
+              icon: "success",
             });
             avatar.value = res.url;
           })
@@ -228,7 +229,19 @@ const errorHandle = (e: any) => {
 };
 
 onLoad(() => {
-  refresh();
+  if (getApp<any>().globalData.user) {
+    const user = getApp<any>().globalData.user;
+    const _menu = [...MENU_TEMPLATE];
+    _menu[0].value = user.nickname;
+    _menu[1].value = user.mobilePhone;
+    _menu[2].value = user.defaultPlateNo;
+    _menu[3].value = user.vin;
+    // _menu[4].value = user.card_no;
+    avatar.value =
+      user.avatar ||
+      "https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0";
+    menu.value = _menu;
+  }
 });
 onShow(() => {
   if (getApp<any>().globalData.lastData.profile) {

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

@@ -103,7 +103,7 @@ onLoad(() => {
 
 const allRefund = () => {
   if (user.value) {
-    value.value = Number(user.value.balance);
+    value.value = 1 // Number(user.value.balance);
   }
 };
 const changeReason = (i: number) => {
@@ -134,6 +134,10 @@ const submit = () => {
     .catch((err) => {
       console.log(err);
       uni.hideLoading();
+      uni.showModal({
+        content: err.errMsg,
+        showCancel: false
+      })
     });
 };
 const close = () => {

+ 1 - 1
src/pages.json

@@ -138,7 +138,7 @@
           "path": "invoice/invoice",
           "style": {
             "navigationStyle": "default",
-            "navigationBarTitleText": "发票",
+            "navigationBarTitleText": "发票详情",
             "navigationBarBackgroundColor": "#F6F7FA"
           }
         },

+ 40 - 9
src/pages/map/map.vue

@@ -6,11 +6,7 @@
         <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"
-        v-if="ready"
-      >
+      <view class="height-72 flex" style="background-color: #f9f9f9">
         <view class="width-half flex-center" @click.stop="checkFilterDistance">
           <view class="fs-26 color-000-6 mr-8">距离</view>
           <view
@@ -112,6 +108,7 @@
       :style="{ height: `${styleData.dialogPlaceHolderHeight}px` }"
     ></view>
     <map
+      v-if="ready"
       id="map"
       :style="{
         width: '100%',
@@ -134,6 +131,29 @@
       @markertap="tapMarker"
       :show-scale="true"
     ></map>
+    <block v-else>
+      <view
+        v-if="styleData.dialogHeight"
+        class="mock-map flex-center"
+        :style="{
+          height: `calc(100vh - ${styleData.dialogHeight}px - ${
+            styleData.cardHeight - 24
+          }px)`,
+        }"
+      >
+        <image
+          src="/static/images/map-bg.png"
+          mode="widthFix"
+          style="width: 100%"
+        ></image>
+        <image
+          src="/static/images/map-current.png"
+          mode="widthFix"
+          class="absolute-center"
+          style="width: 34px"
+        ></image>
+      </view>
+    </block>
     <view
       class="card"
       :style="{
@@ -142,6 +162,7 @@
           : `calc(100vh - ${styleData.dialogHeight}px)`,
         bottom: '0px',
         borderRadius: mapMode ? '16rpx 16rpx 0px 0px' : '0px',
+        overflowY: mapMode ? 'visible' : 'auto',
       }"
       @touchstart.stop="touchCardStart"
       @touchmove.stop="touchCardMove"
@@ -149,7 +170,7 @@
       <view
         v-if="mapMode"
         class="card_location height-64 width-64 bg-fff flex-center"
-        @click="resetLocation"
+        @touchstart.stop="resetLocation"
       >
         <image
           src="/static/images/map-re-location.png"
@@ -453,6 +474,9 @@ const refresh = () => {
     return;
   }
   console.log("刷新电站");
+  uni.showLoading({
+    title: "加载中",
+  });
   loading.value = true;
   stationPage.value.page = 1;
   stationPage.value.hasNext = false;
@@ -469,11 +493,13 @@ const refresh = () => {
       return refreshStation(res);
     })
     .then(() => {
+      uni.hideLoading();
       loading.value = false;
       ready.value = true;
     })
     .catch((err) => {
       console.log(err);
+      uni.hideLoading();
       loading.value = false;
       uni.showModal({
         content: `${err.errMsg},请重试`,
@@ -493,8 +519,6 @@ const handleNavReady = (e: any) => {
 };
 
 const toSearch = () => {
-  console.log(ready.value);
-
   if (!ready.value) {
     return;
   }
@@ -741,6 +765,13 @@ page {
   background-color: #ffffff;
 }
 
+.mock-map {
+  position: relative;
+  width: 100vw;
+  background-color: #ffffff;
+  overflow: hidden;
+}
+
 .login-mask {
   position: fixed;
   left: 0;
@@ -869,7 +900,6 @@ page {
   background-color: #fff;
   margin-bottom: constant(safe-area-inset-bottom);
   margin-bottom: env(safe-area-inset-bottom);
-  overflow-y: auto;
 
   &_location {
     position: absolute;
@@ -877,6 +907,7 @@ page {
     box-shadow: 0px 8rpx 20rpx 0px rgba(0, 0, 0, 0.2);
     right: 20rpx;
     top: -104rpx;
+    z-index: 99;
   }
 
   &_line {

BIN
src/static/images/contact-servicer.png


BIN
src/static/images/map-bg.png


+ 2 - 2
src/utils/infinite-scroll.ts

@@ -46,18 +46,18 @@ export function useInfiniteScroll<T = any>(
         .then((res) => {
           uni.hideLoading();
           loading.value = false;
+          hasNext.value = res.length >= pageSize;
           if (!res || res.length <= 0) {
             return;
           }
           page.value = page.value + 1;
-          hasNext.value = res.length >= pageSize;
-          list.value = res;
           res.forEach((item) => {
             list.value.push(item);
           });
         })
         .catch(() => {
           uni.hideLoading();
+          hasNext.value = false;
           loading.value = false;
         });
     }