|
@@ -9,6 +9,9 @@
|
|
|
:key="index"
|
|
:key="index"
|
|
|
@click="detail(index)"
|
|
@click="detail(index)"
|
|
|
>
|
|
>
|
|
|
|
|
+ <view class="mr-28" v-if="isInvoice">
|
|
|
|
|
+ <style-checkbox :checked="item.checked"></style-checkbox>
|
|
|
|
|
+ </view>
|
|
|
<view>
|
|
<view>
|
|
|
<view class="fs-30 fw-500" key="title" duration="300">充电费用</view>
|
|
<view class="fs-30 fw-500" key="title" duration="300">充电费用</view>
|
|
|
<view class="fs-24 mt-10" style="color: rgba(0, 0, 0, 0.4)">{{
|
|
<view class="fs-24 mt-10" style="color: rgba(0, 0, 0, 0.4)">{{
|
|
@@ -33,34 +36,152 @@
|
|
|
v-if="infiniteScroller.list && infiniteScroller.list.length <= 0"
|
|
v-if="infiniteScroller.list && infiniteScroller.list.length <= 0"
|
|
|
>暂无数据</view
|
|
>暂无数据</view
|
|
|
>
|
|
>
|
|
|
|
|
+
|
|
|
|
|
+ <view class="foot-placeholder"></view>
|
|
|
|
|
+
|
|
|
|
|
+ <style-bottom-view>
|
|
|
|
|
+ <view class="foot flex-align-center flex-justify-end" v-if="!isInvoice">
|
|
|
|
|
+ <view
|
|
|
|
|
+ class="flex-center mr-40 height-72 br-72"
|
|
|
|
|
+ style="width: 176rpx; border: 1rpx solid rgba(0, 0, 0, 0.2)"
|
|
|
|
|
+ @click="openInvoice"
|
|
|
|
|
+ >
|
|
|
|
|
+ <view class="fs-28 color-333 mr-12">开发票</view>
|
|
|
|
|
+ <uni-icons type="right" size="14" color="#333"></uni-icons>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ <view class="foot flex-align-center relative" v-else>
|
|
|
|
|
+ <view
|
|
|
|
|
+ class="height-56 flex-align-center absolute-top-left pl-30"
|
|
|
|
|
+ style="
|
|
|
|
|
+ background-color: #f6f7fa;
|
|
|
|
|
+ width: 100%;
|
|
|
|
|
+ transform: translateY(-100%);
|
|
|
|
|
+ "
|
|
|
|
|
+ >
|
|
|
|
|
+ <view class="fs-28 color-primary mr-8">{{ checkedCount }}</view>
|
|
|
|
|
+ <view class="fs-28 color-000">个订单,共</view>
|
|
|
|
|
+ <view class="fs-28 color-primary mr-8 ml-8">{{ checkedPrice }}</view>
|
|
|
|
|
+ <view class="fs-28 color-000">元</view>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ <view class="flex-align-center ml-30" @click="checkPage">
|
|
|
|
|
+ <style-checkbox :checked="checkAll"></style-checkbox>
|
|
|
|
|
+ <view class="ml-16 fs-28 color666">本页全选</view>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ <view
|
|
|
|
|
+ class="ml-auto mr-40 bg-primary height-80 br-80 fs-32 fw-500 color-fff flex-center"
|
|
|
|
|
+ style="width: 216rpx"
|
|
|
|
|
+ @click="nextInvoice"
|
|
|
|
|
+ >下一步</view
|
|
|
|
|
+ >
|
|
|
|
|
+ </view>
|
|
|
|
|
+ </style-bottom-view>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
import { onLoad, onPullDownRefresh, onReachBottom } from "@dcloudio/uni-app";
|
|
import { onLoad, onPullDownRefresh, onReachBottom } from "@dcloudio/uni-app";
|
|
|
import { fetchWallet } from "../../api/user";
|
|
import { fetchWallet } from "../../api/user";
|
|
|
|
|
+import { applyInvoice } from "../../api/index";
|
|
|
import { useInfiniteScroll } from "../../utils/infinite-scroll";
|
|
import { useInfiniteScroll } from "../../utils/infinite-scroll";
|
|
|
|
|
+import { ref } from "vue";
|
|
|
|
|
+
|
|
|
|
|
+const isInvoice = ref(false);
|
|
|
|
|
+const checkAll = ref(false);
|
|
|
|
|
+const checkedPrice = ref(0);
|
|
|
|
|
+const checkedCount = ref(0);
|
|
|
|
|
+
|
|
|
const infiniteScroller = useInfiniteScroll(10, (page) => {
|
|
const infiniteScroller = useInfiniteScroll(10, (page) => {
|
|
|
return fetchWallet(3, page, 10).then((res: any) => {
|
|
return fetchWallet(3, page, 10).then((res: any) => {
|
|
|
if (res && res.length) {
|
|
if (res && res.length) {
|
|
|
res.forEach((item: any) => {
|
|
res.forEach((item: any) => {
|
|
|
item.amount = (Number(item.amount) / 100).toFixed(2);
|
|
item.amount = (Number(item.amount) / 100).toFixed(2);
|
|
|
|
|
+ item.checked = false;
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
return res;
|
|
return res;
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
|
|
+
|
|
|
|
|
+const setCheckData = () => {
|
|
|
|
|
+ let count = 0;
|
|
|
|
|
+ let price = 0;
|
|
|
|
|
+ infiniteScroller.list.forEach((item: any) => {
|
|
|
|
|
+ if (item.checked) {
|
|
|
|
|
+ count++;
|
|
|
|
|
+ price += Number(item.amount);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ checkAll.value = infiniteScroller.list.every((item: any) => item.checked);
|
|
|
|
|
+ checkedCount.value = count;
|
|
|
|
|
+ checkedPrice.value = Number(Number(price).toFixed(2));
|
|
|
|
|
+};
|
|
|
const detail = (index: number) => {
|
|
const detail = (index: number) => {
|
|
|
if (!infiniteScroller.list) {
|
|
if (!infiniteScroller.list) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
+ if (isInvoice) {
|
|
|
|
|
+ infiniteScroller.list[index].checked =
|
|
|
|
|
+ !infiniteScroller.list[index].checked;
|
|
|
|
|
+ setCheckData();
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
uni.navigateTo({
|
|
uni.navigateTo({
|
|
|
url: `/pages-charge/order/order?id=${infiniteScroller.list[index].orderNo}`,
|
|
url: `/pages-charge/order/order?id=${infiniteScroller.list[index].orderNo}`,
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
|
|
|
+const openInvoice = () => {
|
|
|
|
|
+ isInvoice.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)
|
|
|
|
|
+ )
|
|
|
|
|
+ .then((res) => {
|
|
|
|
|
+ uni.hideLoading();
|
|
|
|
|
+ uni.navigateToMiniProgram({
|
|
|
|
|
+ appId: res.miniprogramAppid,
|
|
|
|
|
+ path: res.miniprogramPath,
|
|
|
|
|
+ success(res) {
|
|
|
|
|
+ console.log("打开成功");
|
|
|
|
|
+ },
|
|
|
|
|
+ });
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch((err) => {
|
|
|
|
|
+ uni.hideLoading();
|
|
|
|
|
+ uni.showModal({
|
|
|
|
|
+ content: `${err.errMsg},请重试`,
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+};
|
|
|
|
|
+const checkPage = () => {
|
|
|
|
|
+ infiniteScroller.list = infiniteScroller.list.map((item: any) => {
|
|
|
|
|
+ return {
|
|
|
|
|
+ ...item,
|
|
|
|
|
+ checked: checkAll.value ? false : true,
|
|
|
|
|
+ };
|
|
|
|
|
+ });
|
|
|
|
|
+ setCheckData();
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
onLoad(() => {
|
|
onLoad(() => {
|
|
|
infiniteScroller.refresh();
|
|
infiniteScroller.refresh();
|
|
|
});
|
|
});
|
|
|
onPullDownRefresh(() => {
|
|
onPullDownRefresh(() => {
|
|
|
|
|
+ if (isInvoice.value) {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
infiniteScroller.refresh();
|
|
infiniteScroller.refresh();
|
|
|
});
|
|
});
|
|
|
onReachBottom(() => {
|
|
onReachBottom(() => {
|
|
@@ -73,4 +194,11 @@ onReachBottom(() => {
|
|
|
height: 170rpx;
|
|
height: 170rpx;
|
|
|
border-bottom: 1rpx solid rgba(0, 0, 0, 0.1);
|
|
border-bottom: 1rpx solid rgba(0, 0, 0, 0.1);
|
|
|
}
|
|
}
|
|
|
|
|
+.foot-placeholder {
|
|
|
|
|
+ height: 112rpx;
|
|
|
|
|
+}
|
|
|
|
|
+.foot {
|
|
|
|
|
+ height: 112rpx;
|
|
|
|
|
+ border-top: 1px solid rgba(0, 0, 0, 0.1);
|
|
|
|
|
+}
|
|
|
</style>
|
|
</style>
|