|
|
@@ -1,6 +1,10 @@
|
|
|
<template>
|
|
|
<view class="page flex-column">
|
|
|
- <navigation-bar title="我的钱包" @ready="ready"></navigation-bar>
|
|
|
+ <navigation-bar
|
|
|
+ autoFixedStyle="background-color:#fff;"
|
|
|
+ title="我的钱包"
|
|
|
+ @ready="ready"
|
|
|
+ ></navigation-bar>
|
|
|
<view class="head flex-shrink">
|
|
|
<view>
|
|
|
<image class="bg" src="/pages-user/static/wallet-banner.png"></image>
|
|
|
@@ -12,7 +16,11 @@
|
|
|
color="#ffffff"
|
|
|
></uni-icons>
|
|
|
<view class="fs-36 color-fff fw-500 ml-16">我的钱包</view>
|
|
|
- <view class="btn flex-center fs-28 ml-auto" @click="toRefund">退款</view>
|
|
|
+ <view
|
|
|
+ class="btn flex-center fs-28 ml-auto"
|
|
|
+ @click="to(`/pages-user/wallet-refund/wallet-refund`)"
|
|
|
+ >退款</view
|
|
|
+ >
|
|
|
</view>
|
|
|
<view class="price mt-50" v-if="user">
|
|
|
<text class="color-fff fw-600 fs-48" style="vertical-align: top"
|
|
|
@@ -45,54 +53,56 @@
|
|
|
></view
|
|
|
></view>
|
|
|
</view>
|
|
|
- <view class="list flex-grow">
|
|
|
- <scroll-view
|
|
|
- class="scroll-view"
|
|
|
- :style="{
|
|
|
- height: `${scrollViewHeight}px`,
|
|
|
- }"
|
|
|
- scroll-y="true"
|
|
|
- v-if="scrollViewHeight"
|
|
|
+ <view class="list pl-30 pr-30">
|
|
|
+ <view
|
|
|
+ class="item flex-align-center"
|
|
|
+ v-for="(item, index) in infiniteScroller.list"
|
|
|
+ :key="index"
|
|
|
+ @click="detail(index)"
|
|
|
>
|
|
|
- <view
|
|
|
- class="item flex-align-center"
|
|
|
- v-for="(item, index) in list"
|
|
|
- :key="index"
|
|
|
- @click="detail(index)"
|
|
|
- >
|
|
|
- <view>
|
|
|
- <view class="fs-30 fw-500" key="title" duration="300">{{
|
|
|
- typeMap[item.type - 1]
|
|
|
- }}</view>
|
|
|
- <view class="fs-24" style="color: rgba(0, 0, 0, 0.4)">余额</view>
|
|
|
- </view>
|
|
|
- <view class="ml-auto" style="text-align: right">
|
|
|
- <view class="fs-30 fw-500">
|
|
|
- <text>{{ item.type > 1 ? "- " : "" }}{{ item.amount }}</text>
|
|
|
- <text class="fs-24 ml-6">元</text>
|
|
|
- </view>
|
|
|
- <view class="fs-24" style="color: rgba(0, 0, 0, 0.4)">{{
|
|
|
- item.transactionTime
|
|
|
- }}</view>
|
|
|
- </view>
|
|
|
- <view class="ml-32" v-if="item.type === 3">
|
|
|
- <uni-icons
|
|
|
- type="right"
|
|
|
- size="12"
|
|
|
- color="rgba(0,0,0,0.4)"
|
|
|
- ></uni-icons>
|
|
|
+ <view>
|
|
|
+ <view class="fs-30 fw-500" key="title" duration="300">{{
|
|
|
+ typeMap[item.type - 1]
|
|
|
+ }}</view>
|
|
|
+ <view class="fs-24" style="color: rgba(0, 0, 0, 0.4)">余额</view>
|
|
|
+ </view>
|
|
|
+ <view class="ml-auto" style="text-align: right">
|
|
|
+ <view class="fs-30 fw-500">
|
|
|
+ <text>{{ item.type > 1 ? "- " : "" }}{{ item.amount }}</text>
|
|
|
+ <text class="fs-24 ml-6">元</text>
|
|
|
</view>
|
|
|
+ <view class="fs-24" style="color: rgba(0, 0, 0, 0.4)">{{
|
|
|
+ item.transactionTime
|
|
|
+ }}</view>
|
|
|
+ </view>
|
|
|
+ <view class="ml-32" v-if="item.type === 3">
|
|
|
+ <uni-icons
|
|
|
+ type="right"
|
|
|
+ size="12"
|
|
|
+ color="rgba(0,0,0,0.4)"
|
|
|
+ ></uni-icons>
|
|
|
</view>
|
|
|
- <view style="height: 200rpx"></view>
|
|
|
- </scroll-view>
|
|
|
+ </view>
|
|
|
</view>
|
|
|
+ <view style="height: 170rpx;"></view>
|
|
|
</view>
|
|
|
+ <style-bottom-view background="#ffffff">
|
|
|
+ <view class="pl-40 pr-40 pb-30 pt-30">
|
|
|
+ <style-button
|
|
|
+ type="primary"
|
|
|
+ @click="to(`/pages-user/wallet-recharge/wallet-recharge`)"
|
|
|
+ >充值</style-button
|
|
|
+ >
|
|
|
+ </view>
|
|
|
+ </style-bottom-view>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import { onLoad } from "@dcloudio/uni-app";
|
|
|
+import { useInfiniteScroll } from "../../utils/infinite-scroll";
|
|
|
+import { onLoad, onReachBottom, onPullDownRefresh } from "@dcloudio/uni-app";
|
|
|
import { fetchWallet } from "../../api/user";
|
|
|
+import { to } from "../../utils/navigate";
|
|
|
import { ref } from "vue";
|
|
|
import { rpxToPx } from "@/utils/device";
|
|
|
|
|
|
@@ -119,17 +129,33 @@ const tabs = ref([
|
|
|
]);
|
|
|
|
|
|
const typeMap = ref(["充值", "提现", "消费"]);
|
|
|
-const list = ref<any[]>([]);
|
|
|
+const infiniteScroller = useInfiniteScroll(10, (page) => {
|
|
|
+ return fetchWallet(tab.value, page, 10).then((res: any) => {
|
|
|
+ if (res && res.length) {
|
|
|
+ res.forEach((item: any) => {
|
|
|
+ item.amount = (Number(item.amount) / 100).toFixed(2);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ });
|
|
|
+});
|
|
|
const scrollViewHeight = ref(0);
|
|
|
|
|
|
onLoad(() => {
|
|
|
- refresh();
|
|
|
-
|
|
|
+ infiniteScroller.refresh();
|
|
|
if (getApp<any>().globalData.user) {
|
|
|
user.value = getApp<any>().globalData.user;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+onReachBottom(() => {
|
|
|
+ infiniteScroller.next();
|
|
|
+});
|
|
|
+
|
|
|
+onPullDownRefresh(() => {
|
|
|
+ infiniteScroller.refresh();
|
|
|
+});
|
|
|
+
|
|
|
const ready = (e: any) => {
|
|
|
scrollViewHeight.value =
|
|
|
getApp<any>().globalData.device.windowHeight -
|
|
|
@@ -138,33 +164,19 @@ const ready = (e: any) => {
|
|
|
|
|
|
const changeTab = (index: number) => {
|
|
|
tab.value = tabs.value[index].value;
|
|
|
- refresh();
|
|
|
-};
|
|
|
-
|
|
|
-const refresh = () => {
|
|
|
- fetchWallet(tab.value, 1, 10).then((res: any) => {
|
|
|
- if (res && res.length) {
|
|
|
- res.forEach((item: any) => {
|
|
|
- item.amount = (Number(item.amount) / 100).toFixed(2);
|
|
|
- });
|
|
|
- }
|
|
|
- list.value = res;
|
|
|
- });
|
|
|
+ infiniteScroller.refresh();
|
|
|
};
|
|
|
|
|
|
const detail = (index: number) => {
|
|
|
- if (list.value[index].type === 3) {
|
|
|
+ if (!infiniteScroller.list) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (infiniteScroller.list[index].type === 3) {
|
|
|
uni.navigateTo({
|
|
|
- url: `/pages-charge/order/order?id=${list.value[index].orderNo}`,
|
|
|
+ url: `/pages-charge/order/order?id=${infiniteScroller.list[index].orderNo}`,
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
-
|
|
|
-const toRefund = () => {
|
|
|
- uni.navigateTo({
|
|
|
- url: `/pages-user/wallet-refund/wallet-refund`,
|
|
|
- });
|
|
|
-}
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss">
|
|
|
@@ -222,12 +234,6 @@ const toRefund = () => {
|
|
|
}
|
|
|
}
|
|
|
.list {
|
|
|
- height: 100%;
|
|
|
- .scroll-view {
|
|
|
- width: 100%;
|
|
|
- box-sizing: border-box;
|
|
|
- padding: 0rpx 30rpx;
|
|
|
- }
|
|
|
.item {
|
|
|
height: 170rpx;
|
|
|
border-bottom: 1rpx solid rgba(0, 0, 0, 0.1);
|