Explorar el Código

fix: 用户订单明细

chenjj hace 1 semana
padre
commit
8d0ca10308
Se han modificado 3 ficheros con 139 adiciones y 59 borrados
  1. 9 0
      api/mine.js
  2. 0 2
      pages/common/orderList/index.vue
  3. 130 57
      pages_mine/pages/income/index.vue

+ 9 - 0
api/mine.js

@@ -35,3 +35,12 @@ export function getAccountChangeList(params) {
         params
     })
 }
+
+//查询用户的总收入和总支出
+export function getTotalMoney(params) {
+    return request({
+        url: `/core/client/account-change/totalMoney`,
+        method: 'get',
+        params
+    })
+}

+ 0 - 2
pages/common/orderList/index.vue

@@ -35,7 +35,6 @@ const emit = defineEmits(['refresh']);
 const userType = uni.getStorageSync('userType') //读取本地存储
 const isRefreshing = ref(false)
 
-const isBottom = ref(false);
 
 const loadmoreInfo = ref({
 	status: 'loadmore',
@@ -60,7 +59,6 @@ const handleRefreshing = (status) => {
 
 //下拉刷新
 const handleBottom = (value) => {
-    isBottom.value = value;
     loadmoreInfo.value.status = value?'loading':'nomore';
 }
 defineExpose({

+ 130 - 57
pages_mine/pages/income/index.vue

@@ -1,48 +1,55 @@
 <template>
-    <view class="income-main">
-        <view class="income-header card-box">
-            <text class="income-title" @click="onShows">
-                {{ dataYMD }}
-            </text>
-            <view class="income-header-right">
-                <text>收入: ¥{{ data.totalEarning }}</text>
-                <text class="income-header-right-right">支出: ¥{{ data.totalExpend }}</text>
+   <scroll-view refresher-enabled :refresher-triggered="isRefreshing" @refresherrefresh="onCustomRefresh"
+        class="scroll-view-class" @scrolltolower="scrolltolower" scroll-y>
+        <view class="income-main">
+            <view class="income-header card-box">
+                <text class="income-title" @click="onShows">
+                    {{ dataYMD }}
+                </text>
+                <view class="income-header-right">
+                    <text>收入: ¥{{ data.totalEarning }}</text>
+                    <text class="income-header-right-right">支出: ¥{{ data.totalExpend }}</text>
+                </view>
             </view>
-        </view>
 
-        <view v-if="data.clientAccountChangeVOlist && data.clientAccountChangeVOlist.length > 0">
-            <view class="card-box icome-item" v-for="item in data.clientAccountChangeVOlist" :key="item.code" @click="onClick(item)">
-                <view class="card-left">
-                    <!-- <img :src="baseUrl" alt="" class="income-img"> -->
-                    <view class="card-left-text">
-                        <view class="card-left-name">
-                            <dict-tag :options="jlzj_client_source_type" :value="item.sourceType" />
-                            ({{ item.businessTierName }})
+            <view v-if="data.clientAccountChangeVOlist && data.clientAccountChangeVOlist.length > 0">
+                <view class="card-box icome-item" v-for="item in data.clientAccountChangeVOlist" :key="item.code"
+                    @click="onClick(item)">
+                    <view class="card-left">
+                        <!-- <img :src="baseUrl" alt="" class="income-img"> -->
+                        <view class="card-left-text">
+                            <view class="card-left-name">
+                                <dict-tag :options="jlzj_client_source_type" :value="item.sourceType" />
+                                ({{ item.businessTierName }})
+                            </view>
+                            <view class="card-left-date">{{ item.createTime }}</view>
                         </view>
-                        <view class="card-left-date">{{ item.createTime }}</view>
                     </view>
-                </view>
 
-                <view class="card-rigth"
-                    :style="{ color: item.changeType === '1' ? 'rgba(76, 175, 80, 1)' : 'rgba(244, 67, 54, 1)' }">
-                    {{ item.changeType === '1' ? '+' : '-' }}{{ item.changeMoney }}
+                    <view class="card-rigth"
+                        :style="{ color: item.changeType === '1' ? 'rgba(76, 175, 80, 1)' : 'rgba(244, 67, 54, 1)' }">
+                        {{ item.changeType === '1' ? '+' : '-' }}{{ item.changeMoney }}
+                    </view>
                 </view>
-
+                <up-loadmore style="margin-top: 40rpx;" :status="loadmoreInfo.status"
+                    :loadmoreText="loadmoreInfo.loadingText" :loadingText="loadmoreInfo.loadmoreText"
+                    :nomoreText="loadmoreInfo.nomoreText" @loadmore="handleLoadmore" />
+            </view>
+            <view v-else>
+                <NoneView value="您还没有相关账单" />
             </view>
-        </view>
-        <view v-else>
-            <NoneView value="您还没有相关账单" />
-        </view>
 
 
-        <up-datetime-picker :show="show" v-model="datetime" mode="date" ref="uPickerRef" @confirm="confirm"
-            @cancel="cancel"></up-datetime-picker>
-    </view>
+            <up-datetime-picker :show="show" v-model="datetime" mode="date" ref="uPickerRef" @confirm="confirm"
+                @cancel="cancel"></up-datetime-picker>
+        </view>
+    </scroll-view>
+
 </template>
 
 <script setup>
 import { ref, computed } from 'vue'
-import { getAccountChangeList } from "@/api/mine";
+import { getAccountChangeList, getTotalMoney } from "@/api/mine";
 import {
     onShow
 } from '@dcloudio/uni-app';
@@ -73,42 +80,75 @@ const dataYMD = computed(() => {
 })
 
 const uPickerRef = ref(null)
+const isRefreshing = ref(false)
+
+
+const loadmoreInfo = ref({
+    status: 'loadmore',
+    loadingText: '努力加载中...',
+    loadmoreText: '点击加载更多~',
+    nomoreText: '已经到底啦~'
+})
+const pages = ref({
+    current: 1,
+    pageSize: 10,
+    total: 0,
+})
 const onShows = () => {
     show.value = true;
 };
 
 const confirm = () => {
-    console.log('confirm', datetime.value);
     show.value = false;
-    init();
+    init('top');
+    totalInit();
 };
 
 const cancel = () => {
     show.value = false;
 };
-const onClick = (record) =>{
+const onClick = (record) => {
     record.mainOrderId && uni.navigateTo({
         url: `/pages_classify/pages/orderItem/orderdetails?mainOrderId=${record.mainOrderId}`
     });
 }
+const scrolltolower = () => {
+    init('bottom')
+};
 
-const init = async () => {
+const onCustomRefresh = () => {
+    isRefreshing.value = true;
+    pages.value.current = 1;
+    // data.value.clientAccountChangeVOlist = [];
+    init('top')
+};
+
+const init = async (type) => {
     try {
-        uni.showLoading({
-            title: '数据加载中...'
-        });
 
-        if (userType === 2) {
-            // const res = await getVolunteerAccountInfo();
-            // data.value =res.data;			
-        }
-        if (userType === 1) {
-            const res = await getAccountChangeList({
-                createTime: dayjs(datetime.value).format('YYYY-MM-DD')
-            });
-            console.log(1, res);
-            res.data &&  (data.value = res.data);
+
+        if (type === 'bottom') {
+            if (data.value.clientAccountChangeVOlist.length < pages.value.total) {
+                loadmoreInfo.value.status = 'loading';
+                pages.value.current++;
+            } else {
+                loadmoreInfo.value.status = 'nomore';
+                return;
+            }
+        } else {
+            uni.showLoading({
+                title: '数据加载中...',
+            })
         }
+
+        const listApi = userType === 1 ? getAccountChangeList : getAccountChangeList;
+        const res = await listApi({
+            createTime: dayjs(datetime.value).format('YYYY-MM-DD'),
+            pageNum: pages.value.current,
+			pageSize: pages.value.pageSize,
+        });
+        data.value.clientAccountChangeVOlist =type === 'top'? res.rows : [...data.value.clientAccountChangeVOlist, ...res.rows];
+        pages.value.total = res.total;
     } catch (error) {
         console.log('error', error);
         uni.showToast({
@@ -116,11 +156,33 @@ const init = async () => {
             icon: 'error',
         });
     } finally {
-        uni.hideLoading();
+        if (type === 'top') {
+            isRefreshing.value = false;
+            uni.hideLoading();
+        } else {
+            loadmoreInfo.value.status = 'nomore';
+        }
+    }
+}
+
+const totalInit = async () => {
+    try {
+        const res = await getTotalMoney({
+            createTime: dayjs(datetime.value).format('YYYY-MM-DD'),
+        });
+        data.value.totalEarning = res.data.totalEarning;
+        data.value.totalExpend = res.data.totalExpend;
+    } catch (error) {
+        console.log('error', error);
+        uni.showToast({
+            title: error.msg,
+            icon: 'error',
+        });
     }
 }
 onShow(() => {
-    init();
+    init('top');
+    totalInit();
 })
 </script>
 
@@ -133,14 +195,14 @@ onShow(() => {
 }
 
 .income-main {
-    position: fixed;
-    top: 0px;
-    left: 0px;
-    right: 0px;
-    bottom: 0px;
-    background: rgba(245, 245, 245, 1);
+    // position: fixed;
+    // top: 0px;
+    // left: 0px;
+    // right: 0px;
+    // bottom: 0px;
+    
     padding: 12px;
-    overflow: auto;
+    // overflow: auto;
 
     .income-title {
         font-size: 16px;
@@ -220,4 +282,15 @@ onShow(() => {
     }
 
 }
+
+.scroll-view-class {
+    // height: 100%;
+    height: 100vh;
+    background: rgba(245, 245, 245, 1);
+    // position: fixed;
+    // top: 0px;
+    // bottom: 0;
+    // left: 0;
+    // right: 0;
+}
 </style>